caglue - Coding Agent Glue

AI coding agent that works with any OpenAI-compatible API

caglue terminal session
curl -fsSL https://www.minzkn.com/public/release/caglue/caglue-latest-linux-x86_64 -o caglue && chmod +x caglue
→ Linux x86_64 one-liner · see the Download section below for aarch64 and macOS

Why caglue?

Most AI coding tools force you into a specific cloud, a specific model, or a bloated runtime. caglue is different:

What is caglue?

caglue (Coding Agent Glue) is a terminal-based AI assistant that lives in your command line. You type a task in plain English, and it uses AI models — running locally on your machine or in the cloud — to carry it out by reading, writing, and searching your files, running shell commands, browsing the web, managing git repositories, and more.

Think of it as an AI pair programmer that you control through your terminal. It works with any OpenAI-compatible backend, so you are never locked into a single provider.

Core Capabilities

caglue is a full MCP client — discover and invoke tools from any MCP server (stdio subprocess or remote HTTP). Built-in tools wrap the MCP protocol so the AI can call external tools seamlessly.

caglue mcp list
→ List configured MCP servers
caglue mcp add filesystem myserver
→ Add stdio MCP server from a built-in preset (custom env/args via the REPL /mcp add)
caglue mcp presets
→ Show the built-in preset catalogue

Config file: ~/.config/caglue/mcp.json — supports both stdio subprocess and remote HTTP transports.

Subagents (Multi-Agent)

Delegate focused subtasks to isolated AI agents. Each subagent gets its own context and tool set, may run a different model, and runs in parallel or sequence before reporting results back to the parent.

tool_task_run(prompt="review security of auth module", tools_whitelist=[read_file,search_files], model="gpt-4o")
→ Launch a focused subagent (the AI calls this tool in the REPL)

Subagents inherit parent's permission mode and hooks. Use tool_task_run, tool_task_run_batch, tool_task_run_chain from tools, or /agent-run <name> "<prompt>" to run a file-based agent definition. Agent files live in ~/.config/caglue/agents/*.md and may carry tools_whitelist, max_rounds, and depth_limit; a run is refused when the parent depth plus the agent's depth_limit would exceed 3. Manage transcripts with /subagent-list, /subagent-resume, /subagent-purge.

Language Server Protocol (LSP)

Native LSP client built in — 14 LSP tools for code intelligence: diagnostics, workspace diagnostics, hover, definition, references, implementation, type definition, rename, document symbols, workspace symbols, call hierarchy, code actions, and formatting. Works with any LSP server (clangd, gopls, rust-analyzer, pyright, typescript-language-server, etc.).

lsp_diagnostics -f src/main.c
→ LSP tool: get diagnostics for a file (the AI calls it in the REPL)
lsp_references -f src/main.c -l 42 -c 8
→ LSP tool: find references at a position (the AI calls it in the REPL)

There is no caglue lsp CLI subcommand — LSP is exposed as lsp_* tools that the model invokes from the REPL. Disable specific servers via config lsp_disable (CSV of server IDs).

Subversion (SVN) Support

Full SVN tooling alongside git — 12 SVN tools: diff, status, log, info, add, revert, delete, commit, update, move, cleanup, copy. Useful for legacy codebases or mixed VCS environments.

svn_status -s
→ SVN tool: working copy status (the AI calls it in the REPL)
svn_diff -r HEAD
→ SVN tool: diff against HEAD (the AI calls it in the REPL)

There is no caglue svn CLI subcommand — SVN is exposed as svn_* tools that the model invokes from the REPL.

PDF Converter

Convert PDFs to Markdown, JSON, HTML, or semantic chunks. Four modes: text_only (fast text extraction), structure (heuristic layout), ocr (VLM-based OCR), vlm (advanced VLM analysis). Supports encrypted PDFs (Standard Security Handler Rev 2–6).

