src — ide

Module: src-ide Cohesion: 0.80 Members: 0

src — ide

The src/ide module serves as the integration layer between the core Code Buddy application and various Integrated Development Environments (IDEs). It provides distinct bridges for JetBrains IDEs and VS Code, abstracting IDE-specific functionalities such as diff viewing, code selection sharing, diagnostic reporting, and session management.

This module is crucial for Code Buddy's ability to interact seamlessly with a developer's working environment, enabling features like applying AI-generated code changes, understanding the current editor context, and managing development workflows directly within the IDE.

Module Architecture

The src/ide module is composed of two primary classes, each dedicated to a specific IDE family:

Both bridges encapsulate IDE-specific logic and state, providing a consistent API for the rest of the Code Buddy application to interact with the developer's environment.

graph TD
    A[Code Buddy Core] --> B(src/ide Module)
    B --> C{JetBrainsBridge}
    B --> D{VSCodeBridge}
    C -- Manages --> C1[Diffs]
    C -- Manages --> C2[Selections]
    C -- Manages --> C3[Diagnostics]
    D -- Manages --> D1[Inline Diffs]
    D -- Manages --> D2[Session History]
    D -- Manages --> D3[Plan Reviews]
    D -- Provides --> D4[Editor Context]

JetBrains Integration (JetBrainsBridge)

The JetBrainsBridge class (src/ide/jetbrains-plugin.ts) provides the necessary scaffolding and logic to integrate Code Buddy with JetBrains IDEs. It manages features like displaying diffs, sharing code selections, reporting diagnostics, and configuring quick launch shortcuts.

Key Capabilities

Configuration (JetBrainsConfig)

The behavior of JetBrainsBridge is controlled by the JetBrainsConfig interface. An instance can be initialized with a partial configuration, falling back to DEFAULT_CONFIG for unspecified properties.

export interface JetBrainsConfig {
  enableDiffViewer: boolean;
  enableSelectionSharing: boolean;
  enableDiagnosticSharing: boolean;
  quickLaunchShortcut: string;
  supportedIDEs: string[];
}

Core Methods

Internal State

The JetBrainsBridge maintains its state using private properties:


VS Code Integration (VSCodeBridge)

The VSCodeBridge class (src/ide/vscode-extension.ts) provides the necessary scaffolding and logic to integrate Code Buddy with Visual Studio Code. It focuses on features like inline diffs, contextual @-mentions, plan reviews, and session history.

Key Capabilities

Configuration (VSCodeExtensionConfig)

The behavior of VSCodeBridge is controlled by the VSCodeExtensionConfig interface. An instance can be initialized with a partial configuration, falling back to DEFAULT_CONFIG.

export interface VSCodeExtensionConfig {
  enableInlineDiffs: boolean;
  enableAtMentions: boolean;
  enablePlanReview: boolean;
  enableSessionHistory: boolean;
  enableRemoteSessions: boolean;
  autoActivatePythonVenv: boolean;
  multilineInput: boolean;
}

Core Methods

Internal State

The VSCodeBridge maintains its state using private properties:


Integration Points

The src/ide module is primarily consumed by testing utilities and potentially other core Code Buddy features that need to interact with the IDE.