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

@@ -1,8 +1,5 @@
import { getChannelPlugin } from "../../channels/plugins/index.js";
import type {
ChannelId,
ChannelSetupInput,
} from "../../channels/plugins/types.js";
import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.js";
import type { ClawdbotConfig } from "../../config/config.js";
import { normalizeAccountId } from "../../routing/session-key.js";
@@ -17,9 +14,7 @@ export function applyAccountName(params: {
const accountId = normalizeAccountId(params.accountId);
const plugin = getChannelPlugin(params.channel);
const apply = plugin?.setup?.applyAccountName;
return apply
? apply({ cfg: params.cfg, accountId, name: params.name })
: params.cfg;
return apply ? apply({ cfg: params.cfg, accountId, name: params.name }) : params.cfg;
}
export function applyChannelAccountConfig(params: {

View File

@@ -1,13 +1,7 @@
import {
getChannelPlugin,
normalizeChannelId,
} from "../../channels/plugins/index.js";
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
import type { ChannelId } from "../../channels/plugins/types.js";
import { writeConfigFile } from "../../config/config.js";
import {
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
} from "../../routing/session-key.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
import { createClackPrompter } from "../../wizard/clack-prompter.js";
import { setupChannels } from "../onboard-channels.js";

View File

@@ -5,15 +5,9 @@ import {
} from "../../agents/auth-profiles.js";
import { listChannelPlugins } from "../../channels/plugins/index.js";
import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js";
import type {
ChannelAccountSnapshot,
ChannelPlugin,
} from "../../channels/plugins/types.js";
import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js";
import { withProgress } from "../../cli/progress.js";
import {
formatUsageReportLines,
loadProviderUsageSummary,
} from "../../infra/provider-usage.js";
import { formatUsageReportLines, loadProviderUsageSummary } from "../../infra/provider-usage.js";
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
import { formatDocsLink } from "../../terminal/links.js";
import { theme } from "../../terminal/theme.js";
@@ -72,10 +66,7 @@ function formatAccountLine(params: {
if (snapshot.linked !== undefined) {
bits.push(formatLinked(snapshot.linked));
}
if (
shouldShowConfigured(channel) &&
typeof snapshot.configured === "boolean"
) {
if (shouldShowConfigured(channel) && typeof snapshot.configured === "boolean") {
bits.push(formatConfigured(snapshot.configured));
}
if (snapshot.tokenSource) {
@@ -120,16 +111,12 @@ export async function channelsListCommand(
const plugins = listChannelPlugins();
const authStore = loadAuthProfileStore();
const authProfiles = Object.entries(authStore.profiles).map(
([profileId, profile]) => ({
id: profileId,
provider: profile.provider,
type: profile.type,
isExternal:
profileId === CLAUDE_CLI_PROFILE_ID ||
profileId === CODEX_CLI_PROFILE_ID,
}),
);
const authProfiles = Object.entries(authStore.profiles).map(([profileId, profile]) => ({
id: profileId,
provider: profile.provider,
type: profile.type,
isExternal: profileId === CLAUDE_CLI_PROFILE_ID || profileId === CODEX_CLI_PROFILE_ID,
}));
if (opts.json) {
const usage = includeUsage ? await loadProviderUsageSummary() : undefined;
const chat: Record<string, string[]> = {};
@@ -169,9 +156,7 @@ export async function channelsListCommand(
} else {
for (const profile of authProfiles) {
const external = profile.isExternal ? theme.muted(" (synced)") : "";
lines.push(
`- ${theme.accent(profile.id)} (${theme.success(profile.type)}${external})`,
);
lines.push(`- ${theme.accent(profile.id)} (${theme.success(profile.type)}${external})`);
}
}
@@ -190,7 +175,5 @@ export async function channelsListCommand(
}
runtime.log("");
runtime.log(
`Docs: ${formatDocsLink("/gateway/configuration", "gateway/configuration")}`,
);
runtime.log(`Docs: ${formatDocsLink("/gateway/configuration", "gateway/configuration")}`);
}

View File

@@ -15,10 +15,7 @@ type LogLine = ReturnType<typeof parseLogLine>;
const DEFAULT_LIMIT = 200;
const MAX_BYTES = 1_000_000;
const CHANNELS = new Set<string>([
...listChannelPlugins().map((plugin) => plugin.id),
"all",
]);
const CHANNELS = new Set<string>([...listChannelPlugins().map((plugin) => plugin.id), "all"]);
function parseChannelFilter(raw?: string) {
const trimmed = raw?.trim().toLowerCase();
@@ -65,8 +62,7 @@ export async function channelsLogsCommand(
runtime: RuntimeEnv = defaultRuntime,
) {
const channel = parseChannelFilter(opts.channel);
const limitRaw =
typeof opts.lines === "string" ? Number(opts.lines) : opts.lines;
const limitRaw = typeof opts.lines === "string" ? Number(opts.lines) : opts.lines;
const limit =
typeof limitRaw === "number" && Number.isFinite(limitRaw) && limitRaw > 0
? Math.floor(limitRaw)

View File

@@ -5,18 +5,10 @@ import {
normalizeChannelId,
} from "../../channels/plugins/index.js";
import { type ClawdbotConfig, writeConfigFile } from "../../config/config.js";
import {
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
} from "../../routing/session-key.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
import { createClackPrompter } from "../../wizard/clack-prompter.js";
import {
type ChatChannel,
channelLabel,
requireValidConfig,
shouldUseWizard,
} from "./shared.js";
import { type ChatChannel, channelLabel, requireValidConfig, shouldUseWizard } from "./shared.js";
export type ChannelsRemoveOptions = {
channel?: string;
@@ -102,8 +94,7 @@ export async function channelsRemoveCommand(
}
const resolvedAccountId =
normalizeAccountId(accountId) ??
resolveChannelDefaultAccountId({ plugin, cfg });
normalizeAccountId(accountId) ?? resolveChannelDefaultAccountId({ plugin, cfg });
const accountKey = resolvedAccountId || DEFAULT_ACCOUNT_ID;
let next = { ...cfg };

View File

@@ -1,11 +1,5 @@
import {
type ChannelId,
getChannelPlugin,
} from "../../channels/plugins/index.js";
import {
type ClawdbotConfig,
readConfigFileSnapshot,
} from "../../config/config.js";
import { type ChannelId, getChannelPlugin } from "../../channels/plugins/index.js";
import { type ClawdbotConfig, readConfigFileSnapshot } from "../../config/config.js";
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
@@ -18,9 +12,7 @@ export async function requireValidConfig(
if (snapshot.exists && !snapshot.valid) {
const issues =
snapshot.issues.length > 0
? snapshot.issues
.map((issue) => `- ${issue.path}: ${issue.message}`)
.join("\n")
? snapshot.issues.map((issue) => `- ${issue.path}: ${issue.message}`).join("\n")
: "Unknown validation issue.";
runtime.error(`Config invalid:\n${issues}`);
runtime.error("Fix the config or run clawdbot doctor.");
@@ -30,10 +22,7 @@ export async function requireValidConfig(
return snapshot.config;
}
export function formatAccountLabel(params: {
accountId: string;
name?: string;
}) {
export function formatAccountLabel(params: { accountId: string; name?: string }) {
const base = params.accountId || DEFAULT_ACCOUNT_ID;
if (params.name?.trim()) return `${base} (${params.name.trim()})`;
return base;
@@ -56,12 +45,8 @@ export function formatChannelAccountLabel(params: {
accountId: params.accountId,
name: params.name,
});
const styledChannel = params.channelStyle
? params.channelStyle(channelText)
: channelText;
const styledAccount = params.accountStyle
? params.accountStyle(accountText)
: accountText;
const styledChannel = params.channelStyle ? params.channelStyle(channelText) : channelText;
const styledAccount = params.accountStyle ? params.accountStyle(accountText) : accountText;
return `${styledChannel} ${styledAccount}`;
}

View File

@@ -2,21 +2,14 @@ import { listChannelPlugins } from "../../channels/plugins/index.js";
import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js";
import type { ChannelAccountSnapshot } from "../../channels/plugins/types.js";
import { withProgress } from "../../cli/progress.js";
import {
type ClawdbotConfig,
readConfigFileSnapshot,
} from "../../config/config.js";
import { type ClawdbotConfig, readConfigFileSnapshot } from "../../config/config.js";
import { callGateway } from "../../gateway/call.js";
import { formatAge } from "../../infra/channel-summary.js";
import { collectChannelStatusIssues } from "../../infra/channels-status-issues.js";
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
import { formatDocsLink } from "../../terminal/links.js";
import { theme } from "../../terminal/theme.js";
import {
type ChatChannel,
formatChannelAccountLabel,
requireValidConfig,
} from "./shared.js";
import { type ChatChannel, formatChannelAccountLabel, requireValidConfig } from "./shared.js";
export type ChannelsStatusOptions = {
json?: boolean;
@@ -24,15 +17,10 @@ export type ChannelsStatusOptions = {
timeout?: string;
};
export function formatGatewayChannelsStatusLines(
payload: Record<string, unknown>,
): string[] {
export function formatGatewayChannelsStatusLines(payload: Record<string, unknown>): string[] {
const lines: string[] = [];
lines.push(theme.success("Gateway reachable."));
const accountLines = (
provider: ChatChannel,
accounts: Array<Record<string, unknown>>,
) =>
const accountLines = (provider: ChatChannel, accounts: Array<Record<string, unknown>>) =>
accounts.map((account) => {
const bits: string[] = [];
if (typeof account.enabled === "boolean") {
@@ -51,13 +39,11 @@ export function formatGatewayChannelsStatusLines(
bits.push(account.connected ? "connected" : "disconnected");
}
const inboundAt =
typeof account.lastInboundAt === "number" &&
Number.isFinite(account.lastInboundAt)
typeof account.lastInboundAt === "number" && Number.isFinite(account.lastInboundAt)
? account.lastInboundAt
: null;
const outboundAt =
typeof account.lastOutboundAt === "number" &&
Number.isFinite(account.lastOutboundAt)
typeof account.lastOutboundAt === "number" && Number.isFinite(account.lastOutboundAt)
? account.lastOutboundAt
: null;
if (inboundAt) bits.push(`in:${formatAge(Date.now() - inboundAt)}`);
@@ -74,16 +60,10 @@ export function formatGatewayChannelsStatusLines(
if (typeof account.tokenSource === "string" && account.tokenSource) {
bits.push(`token:${account.tokenSource}`);
}
if (
typeof account.botTokenSource === "string" &&
account.botTokenSource
) {
if (typeof account.botTokenSource === "string" && account.botTokenSource) {
bits.push(`bot:${account.botTokenSource}`);
}
if (
typeof account.appTokenSource === "string" &&
account.appTokenSource
) {
if (typeof account.appTokenSource === "string" && account.appTokenSource) {
bits.push(`app:${account.appTokenSource}`);
}
const application = account.application as
@@ -114,8 +94,7 @@ export function formatGatewayChannelsStatusLines(
if (typeof account.lastError === "string" && account.lastError) {
bits.push(`error:${account.lastError}`);
}
const accountId =
typeof account.accountId === "string" ? account.accountId : "default";
const accountId = typeof account.accountId === "string" ? account.accountId : "default";
const name = typeof account.name === "string" ? account.name.trim() : "";
const labelText = formatChannelAccountLabel({
channel: provider,
@@ -126,12 +105,8 @@ export function formatGatewayChannelsStatusLines(
});
const plugins = listChannelPlugins();
const accountsByChannel = payload.channelAccounts as
| Record<string, unknown>
| undefined;
const accountPayloads: Partial<
Record<string, Array<Record<string, unknown>>>
> = {};
const accountsByChannel = payload.channelAccounts as Record<string, unknown> | undefined;
const accountPayloads: Partial<Record<string, Array<Record<string, unknown>>>> = {};
for (const plugin of plugins) {
const raw = accountsByChannel?.[plugin.id];
if (Array.isArray(raw)) {
@@ -178,10 +153,7 @@ async function formatConfigChannelsStatusLines(
}
if (meta.path || meta.mode) lines.push("");
const accountLines = (
provider: ChatChannel,
accounts: Array<Record<string, unknown>>,
) =>
const accountLines = (provider: ChatChannel, accounts: Array<Record<string, unknown>>) =>
accounts.map((account) => {
const bits: string[] = [];
if (typeof account.enabled === "boolean") {
@@ -199,23 +171,16 @@ async function formatConfigChannelsStatusLines(
if (typeof account.tokenSource === "string" && account.tokenSource) {
bits.push(`token:${account.tokenSource}`);
}
if (
typeof account.botTokenSource === "string" &&
account.botTokenSource
) {
if (typeof account.botTokenSource === "string" && account.botTokenSource) {
bits.push(`bot:${account.botTokenSource}`);
}
if (
typeof account.appTokenSource === "string" &&
account.appTokenSource
) {
if (typeof account.appTokenSource === "string" && account.appTokenSource) {
bits.push(`app:${account.appTokenSource}`);
}
if (typeof account.baseUrl === "string" && account.baseUrl) {
bits.push(`url:${account.baseUrl}`);
}
const accountId =
typeof account.accountId === "string" ? account.accountId : "default";
const accountId = typeof account.accountId === "string" ? account.accountId : "default";
const name = typeof account.name === "string" ? account.name.trim() : "";
const labelText = formatChannelAccountLabel({
channel: provider,
@@ -255,9 +220,7 @@ export async function channelsStatusCommand(
runtime: RuntimeEnv = defaultRuntime,
) {
const timeoutMs = Number(opts.timeout ?? 10_000);
const statusLabel = opts.probe
? "Checking channel status (probe)…"
: "Checking channel status…";
const statusLabel = opts.probe ? "Checking channel status (probe)…" : "Checking channel status…";
const shouldLogStatus = opts.json !== true && !process.stderr.isTTY;
if (shouldLogStatus) runtime.log(statusLabel);
try {
@@ -278,11 +241,7 @@ export async function channelsStatusCommand(
runtime.log(JSON.stringify(payload, null, 2));
return;
}
runtime.log(
formatGatewayChannelsStatusLines(payload as Record<string, unknown>).join(
"\n",
),
);
runtime.log(formatGatewayChannelsStatusLines(payload as Record<string, unknown>).join("\n"));
} catch (err) {
runtime.error(`Gateway not reachable: ${String(err)}`);
const cfg = await requireValidConfig(runtime);