caglue pdfconvert paper.pdf -m structure
→ Convert with layout analysis
caglue pdfconvert encrypted.pdf -pwd "secret" -f json
→ Decrypt and convert

DNS Tools (dig/nslookup Parity)

BIND9-compatible dig and nslookup subcommands: UDP/TCP, EDNS0 (+edns/+do/+bufsize=N), DoT (DNS over TLS), DoH (DNS over HTTPS, +https=URL), AXFR/IXFR zone transfer, +trace iterative resolver, section toggles (+[no]answer, +[no]authority, +[no]additional), +identify, +short, +multiline, reverse lookup via -x.

caglue dig example.com +trace
→ Iterative root-walk trace
caglue dig @1.1.1.1 example.com +tls +tlsverify
→ DNS over TLS with cert verification
caglue nslookup -type=MX example.com
→ nslookup MX records (options: -type=TYPE name [server])

GNU Parallel Parity

caglue parallel — GNU parallel-compatible core. Supports -N, -L, -j, --colsep, --pipe, --halt, {}/{.}/{/} replacements, -C attached values (-C,), plus --results, --joblog, --timeout, --retries, --bar, --eta.

caglue parallel -j4 -N2 echo job {1} {2} ::: a b c d e f
→ Run jobs in parallel (2 args per job)
printf 'a,1\nb,2' | caglue parallel -C, echo col1={1} col2={2}
→ CSV column splitting

Visual Canvas (48 tools)

The largest single tool family in caglue. A programmatic scene graph for diagrams, mockups, and schematics — no GUI toolkit, no browser engine. The model states the structure and caglue lays it out.

canvas_create · canvas_flowchart · canvas_save(out.png / .svg / .pdf / .mmd)
→ Raster, vector, Graphviz, Mermaid, Excalidraw and draw.io export

Git & SVN Working Copy Management

Full read/write coverage of both major version control systems, plus managed worktrees for isolated parallel work.

Local RAG Store

An embedded vector store over your own files — no external service. Index a directory, a single file, or the commit history of a local git repository, then retrieve relevant chunks into the AI's context.

caglue rag add ./docs && caglue rag ask "how does compaction work?"
→ 6 RAG tools are also available to the AI directly in the REPL

Checksums & Digests

A complete coreutils-compatible checksum family built in pure C — 10 subcommands, no coreutils dependency, no subprocess spawn.

Embedded Test Suite & Session Replay

The test suite is compiled into the executable — no test runner to install, no make check prerequisite. Every test is forked into its own child process, so a crash in one test cannot take the suite down and ports/temp files never collide. 270 tests registered, run in parallel.

caglue selftest # run every test (TAP output, parallel) caglue selftest list # list the 270 registered tests caglue selftest test_json # run one suite by name caglue selftest 3 # run one suite by 1-indexed number
→ also available inside the REPL as /selftest

Crypto (PEM & Big Number)

Pure C11 cryptographic primitives — no OpenSSL dependency at all (the TLS backend is entirely self-implemented pure C). These ship as libraries (libcaglue_pem, libcaglue_bignum), not CLI subcommands: PEM (RFC 7468 encode/decode) and Big Number arithmetic (Karatsuba multiplication, Knuth division, Miller-Rabin primality, modpow, modinv, GCD). Foundation for RSA, X.509, AES, and the TLS 1.2/1.3 implementation.

✅ Linux x86_64 — ready (static binary)
✅ Linux aarch64 — ready (static binary)
✅ macOS 12+ (Apple Silicon) — ready
✅ No Python or Node.js required.

Download

curl \ https://www.minzkn.com/public/release/caglue/caglue-latest-linux-x86_64 \ -o caglue
→ Linux x86_64
curl \ https://www.minzkn.com/public/release/caglue/caglue-latest-linux-aarch64 \ -o caglue
→ Linux aarch64
curl \ https://www.minzkn.com/public/release/caglue/caglue-latest-darwin-aarch64 \ -o caglue
→ macOS Apple Silicon
chmod +x caglue
→ Make executable (all platforms)

