Kode Documentation

repository·main·Indexed 26 days ago

https://github.com/shareai-lab/kode-cli

An AI-powered terminal coding companion and SDK designed to help developers understand codebases, edit files, execute commands, and automate workflows. It features a terminal-based CLI with an Ink TUI, a headless API server, and a React-based WebUI. The ecosystem includes the @shareai-lab/kode package, providing a core engine for headless execution, a daemon client for external integration, and support for Agent Client Protocol (ACP) and Model Context Protocol (MCP).

Tokens
136.7K
Snippets
218
Records
717
Agent score
89%

What's inside Kode

  1. Overview of the KODE Tool System

    main

    The KODE SDK tool system allows agents to interact with the environment through built-in and custom tools. Key features include:

    • Prompt Instructions: Detailed guidance for models to ensure safe usage.
    • Structured Returns: Tools return predictable JSON structures.
    • FilePool Integration: File tools use FilePool to validate freshness and prevent conflicts during reads/writes.
    • Audit Trail: ToolCallRecord tracks approvals, duration, and errors, supporting full restoration on Resume.
    • MCP Integration: Supports Model Context Protocol (MCP) via ToolRegistry.registerMCPLoader.
  2. Overview of the Kode Configuration System

    main

    The configuration system manages reading and writing settings, default values, and model profiles/pointers. It is responsible for:

    • Reading configurations: Loads settings from user-level (~/.kode.json) and project-level (./.kode.json) files.
    • Managing Model Profiles: Maintains model profiles and pointers (e.g., main, task, quick, compact) along with compatibility aliases.
    • Configuration Maintenance: Handles version migrations and automatic configuration repairs (best-effort, designed not to interfere with standard workflows).
  3. Overview of MCP Host/Transport Adaptation

    main
    The packages/host-mcp package provides Model Context Protocol (MCP) host and transport adaptation. It supports both MCP server and client roles. A key feature is the unification of tool schemas using the ToolSpec system to ensure consistency across different platforms and clients.
  4. Overview of Agent Client Protocol (ACP) Host/Transport

    main
    The host-acp package provides implementation for the Agent Client Protocol (ACP) host and transport layers. It enables communication between agents and clients using JSON-RPC over stdio. Future support for WebSocket (WS) and HTTP variants is planned. The implementation shares schemas with core/protocol to ensure consistency.
  5. Overview of the Node.js Runtime implementation

    main

    The packages/runtime-node package provides the Node.js implementation of the Runtime interface defined in packages/runtime. It serves as the default/baseline runtime for the core and headless engines. It provides implementations for the following system capabilities:

    • fs: File system operations
    • spawn: Process spawning
    • env: Environment variable access
    • os: Operating system information
    • clock: Time and clock functions
    • log: Logging utilities
  6. Use the Arctic Frost theme

    main

    The Arctic Frost theme is a winter-inspired visual style designed for clarity, precision, and professionalism. It is characterized by a cool color palette and clean typography.

    Color Palette

    • Ice Blue: #d4e4f7 (Light backgrounds and highlights)
    • Steel Blue: #4a6fa5 (Primary accent color)
    • Silver: #c0c0c0 (Metallic accent elements)
    • Crisp White: #fafafa (Clean backgrounds and text)

    Typography

    • Headers: DejaVu Sans Bold
    • Body Text: DejaVu Sans

    This theme is best suited for:

    • Healthcare presentations
    • Technology solutions
    • Winter sports
    • Clean tech
    • Pharmaceutical content
  7. Understand the @kode/runtime abstraction layer

    main

    The @kode/runtime package provides an abstraction layer for essential runtime capabilities such as file system (fs), process spawning (spawn), environment variables (env), current working directory (cwd), clock, and logging.

    This abstraction allows the @kode/core package to depend on high-level runtime interfaces rather than specific platform implementations. This design enables the core logic to remain platform-agnostic.

  8. Use the Forest Canopy theme

    main

    The Forest Canopy theme provides a natural and grounded aesthetic using earth tones inspired by dense forest environments. It is characterized by the following design specifications:

    Color Palette

    • Forest Green: #2d4a2b (Primary dark green)
    • Sage: #7d8471 (Muted green accent)
    • Olive: #a4ac86 (Light accent color)
    • Ivory: #faf9f6 (Backgrounds and text)

    Typography

    • Headers: FreeSerif Bold
    • Body Text: FreeSans
  9. Understand KODE SDK Event Channels

    main

    The KODE SDK organizes events into three distinct channels based on their purpose and intended subscriber:

    • progress: Used for streaming output such as text chunks and tool calls. Typically consumed by a User Interface.
    • control: Used for permission requests and decision-making. Typically consumed by Business Logic.
    • monitor: Used for system observability, including errors, token usage, and state changes. Typically consumed by Monitoring or Logging systems.
  10. Use Bun runtime for performance-optimized execution

    main

    The packages/runtime-bun package provides a Bun-based implementation of the packages/runtime interface. It encapsulates Bun's native file and process capabilities to provide a high-performance execution path.

    Use this implementation for:

    • Development and experimental scenarios requiring Bun's features.
    • Binary build scenarios where single-file executables are created using bun --compile (refer to docs/binary-distribution.md for details).

    Note: The default runtime baseline for npm packages is Node.js.

  11. Test local web applications with webapp-testing

    main

    The webapp-testing skill is a toolkit for interacting with and testing local web applications using Playwright. It supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

    Approach Selection

    • Static HTML: Read the HTML file directly to identify selectors, then write a Playwright script using those selectors.
    • Dynamic Webapps:
      • If the server is not running: Use the scripts/with_server.py helper to manage the server lifecycle.
      • If the server is running: Use a 'Reconnaissance-then-action' pattern: navigate and wait for networkidle, take a screenshot or inspect the DOM to identify selectors, and then execute actions.
  12. Understand the @shareai-lab/kode package structure

    main
    Although the repository is organized as a monorepo with multiple internal packages, it is currently published as a single npm package: @shareai-lab/kode. Developers can access specific internal modules through the published SDK subpaths.