feat: CLI backend integration for VSCode extension#134
feat: CLI backend integration for VSCode extension#134markijbema merged 10 commits intomark/top-bar-buttonsfrom
Conversation
dc83b2d to
8674c36
Compare
Implement CLI backend integration to enable communication between the VSCode extension and the Kilo CLI backend server. New files: - src/services/cli-backend/types.ts - Type definitions for API requests/responses - src/services/cli-backend/server-manager.ts - Server lifecycle management - src/services/cli-backend/http-client.ts - REST API client for backend communication - src/services/cli-backend/sse-client.ts - SSE streaming client for real-time events - src/services/cli-backend/index.ts - Main exports - src/types/eventsource.d.ts - EventSource type declarations Modified files: - package.json - Added eventsource dependency - src/KiloProvider.ts - Integrated with CLI backend services - src/extension.ts - Updated to pass extension context - .vscodeignore - Updated exclusions Key features: - Server lifecycle management (start/stop/health checks) - HTTP client for REST API communication - SSE client for streaming responses - Webview integration for message passing
988c0cf to
ac47928
Compare
Update all debug console.log statements to use the prefix '[Kilo New]' followed by the component name for consistent logging across the CLI backend integration. Changed prefixes: - [KiloProvider] -> [Kilo New] KiloProvider: - [ServerManager] -> [Kilo New] ServerManager: - [CLI Server] -> [Kilo New] ServerManager: - [SSEClient] -> [Kilo New] SSE: - [Webview/App] -> [Kilo New] App:
The path was using '../../../opencode/bin/kilo' which resolved to 'kilo-with-vscode/opencode/bin/kilo' instead of the correct 'kilo-with-vscode/packages/opencode/bin/kilo'. Fixed by changing to '../../opencode/bin/kilo' which correctly navigates from packages/kilo-vscode/dist/ to packages/opencode/bin/kilo.
| * Get or start the server instance | ||
| */ | ||
| async getServer(): Promise<ServerInstance> { | ||
| console.log('[Kilo New] ServerManager: 🔍 getServer called'); |
There was a problem hiding this comment.
prefix this everywhere because i now have 2 kilo extensions running and i want to find these messages
| process: ChildProcess | ||
| } | ||
|
|
||
| export class ServerManager { |
There was a problem hiding this comment.
at some point we have to think about how exactly we want to do this, for production we probably need a release per platform. For now my criterium is that this 'just works' when i run the extension from my vscode.
5ff07b9 to
7a0d3b6
Compare
| @@ -0,0 +1,180 @@ | |||
| import EventSource from "eventsource" | |||
There was a problem hiding this comment.
CRITICAL: eventsource is declared with export = but imported as default
packages/kilo-vscode/src/types/eventsource.d.ts uses export = EventSource, which (with the current packages/kilo-vscode/tsconfig.json not enabling esModuleInterop) can make import EventSource from "eventsource" fail type-checking. Use a require-style import here (or enable esModuleInterop).
| import EventSource from "eventsource" | |
| import EventSource = require("eventsource") |
There was a problem hiding this comment.
That suggested change is wild and wrong, as it still does import.
| type: "permission.replied" | ||
| properties: { sessionID: string; requestID: string; reply: "once" | "always" | "reject" } | ||
| } | ||
| | { type: "todo.updated"; properties: { sessionID: string; items: TodoItem[] } } |
There was a problem hiding this comment.
WARNING: SSE todo.updated payload shape doesn't match server (todos vs items)
Server publishes todo.updated with properties.todos (see packages/opencode/src/session/todo.ts), but the VS Code client expects properties.items in packages/kilo-vscode/src/services/cli-backend/types.ts. This will silently drop todo updates at runtime.
| | { type: "todo.updated"; properties: { sessionID: string; items: TodoItem[] } } | |
| | { type: "todo.updated"; properties: { sessionID: string; todos: TodoItem[] } } |
|
|
||
| // Create HttpClient and SSEClient instances | ||
| this.httpClient = new HttpClient(config); | ||
| this.sseClient = new SSEClient(config); |
There was a problem hiding this comment.
WARNING: Re-resolving the webview can leak old SSE/EventSource connections
initializeConnection() always replaces this.sseClient / this.httpClient without disposing previous instances. If the webview is resolved multiple times (reload / view recreated), this can leave the old EventSource connected and duplicate event delivery. Consider disposing existing clients (or guarding initializeConnection() so it only runs once per extension activation).
| @@ -0,0 +1,180 @@ | |||
| import EventSource from "eventsource" | |||
There was a problem hiding this comment.
That suggested change is wild and wrong, as it still does import.
Summary
This PR implements CLI backend integration to enable communication between the VSCode extension and the Kilo CLI backend server.
Implementation Plan Reference
See
cli-backend-integration-plan-v2.mdfor the detailed implementation plan.Key Features
Server Lifecycle Management
HTTP Client
SSE Streaming Client
Webview Integration
Files Changed
New Files
src/services/cli-backend/types.ts- Type definitions for API requests/responsessrc/services/cli-backend/server-manager.ts- Server lifecycle managementsrc/services/cli-backend/http-client.ts- REST API clientsrc/services/cli-backend/sse-client.ts- SSE streaming clientsrc/services/cli-backend/index.ts- Main exportssrc/types/eventsource.d.ts- EventSource type declarationsModified Files
package.json- Added eventsource dependencysrc/KiloProvider.ts- Integrated with CLI backend servicessrc/extension.ts- Updated to pass extension context.vscodeignore- Updated exclusions