All releases

macOS: if Gatekeeper blocks the unsigned binary, run xattr -d com.apple.quarantine caglue to remove the quarantine attribute.

Setup

caglue setup walks you through an interactive wizard: pick a provider preset, enter credentials, choose a model, and configure global behavior (permission mode, gate timeouts, hooks). Your settings are saved in ~/.config/caglue/config.

caglue setup
→ Configure API key, model, preferences

Or set the environment variable directly:

export OPENAI_API_KEY="sk-..."
→ Use default provider (opencode zen)

Quick one-liner shortcuts

Once configured, these CLI shortcuts let you inspect or switch settings on the fly:

caglue model
→ Show current model
caglue model gpt-4o
→ Switch model
caglue api-base http://localhost:11434/v1
→ Point to a different endpoint
caglue doctor
→ End-to-end health check
caglue usage
→ Token consumption (last 30 days)

Quick example

Here is what a real caglue session looks like. The user just types what they want in plain English, and caglue takes care of the rest:

$ caglue
→ Start the interactive REPL
You: explain src/parser.c in 3 sentences
→ caglue reads the file and summarises it
You: add a null-check before the memcpy call
→ caglue finds the code, edits it, and shows you the diff
You: run the tests to make sure nothing broke
→ caglue runs make check and reports pass/fail

How it works

  1. You describe the task — say "explain this function" or "fix the bug in main.c"
  2. caglue plans and acts — it reads your code, runs commands, searches the web, edits files, all on its own
  3. You review every change — each file edit is shown as a diff; you approve or reject before anything is written
  4. Optional review round — caglue can run an AI security/quality review on its own changes before handing control back

Usage

1. Check your installation

caglue --help
→ See all flags and subcommands
caglue --version
→ Print version and build info

2. Start the interactive REPL

Run caglue with no arguments to start an interactive session. You are talking to an AI — just describe what you need in plain language.

caglue
→ Start interactive REPL

Inside the REPL, these slash commands help you control the session:

/help
→ List available slash commands
/compact
→ Summarise conversation to save context
/instructions ...
→ Set custom system prompt for the session
/plan "explore the codebase structure"
→ Side-effect-free planning turn (read-only)
/review
→ Toggle review mode or run one-shot review
/doctor api
→ Diagnose API/provider connectivity

