diff --git a/src/cli/App.tsx b/src/cli/App.tsx index 49ce3c4..96088c9 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -2547,7 +2547,11 @@ export default function App({ setApprovalContexts(contexts); } catch (error) { // If analysis fails, leave context as null (will show basic options) - console.error("Failed to analyze startup approvals:", error); + debugLog( + "approvals", + "Failed to analyze startup approvals: %O", + error, + ); } }; @@ -2861,7 +2865,7 @@ export default function App({ setCurrentToolset(persistedToolsetPreference); } } catch (error) { - console.error("Error fetching agent config:", error); + debugLog("agent-config", "Error fetching agent config: %O", error); } }; fetchConfig(); @@ -3680,7 +3684,7 @@ export default function App({ } } catch (error) { // Silently fail - don't interrupt the conversation flow - console.error("Failed to sync agent state:", error); + debugLog("sync-agent", "Failed to sync agent state: %O", error); } }; @@ -7496,8 +7500,9 @@ export default function App({ setApprovalContexts(contexts); } catch (approvalError) { // If analysis fails, leave context as null (will show basic options) - console.error( - "Failed to analyze resume approvals:", + debugLog( + "approvals", + "Failed to analyze resume approvals: %O", approvalError, ); } @@ -9524,9 +9529,12 @@ ${SYSTEM_REMINDER_CLOSE} a.size === b.size && [...a].every((id) => b.has(id)); if (!setsEqual(expectedIds, sendingIds)) { - console.error("[BUG] Approval ID mismatch detected"); - console.error("Expected IDs:", Array.from(expectedIds)); - console.error("Sending IDs:", Array.from(sendingIds)); + debugLog( + "approvals", + "[BUG] Approval ID mismatch detected. Expected: %O, Sending: %O", + Array.from(expectedIds), + Array.from(sendingIds), + ); throw new Error( "Approval ID mismatch - refusing to send mismatched IDs", ); @@ -12229,8 +12237,9 @@ Plan file path: ${planFilePath}`; setApprovalContexts(contexts); } catch (approvalError) { // If analysis fails, leave context as null (will show basic options) - console.error( - "Failed to analyze resume approvals:", + debugLog( + "approvals", + "Failed to analyze resume approvals: %O", approvalError, ); } diff --git a/src/cli/components/MemoryTabViewer.tsx b/src/cli/components/MemoryTabViewer.tsx index 06a5e78..e8dbfcd 100644 --- a/src/cli/components/MemoryTabViewer.tsx +++ b/src/cli/components/MemoryTabViewer.tsx @@ -3,6 +3,7 @@ import { Box, useInput } from "ink"; import Link from "ink-link"; import { useEffect, useState } from "react"; import { getClient } from "../../agent/client"; +import { debugLog } from "../../utils/debug"; import { useTerminalWidth } from "../hooks/useTerminalWidth"; import { colors } from "./colors"; import { MarkdownDisplay } from "./MarkdownDisplay"; @@ -56,7 +57,7 @@ export function MemoryTabViewer({ }); setFreshBlocks(agent.memory?.blocks || []); } catch (error) { - console.error("Failed to fetch memory blocks:", error); + debugLog("memory-tab", "Failed to fetch memory blocks: %O", error); // Fall back to passed-in blocks if fetch fails setFreshBlocks(blocks); } finally { diff --git a/src/cli/components/ProviderSelector.tsx b/src/cli/components/ProviderSelector.tsx index e2c29ca..3a585e1 100644 --- a/src/cli/components/ProviderSelector.tsx +++ b/src/cli/components/ProviderSelector.tsx @@ -15,6 +15,7 @@ import { type AwsProfile, parseAwsCredentials, } from "../../utils/aws-credentials"; +import { debugLog } from "../../utils/debug"; import { useTerminalWidth } from "../hooks/useTerminalWidth"; import { colors } from "./colors"; import { Text } from "./Text"; @@ -166,8 +167,7 @@ export function ProviderSelector({ } }) .catch((err) => { - // eslint-disable-next-line no-console - console.error("Failed to parse AWS credentials:", err); + debugLog("provider", "Failed to parse AWS credentials: %O", err); if (mountedRef.current) { setAwsProfiles([]); setIsLoadingProfiles(false); diff --git a/src/cli/helpers/fileSearch.ts b/src/cli/helpers/fileSearch.ts index be0c3a0..8d0f3b8 100644 --- a/src/cli/helpers/fileSearch.ts +++ b/src/cli/helpers/fileSearch.ts @@ -1,5 +1,6 @@ import { readdirSync, statSync } from "node:fs"; import { join, resolve } from "node:path"; +import { debugLog } from "../../utils/debug"; interface FileMatch { path: string; @@ -245,7 +246,7 @@ export async function searchFiles( }); } catch (error) { // Return empty array on any error - console.error("File search error:", error); + debugLog("file-search", "File search error: %O", error); return []; } diff --git a/src/tools/impl/Read.ts b/src/tools/impl/Read.ts index 0f2683e..11ecd55 100644 --- a/src/tools/impl/Read.ts +++ b/src/tools/impl/Read.ts @@ -8,6 +8,7 @@ import { LETTA_CLOUD_API_URL } from "../../auth/oauth.js"; import { resizeImageIfNeeded } from "../../cli/helpers/imageResize.js"; import { SYSTEM_REMINDER_CLOSE, SYSTEM_REMINDER_OPEN } from "../../constants"; import { settingsManager } from "../../settings-manager.js"; +import { debugLog } from "../../utils/debug.js"; import { OVERFLOW_CONFIG, writeOverflowFile } from "./overflow.js"; import { LIMITS } from "./truncation.js"; import { validateRequiredParams } from "./validation.js"; @@ -179,7 +180,7 @@ function formatWithLineNumbers( overflowPath = writeOverflowFile(content, workingDirectory, "Read"); } catch (error) { // Silently fail if overflow file creation fails - console.error("Failed to write overflow file:", error); + debugLog("read", "Failed to write overflow file: %O", error); } } diff --git a/src/tools/impl/truncation.ts b/src/tools/impl/truncation.ts index 0be2acd..00b36f1 100644 --- a/src/tools/impl/truncation.ts +++ b/src/tools/impl/truncation.ts @@ -4,6 +4,7 @@ * When outputs exceed limits, full content can be written to overflow files. */ +import { debugLog } from "../../utils/debug.js"; import { OVERFLOW_CONFIG, writeOverflowFile } from "./overflow.js"; // Limits based on Claude Code's proven production values @@ -64,7 +65,7 @@ export function truncateByChars( ); } catch (error) { // Silently fail if overflow file creation fails - console.error("Failed to write overflow file:", error); + debugLog("truncation", "Failed to write overflow file: %O", error); } } @@ -167,7 +168,7 @@ export function truncateByLines( ); } catch (error) { // Silently fail if overflow file creation fails - console.error("Failed to write overflow file:", error); + debugLog("truncation", "Failed to write overflow file: %O", error); } } @@ -250,7 +251,7 @@ export function truncateArray( ); } catch (error) { // Silently fail if overflow file creation fails - console.error("Failed to write overflow file:", error); + debugLog("truncation", "Failed to write overflow file: %O", error); } }