Skip to content

cs68614-hash/connai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                 โ”‚
โ”‚    โ•ญโ”€โ”€โ”€โ•ฎ     โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ    โ•ญโ”€โ”€โ”€โ•ฎ    โ•ญโ”€โ”€โ”€โ•ฎ                        โ”‚
โ”‚   โ•ฑ     โ•ฒ   โ•ฑ       โ•ฒ  โ•ฑ     โ•ฒ  โ•ฑ     โ•ฒ                       โ”‚
โ”‚  โ•ฑ  VS   โ•ฒ โ•ฑ  ConnAI โ•ฒโ•ฑ   AI   โ•ฒโ•ฑ Web   โ•ฒ                      โ”‚
โ”‚  โ•ฒ Code  โ•ฑ โ•ฒ Protocolโ•ฑโ•ฒ Bridge โ•ฑโ•ฒBrowserโ•ฑ                      โ”‚
โ”‚   โ•ฒ_____โ•ฑ   โ•ฒ_______โ•ฑ  โ•ฒ_____โ•ฑ  โ•ฒ_____โ•ฑ                       โ”‚
โ”‚       โ•ฒ         โ”‚         โ”‚         โ•ฑ                          โ”‚
โ”‚        โ•ฒ________โ”‚_________โ”‚________โ•ฑ                           โ”‚
โ”‚                 โ”‚    ๐Ÿ”—   โ”‚                                    โ”‚
โ”‚               Real-time Bridge                                 โ”‚
โ”‚                                                                 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

ConnAI - AI-Powered Code Context Bridge

Build Status Version License: MIT VS Code Marketplace

๐ŸŒ‰ Seamlessly bridge VS Code with web browsers through AI-powered code context sharing

Built with a modern Monorepo architecture, ConnAI provides real-time, bidirectional communication between your local development environment and any web application.

โœจ Features

๐Ÿ—๏ธ Monorepo Architecture

  • Multi-package workspace with pnpm workspaces
  • Shared protocol (@connai/protocol) for cross-package communication
  • Unified build system and development workflow
  • Cross-package type safety and dependency management

๐Ÿ”Œ Protocol-Based Communication

  • Standardized ConnAI Protocol for editor-agnostic communication
  • HTTP RESTful API with auto-discovery and health monitoring
  • Smart port management with automatic detection (6718-6817, 8080-8090)
  • Auto-connect functionality - zero configuration required
  • WebSocket support (coming soon) for real-time push notifications

๐ŸŒ Browser Extension (Chrome/Edge)

  • Universal web integration - works on any website
  • Smart input detection - type # in any input field to trigger
  • Context menu integration with rich UI and visual feedback
  • Auto-connect to VS Code with intelligent port scanning
  • Background connection management with health checks and reconnection
  • Manual server configuration when auto-detection fails

๐Ÿ–ฅ๏ธ VS Code Extension

  • HTTP protocol server on configurable ports
  • Multi-workspace support with automatic port assignment
  • Real-time context extraction from active editor
  • Rich context types: focused file, selected text, open tabs, problems, file tree
  • File operations and workspace management
  • Health monitoring and diagnostic endpoints

๐Ÿง  AI-Optimized Context Analysis

  • Token-aware processing for AI model optimization
  • Smart file filtering with .gitignore support
  • Metadata enrichment with file types and structure analysis
  • Configurable context depth and scope control

๐Ÿ—๏ธ Architecture Overview

ConnAI is built as a modern Monorepo with four main packages:

๐Ÿ“ฆ ConnAI Monorepo
โ”œโ”€โ”€ ๐Ÿ”Œ protocol/          # Core protocol layer & communication contracts
โ”œโ”€โ”€ ๐Ÿ–ฅ๏ธ vscode-extension/  # VS Code integration & HTTP server
โ”œโ”€โ”€ ๐ŸŒ browser-extension/ # Browser extension (Chrome/Edge) with React UI
โ””โ”€โ”€ ๐Ÿ“ฆ shared/           # Shared utilities, types & constants

๐Ÿ”„ Communication Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐ŸŒ Browser     โ”‚    โ”‚  ๐Ÿ”— ConnAI      โ”‚    โ”‚  ๐Ÿ–ฅ๏ธ VS Code    โ”‚
โ”‚   Extension     โ”‚โ—„โ”€โ”€โ–บโ”‚   Protocol      โ”‚โ—„โ”€โ”€โ–บโ”‚   Extension     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
   ๐Ÿ” Auto-discovery        ๐Ÿš€ HTTP/WebSocket       ๐Ÿ“„ Context extraction
   ๐Ÿ”„ Smart reconnect       โšก Health monitoring      ๐Ÿ—‚๏ธ File operations
   ๐ŸŽจ User interface        ๐Ÿ›ก๏ธ Error handling        ๐Ÿ“Š Workspace info
   ๐Ÿ“ Input detection       ๐Ÿ”ง Port management       ๐Ÿ—๏ธ Multi-workspace

