From f76e171f0f2c8e742876c0f4fa1f2400fc6a650f Mon Sep 17 00:00:00 2001 From: Lesnak1 Date: Mon, 17 Aug 2026 03:44:28 +0300 Subject: [PATCH] fix(logging): route diagnostic logs to stderr to prevent stdio transport corruption Resolves #15 --- sidebar.ts | 3 +-- tools.ts | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sidebar.ts b/sidebar.ts index f367b95..8f960aa 100644 --- a/sidebar.ts +++ b/sidebar.ts @@ -1793,8 +1793,7 @@ export async function fetchAndUpdateSidebar() { throw new Error(`Failed to fetch sidebar: ${response.statusText}`); } sidebarContent = await response.text(); - console.log('Successfully fetched and updated sidebar content'); - console.log(sidebarContent); + console.error('Successfully fetched and updated sidebar content'); } catch (error) { console.error('Error fetching sidebar:', error); // We'll keep using the fallback content if fetch fails diff --git a/tools.ts b/tools.ts index c83fa47..d400bd6 100644 --- a/tools.ts +++ b/tools.ts @@ -5,26 +5,26 @@ import { z } from "zod"; export const getGuide = async ({ guideLink, }: z.infer) => { - console.log("Received request for guide:", guideLink); + console.error("Received request for guide:", guideLink); try { // Remove the base URL prefix and ensure the path starts correctly const guidePath = guideLink.replace("https://docs.base.org", ""); const githubRawUrl = `https://raw.githubusercontent.com/base/web/refs/heads/master/apps/base-docs/docs/pages${guidePath}.mdx`; - console.log("Fetching from URL:", githubRawUrl); + console.error("Fetching from URL:", githubRawUrl); const response = await fetch(githubRawUrl); if (!response.ok) { throw new Error(`Failed to fetch guide: ${response.statusText}`); } const guide = await response.text(); - console.log("Successfully fetched guide content"); + console.error("Successfully fetched guide content"); let finalResult = guide; if (process.env.OPENAI_API_KEY) { const client = new OpenAI(); // Process the guide content with GPT-4 - console.log("Processing with ChatGPT..."); + console.error("Processing with ChatGPT..."); const result = await client.responses.create({ model: "gpt-4o-mini", input: [ @@ -37,7 +37,7 @@ export const getGuide = async ({ ], }); finalResult = result.output_text; - console.log("Successfully processed guide content"); + console.error("Successfully processed guide content"); } return {