caglue also loads ./.caglue/instructions/*.md automatically when the directory exists — commit these to your repository so every contributor (and AI) follows the same conventions. A user-global scope at ~/.config/caglue/instructions/*.md applies across all projects as well. Run caglue init to scaffold the project-local directory. Files load in lexicographic order; use 00-, 10- prefixes to control ordering.

💡 Prompt marks (OSC 133): caglue wraps every prompt in FinalTerm semantic markers — press Ctrl+Shift+↑/↓ in iTerm2, WezTerm, Kitty, or Windows Terminal to jump between turns.

REPL key bindings

TabComplete slash command or filename
Shift+TabCycle permission mode (PLAN → ASK → BYPASS)
Alt+EnterInsert literal newline (multiline composer)
Ctrl+OOpen last response in $PAGER
Ctrl+RReverse-search history
↑/↓Previous/next visual row or history entry
Ctrl+A/EBeginning / end of line
Ctrl+K/UKill to end / beginning of line
Ctrl+WKill previous word
Ctrl+YYank (paste)
Ctrl+LClear screen
Ctrl+CCancel current turn; press twice within 2s to exit

3. One-shot mode (no REPL)

Pass a task and file directly — caglue runs once and exits. Great for scripting or quick questions.

caglue -p "explain this function" -f parser.c
→ Explain a specific file
caglue -p "find potential bugs" -f src/
→ Review a directory
caglue -p "add error handling to main" -f main.c
→ Ask caglue to edit your code

4. Use a local LLM

Point caglue at Ollama, vLLM, or any OpenAI-compatible server running on your machine. No data leaves your computer.

caglue --no-tls --api-base http://localhost:11434/v1 \ --model llama3
→ Ollama on localhost

5. Set environment variables

Skip typing --api-base and --api-key every time by exporting these in your shell profile:

export OPENAI_API_KEY="sk-..."
→ Your API key
export OPENAI_API_BASE="https://api.openai.com/v1"
→ API base URL
export OPENAI_MODEL="gpt-4o"
→ Default model name

6. Non-interactive / auto-approve

When you trust caglue and want to skip confirmation prompts (e.g. in CI), pass --auto-approve to auto-approve every action, or export CAGLUE_YES=1 for the same effect via the environment. The persistent equivalent is the permission_mode config key — caglue config set permission_mode bypass — one of five modes (deny / ask / allow / bypass / plan).

caglue --auto-approve -p "fix all lint warnings" -f src/
→ Auto-approve mode

Skills & Automation

caglue ships with built-in skills — ready-to-use workflows that combine instructions and tool access patterns for common tasks. Use them from the REPL (/skill review) or the CLI:

Subagents (Multi-Agent Workflows)

Delegate focused subtasks to isolated conversation contexts. Each subagent runs with its own tool whitelist, model override, and depth limit — perfect for parallel security reviews, code analysis, or test generation.

/agent-run review "Check for SQL injection vulnerabilities"
→ Run a file-based subagent with custom prompt
/agent-list
→ List available agent definitions (in the REPL)

Agent files live in ~/.config/caglue/agents/*.md and ./.caglue/agents/*.md — define tools_whitelist, model_override, max_rounds, depth_limit, and custom system prompts per agent. Depth is capped at 3: a subagent is refused when its own depth_limit plus the parent's depth would exceed that.

caglue skill run review
→ Run the review skill (or /skill review inside the REPL)

Session management

Save, fork, and restore entire REPL sessions. Each session preserves conversation history, context budget state, and provider settings.

/session mysession
→ Save or load a named session
/sessions
→ List all saved sessions
/fork experiment
→ Fork current session into a new id

What can you do with caglue?

Quick Start — Usage

Get productive in minutes:

  1. Install — Download the static binary for your platform (see Download)
  2. Configure — Run caglue setup to pick a provider (opencode zen, OpenAI, Ollama, etc.) and enter credentials
  3. Start coding — Run caglue for the interactive REPL, or use one-shot: caglue -p "explain this function" -f parser.c

Tools at a glance

caglue ships with 206 built-in tools organized by category. Every tool declares a JSON Schema for its parameters, so the AI knows exactly what each one expects.

📁 File I/O — read_file, write_file, edit_file, multi_edit, edit_files, apply_context_patch, apply_unified_diff, delete_file, move_file, copy_file, mkdir, chmod, symlink
📂 File Discovery — glob, list_dir, tree, find, search_files, file_stat, file_hash, file_meta, resolve_path, repository_map, watch_files, which
📦 Archive — archive_extract, archive_create, archive_list (zip/tar/tgz/tbz2/txz/tzst/7z)
🔍 Diff — diff_files, diff_dirs
🌐 Web — web_fetch, web_save, web_search, wget
⚡ Process — bash, shell, node, python3, awk, parallel, process_list, process_output, process_kill, process_input, process_wait, process_status
🧩 JSON & YAML — json_extract, json_patch, json_validate, yaml_to_json, yaml_validate
✏️ Text & Data — text_transform, regex_test, regex_replace, calculate, string_hash, crc_string, hex_dump, random_bytes, uuid_v4, wc
🔨 Build & Test — build, run_tests, caglue_subcmd, caglue_subcmd_mut
🧠 Agent Meta — ask_user_question, notify_user, todo_write, memory_read, memory_write, memory_delete, memory_search, rag_add, rag_search, rag_remove, rag_list, rag_config, rag_reindex, read_env, list_tools, tool_info, session_status, context_compact, attach_file
🗃️ Git — git_diff, git_status, git_log, git_show, git_add, git_commit, git_checkout, git_branch, git_push, git_merge, git_reset, git_stash, git_fetch, git_blame, git_tag, git_remote, git_worktree_list, git_worktree_add, git_worktree_remove
🗃️ SVN — svn_diff, svn_status, svn_log, svn_info, svn_add, svn_revert, svn_delete, svn_commit, svn_update, svn_move, svn_cleanup, svn_copy
🎨 Visual Canvas — 48 tools for diagrams: canvas_create, canvas_flowchart, canvas_sequence, canvas_er, canvas_tree, canvas_mindmap, canvas_network, canvas_grid, canvas_table, canvas_shape_add, canvas_shape_custom, canvas_stencil_list, canvas_text_add, canvas_add, canvas_connector_add, canvas_connector_edit, canvas_connector_route, canvas_group, canvas_ungroup, canvas_load, canvas_save, canvas_zorder, canvas_align, canvas_distribute, canvas_snap, canvas_layer_add, canvas_layer_remove, canvas_layer_reorder, canvas_layer_list, canvas_layer_merge, canvas_layer_flatten, canvas_layer_set_visible, canvas_layer_solo, canvas_layer_set_opacity, canvas_layer_set_locked, canvas_layer_set_blend, canvas_obj_edit, canvas_obj_delete, canvas_describe, canvas_query, canvas_dump, canvas_diff, canvas_validate, canvas_style_check, canvas_palette, canvas_overlap_report, canvas_resolve_overlaps, canvas_destroy
📄 PDF — pdf_read, pdf_convert, pdf_info, pdf_metadata, pdf_fonts, pdf_create, pdf_embed_image, pdf_image_extract, pdf_rasterize, pdf_merge, pdf_separate, pdf_detach
🖼️ Media — image_generate, image_convert, image_analyze, audio_speak, video_generate
🤖 Subagents — tool_task_run, tool_task_run_batch, tool_task_run_chain, agent_shared_memory_set, agent_shared_memory_get, agent_broadcast, agent_barrier, agent_reduce
🔍 LSP — 14 clangd-powered tools: lsp_definition, lsp_references, lsp_hover, lsp_type_definition, lsp_implementation, lsp_document_symbols, lsp_workspace_symbol, lsp_workspace_diagnostics, lsp_diagnostics, lsp_code_actions, lsp_apply_code_action, lsp_rename, lsp_format, lsp_call_hierarchy (auto-registered when clangd is available)
🔌 MCP — Model Context Protocol server integration (risk-classified tools, available to the AI as <server>:<tool>)
🕐 System — now, sysinfo
📜 Large tool results — read_tool_result, search_tool_result (page through or grep a tool output that exceeded the context window)

Full tool list: run caglue tools or call the list_tools tool from the REPL.

Update

caglue update
→ Check and install latest version

Provider Management

Switch between multiple AI providers (opencode zen, OpenAI, Ollama, Groq, OpenRouter, etc.) with a single command. Each provider has its own API endpoint, credentials, and default model — caglue resolves the active one at request time.

caglue provider list
→ List registered providers (active marked with *)
caglue provider presets
→ Show built-in preset catalogue
caglue provider add
→ Interactive wizard: pick preset → credentials → model
caglue provider add --preset openai
→ Non-interactive: use preset defaults
caglue provider edit openai
→ Re-prompt with current values as defaults
caglue provider use ollama
→ Switch active provider (persists)
caglue provider test openai --with-chat
→ Probe /v1/models + 1-token chat completion
caglue provider remove oldprovider
→ Delete a provider section

Default endpoint: OpenRouter (https://openrouter.ai/api/v1, model openrouter/auto). Use /models in the REPL to list other model IDs offered by the active endpoint.


Configuration

caglue reads settings from ~/.config/caglue/config (INI-style). Run caglue setup to create one interactively, or edit the file directly for fine-grained control. Provider-specific settings live in [provider <name>] sections; global behavior settings are in the auto-block.

Priority (highest first): CLI flags > environment variables > config file > built-in defaults

Provider configuration (per-provider)

Global configuration (caglue behavior)

RAG store configuration (caglue rag)

Full list (77 keys): run caglue config keys.


Permission modes

caglue has five permission modes (ask / allow / deny / bypass / plan) that control what the AI can do. Switch between the three cycling modes with Shift+Tab inside the REPL:

Model Context Protocol (MCP)

Extend caglue with external tool servers using the MCP standard. Connect to databases, cloud services, or custom toolchains — caglue automatically classifies each MCP tool by risk level and applies permission rules per server.

caglue mcp add Filesystem
→ Add a built-in preset server non-interactively
caglue mcp presets
→ 26 built-in presets (GitHub, Git, SQLite, Playwright…)

Verbs: list, tools <server>, presets, add <preset> [name], remove <name>, env, include, exclude. Changes take effect on next launch; inside the REPL use /mcp refresh.

Or add servers to ~/.config/caglue/mcp.json — supports stdio subprocess, remote Streamable HTTP, environment variables, and per-server tool include/exclude filters:

{
"servers": [
{ "name": "git", "command": "npx @modelcontextprotocol/server-git" },
{ "name": "fetch", "url": "https://mcp.example.com/mcp",
"headers": { "Authorization": "Bearer TOKEN" } },
{ "name": "playwright", "command": "npx @playwright/mcp@latest",
"env": { "PLAYWRIGHT_BROWSERS_PATH": "0" } }
]
}
→ ~/.config/caglue/mcp.json — stdio subprocess + remote HTTP

Browser mirror (webmirror)

Mirror your REPL session to a browser in real time — useful for demos, pairing, or monitoring from another device on the same LAN. The browser shows a full terminal emulator with ANSI color, CJK support, keyboard input, and a scrollback buffer.

⚠️ The browser view is session-equivalent — it can run commands, edit files, and answer permission gates. HTTP Basic Auth is the only protection. Set credentials via environment variables (CAGLUE_WEB_USER, CAGLUE_WEB_PASS, CAGLUE_WEB_PASS_ENV) or type them at the interactive prompt.

/start-web
→ Start mirror on a free port
/start-web 8080
→ Start on a specific port
/stop-web
→ Tear down the mirror
/clear-web
→ Forget cached credentials

While active, the footer shows a web chip with the current viewer count (real-time across LAN). Use /stop-web to shut it down when no longer needed.

Static web server (caglue serve)

Run a standalone HTTP/1.1 static-file server with FastCGI proxy and WebSocket support. Useful for local development, demos, or serving documentation. Binds 127.0.0.1 by default — pass --bind 0.0.0.0 to expose deliberately.

caglue serve ./public --port 8080 --threads 8
→ Serve ./public on port 8080 with 8 workers
caglue serve --fcgi /=./public@127.0.0.1:9000
→ Proxy PHP requests to php-fpm
caglue serve --cert cert.pem --key key.pem
→ HTTPS with TLS 1.2+
caglue serve --ws ./public
→ Also expose a WebSocket echo channel at /ws

Token usage tracking

Track token consumption per model and per day from local rollout logs. No API connection required — caglue reads ~/.local/share/caglue/rollout/*.jsonl.

caglue usage
→ Last 30 days (default)
caglue usage 7
→ Last 7 days
caglue usage 0
→ All time

Set CAGLUE_PRICE_<MODEL>_IN/_OUT/_CACHED (per-1M tokens) to add a USD column.

Debug mode

When something does not work as expected, run with --verbose (or -v) to see detailed logs of every HTTP request, tool dispatch, and AI response. Repeat for more verbosity (-vv).

caglue -v -p "explain this function" -f parser.c
→ Verbose debug output

Share caglue with your developer friends!

댓글