CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-google--gemini-cli-core

Gemini CLI Core - Core functionality library for the open-source AI agent that brings the power of Gemini directly into your terminal.

Overall
score

87%

Evaluation87%

1.01x

Agent success when using this tile

Overview
Eval results
Files

ide-integration.mddocs/

IDE Integration

Deep integration capabilities for IDEs and code editors with context awareness, file monitoring, installation utilities, and communication protocols.

Capabilities

IDE Context Management

Context management system for tracking open files, cursor positions, and IDE state.

/**
 * IDE context information
 */
interface IdeContext {
  /** Array of open files in the IDE */
  files: File[];
  /** Current working directory */
  cwd: string;
  /** Additional metadata */
  metadata?: Record<string, any>;
}

/**
 * Open file information
 */
interface File {
  /** File name */
  name: string;
  /** Full file path */
  path: string;
  /** File content */
  content: string;
  /** Cursor position (optional) */
  cursor?: {
    line: number;
    column: number;
  };
  /** Selection range (optional) */
  selection?: {
    start: { line: number; column: number };
    end: { line: number; column: number };
  };
  /** Language identifier */
  language?: string;
  /** Whether file has unsaved changes */
  isDirty?: boolean;
}

/**
 * IDE context notification schema
 */
interface IdeContextNotification {
  type: 'context_update';
  context: IdeContext;
  timestamp: string;
}

IDE Client Communication

Client for communicating with IDE extensions and managing bidirectional data exchange.

/**
 * IDE client for communication with IDE extensions
 */
class IdeClient {
  constructor(config?: IdeClientConfig);
  
  // Connection management
  connect(): Promise<void>;
  disconnect(): Promise<void>;
  isConnected(): boolean;
  
  // Context operations
  getCurrentContext(): Promise<IdeContext>;
  updateContext(context: Partial<IdeContext>): Promise<void>;
  
  // File operations
  openFile(path: string): Promise<void>;
  closeFile(path: string): Promise<void>;
  saveFile(path: string): Promise<void>;
  getFileContent(path: string): Promise<string>;
  
  // Editor operations
  setCursorPosition(path: string, line: number, column: number): Promise<void>;
  setSelection(
    path: string, 
    start: {line: number, column: number}, 
    end: {line: number, column: number}
  ): Promise<void>;
  insertText(path: string, position: {line: number, column: number}, text: string): Promise<void>;
  replaceText(
    path: string, 
    range: {start: {line: number, column: number}, end: {line: number, column: number}}, 
    text: string
  ): Promise<void>;
  
  // Notification handling
  onContextUpdate(handler: (context: IdeContext) => void): void;
  onFileChange(handler: (file: File) => void): void;
  onCursorMove(handler: (position: {line: number, column: number}, file: string) => void): void;
  
  // Command execution
  executeCommand(command: string, args?: any[]): Promise<any>;
  
  // UI operations
  showMessage(message: string, type?: 'info' | 'warning' | 'error'): Promise<void>;
  showQuickPick(items: QuickPickItem[], options?: QuickPickOptions): Promise<QuickPickItem | undefined>;
  showInputBox(options?: InputBoxOptions): Promise<string | undefined>;
}

/**
 * IDE client configuration
 */
interface IdeClientConfig {
  connectionType: 'websocket' | 'stdio' | 'tcp';
  host?: string;
  port?: number;
  timeout?: number;
  retryAttempts?: number;
  enableHeartbeat?: boolean;
}

/**
 * Quick pick item for UI operations
 */
interface QuickPickItem {
  label: string;
  description?: string;
  detail?: string;
  value?: any;
}

/**
 * Quick pick options
 */
interface QuickPickOptions {
  title?: string;
  placeholder?: string;
  canPickMany?: boolean;
  matchOnDescription?: boolean;
  matchOnDetail?: boolean;
}

/**
 * Input box options
 */
interface InputBoxOptions {
  title?: string;
  placeholder?: string;
  value?: string;
  prompt?: string;
  password?: boolean;
  validateInput?: (value: string) => string | undefined;
}

IDE Detection

Utilities for detecting the current IDE environment and gathering information about the development setup.

/**
 * Detected IDE information
 */
interface DetectedIde {
  name: string;
  version?: string;
  path?: string;
  processId?: number;
  capabilities: IdeCapabilities;
}

/**
 * IDE capabilities
 */
interface IdeCapabilities {
  fileOperations: boolean;
  terminalIntegration: boolean;
  debuggerSupport: boolean;
  extensionSupport: boolean;
  languageServerProtocol: boolean;
  webviewSupport: boolean;
}

/**
 * IDE information interface
 */
interface IdeInfo {
  name: string;
  displayName: string;
  version: string;
  path: string;
  configPath?: string;
  extensionsPath?: string;
  workspacePath?: string;
}

/**
 * Get information about the current IDE environment
 * @returns Detected IDE information or null if not detected
 */
function getIdeInfo(): Promise<IdeInfo | null>;

/**
 * Detect current IDE environment
 * @returns Detected IDE information
 */
function detectIde(): Promise<DetectedIde | null>;

IDE Installation

Utilities for installing and configuring IDE extensions and integrations.

/**
 * IDE installer for managing extensions and configurations
 */
class IdeInstaller {
  constructor(ideInfo: IdeInfo);
  
  // Extension management
  installExtension(extensionId: string): Promise<boolean>;
  uninstallExtension(extensionId: string): Promise<boolean>;
  isExtensionInstalled(extensionId: string): Promise<boolean>;
  listInstalledExtensions(): Promise<InstalledExtension[]>;
  
  // Configuration management
  updateConfiguration(settings: Record<string, any>): Promise<void>;
  getConfiguration(): Promise<Record<string, any>>;
  
  // Workspace management
  createWorkspace(path: string, settings?: Record<string, any>): Promise<void>;
  openWorkspace(path: string): Promise<void>;
  
  // Integration setup
  setupGeminiIntegration(config: GeminiIntegrationConfig): Promise<boolean>;
  verifyIntegration(): Promise<IntegrationStatus>;
}

/**
 * Installed extension information
 */
interface InstalledExtension {
  id: string;
  name: string;
  version: string;
  enabled: boolean;
  publisher: string;
  description?: string;
}

/**
 * Gemini integration configuration
 */
interface GeminiIntegrationConfig {
  apiKey?: string;
  model?: string;
  enableAutoComplete?: boolean;
  enableInlineChat?: boolean;
  enableCodeAnalysis?: boolean;
  shortcuts?: Record<string, string>;
}

/**
 * Integration status
 */
interface IntegrationStatus {
  isInstalled: boolean;
  isConfigured: boolean;
  isEnabled: boolean;
  version?: string;
  errors?: string[];
  warnings?: string[];
}

Type Schemas

Zod schemas for validating IDE-related data structures.

import { z } from 'zod';

/**
 * File schema for validation
 */
const FileSchema = z.object({
  name: z.string(),
  path: z.string(),
  content: z.string(),
  cursor: z.object({
    line: z.number(),
    column: z.number()
  }).optional(),
  selection: z.object({
    start: z.object({
      line: z.number(),
      column: z.number()
    }),
    end: z.object({
      line: z.number(),
      column: z.number()
    })
  }).optional(),
  language: z.string().optional(),
  isDirty: z.boolean().optional()
});

/**
 * IDE context schema for validation
 */
const IdeContextSchema = z.object({
  files: z.array(FileSchema),
  cwd: z.string(),
  metadata: z.record(z.any()).optional()
});

/**
 * IDE context notification schema for validation
 */
const IdeContextNotificationSchema = z.object({
  type: z.literal('context_update'),
  context: IdeContextSchema,
  timestamp: z.string()
});

// Type exports from schemas
type File = z.infer<typeof FileSchema>;
type IdeContext = z.infer<typeof IdeContextSchema>;
type IdeContextNotification = z.infer<typeof IdeContextNotificationSchema>;

IDE Constants

Constants and configuration values for IDE integration.

/**
 * IDE-related constants
 */
const IDE_CONSTANTS = {
  // Connection settings
  DEFAULT_WEBSOCKET_PORT: 8080,
  DEFAULT_TCP_PORT: 9090,
  CONNECTION_TIMEOUT: 30000,
  HEARTBEAT_INTERVAL: 30000,
  
  // File watching
  WATCH_DEBOUNCE_MS: 300,
  MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
  
  // Extension IDs
  VSCODE_EXTENSION_ID: 'google.gemini-vscode',
  INTELLIJ_PLUGIN_ID: 'com.google.gemini-intellij',
  
  // Configuration paths
  VSCODE_CONFIG_PATH: '.vscode/settings.json',
  INTELLIJ_CONFIG_PATH: '.idea/gemini.xml',
  
  // Supported file extensions
  SUPPORTED_LANGUAGES: [
    'typescript', 'javascript', 'python', 'java', 'go',
    'rust', 'cpp', 'c', 'csharp', 'php', 'ruby'
  ]
};

Usage Examples:

import { 
  IdeClient,
  getIdeInfo,
  detectIde,
  IdeInstaller,
  IdeContext,
  File
} from '@google/gemini-cli-core';

// Detect current IDE
const ideInfo = await getIdeInfo();
if (ideInfo) {
  console.log(`Detected IDE: ${ideInfo.displayName} v${ideInfo.version}`);
  
  // Setup installer
  const installer = new IdeInstaller(ideInfo);
  
  // Install Gemini extension
  const installed = await installer.installExtension('google.gemini-vscode');
  if (installed) {
    console.log('Gemini extension installed successfully');
    
    // Configure integration
    await installer.setupGeminiIntegration({
      apiKey: process.env.GEMINI_API_KEY,
      model: 'gemini-1.5-flash',
      enableAutoComplete: true,
      enableInlineChat: true
    });
  }
}

// IDE client communication
const ideClient = new IdeClient({
  connectionType: 'websocket',
  port: 8080,
  timeout: 30000
});

// Connect to IDE
await ideClient.connect();
console.log('Connected to IDE');

// Get current context
const context = await ideClient.getCurrentContext();
console.log(`Current directory: ${context.cwd}`);
console.log(`Open files: ${context.files.length}`);

// Listen for context updates
ideClient.onContextUpdate((newContext) => {
  console.log('Context updated:', newContext);
});

// Listen for file changes
ideClient.onFileChange((file) => {
  console.log(`File changed: ${file.path}`);
  if (file.isDirty) {
    console.log('File has unsaved changes');
  }
});

// Open a file
await ideClient.openFile('/path/to/file.ts');

// Insert text at cursor position
await ideClient.insertText('/path/to/file.ts', {line: 10, column: 0}, '// TODO: Implement this\n');

// Show a message to user
await ideClient.showMessage('Analysis complete!', 'info');

// Show quick pick for user selection
const selected = await ideClient.showQuickPick([
  { label: 'Option 1', description: 'First option' },
  { label: 'Option 2', description: 'Second option' }
], {
  title: 'Choose an option',
  placeholder: 'Select one...'
});

if (selected) {
  console.log(`User selected: ${selected.label}`);
}

Install with Tessl CLI

npx tessl i tessl/npm-google--gemini-cli-core

docs

configuration.md

core-ai.md

ide-integration.md

index.md

mcp-oauth.md

services.md

telemetry.md

tools.md

utilities.md

tile.json