diff --git a/benchmark/apps/cli/src/index.ts b/benchmark/apps/cli/src/index.ts index d8daa34378..8410c43277 100644 --- a/benchmark/apps/cli/src/index.ts +++ b/benchmark/apps/cli/src/index.ts @@ -222,30 +222,23 @@ const runExercise = async ({ run, task, server }: { run: Run; task: Task; server }) client.sendMessage({ - type: IpcMessageType.VSCodeCommand, + type: IpcMessageType.TaskCommand, origin: IpcOrigin.Client, clientId: client.clientId!, - data: "workbench.action.closeWindow", + data: { + commandName: TaskCommandName.StartNewTask, + data: { + configuration: { + ...rooCodeDefaults, + openRouterApiKey: process.env.OPENROUTER_API_KEY!, + ...run.settings, + }, + text: prompt, + newTab: true, + }, + }, }) - // client.sendMessage({ - // type: IpcMessageType.TaskCommand, - // origin: IpcOrigin.Client, - // clientId: client.clientId!, - // data: { - // commandName: TaskCommandName.StartNewTask, - // data: { - // configuration: { - // ...rooCodeDefaults, - // openRouterApiKey: process.env.OPENROUTER_API_KEY!, - // ...run.settings, - // }, - // text: prompt, - // newTab: true, - // }, - // }, - // }) - console.log(`[cli#runExercise | ${language} / ${exercise}] StartNewTask`) try { diff --git a/src/exports/api.ts b/src/exports/api.ts index 2d2e695b05..8bbb93486e 100644 --- a/src/exports/api.ts +++ b/src/exports/api.ts @@ -6,9 +6,9 @@ import { openClineInNewTab } from "../activate/registerCommands" import { RooCodeSettings, RooCodeEvents, RooCodeEventName } from "../schemas" import { IpcOrigin, IpcMessageType, TaskCommandName, TaskEvent } from "../schemas/ipc" -import { formatLog } from "./formatLog" import { RooCodeAPI } from "./interface" import { IpcServer } from "./ipc" +import { outputChannelLog } from "./log" export class API extends EventEmitter implements RooCodeAPI { private readonly outputChannel: vscode.OutputChannel @@ -27,8 +27,7 @@ export class API extends EventEmitter implements RooCodeAPI { this.registerListeners(this.sidebarProvider) if (socketPath) { - this.ipc = new IpcServer(socketPath, (...args: unknown[]) => formatLog(this.outputChannel, ...args)) - + this.ipc = new IpcServer(socketPath, (...args: unknown[]) => outputChannelLog(this.outputChannel, ...args)) this.ipc.listen() this.outputChannel.appendLine( diff --git a/src/exports/formatLog.ts b/src/exports/formatLog.ts deleted file mode 100644 index 30142ffee4..0000000000 --- a/src/exports/formatLog.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @fileoverview Utility for robust object logging with special handling for various data types - */ - -import * as vscode from "vscode" - -/** - * Formats and logs values to a VSCode output channel with special handling for various data types - * - * Features: - * - Explicit handling for null and undefined values - * - Special handling for Error objects to preserve stack traces - * - Handles circular references in objects - * - Properly formats special types like BigInt, functions, and symbols - * - Pretty prints objects with indentation for better readability - * - * @param outputChannel - The VSCode output channel to log to - * @param args - The values to log - */ -export function formatLog(outputChannel: vscode.OutputChannel, ...args: unknown[]): void { - for (const arg of args) { - if (arg === null) { - outputChannel.appendLine("null") - } else if (arg === undefined) { - outputChannel.appendLine("undefined") - } else if (typeof arg === "string") { - outputChannel.appendLine(arg) - } else if (arg instanceof Error) { - // Special handling for Error objects to preserve stack traces - outputChannel.appendLine(`Error: ${arg.message}\n${arg.stack || ""}`) - } else { - try { - outputChannel.appendLine( - JSON.stringify( - arg, - (key, value) => { - // Handle special types that JSON.stringify doesn't handle well - if (typeof value === "bigint") return `BigInt(${value})` - if (typeof value === "function") return `Function: ${value.name || "anonymous"}` - if (typeof value === "symbol") return value.toString() - return value - }, - 2, - ), - ) // Pretty print with 2 spaces - } catch (error) { - // Handle circular references or other JSON.stringify errors - outputChannel.appendLine(`[Non-serializable object: ${Object.prototype.toString.call(arg)}]`) - } - } - } -} diff --git a/src/exports/log.ts b/src/exports/log.ts new file mode 100644 index 0000000000..1d77172fd1 --- /dev/null +++ b/src/exports/log.ts @@ -0,0 +1,32 @@ +import * as vscode from "vscode" + +export function outputChannelLog(outputChannel: vscode.OutputChannel, ...args: unknown[]) { + for (const arg of args) { + if (arg === null) { + outputChannel.appendLine("null") + } else if (arg === undefined) { + outputChannel.appendLine("undefined") + } else if (typeof arg === "string") { + outputChannel.appendLine(arg) + } else if (arg instanceof Error) { + outputChannel.appendLine(`Error: ${arg.message}\n${arg.stack || ""}`) + } else { + try { + outputChannel.appendLine( + JSON.stringify( + arg, + (key, value) => { + if (typeof value === "bigint") return `BigInt(${value})` + if (typeof value === "function") return `Function: ${value.name || "anonymous"}` + if (typeof value === "symbol") return value.toString() + return value + }, + 2, + ), + ) + } catch (error) { + outputChannel.appendLine(`[Non-serializable object: ${Object.prototype.toString.call(arg)}]`) + } + } + } +}