{"id":31975342,"url":"https://github.com/tsahil01/vscode-context-bridge","last_synced_at":"2025-10-14T20:39:32.693Z","repository":{"id":300921942,"uuid":"1007520981","full_name":"tsahil01/vscode-context-bridge","owner":"tsahil01","description":"Exposes editor context information via HTTP \u0026 WS APIs, allowing external apps to access real-time Editor state. Useful for building integrations, tools, or services that need to interact with the code editor.","archived":false,"fork":false,"pushed_at":"2025-07-15T06:08:13.000Z","size":1469,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-15T14:42:53.815Z","etag":null,"topics":["bridge","context","http","vscode","vscode-extension","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsahil01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T06:08:23.000Z","updated_at":"2025-07-15T06:08:16.000Z","dependencies_parsed_at":"2025-06-24T09:45:09.300Z","dependency_job_id":"77762dcd-44c0-4891-9201-202216581921","html_url":"https://github.com/tsahil01/vscode-context-bridge","commit_stats":null,"previous_names":["tsahil01/vscode-context-bridge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tsahil01/vscode-context-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsahil01%2Fvscode-context-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsahil01%2Fvscode-context-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsahil01%2Fvscode-context-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsahil01%2Fvscode-context-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsahil01","download_url":"https://codeload.github.com/tsahil01/vscode-context-bridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsahil01%2Fvscode-context-bridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020894,"owners_count":26086949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bridge","context","http","vscode","vscode-extension","websocket"],"created_at":"2025-10-14T20:39:31.650Z","updated_at":"2025-10-14T20:39:32.687Z","avatar_url":"https://github.com/tsahil01.png","language":"TypeScript","readme":"# Context Bridge Extension\n\n```sh\ncode --install-extension SahilTiwaskar.vscode-context-bridge\n```\n\nThe extension exposes editor context information via HTTP and WebSocket APIs, allowing external applications to access real-time VS Code editor state. \nThis can be useful for building integrations, tools, or services that need to interact with the VS Code editor environment.\n\n## Table of Contents\n- [Features](#features)\n- [Installation](#installation)\n  - [Prerequisites](#prerequisites)\n  - [Building from Source](#building-from-source)\n  - [Installing in VS Code](#installing-in-vs-code)\n- [Usage](#usage)\n- [Starting the Server](#starting-the-server)\n- [Configuration](#configuration)\n- [Available Commands](#available-commands)\n\n## Features\n\n- **Real-time Updates**: WebSocket support for live context updates\n- **Active File Information**: Get details about the currently open and active file\n- **Text Selection**: Access currently selected text with position information\n- **Open Tabs**: List all files/tabs currently open in the workspace\n- **Code Diffs**: Retrieve code changes and modifications in the workspace\n- **Diagnostics**: Access linting errors, warnings, and other diagnostics\n- **Command Execution**: Send commands to VS Code from external processes\n- **Change Proposals**: External tools can propose code changes with accept/reject interface\n- **Configurable**: Control what information is shared for privacy\n\n## Installation\n\n### Prerequisites\n\n- Visual Studio Code 1.74.0 or higher\n- Node.js 16.0.0 or higher\n\n### Building from Source\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/tsahil01/vscode-context-bridge\ncd vscode-context-bridge\n```\n\n2. Install dependencies:\n```bash\nnpm install\nnpm install -g vsce\n```\n\n3. Compile the extension:\n```bash\nnpm run compile\n```\n\n4. Package the extension (optional):\n```bash\nnpm run vscode:prepublish\n```\n\n5. Generate the VSIX file:\n```bash\nnpm run package\n```\n\n### Installing in VS Code\n\n1. Open VS Code\n2. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS) to open the command palette\n3. Type \"Extensions: Install from VSIX\" and select it\n4. Choose the compiled extension file (if packaged) or use the development version\n\n## Usage\n\n### Starting the Server\n\n1. Open VS Code with a workspace\n2. Press `Ctrl+Shift+P` to open the command palette\n3. Type `Start Context Bridge Server` and select it\n4. The server will start on the configured port (default: 3210)\n\n### Configuration\n\nThe extension can be configured through the VS Code settings:\n- Open settings (`Ctrl+,` or `Cmd+,` on macOS)\n- Search for `Context Bridge` and adjust the things you want to change.\n- OR you can change it from the status bar by clicking the `Context Bridge` icon.\n\n\n## API Reference\n\n### HTTP Endpoints\n\n#### GET /context\nRetrieve all context information.\n\n**Response:**\n```json\n{\n    \"activeFile\": {\n        \"path\": \"/path/to/file.ts\",\n        \"name\": \"file.ts\",\n        \"language\": \"typescript\",\n        \"content\": \"file content...\",\n        \"lineCount\": 100,\n        \"isDirty\": false\n    },\n    \"textSelection\": {\n        \"text\": \"selected text\",\n        \"startLine\": 10,\n        \"startCharacter\": 5,\n        \"endLine\": 10,\n        \"endCharacter\": 15,\n        \"range\": {\n            \"start\": {\"line\": 10, \"character\": 5},\n            \"end\": {\"line\": 10, \"character\": 15}\n        }\n    },\n    \"openTabs\": [\n        {\n            \"path\": \"/path/to/file.ts\",\n            \"name\": \"file.ts\",\n            \"language\": \"typescript\",\n            \"isActive\": true,\n            \"isDirty\": false\n        }\n    ],\n    \"diffs\": [\n        {\n            \"filePath\": \"/path/to/file.ts\",\n            \"fileName\": \"file.ts\",\n            \"changes\": [\n                {\n                    \"type\": \"add\",\n                    \"lineNumber\": 1,\n                    \"newText\": \"added content\"\n                },\n                {\n                    \"type\": \"delete\",\n                    \"lineNumber\": 2,\n                    \"originalText\": \"deleted content\"\n                },\n                {\n                    \"type\": \"modify\",\n                    \"lineNumber\": 3,\n                    \"newText\": \"modified content\"\n                }\n            ]\n        }\n    ],\n    \"diagnostics\": [\n        {\n            \"filePath\": \"/path/to/file.ts\",\n            \"fileName\": \"file.ts\",\n            \"diagnostics\": [\n                {\n                    \"message\": \"Error message\",\n                    \"severity\": \"error\",\n                    \"range\": {\n                        \"start\": {\"line\": 10, \"character\": 5},\n                        \"end\": {\"line\": 10, \"character\": 15}\n                    },\n                    \"source\": \"typescript\",\n                    \"code\": \"TS2304\"\n                }\n            ]\n        }\n    ],\n    \"timestamp\": 1640995200000\n}\n```\n\n#### POST /command\nExecute a command in VS Code.\n\n**Request:**\n```json\n{\n    \"command\": \"openFile\",\n    \"arguments\": [\"/path/to/file.ts\"],\n    \"options\": {\"preview\": false}\n}\n```\n\n**Response:**\n```json\n{\n    \"success\": true,\n    \"data\": {\n        \"filePath\": \"/path/to/file.ts\"\n    },\n    \"message\": \"Command executed successfully\"\n}\n```\n\n#### POST /propose-change\nPropose a code change that will be shown to the user with accept/reject options.\n\n**Request:**\n```json\n{\n    \"title\": \"Add error handling\",\n    \"filePath\": \"/path/to/file.js\",\n    \"changes\": [\n        {\n            \"originalContent\": \"function getData() {\\n    const data = JSON.parse(response);\\n    return data;\\n}\",\n            \"proposedContent\": \"function getData() {\\n    try {\\n        const data = JSON.parse(response);\\n        return data;\\n    } catch (error) {\\n        console.error('Failed to parse response:', error);\\n        return null;\\n    }\\n}\",\n            \"description\": \"Add try-catch error handling\"\n        }\n    ]\n}\n```\n\n**Response:**\n```json\n{\n    \"success\": true,\n    \"proposalId\": \"change_1640995200000_abc123\",\n    \"data\": {\n        \"proposalId\": \"change_1640995200000_abc123\",\n        \"filePath\": \"/path/to/file.js\"\n    },\n    \"message\": \"Change proposal change_1640995200000_abc123 accepted and applied\",\n    \"accepted\": true\n}\n```\n\n**Available Commands:**\n- `openFile(filePath, options)`: Open a file in editor\n- `selectText(startLine, startChar, endLine, endChar)`: Select text in the active editor\n- `writeFile(filePath, content)`: Write content to a file\n- `deleteFile(filePath)`: Delete a file\n- `showNotification(message, type)`: Show a notification (type: 'info', 'warning', 'error')\n- `proposeChange(proposalRequest)`: Propose a code change with accept/reject dialog\n- `acceptProposal(proposalId)`: Accept a change proposal\n- `rejectProposal(proposalId)`: Reject a change proposal\n\n#### GET /health\nHealth check endpoint.\n\n**Response:**\n```json\n{\n    \"status\": \"ok\",\n    \"server\": \"running\"\n}\n```\n\n### WebSocket API\n\nConnect to `ws://localhost:3210` for real-time updates.\n\n**Client Message Types:**\n\n1. **Get Context**\n```json\n{\n    \"type\": \"getContext\"\n}\n```\n\n2. **Execute Command**\n```json\n{\n    \"type\": \"command\",\n    \"command\": {\n        \"command\": \"openFile\",\n        \"arguments\": [\"/path/to/file.ts\"],\n        \"options\": {\"preview\": false}\n    }\n}\n```\n\n**Server Response Types:**\n\n1. **Context Update**\n```json\n{\n    \"type\": \"context\",\n    \"data\": {\n        // Same as HTTP /context response\n    }\n}\n```\n\n2. **Command Response**\n```json\n{\n    \"type\": \"commandResponse\",\n    \"data\": {\n        \"success\": true,\n        \"data\": {\"filePath\": \"/path/to/file.ts\"},\n        \"message\": \"Command executed successfully\"\n    }\n}\n```\n\n3. **Error Response**\n```json\n{\n    \"error\": \"Invalid msg format\"\n}\n```\n\n**Real-time Updates:**\nThe WebSocket connection automatically receives context updates when:\n- Active file changes\n- Text selection changes\n- Document content changes\n\n## Node.js Client Example\n\nSee [`examples/client.js`](examples/client.js) for a complete Node.js client implementation that demonstrates how to connect to the Context Bridge server via HTTP and WebSocket, and how to use its API.\n\n## Security Considerations\n\n1. **Disable tool**: The extension can be disabled in VS Code settings to prevent unauthorized access over HTTP/WebSocket networks.\n2. **Network Access**: The server binds to localhost by default for security\n4. **Information Sharing**: Configure what information is shared based on your needs\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Port Already in Use**: Change the port in VS Code settings\n3. **Connection Refused**: Ensure the VS Code extension server is running\n4. **Permission Denied**: Check file permissions for the workspace\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nThis project is licensed under the ISC License - see the LICENSE file for details.\n\n## Support\n\nFor issues and feature requests, please use the GitHub issue tracker.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsahil01%2Fvscode-context-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsahil01%2Fvscode-context-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsahil01%2Fvscode-context-bridge/lists"}