๐Ÿ”Œ Protocol Layer (@connai/protocol)

The heart of ConnAI is its standardized protocol layer that provides:

  • Editor-agnostic interface for future extensibility (Cursor, WebStorm, etc.)
  • Type-safe message contracts for reliable communication
  • Transport abstraction supporting HTTP and WebSocket
  • Capability negotiation for feature discovery
  • Error handling with detailed diagnostics and retry logic
// Example protocol usage
import { createProtocolClient } from '@connai/protocol';

const client = createProtocolClient({
  serverUrl: 'http://localhost:6797',
  timeout: 10000,
  maxReconnectAttempts: 5
});

await client.connect();
const context = await client.sendRequest('get_context', {
  type: 'focused_file',
  workspaceId: 'default'
});

๐Ÿš€ Quick Start

1. Development Setup

# Clone the repository
git clone <repository-url>
cd connai

# Install dependencies
pnpm install

# Build all packages
pnpm run build

2. VS Code Extension

# Build VS Code extension
cd packages/vscode-extension
pnpm run compile

# Install in VS Code
# Method 1: Development mode
# - Press F5 to launch Extension Development Host
# Method 2: Install VSIX
# - Package: pnpm run package
# - Install via Extensions: "Install from VSIX"

3. Browser Extension

# Build browser extension
cd packages/browser-extension
pnpm build

# Install in Chrome/Edge
# 1. Open chrome://extensions/
# 2. Enable "Developer mode"
# 3. Click "Load unpacked"
# 4. Select packages/browser-extension/.output/chrome-mv3/

4. Usage

  1. Start VS Code with a project open
  2. Activate ConnAI extension (starts automatically on first use)
  3. Install browser extension (auto-connects to VS Code)
  4. Go to any webpage with text inputs
  5. Type # in any input field โ†’ Context menu appears
  6. Select context type โ†’ VS Code data is inserted automatically

๐ŸŽฏ Use Cases

For AI Development

  • ChatGPT/Claude Integration: Easily share code context with AI assistants
  • Code Review Assistance: Provide full context for AI-powered code reviews
  • Documentation Generation: Share project structure for AI documentation tools
  • Debugging Help: Include relevant code and error context in AI queries

For Web Development

  • Issue Reporting: Automatically include relevant code context in bug reports
  • Code Sharing: Share code snippets with full context on forums/chat
  • Pair Programming: Remote collaboration with shared context
  • Technical Support: Provide complete context when asking for help

for Content Creation

  • Technical Writing: Include live code examples in documentation
  • Tutorials/Courses: Dynamic code context for educational content
  • Blog Posts: Embed current project state in technical articles
  • Code Reviews: Share context-rich code snippets for review

๐Ÿ”ง Configuration

VS Code Extension Settings

{
  "connai.server.port": 6797,
  "connai.server.host": "127.0.0.1",
  "connai.workspace.basePort": 6718,
  "connai.workspace.portRange": 100,
  "connai.cache.ttl": 300000,
  "connai.ignore.useGitignore": true,
  "connai.ignore.customPatterns": ["*.log", "tmp/", "node_modules/"]
}

Browser Extension Settings

The browser extension automatically detects VS Code servers but can be manually configured:

  • Auto-detect servers: Scans ports 6718-6817 and 8080-8090
  • Manual configuration: Set specific server URL and port in popup
  • Connection timeout: Configurable timeout for server connections (default: 10s)
  • Reconnection settings: Automatic reconnection with exponential backoff

Supported Context Types

Context Type Description VS Code Command Browser Shortcut
๐Ÿ“„ Focused File Current active file content connai.getFocusedFile Type # โ†’ Select
๐ŸŽฏ Selected Text Currently selected text/cursor connai.getSelectedText Type # โ†’ Select
๐Ÿ“‘ All Open Tabs List of all open editor tabs connai.getAllOpenTabs Type # โ†’ Select
โš ๏ธ Problems Current errors and warnings connai.getProblems Type # โ†’ Select
๐ŸŒฒ File Tree Project file structure connai.getFileTree Type # โ†’ Select
๐Ÿ“š Full Workspace Complete project overview connai.getFullWorkspace Type # โ†’ Select

๐Ÿ’ป Development

