-
Notifications
You must be signed in to change notification settings - Fork 614
fix: update kimi init script and acp command #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughDefault Kimi CLI invocation and init commands changed; ACP process manager now performs pre-start health checks, wraps connection init in a 5-minute timeout, logs startup/success/failure, attaches stdout/stderr hooks, records lifecycle telemetry, and force-kills on failed startups. Changes
Sequence Diagram(s)sequenceDiagram
participant Spawner as Process Spawner
participant Child as ACP Child Process
participant Connector as ClientSideConnection
participant Logger as Telemetry/Logger
Spawner->>Child: spawn child (record pid)
Spawner->>Logger: log "spawn" (pid)
Note right of Spawner: verify child not killed
Spawner->>Connector: initialize connection (Promise.race with 5min timeout)
alt init success
Connector-->>Spawner: ready
Spawner->>Logger: log "init success" (readyAt, pid)
Child->>Logger: stdout/stderr -> hooked logs
else init failure or timeout
Connector-->>Spawner: error/timeout
Spawner->>Logger: log "init failure" (error, pid)
Spawner->>Child: force kill (if running)
Spawner->>Logger: log "killed" (pid)
end
Child->>Spawner: exit event
Spawner->>Logger: log "exit" (pid, code)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🧰 Additional context used📓 Path-based instructions (25)package.json📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Files:
**/*.{ts,tsx,js,jsx,vue}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.vue📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/renderer/**/*.vue📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/renderer/src/**/*.{vue,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)
Files:
src/**/*📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Files:
src/renderer/**/*.{vue,js,ts}📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Files:
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Files:
src/renderer/src/**/*.vue📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Files:
src/renderer/**/*.{ts,tsx,vue}📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Files:
src/renderer/**📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Files:
src/renderer/**/*.{ts,vue}📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Files:
src/renderer/src/**/*.{ts,tsx,vue}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/renderer/src/components/**/*.vue📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.{ts,tsx,vue,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/renderer/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,ts,jsx,tsx,mjs,cjs}📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Files:
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Files:
src/renderer/**/composables/*.ts📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Files:
src/renderer/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Files:
src/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (8)📚 Learning: 2025-11-25T05:26:15.918ZApplied to files:
📚 Learning: 2025-11-25T05:28:20.500ZApplied to files:
📚 Learning: 2025-11-25T05:28:20.500ZApplied to files:
📚 Learning: 2025-11-25T05:26:15.918ZApplied to files:
📚 Learning: 2025-11-25T05:28:20.500ZApplied to files:
📚 Learning: 2025-11-25T05:28:04.439ZApplied to files:
📚 Learning: 2025-11-25T05:28:04.439ZApplied to files:
📚 Learning: 2025-11-25T05:26:11.297ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (1)
184-221: Timeout promise continues running after successful initialization.The timeout promise created at lines 195-203 will continue its
setTimeouteven afterinitPromiseresolves successfully. While this is a minor memory concern (the rejection is a no-op afterPromise.racesettles), it's cleaner to cancel the timer.const timeoutMs = 30000 // 30 seconds timeout for initialization + let timeoutId: NodeJS.Timeout | undefined try { const initPromise = connection.initialize({ protocolVersion: PROTOCOL_VERSION, clientCapabilities: {}, clientInfo: { name: 'DeepChat', version: app.getVersion() } }) const timeoutPromise = new Promise<never>((_, reject) => { - setTimeout(() => { + timeoutId = setTimeout(() => { reject( new Error( `[ACP] Connection initialization timeout after ${timeoutMs}ms for agent ${agent.id}` ) ) }, timeoutMs) }) await Promise.race([initPromise, timeoutPromise]) + clearTimeout(timeoutId) console.info(`[ACP] Connection initialization completed successfully for agent ${agent.id}`) } catch (error) { + clearTimeout(timeoutId) console.error(`[ACP] Connection initialization failed for agent ${agent.id}:`, error)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/presenter/configPresenter/acpConfHelper.ts(1 hunks)src/main/presenter/configPresenter/acpInitHelper.ts(1 hunks)src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Enable and maintain strict TypeScript type checking for all files
**/*.{ts,tsx}: Always use try-catch to handle possible errors in TypeScript code
Provide meaningful error messages when catching errors
Log detailed error logs including error details, context, and stack traces
Distinguish and handle different error types (UserError, NetworkError, SystemError, BusinessError) with appropriate handlers in TypeScript
Use structured logging with logger.error(), logger.warn(), logger.info(), logger.debug() methods from logging utilities
Do not suppress errors (avoid empty catch blocks or silently ignoring errors)
Provide user-friendly error messages for user-facing errors in TypeScript components
Implement error retry mechanisms for transient failures in TypeScript
Avoid logging sensitive information (passwords, tokens, PII) in logs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Organize core business logic into dedicated Presenter classes, with one presenter per functional domain
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use EventBus from
src/main/eventbus.tsfor main-to-renderer communication, broadcasting events viamainWindow.webContents.send()
src/main/**/*.ts: Use EventBus pattern for inter-process communication within the main process to decouple modules
Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations
src/main/**/*.ts: Electron main process code belongs insrc/main/with presenters inpresenter/(Window/Tab/Thread/Mcp/Config/LLMProvider) andeventbus.tsfor app events
Use the Presenter pattern in the main process for UI coordination
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Do not include AI co-authoring information (e.g., 'Co-Authored-By: Claude') in git commits
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Write logs and comments in English
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/main/presenter/llmProviderPresenter/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)
Define the standardized
LLMCoreStreamEventinterface with fields:type(text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data),content(for text),reasoning_content(for reasoning),tool_call_id,tool_call_name,tool_call_arguments_chunk(for streaming),tool_call_arguments_complete(for complete arguments),error_message,usageobject with token counts,stop_reason(tool_use | max_tokens | stop_sequence | error | complete), andimage_dataobject with Base64-encoded data and mimeType
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
New features should be developed in the
srcdirectory
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/main/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Main process code for Electron should be placed in
src/main
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/**/*.{ts,tsx,vue,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier with single quotes, no semicolons, and 100 character width
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use OxLint for linting JavaScript and TypeScript files
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Use camelCase for variable and function names in TypeScript files
Use PascalCase for type and class names in TypeScript
Use SCREAMING_SNAKE_CASE for constant names
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use EventBus for inter-process communication events
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
src/main/presenter/configPresenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Store and retrieve custom prompts via
configPresenter.getCustomPrompts()for config-based data source management
Files:
src/main/presenter/configPresenter/acpConfHelper.tssrc/main/presenter/configPresenter/acpInitHelper.ts
🧠 Learnings (5)
📚 Learning: 2025-11-25T05:27:12.201Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.201Z
Learning: Implement separation of concerns where `src/main/presenter/llmProviderPresenter/index.ts` manages the Agent loop and conversation history, while Provider files handle LLM API interactions, Provider-specific request/response formatting, tool definition conversion, and native vs non-native tool call mechanisms
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:26:11.297Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.297Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:27:12.201Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.201Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts` (`startStreamCompletion`), implement the Agent loop that manages the overall conversation flow, including multiple rounds of LLM calls and tool usage, maintaining `conversationMessages` history, calling `provider.coreStream()` on each iteration, and controlling the loop using `needContinueConversation` and `toolCallCount` (compared against `MAX_TOOL_CALLS`)
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:26:24.860Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/electron-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:26:24.860Z
Learning: Applies to {src/main/presenter/**/*.ts,src/renderer/**/*.ts} : Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:27:12.201Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.201Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts`, listen for standardized events yielded by `coreStream` and handle them accordingly: buffer text content (`currentContent`), handle `tool_call_start/chunk/end` events by collecting tool details and calling `presenter.mcpPresenter.callTool`, send frontend events via `eventBus` with tool call status, format tool results for the next LLM call, and set `needContinueConversation = true`
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
🧬 Code graph analysis (1)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (1)
test/mocks/electron.ts (1)
app(2-10)
🔇 Additional comments (5)
src/main/presenter/configPresenter/acpConfHelper.ts (1)
27-28: LGTM!The default profile update aligns with the new initialization flow in
acpInitHelper.ts. Afteruv tool install kimi-cliis executed during initialization, thekimicommand becomes available system-wide, making this direct invocation correct.src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (4)
177-182: LGTM - Good defensive check.Pre-initialization health check properly guards against the race condition where the process exits before initialization begins. The error message is descriptive with the PID included for debugging.
254-259: LGTM - Improved stderr logging.The enhanced stderr logging with trimming and conditional output is appropriate for capturing agent errors. Unlike stdout, stderr is not consumed by the protocol stream.
261-266: LGTM - Good process error handling.Adding an error handler for the child process prevents unhandled
errorevents (e.g., spawn failures, ENOENT). The monitoring log provides useful observability.
238-239: LGTM - Improved exit logging.Including the PID in the exit log message improves debuggability when multiple agent processes are running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (1)
247-252: Remove stdout logging - it corrupts the ACP protocol stream.This stdout listener conflicts with the protocol stream consumer. At line 173,
createAgentStream()convertschild.stdoutto a Web ReadableStream and passes it tondJsonStream()(line 546), which the ACPClientSideConnectionimmediately begins consuming for JSON-RPC messages (line 175). Adding this separate.on('data')listener at lines 247-252 creates competing consumers that unpredictably split the stream data, corrupting protocol messages and causing parsing failures.Remove these stdout listeners entirely:
- child.stdout?.on('data', (chunk: Buffer) => { - const output = chunk.toString().trim() - if (output) { - console.info(`[ACP] ${agent.id} stdout: ${output}`) - } - }) -If debugging output is needed, use ACP's diagnostic mechanisms or implement non-invasive logging (e.g., stream duplication via
Transformbefore Web conversion), not competing data listeners.
🧹 Nitpick comments (2)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (2)
186-186: Reduce initialization timeout from 5 minutes to 30-60 seconds.A 5-minute timeout is excessive for connection initialization. Typical ACP handshakes complete within seconds, and a hang beyond 30-60 seconds usually indicates an unrecoverable failure. The current timeout delays error detection and degrades user experience.
Apply this diff to use a 60-second timeout:
- const timeoutMs = 60 * 1000 * 5 // 5 minutes timeout for initialization + const timeoutMs = 60 * 1000 // 60 seconds timeout for initializationOr for a 30-second timeout:
- const timeoutMs = 60 * 1000 * 5 // 5 minutes timeout for initialization + const timeoutMs = 30 * 1000 // 30 seconds timeout for initializationAlso applies to: 195-203
186-186: Reorder timeout calculation for clarity.
60 * 1000 * 5reads as "60 seconds times 5". Reordering to5 * 60 * 1000makes the intent clearer: "5 minutes in milliseconds".- const timeoutMs = 60 * 1000 * 5 // 5 minutes timeout for initialization + const timeoutMs = 5 * 60 * 1000 // 5 minutes timeout for initialization
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Enable and maintain strict TypeScript type checking for all files
**/*.{ts,tsx}: Always use try-catch to handle possible errors in TypeScript code
Provide meaningful error messages when catching errors
Log detailed error logs including error details, context, and stack traces
Distinguish and handle different error types (UserError, NetworkError, SystemError, BusinessError) with appropriate handlers in TypeScript
Use structured logging with logger.error(), logger.warn(), logger.info(), logger.debug() methods from logging utilities
Do not suppress errors (avoid empty catch blocks or silently ignoring errors)
Provide user-friendly error messages for user-facing errors in TypeScript components
Implement error retry mechanisms for transient failures in TypeScript
Avoid logging sensitive information (passwords, tokens, PII) in logs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Organize core business logic into dedicated Presenter classes, with one presenter per functional domain
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use EventBus from
src/main/eventbus.tsfor main-to-renderer communication, broadcasting events viamainWindow.webContents.send()
src/main/**/*.ts: Use EventBus pattern for inter-process communication within the main process to decouple modules
Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations
src/main/**/*.ts: Electron main process code belongs insrc/main/with presenters inpresenter/(Window/Tab/Thread/Mcp/Config/LLMProvider) andeventbus.tsfor app events
Use the Presenter pattern in the main process for UI coordination
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Do not include AI co-authoring information (e.g., 'Co-Authored-By: Claude') in git commits
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Write logs and comments in English
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/main/presenter/llmProviderPresenter/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)
Define the standardized
LLMCoreStreamEventinterface with fields:type(text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data),content(for text),reasoning_content(for reasoning),tool_call_id,tool_call_name,tool_call_arguments_chunk(for streaming),tool_call_arguments_complete(for complete arguments),error_message,usageobject with token counts,stop_reason(tool_use | max_tokens | stop_sequence | error | complete), andimage_dataobject with Base64-encoded data and mimeType
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
New features should be developed in the
srcdirectory
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/main/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Main process code for Electron should be placed in
src/main
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*.{ts,tsx,vue,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier with single quotes, no semicolons, and 100 character width
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use OxLint for linting JavaScript and TypeScript files
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Use camelCase for variable and function names in TypeScript files
Use PascalCase for type and class names in TypeScript
Use SCREAMING_SNAKE_CASE for constant names
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use EventBus for inter-process communication events
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
🧠 Learnings (4)
📚 Learning: 2025-11-25T05:27:12.201Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.201Z
Learning: Implement separation of concerns where `src/main/presenter/llmProviderPresenter/index.ts` manages the Agent loop and conversation history, while Provider files handle LLM API interactions, Provider-specific request/response formatting, tool definition conversion, and native vs non-native tool call mechanisms
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:26:11.297Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.297Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:27:12.201Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.201Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts` (`startStreamCompletion`), implement the Agent loop that manages the overall conversation flow, including multiple rounds of LLM calls and tool usage, maintaining `conversationMessages` history, calling `provider.coreStream()` on each iteration, and controlling the loop using `needContinueConversation` and `toolCallCount` (compared against `MAX_TOOL_CALLS`)
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:26:24.860Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/electron-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:26:24.860Z
Learning: Applies to {src/main/presenter/**/*.ts,src/renderer/**/*.ts} : Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
🧬 Code graph analysis (1)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (1)
test/mocks/electron.ts (1)
app(2-10)
🔇 Additional comments (4)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (4)
177-182: Good defensive check before initialization.This health check prevents attempting to initialize a connection to an already-dead process. The error message includes helpful debugging context.
207-221: Well-structured error handling and cleanup.The error handling properly logs failures, cleans up the child process if still running, and re-throws to propagate the error. The try-catch around
child.kill()prevents secondary failures during cleanup.
254-259: Stderr logging is safe and helpful.Unlike stdout, stderr is not part of the ACP protocol stream (only stdout is converted to Web stream in
createAgentStream), so this logging listener doesn't interfere with protocol parsing. The trim and conditional check avoid noise from empty lines.
261-266: Good addition for process observability.The error event handler captures process-level errors that might not immediately trigger exit events, improving debugging capabilities. The monitoring log confirms setup with helpful context.
Summary by CodeRabbit
Chores
Bug Fixes / Reliability
Refactor
Style
✏️ Tip: You can customize this high-level summary in your review settings.