CodeMie AI Coding Assistant

repository·main·Indexed 42 days ago

https://github.com/codemie-ai/codemie-code

A unified AI coding assistant CLI (v0.15.2) that manages multiple agents including Claude Code, Gemini, OpenAI, and Copilot. It features multi-provider support (AWS Bedrock, Azure, LiteLLM, Ollama), a built-in LangGraph agent with git integration, and MCP proxy support. The ecosystem includes a Chrome extension for browser automation and page context, a Microsoft Teams bot (v1.1.9), and cross-platform installation wizards for Windows and macOS.

Tokens
293.1K
Snippets
717
Records
1.2K
Agent score
53%

What's inside CodeMie

  1. Core features of the EPAM AI/Run CodeMie extension

    main

    The Chrome extension provides several capabilities for interacting with web content and the CodeMie assistant:

    • Page Context: Answers questions grounded in the current page content, including direct HTTP(S) PDF URLs.
    • Text Interaction: Select text and use the right-click menu or the floating Ask CodeMie button to ask questions.
    • Browser Automation: Performs clicking, typing, and multi-step flows. By default, state-changing actions require user approval. You can use Auto-approve for trusted pages to skip prompts.
    • Action Recording: Records a sequence of actions for later replay.
    • Context Expansion: Attaches other open tabs as additional context for queries.
    • External Connectivity: Searches the web and connects to tools via MCP (Model Context Protocol) servers.
    • Knowledge Management: Saves pages and notes locally as Knowledge, which can be used as context for future queries.
    • Conversation Sync: Syncs chats tied to a selected assistant to your CodeMie account. Temporary chats or chats without an assistant remain local to the browser session.
  2. Overview of the CodeMie Plugin System

    main

    The Plugin System allows you to extend CodeMie Code by bundling reusable packages of skills, commands, agents, hooks, and MCP servers.

    Key features include:

    • Bundling: Package multiple components into a single distributable unit.
    • Namespacing: All components are automatically prefixed with plugin-name: (e.g., security-tools:code-review) to prevent naming conflicts.
    • Distribution: Plugins can be shared via directories, git repositories, or local paths.
    • Management: Use the codemie plugin CLI to install, uninstall, enable, or disable plugins.
    • Automatic Discovery: Plugins are automatically detected from project, user, and CLI-specified locations.
  3. Overview of the CodeMie Hooks System

    main

    The CodeMie Hooks system allows you to extend agent execution by running custom shell commands or LLM-based prompts at specific lifecycle points. Hooks can be used to inject context, block or modify tool usage, track activity, or enforce security policies. Hooks are configured within your profile in the ~/.codemie/codemie-cli.config.json file.

    {
      "version": 2,
      "activeProfile": "default",
      "profiles": {
        "default": {
          "hooks": {
            "PreToolUse": [
              {
                "matcher": "Bash|Write",
                "hooks": [
                  {
                    "type": "command",
                    "command": "/path/to/pre-tool-hook.sh",
                    "timeout": 60000
                  }
                ]
              }
            ]
          }
        }
      }
    }
  4. Manage GitHub Copilot CLI via CodeMie

    main

    The GitHub Copilot CLI is a managed agent within CodeMie. Unlike standard analytics-only plugins, it can be installed, uninstalled, and run directly through the CodeMie CLI. It uses the @github/copilot npm package and is configured to work with specific CodeMie provider profiles.

    Key Metadata Properties:

    • Name: copilot-cli (internal) / copilot (alias)
    • NPM Package: @github/copilot
    • Supported Providers: ai-run-sso and litellm only. Other providers (like standard bearer-auth) are not supported.
    • CLI Command: Controlled by CODEMIE_COPILOT_BIN environment variable (defaults to copilot).
    • Authentication: Managed via CodeMie SSO/LiteLLM; direct GitHub login or subscription is not required when using the CodeMie-managed path.
    // Example of the metadata structure used by the agent
    export const CopilotCliPluginMetadata: AgentMetadata = {
      name: COPILOT_CLI_AGENT_NAME,
      displayName: COPILOT_CLI_DISPLAY_NAME,
      description: 'GitHub Copilot CLI - AI coding agent managed by CodeMie',
      npmPackage: '@github/copilot',
      cliCommand: process.env.CODEMIE_COPILOT_BIN || 'copilot',
      supportedVersion: COPILOT_SUPPORTED_VERSION,
      minimumSupportedVersion: COPILOT_MINIMUM_SUPPORTED_VERSION,
      dataPaths: { home: '.copilot' },
      envMapping: { baseUrl: [], apiKey: [], model: [] },
      supportedProviders: ['ai-run-sso', 'litellm'],
      // ...
    };
  5. Understand Copilot CLI Managed Agent terminology and aliases

    main

    When working with the Copilot CLI managed agent, note the following naming conventions used for command boundaries and internal identification:

    • User-facing alias: copilot (used at command boundaries).
    • Launcher/Help commands: Render as codemie-copilot or codemie install copilot.
    • Internal key: copilot-cli (used in interfaces and conversation folder expectations).
    • Client identity: codemie-copilot.
  6. Follow ownership resolution conventions

    main

    When implementing or modifying session ownership logic, adhere to these technical constraints:

    • Resolution Order: Ownership resolution must be index-first (using correlation JSON + sidecar marker). Only fall back to a bounded transcript scan for legacy sessions. Never perform a full-file read for ownership checks.
    • Safety: Wrap every filesystem read in a non-fatal try/catch. If a read fails, the system must fail-closed for ownership determination (i.e., treat the session as 'external/not owned').
    • Performance: Ownership index results may be cached for the duration of the process lifetime, as analytics CLI runs are typically short-lived.
    • Marker Storage: Ownership markers should be stored in a sidecar file rather than appended to the live transcript to avoid appendFileSync race conditions.
  7. How Git remote URL normalization works

    main

    The CodeMie CLI identifies repositories by normalizing the Git origin remote URL into a stable <org>/<repo> format. This ensures metrics contain privacy-safe and consistent identifiers.

    Normalization Rules:

    • Removes protocols (e.g., https://, git@).
    • Removes hostnames (e.g., github.com).
    • Removes embedded credentials or tokens.
    • Removes the .git suffix.

    Examples:

    • git@gitbud.epam.com:epm-cdme/codemie.git $\rightarrow$ epm-cdme/codemie
    • git@github.com:codemie-ai/codemie-code.git $\rightarrow$ codemie-ai/codemie-code
    • https://user:token@github.com/org/repo.git $\rightarrow$ org/repo
    /* Logic implemented in src/utils/processes.ts */
    // Input: git@github.com:codemie-ai/codemie-code.git
    // Output: codemie-ai/codemie-code
  8. How the CodeMie Proxy layered architecture works

    main

    The proxy operates through four distinct layers:

    1. Layer 1: Entry Point (CodeMieProxy): Manages the HTTP server lifecycle, port binding, and top-level error handling.
    2. Layer 2: Plugin Management (PluginRegistry): Handles plugin registration, priority-based sorting, and lifecycle management (enable/disable).
    3. Layer 3: Request Handling: Orchestrates context building and hook execution (onRequest, onResponseHeaders, etc.) while managing errors via plugin hooks.
    4. Layer 4: HTTP Forwarding (ProxyHTTPClient): Manages upstream connections, SSL/TLS, and ensures true HTTP streaming without buffering.
  9. Understand the ConfigLoader profile composition and URL gate

    main

    The ConfigLoader uses a priority stack to merge configuration from multiple sources:

    1. Defaults
    2. Global configuration (globalConfig)
    3. Local project configuration (localConfig)
    4. Environment variables
    5. CLI overrides

    Profile Composition Logic: When running with a specific profile (e.g., --profile <name>) in a repository that has its own .codemie/codemie-cli.config.json, the loader attempts to compose the two.

    To prevent 'cross-env profile leaks' (where a local project configuration accidentally points to a different environment than the selected global profile), a URL gate is applied.

    • Same Environment: If the codeMieUrl in the local project config matches the codeMieUrl of the selected global profile, the project-specific fields (codeMieProject, codeMieIntegration, and codeMieUrl) are preserved.
    • Different Environments: If the URLs differ, the local project's codeMieUrl and related project context fields are dropped. The selected global profile's configuration takes precedence to ensure all requests route to the correct environment.

    Key Configuration Fields:

    • codeMieProject: The specific project identifier.
    • codeMieIntegration: The integration context.
    • codeMieUrl: The base URL for the CodeMie API/environment.
  10. Understand Provider Plugins and Capabilities

    main

    The provider subsystem uses ProviderTemplate to declaratively define provider metadata and capabilities. This separates provider identity from operational behaviors like setup, health checks, and model discovery.

    Instead of duplicating provider-specific logic, consumers should check the registered capabilities of a provider. Common capability flags include:

    • streaming
    • tools
    • vision
    • embeddings
    • model-management
    • function-calling
    • sso-auth

    Providers are registered into a process-wide ProviderRegistry using registerProvider(template). Importing src/providers/index.ts automatically registers all built-in providers.

    import { registerProvider } from '@codemieai/code';
    
    // Example of how a provider template defines capabilities
    const myProviderTemplate = {
      name: 'my-provider',
      authType: 'jwt',
      capabilities: ['streaming', 'tools', 'vision'],
      // ... other template fields
    };
    
    registerProvider(myProviderTemplate);
  11. Understand plugin registration and discovery boundaries

    main

    Plugin discovery in this system relies on explicit registration at composition entrypoints. If a plugin is not imported into the correct entrypoint, registry lookups will fail with unsupported or not-found errors rather than falling back to a default plugin.

    Key Entrypoints for Registration:

    • AgentRegistry: For adding to the lazy built-in list.
    • src/providers/index.ts: For provider-specific plugins.
    • src/frameworks/plugins/index.ts: For framework-specific plugins.

    Note that importing these composition entrypoints has side effects and should be performed at a startup boundary or an explicit integration setup point.

  12. Understand StepStatus and RunOutcome types

    main

    The installation engine uses two primary enums to track the lifecycle and results of installation tasks.

    StepStatus

    Represents the current state of an individual Step:

    • .pending: Waiting to be executed.
    • .active: Currently running.
    • .complete: Successfully finished.
    • .warning(String): Finished, but with non-fatal issues.
    • .error(String): Failed to execute.
    • .skipped: Not executed due to conditions.

    RunOutcome

    Represents the final result of the entire installation process:

    • .success: All steps completed successfully.
    • .completedWithWarnings([String]): Installation finished, but some warnings were issued.
    • .failed(stepId: String, message: String, recommendation: String): Installation stopped due to a critical error.
    • .aborted: Installation was manually cancelled by the user.