Prerequisites

  • Node.js 18+ (with pnpm)
  • VS Code 1.101.0+
  • TypeScript 5.8+
  • Chrome/Edge for browser extension testing

Development Setup

# Clone and setup
git clone <repository-url>
cd connai
pnpm install

# Build all packages
pnpm run build

# Watch mode for development
pnpm run dev

# Run specific package in watch mode
cd packages/vscode-extension && pnpm run watch
cd packages/browser-extension && pnpm run dev
cd packages/protocol && pnpm run build:watch

Testing

# Run all tests
pnpm test

# Run tests for specific package
cd packages/protocol && pnpm test
cd packages/vscode-extension && pnpm test

# Integration testing
# 1. Start VS Code Extension Development Host (F5)
# 2. Load browser extension in development mode
# 3. Open test-integration.html for end-to-end testing

Project Structure

connai/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ protocol/                    # Core protocol implementation
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ core/               # Protocol core (message, transport)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ contracts/          # API contracts (context, file, workspace)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ adapters/           # Editor adapters (VS Code, future: Cursor)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.ts            # Public API
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ vscode-extension/           # VS Code extension
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ extension.ts        # Main extension entry
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ server/             # HTTP protocol server
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ context/            # Context providers
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ commands/           # VS Code commands
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils/              # Utilities and helpers
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ browser-extension/          # Browser extension (WXT + React)
โ”‚   โ”‚   โ”œโ”€โ”€ entrypoints/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ background.ts       # Service worker
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ content.ts          # Content script
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ popup/              # Extension popup UI
โ”‚   โ”‚   โ”œโ”€โ”€ src/utils/              # Protocol client, port scanner
โ”‚   โ”‚   โ””โ”€โ”€ wxt.config.ts
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ shared/                     # Shared utilities
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ types.ts            # Common types
โ”‚       โ”‚   โ”œโ”€โ”€ constants.ts        # Shared constants
โ”‚       โ”‚   โ””โ”€โ”€ utils.ts            # Helper functions
โ”‚       โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ examples/                       # Example implementations
โ”œโ”€โ”€ docs/                          # Documentation
โ”œโ”€โ”€ pnpm-workspace.yaml            # Monorepo configuration
โ””โ”€โ”€ package.json                   # Root package configuration

๐Ÿš€ Deployment

VS Code Extension

# Package for distribution
cd packages/vscode-extension
pnpm run package

# Publish to marketplace (requires vsce)
pnpm run publish

Browser Extension

# Build for production
cd packages/browser-extension
pnpm run build

# Package for Chrome Web Store
pnpm run package

๐Ÿ“Š Current Status

โœ… Completed Features

  • Monorepo architecture with pnpm workspaces
  • Core protocol layer (@connai/protocol)
  • VS Code extension with HTTP server
  • Browser extension with auto-connect
  • Smart port management and discovery
  • Rich context extraction (file, selection, tabs, problems, tree)
  • Background connection management
  • Multi-workspace support
  • Protocol integration between browser and VS Code
  • End-to-end testing setup

๐Ÿšง In Progress

  • WebSocket protocol implementation
  • Real-time push notifications
  • Enhanced error handling and user feedback
  • Performance optimization and caching

๐Ÿ”ฎ Future Plans

  • Support for additional editors (Cursor, WebStorm)
  • Advanced AI context optimization
  • Team collaboration features
  • Plugin architecture for custom context providers
  • Performance monitoring and analytics

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure tests pass: pnpm test
  6. Submit a pull request

Development Guidelines

  • Use TypeScript for all new code
  • Follow existing code style and patterns
  • Add tests for new features
  • Update documentation as needed
  • Use conventional commit messages

Package Guidelines

  • Keep packages focused and loosely coupled
  • Use the shared package for common utilities
  • Maintain clean public APIs
  • Document all public interfaces

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

For support and questions:

๐Ÿ™ Acknowledgments


๐Ÿ–ฅ๏ธ โ”€โ”€โ”€โ”€โ”€ ๐Ÿ”— โ”€โ”€โ”€โ”€โ”€ ๐ŸŒ โ”€โ”€โ”€โ”€โ”€ ๐Ÿค–
VS Code   ConnAI   Browser   AI
  โ†•       Protocol    โ†•       โ†•
Your      Bridge    Web     AI
Project             App   Assistant

Made with โค๏ธ for the AI development community

ConnAI bridges the gap between your local development environment and the web,
making AI-assisted coding more seamless and powerful.


๐Ÿ”— Connect โ€ข ๐Ÿš€ Enhance โ€ข ๐Ÿค– Empower

Transform your development workflow with intelligent code context sharing

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors