AI Hakeem Assistant - VS Code Extension
An agentic coding assistant extension for VS Code, powered by a C# backend.
Architecture
The extension uses stdio JSON-RPC for communication with the C# backend:
- VS Code Extension (TypeScript/Node.js) – Provides the UI (webview chat panel)
- C# Host Process – Console app that wraps your backend DLL and speaks JSON-RPC over stdin/stdout
- Your Backend DLL – The core AI/agentic logic
Quick Start
1. Set Up Node Dependencies
cd d:\MyFiles\Projects\alhakeem-vs-code-extension
npm install
2. Build the Extension
npm run build
This compiles TypeScript to JavaScript in dist/extension.js.
3. Set Up the C# Host
The C# host template is in csharp-host/:
cd csharp-host
dotnet new console -f net8.0 -n AlhakeemHost --force
Then update csharp-host/Program.cs to integrate your backend DLL:
// In Program.cs, HandleChat method:
var backendService = new YourBackendService();
var response = await backendService.ProcessMessageAsync(userMessage);
return new { reply = response.text };
4. Build the C# Host
cd csharp-host
dotnet publish -c Release
The executable will be in csharp-host/bin/Release/net8.0/publish/.
Open VS Code settings and configure:
{
"alhakeem.useStdio": true,
"alhakeem.backendPath": "D:\\path\\to\\csharp-host\\bin\\Release\\net8.0\\publish\\AlhakeemHost.exe"
}
6. Run the Extension
In VS Code (Extension Development Host):
- Open this folder in VS Code
- Press
Ctrl+Shift+D to open the debug panel
- Click "Run Extension"
The extension will launch in a new VS Code window. The chat panel should appear on the right side.
Project Structure
alhakeem-vs-code-extension/
├── src/
│ ├── extension.ts # Main extension entry point
│ ├── backend/
│ │ └── connection.ts # JSON-RPC stdio client
│ └── panels/
│ └── chatPanel.ts # Webview panel logic
├── media/
│ ├── chat.css # Webview styles (blue/dark theme)
│ ├── chat.js # Webview client-side logic
│ └── icon.svg # Extension icon
├── csharp-host/
│ ├── Host.csproj # C# project file
│ └── Program.cs # JSON-RPC host implementation
├── package.json # NPM dependencies and scripts
├── tsconfig.json # TypeScript config
└── README.md
JSON-RPC Protocol
The extension and backend communicate via line-delimited JSON-RPC 2.0:
Request (Extension → Backend)
{"jsonrpc":"2.0","method":"chat","params":{"message":"Hello","history":[...]},"id":"uuid-here"}
Response (Backend → Extension)
{"jsonrpc":"2.0","result":{"reply":"Response text"},"id":"uuid-here"}
Notification (one-way, no id field)
{"jsonrpc":"2.0","method":"log","params":{"level":"info","text":"Status update"}}
Supported Methods
chat (Request)
Params:
message (string) – User query
history (ChatMessage[]) – Conversation history
Response:
reply (string) – Assistant response
- (add other fields as needed)
ping (Request)
Response:
UI Design
The extension provides a webview chat panel with:
- Blue user messages (accent:
#0d47a1)
- Dark assistant responses (
#2a2a2a)
- Responsive input field at the bottom
- Auto-scroll on new messages
- Timestamps for each message
The design matches the provided screenshot.
Debugging
Extension Debugging
Press F5 in VS Code to start the extension in debug mode. The extension host window will open.
Backend Debugging
Attach a debugger to the C# process:
- Run the C# host with debugger support
- Use Visual Studio or VS Code's C# extension to attach
Or print logs to stderr:
Console.Error.WriteLine($"[Debug] {message}");
These will appear in the "Debug Console" of the extension host.
Configuration
| Setting |
Type |
Default |
Description |
alhakeem.useStdio |
boolean |
true |
Use stdio JSON-RPC (stdio mode) or HTTP |
alhakeem.backendPath |
string |
"" |
Path to C# host .exe (required for stdio mode) |
alhakeem.backend.host |
string |
127.0.0.1 |
Backend hostname (HTTP mode) |
alhakeem.backend.port |
number |
5000 |
Backend port (HTTP mode) |
Extending the Extension
Add New RPC Methods
- In C# Host (
csharp-host/Program.cs):
case "your_method":
result = await HandleYourMethod(request);
break;
- In TypeScript (src/extension.ts or panels/chatPanel.ts):
const response = await backendConnection.request('your_method', { param1: 'value' });
Add UI Features
Edit media/chat.js and media/chat.css to add new UI elements. Messages are sent to the extension via:
vscode.postMessage({
type: 'your_event_type',
payload: { /* data */ }
});
Troubleshooting
Backend won't start
- Verify the executable path in settings
- Check that the .NET runtime is installed:
dotnet --version
- Check stderr output in VS Code debug console
Messages not sent
- Check browser console (F12 in webview) for JS errors
- Verify stdin/stdout connection in backend
Extension not appearing
- Ensure
npm install completed successfully
- Run
npm run build to compile TypeScript
- Restart the extension host (Ctrl+R)
License
[Your License]