-
Notifications
You must be signed in to change notification settings - Fork 21
Mark/cli backend integration #141
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
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
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.
| @@ -0,0 +1,180 @@ | |||
| import EventSource from "eventsource" | |||
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.
CRITICAL: eventsource import style likely breaks with current TS config
packages/kilo-vscode/src/types/eventsource.d.ts declares the module with export =, but packages/kilo-vscode/src/services/cli-backend/sse-client.ts uses a default import. With esModuleInterop not enabled in packages/kilo-vscode/tsconfig.json, this can fail type-checking and/or runtime interop.
| import EventSource from "eventsource" | |
| import EventSource = require("eventsource") |
| }); | ||
|
|
||
| // Initialize connection to CLI backend | ||
| this.initializeConnection(); |
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.
WARNING: Potential duplicate SSE connections / leaked clients if the webview is resolved more than once
KiloProvider.resolveWebviewView() calls initializeConnection() each time it runs, and initializeConnection() creates a new SSEClient instance without disposing any prior one. If VS Code re-resolves the view (reload window, view recreated, etc.), the previous SSEClient can remain connected and events may be duplicated. Consider disposing/closing any existing SSE connection before creating a new one, or reusing the existing client/server instance.
| }); | ||
| break; | ||
|
|
||
| case 'session.created': |
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.
WARNING: session.created can bind currentSession to an unrelated session
In handleSSEEvent(), the session.created case sets currentSession whenever it’s currently null. Since the SSE stream appears directory-scoped (not session-scoped), a session.created event from another source could arrive first and cause the extension to attach UI actions to the wrong session. It’s safer to only set currentSession from the explicit createSession() response (or gate this assignment on some correlation/intent).
#134
Github forgot to rewriet the base.....