Skip to content

Latest commit

Β 

History

History
103 lines (74 loc) Β· 3.8 KB

File metadata and controls

103 lines (74 loc) Β· 3.8 KB

cortex-act πŸ–οΈ

The AI-Native Code Action Backend β€” the "hands" of the Cortex ecosystem.

cortex-ast sees. cortex-act does.

License: MIT Rust


Overview

cortex-act is a pure-Rust MCP (Model Context Protocol) server that provides AI coding agents with write, edit, and execute capabilities. It is deliberately scoped to output-only operations to enforce a strict separation of concerns:

Project Role Capability
CortexAST πŸ‘οΈ Eyes Read-only: code analysis, symbol lookup, semantic navigation
cortex-act βœ‹ Hands Write/execute: file edits, config patching, shell commands
CortexSync 🧠 Brain Global memory: captures intent/decisions, vectorizes memories

Together, they form the CortexSync Ecosystem β€” a seamless, cross-IDE memory and action layer for AI agents.

Important

To enable full ecosystem features (like task-end memory capture), ensure cortex-sync is running globally and CortexAST is installed as your primary MCP server.


Tools

1. ✏️ cortex_act_edit_ast

Replace or delete a named symbol (function/class/struct) in any source file. Targets by name, not line number. Auto-heals broken AST via local LLM if validation fails. Use cortexast map_overview to discover symbol names first.

2. βš™οΈ cortex_patch_file

Surgically patch config (JSON/YAML/TOML via dot-path), markdown docs (section heading), or .env (key). Avoids full-file rewrites.

  • type=config: target='dependencies.serde'
  • type=docs: target='Installation'
  • type=env: target='API_KEY'

3. ⏳ cortex_act_run_async

Run a shell command as a background job. Returns immediately with job_id. Poll with cortex_check_job. Use for long-running builds, scripts, or any command that may exceed MCP timeout.

4. πŸ“Š cortex_check_job

Poll a background job (from cortex_act_run_async). Returns status (running/done/failed), exit code, duration_secs, and last 20 lines of output (log_tail).

5. πŸ›‘ cortex_kill_job

Terminate a background job (SIGTERM). No-op if job already finished.


Architecture

cortex-act/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs            # MCP stdio server (JSON-RPC 2.0)
β”‚   └── act/
β”‚       β”œβ”€β”€ mod.rs
β”‚       β”œβ”€β”€ editor.rs      # AST Semantic Patcher + Tree-sitter validator
β”‚       β”œβ”€β”€ auto_healer.rs # LLM-based syntax error repair (10s timeout)
β”‚       β”œβ”€β”€ config_patcher.rs  # JSON / YAML / TOML dot-path editor
β”‚       β”œβ”€β”€ docs_patcher.rs    # Markdown section replacer
β”‚       β”œβ”€β”€ env_patcher.rs     # .env key-value patcher
β”‚       └── job_manager.rs    # Async background job runner + file logging

MCP Configuration

Add to your mcp_config.json:

{
  "mcpServers": {
    "cortex-act": {
      "command": "/path/to/cortex-act/target/release/cortex-act",
      "args": []
    }
  }
}

Building

cargo build --release
# Binary: target/release/cortex-act

Design Principles

  1. Single Responsibility β€” Only performs write/execute operations. Never reads or analyzes code.
  2. Two-Phase Commit β€” All AST edits go through a virtual dry-run before touching disk.
  3. Auto-Healing β€” Syntax errors trigger an LLM repair loop with a strict 10-second timeout.
  4. File-based Job Logs β€” Background job output goes to ~/.cortexast/jobs/{job_id}.log to prevent OOM.
  5. Zero unsafe Rust β€” All edits are panic-free and use structured anyhow::Result error handling.

Author

Thanon Aphithanawat β€” thanon@aphithanawat.me

License

MIT Β© 2026 Thanon Aphithanawat