From 0c93b9b7bbc66986e19d4ac925e7d8a73c11084d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 18 Jan 2026 02:19:35 +0000 Subject: [PATCH] style: apply oxfmt --- src/agents/tools/web-fetch-utils.ts | 5 ++- src/agents/tools/web-search.ts | 6 +--- src/agents/tools/web-shared.ts | 7 +++- .../tools/web-tools.enabled-defaults.test.ts | 15 +++------ src/channels/channel-config.ts | 4 +-- src/channels/command-gating.test.ts | 5 ++- .../plugins/onboarding/channel-access.ts | 5 ++- src/channels/plugins/onboarding/discord.ts | 8 ++--- src/channels/plugins/onboarding/slack.ts | 13 ++------ src/channels/plugins/status-issues/shared.ts | 6 ++-- src/cli/memory-cli.test.ts | 4 ++- src/cli/memory-cli.ts | 6 +++- src/commands/auth-choice.apply.qwen-portal.ts | 6 +++- src/commands/channels/resolve.ts | 9 +++-- src/discord/monitor/provider.ts | 4 ++- src/discord/resolve-channels.ts | 10 ++---- src/discord/resolve-users.ts | 6 +--- src/memory/manager.ts | 33 ++++++++++--------- src/slack/directory-live.ts | 4 ++- src/slack/monitor/provider.ts | 8 ++--- src/slack/resolve-users.ts | 12 ++----- 21 files changed, 87 insertions(+), 89 deletions(-) diff --git a/src/agents/tools/web-fetch-utils.ts b/src/agents/tools/web-fetch-utils.ts index 1a780b9d2..33a420703 100644 --- a/src/agents/tools/web-fetch-utils.ts +++ b/src/agents/tools/web-fetch-utils.ts @@ -68,7 +68,10 @@ export function markdownToText(markdown: string): string { return normalizeWhitespace(text); } -export function truncateText(value: string, maxChars: number): { text: string; truncated: boolean } { +export function truncateText( + value: string, + maxChars: number, +): { text: string; truncated: boolean } { if (value.length <= maxChars) return { text: value, truncated: false }; return { text: value.slice(0, maxChars), truncated: true }; } diff --git a/src/agents/tools/web-search.ts b/src/agents/tools/web-search.ts index c8b8eaae7..1a236e251 100644 --- a/src/agents/tools/web-search.ts +++ b/src/agents/tools/web-search.ts @@ -79,11 +79,7 @@ type PerplexityConfig = { model?: string; }; -type PerplexityApiKeySource = - | "config" - | "perplexity_env" - | "openrouter_env" - | "none"; +type PerplexityApiKeySource = "config" | "perplexity_env" | "openrouter_env" | "none"; type PerplexitySearchResponse = { choices?: Array<{ diff --git a/src/agents/tools/web-shared.ts b/src/agents/tools/web-shared.ts index 52876a7e4..d56800067 100644 --- a/src/agents/tools/web-shared.ts +++ b/src/agents/tools/web-shared.ts @@ -36,7 +36,12 @@ export function readCache( return { value: entry.value, cached: true }; } -export function writeCache(cache: Map>, key: string, value: T, ttlMs: number) { +export function writeCache( + cache: Map>, + key: string, + value: T, + ttlMs: number, +) { if (ttlMs <= 0) return; if (cache.size >= DEFAULT_CACHE_MAX_ENTRIES) { const oldest = cache.keys().next(); diff --git a/src/agents/tools/web-tools.enabled-defaults.test.ts b/src/agents/tools/web-tools.enabled-defaults.test.ts index b2d9363f4..c244409c0 100644 --- a/src/agents/tools/web-tools.enabled-defaults.test.ts +++ b/src/agents/tools/web-tools.enabled-defaults.test.ts @@ -104,8 +104,7 @@ describe("web_search perplexity baseUrl defaults", () => { const mockFetch = vi.fn(() => Promise.resolve({ ok: true, - json: () => - Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), + json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), } as Response), ); // @ts-expect-error mock fetch @@ -127,8 +126,7 @@ describe("web_search perplexity baseUrl defaults", () => { const mockFetch = vi.fn(() => Promise.resolve({ ok: true, - json: () => - Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), + json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), } as Response), ); // @ts-expect-error mock fetch @@ -150,8 +148,7 @@ describe("web_search perplexity baseUrl defaults", () => { const mockFetch = vi.fn(() => Promise.resolve({ ok: true, - json: () => - Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), + json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), } as Response), ); // @ts-expect-error mock fetch @@ -172,8 +169,7 @@ describe("web_search perplexity baseUrl defaults", () => { const mockFetch = vi.fn(() => Promise.resolve({ ok: true, - json: () => - Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), + json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), } as Response), ); // @ts-expect-error mock fetch @@ -202,8 +198,7 @@ describe("web_search perplexity baseUrl defaults", () => { const mockFetch = vi.fn(() => Promise.resolve({ ok: true, - json: () => - Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), + json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }), } as Response), ); // @ts-expect-error mock fetch diff --git a/src/channels/channel-config.ts b/src/channels/channel-config.ts index ce9445c51..6bf1300ce 100644 --- a/src/channels/channel-config.ts +++ b/src/channels/channel-config.ts @@ -20,9 +20,7 @@ export function normalizeChannelSlug(value: string): string { .replace(/^-+|-+$/g, ""); } -export function buildChannelKeyCandidates( - ...keys: Array -): string[] { +export function buildChannelKeyCandidates(...keys: Array): string[] { const seen = new Set(); const candidates: string[] = []; for (const key of keys) { diff --git a/src/channels/command-gating.test.ts b/src/channels/command-gating.test.ts index 6c220e2fd..8d922c4cd 100644 --- a/src/channels/command-gating.test.ts +++ b/src/channels/command-gating.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it } from "vitest"; -import { resolveCommandAuthorizedFromAuthorizers, resolveControlCommandGate } from "./command-gating.js"; +import { + resolveCommandAuthorizedFromAuthorizers, + resolveControlCommandGate, +} from "./command-gating.js"; describe("resolveCommandAuthorizedFromAuthorizers", () => { it("denies when useAccessGroups is enabled and no authorizer is configured", () => { diff --git a/src/channels/plugins/onboarding/channel-access.ts b/src/channels/plugins/onboarding/channel-access.ts index e5f11a421..e22536479 100644 --- a/src/channels/plugins/onboarding/channel-access.ts +++ b/src/channels/plugins/onboarding/channel-access.ts @@ -10,7 +10,10 @@ export function parseAllowlistEntries(raw: string): string[] { } export function formatAllowlistEntries(entries: string[]): string { - return entries.map((entry) => entry.trim()).filter(Boolean).join(", "); + return entries + .map((entry) => entry.trim()) + .filter(Boolean) + .join(", "); } export async function promptChannelAccessPolicy(params: { diff --git a/src/channels/plugins/onboarding/discord.ts b/src/channels/plugins/onboarding/discord.ts index 29818ac51..69dc430d4 100644 --- a/src/channels/plugins/onboarding/discord.ts +++ b/src/channels/plugins/onboarding/discord.ts @@ -310,13 +310,13 @@ export const discordOnboardingAdapter: ChannelOnboardingAdapter = { token: accountWithTokens.token, entries: accessConfig.entries, }); - const resolvedChannels = resolved.filter( - (entry) => entry.resolved && entry.channelId, - ); + const resolvedChannels = resolved.filter((entry) => entry.resolved && entry.channelId); const resolvedGuilds = resolved.filter( (entry) => entry.resolved && entry.guildId && !entry.channelId, ); - const unresolved = resolved.filter((entry) => !entry.resolved).map((entry) => entry.input); + const unresolved = resolved + .filter((entry) => !entry.resolved) + .map((entry) => entry.input); if (resolvedChannels.length > 0 || resolvedGuilds.length > 0 || unresolved.length > 0) { const summary: string[] = []; if (resolvedChannels.length > 0) { diff --git a/src/channels/plugins/onboarding/slack.ts b/src/channels/plugins/onboarding/slack.ts index a4b1c4925..76f5f6071 100644 --- a/src/channels/plugins/onboarding/slack.ts +++ b/src/channels/plugins/onboarding/slack.ts @@ -166,9 +166,7 @@ function setSlackChannelAllowlist( accountId: string, channelKeys: string[], ): ClawdbotConfig { - const channels = Object.fromEntries( - channelKeys.map((key) => [key, { allow: true }]), - ); + const channels = Object.fromEntries(channelKeys.map((key) => [key, { allow: true }])); if (accountId === DEFAULT_ACCOUNT_ID) { return { ...cfg, @@ -396,16 +394,11 @@ export const slackOnboardingAdapter: ChannelOnboardingAdapter = { const unresolved = resolved .filter((entry) => !entry.resolved) .map((entry) => entry.input); - keys = [ - ...resolvedKeys, - ...unresolved.map((entry) => entry.trim()).filter(Boolean), - ]; + keys = [...resolvedKeys, ...unresolved.map((entry) => entry.trim()).filter(Boolean)]; if (resolvedKeys.length > 0 || unresolved.length > 0) { await prompter.note( [ - resolvedKeys.length > 0 - ? `Resolved: ${resolvedKeys.join(", ")}` - : undefined, + resolvedKeys.length > 0 ? `Resolved: ${resolvedKeys.join(", ")}` : undefined, unresolved.length > 0 ? `Unresolved (kept as typed): ${unresolved.join(", ")}` : undefined, diff --git a/src/channels/plugins/status-issues/shared.ts b/src/channels/plugins/status-issues/shared.ts index a3e5e1fa9..85cedd3be 100644 --- a/src/channels/plugins/status-issues/shared.ts +++ b/src/channels/plugins/status-issues/shared.ts @@ -17,8 +17,10 @@ export function formatMatchMetadata(params: { ? String(params.matchKey) : undefined; const matchSource = asString(params.matchSource); - const parts = [matchKey ? `matchKey=${matchKey}` : null, matchSource ? `matchSource=${matchSource}` : null] - .filter((entry): entry is string => Boolean(entry)); + const parts = [ + matchKey ? `matchKey=${matchKey}` : null, + matchSource ? `matchSource=${matchSource}` : null, + ].filter((entry): entry is string => Boolean(entry)); return parts.length > 0 ? parts.join(" ") : undefined; } diff --git a/src/cli/memory-cli.test.ts b/src/cli/memory-cli.test.ts index 33a7f99d3..ba2e3eb10 100644 --- a/src/cli/memory-cli.test.ts +++ b/src/cli/memory-cli.test.ts @@ -65,7 +65,9 @@ describe("memory cli", () => { expect(log).toHaveBeenCalledWith(expect.stringContaining("Vector dims: 1024")); expect(log).toHaveBeenCalledWith(expect.stringContaining("Vector path: /opt/sqlite-vec.dylib")); expect(log).toHaveBeenCalledWith(expect.stringContaining("FTS: ready")); - expect(log).toHaveBeenCalledWith(expect.stringContaining("Embedding cache: enabled (123 entries)")); + expect(log).toHaveBeenCalledWith( + expect.stringContaining("Embedding cache: enabled (123 entries)"), + ); expect(close).toHaveBeenCalled(); }); diff --git a/src/cli/memory-cli.ts b/src/cli/memory-cli.ts index 4dadead75..3b4c42661 100644 --- a/src/cli/memory-cli.ts +++ b/src/cli/memory-cli.ts @@ -189,7 +189,11 @@ export function registerMemoryCli(program: Command) { : "unavailable" : "disabled"; const ftsColor = - ftsState === "ready" ? theme.success : ftsState === "unavailable" ? theme.warn : theme.muted; + ftsState === "ready" + ? theme.success + : ftsState === "unavailable" + ? theme.warn + : theme.muted; lines.push(`${label("FTS")} ${colorize(rich, ftsColor, ftsState)}`); if (status.fts.error) { lines.push(`${label("FTS error")} ${warn(status.fts.error)}`); diff --git a/src/commands/auth-choice.apply.qwen-portal.ts b/src/commands/auth-choice.apply.qwen-portal.ts index ab36355cb..4048c7a16 100644 --- a/src/commands/auth-choice.apply.qwen-portal.ts +++ b/src/commands/auth-choice.apply.qwen-portal.ts @@ -1,5 +1,9 @@ import { resolveClawdbotAgentDir } from "../agents/agent-paths.js"; -import { resolveDefaultAgentId, resolveAgentDir, resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; +import { + resolveDefaultAgentId, + resolveAgentDir, + resolveAgentWorkspaceDir, +} from "../agents/agent-scope.js"; import { upsertAuthProfile } from "../agents/auth-profiles.js"; import { normalizeProviderId } from "../agents/model-selection.js"; import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js"; diff --git a/src/commands/channels/resolve.ts b/src/commands/channels/resolve.ts index df67a683e..7394fa30f 100644 --- a/src/commands/channels/resolve.ts +++ b/src/commands/channels/resolve.ts @@ -22,7 +22,9 @@ type ResolveResult = { note?: string; }; -function resolvePreferredKind(kind?: ChannelsResolveOptions["kind"]): ChannelResolveKind | undefined { +function resolvePreferredKind( + kind?: ChannelsResolveOptions["kind"], +): ChannelResolveKind | undefined { if (!kind || kind === "auto") return undefined; if (kind === "user") return "user"; return "group"; @@ -46,10 +48,7 @@ function formatResolveResult(result: ResolveResult): string { return `${result.input} -> ${result.id}${name}${note}`; } -export async function channelsResolveCommand( - opts: ChannelsResolveOptions, - runtime: RuntimeEnv, -) { +export async function channelsResolveCommand(opts: ChannelsResolveOptions, runtime: RuntimeEnv) { const cfg = loadConfig(); const entries = (opts.entries ?? []).map((entry) => entry.trim()).filter(Boolean); if (entries.length === 0) { diff --git a/src/discord/monitor/provider.ts b/src/discord/monitor/provider.ts index 4418d896e..177c584fd 100644 --- a/src/discord/monitor/provider.ts +++ b/src/discord/monitor/provider.ts @@ -302,7 +302,9 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) { guildEntries = nextGuilds; summarizeMapping("discord channel users", mapping, unresolved, runtime); } catch (err) { - runtime.log?.(`discord channel user resolve failed; using config entries. ${String(err)}`); + runtime.log?.( + `discord channel user resolve failed; using config entries. ${String(err)}`, + ); } } } diff --git a/src/discord/resolve-channels.ts b/src/discord/resolve-channels.ts index 9c525c7cd..a37c598e1 100644 --- a/src/discord/resolve-channels.ts +++ b/src/discord/resolve-channels.ts @@ -60,11 +60,7 @@ function parseDiscordChannelInput(raw: string): { return { guild: trimmed, guildOnly: true }; } -async function fetchDiscord( - path: string, - token: string, - fetcher: typeof fetch, -): Promise { +async function fetchDiscord(path: string, token: string, fetcher: typeof fetch): Promise { const res = await fetcher(`${DISCORD_API_BASE}${path}`, { headers: { Authorization: `Bot ${token}` }, }); @@ -107,7 +103,7 @@ async function listGuildChannels( : undefined; return { id: channel.id, - name: "name" in channel ? channel.name ?? "" : "", + name: "name" in channel ? (channel.name ?? "") : "", guildId, type: channel.type, archived, @@ -129,7 +125,7 @@ async function fetchChannel( if (!raw || !("guild_id" in raw)) return null; return { id: raw.id, - name: "name" in raw ? raw.name ?? "" : "", + name: "name" in raw ? (raw.name ?? "") : "", guildId: raw.guild_id ?? "", type: raw.type, }; diff --git a/src/discord/resolve-users.ts b/src/discord/resolve-users.ts index 066ef20f5..65fe6db74 100644 --- a/src/discord/resolve-users.ts +++ b/src/discord/resolve-users.ts @@ -81,11 +81,7 @@ async function listGuilds(token: string, fetcher: typeof fetch): Promise value?.toLowerCase()) .filter(Boolean) as string[]; let score = 0; diff --git a/src/memory/manager.ts b/src/memory/manager.ts index af386eaf6..c9c5d1735 100644 --- a/src/memory/manager.ts +++ b/src/memory/manager.ts @@ -329,12 +329,7 @@ export class MemoryIndexManager { ` ORDER BY dist ASC\n` + ` LIMIT ?`, ) - .all( - vectorToBlob(queryVec), - this.provider.model, - ...sourceFilter.params, - limit, - ) as Array<{ + .all(vectorToBlob(queryVec), this.provider.model, ...sourceFilter.params, limit) as Array<{ id: string; path: string; start_line: number; @@ -376,9 +371,13 @@ export class MemoryIndexManager { } private buildFtsQuery(raw: string): string | null { - const tokens = raw.match(/[A-Za-z0-9_]+/g)?.map((t) => t.trim()).filter(Boolean) ?? []; + const tokens = + raw + .match(/[A-Za-z0-9_]+/g) + ?.map((t) => t.trim()) + .filter(Boolean) ?? []; if (tokens.length === 0) return null; - const quoted = tokens.map((t) => `"${t.replaceAll("\"", "")}"`); + const quoted = tokens.map((t) => `"${t.replaceAll('"', "")}"`); return quoted.join(" AND "); } @@ -603,9 +602,11 @@ export class MemoryIndexManager { ? { enabled: true, entries: - (this.db - .prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`) - .get() as { c: number } | undefined)?.c ?? 0, + ( + this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`).get() as + | { c: number } + | undefined + )?.c ?? 0, maxEntries: this.cache.maxEntries, } : { enabled: false, maxEntries: this.cache.maxEntries }, @@ -1412,9 +1413,9 @@ export class MemoryIndexManager { if (!this.cache.enabled) return; const max = this.cache.maxEntries; if (!max || max <= 0) return; - const row = this.db - .prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`) - .get() as { c: number } | undefined; + const row = this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`).get() as + | { c: number } + | undefined; const count = row?.c ?? 0; if (count <= max) return; const excess = count - max; @@ -1896,7 +1897,9 @@ export class MemoryIndexManager { .run(entry.path, options.source, this.provider.model); } catch {} } - this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(entry.path, options.source); + this.db + .prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`) + .run(entry.path, options.source); for (let i = 0; i < chunks.length; i++) { const chunk = chunks[i]; const embedding = embeddings[i] ?? []; diff --git a/src/slack/directory-live.ts b/src/slack/directory-live.ts index 3b9cab871..dd92ba848 100644 --- a/src/slack/directory-live.ts +++ b/src/slack/directory-live.ts @@ -80,7 +80,9 @@ export async function listSlackDirectoryPeersLive( const name = member.profile?.display_name || member.profile?.real_name || member.real_name; const handle = member.name; const email = member.profile?.email; - const candidates = [name, handle, email].map((item) => item?.trim().toLowerCase()).filter(Boolean); + const candidates = [name, handle, email] + .map((item) => item?.trim().toLowerCase()) + .filter(Boolean); if (!query) return true; return candidates.some((candidate) => candidate?.includes(query)); }); diff --git a/src/slack/monitor/provider.ts b/src/slack/monitor/provider.ts index cbf0dc463..a1de12471 100644 --- a/src/slack/monitor/provider.ts +++ b/src/slack/monitor/provider.ts @@ -187,9 +187,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) { unresolved.push(entry.input); continue; } - mapping.push( - `${entry.input}→${entry.id}${entry.archived ? " (archived)" : ""}`, - ); + mapping.push(`${entry.input}→${entry.id}${entry.archived ? " (archived)" : ""}`); const existing = nextChannels[entry.id] ?? {}; nextChannels[entry.id] = { ...source, ...existing }; } @@ -276,7 +274,9 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) { ctx.channelsConfig = nextChannels; summarizeMapping("slack channel users", mapping, unresolved, runtime); } catch (err) { - runtime.log?.(`slack channel user resolve failed; using config entries. ${String(err)}`); + runtime.log?.( + `slack channel user resolve failed; using config entries. ${String(err)}`, + ); } } } diff --git a/src/slack/resolve-users.ts b/src/slack/resolve-users.ts index 65183615e..034923399 100644 --- a/src/slack/resolve-users.ts +++ b/src/slack/resolve-users.ts @@ -88,11 +88,7 @@ function scoreSlackUser(user: SlackUserLookup, match: { name?: string; email?: s if (match.email && user.email === match.email) score += 5; if (match.name) { const target = match.name.toLowerCase(); - const candidates = [ - user.name, - user.displayName, - user.realName, - ] + const candidates = [user.name, user.displayName, user.realName] .map((value) => value?.toLowerCase()) .filter(Boolean) as string[]; if (candidates.some((value) => value === target)) score += 2; @@ -147,11 +143,7 @@ export async function resolveSlackUserAllowlist(params: { if (parsed.name) { const target = parsed.name.toLowerCase(); const matches = users.filter((user) => { - const candidates = [ - user.name, - user.displayName, - user.realName, - ] + const candidates = [user.name, user.displayName, user.realName] .map((value) => value?.toLowerCase()) .filter(Boolean) as string[]; return candidates.includes(target);