caglue - Coding Agent Glue

AI coding agent that works with any OpenAI-compatible API

caglue terminal session

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 myserver --command "npx -y @modelcontextprotocol/server-filesystem" --args "/tmp"
→ Add stdio MCP server
caglue mcp add remote --url https://api.example.com/mcp --header "Authorization: Bearer ..."
→ Add remote HTTP MCP server

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 has its own tool set, model, context window, and depth limit (default max depth 3). Subagents run in parallel or sequence and report results back to the parent.

/subagent "review security of auth module" --tools read_file,search_files --model gpt-4o --max-depth 2
→ Launch a focused subagent

Subagents inherit parent's permission mode and hooks. Use tool_task_run, tool_task_run_batch, tool_task_run_chain from tools.

Language Server Protocol (LSP)

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

caglue lsp start -- clangd
→ Start LSP server (clangd example)
caglue lsp diagnostics -f src/main.c
→ Get diagnostics for a file

Disable specific servers via config lsp_disable (CSV of server IDs).

Subversion (SVN) Support

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

caglue svn status
→ SVN working copy status
caglue svn diff -r HEAD
→ SVN diff against HEAD

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 --format markdown --mode structure
→ Convert with layout analysis
caglue pdfconvert encrypted.pdf --password "secret" --format json
→ Decrypt and convert

DNS Tools (dig/nslookup Parity)

BIND9-compatible dig and nslookup subcommands with 100% feature parity: UDP/TCP, EDNS0, DoT (DNS over TLS), DoH (DNS over HTTPS), AXFR/IXFR zone transfer, +trace iterative resolver, +nssearch, reverse lookup.

caglue dig example.com +trace +dnssec
→ Iterative trace with DNSSEC
caglue dig @1.1.1.1 example.com +tls +tlsverify
→ DNS over TLS with cert verification
caglue nslookup -port=853 -type=MX example.com
→ nslookup on DoT port

GNU Parallel Parity

caglue parallel — drop-in replacement for GNU parallel. Supports -N, -L, -j, --colsep, --pipe, --halt, {}/{.}/{/} replacements, -C attached values (-C,), exit code = failed job count (capped at 101).

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

Crypto (PEM & Big Number)

Pure C11 cryptographic primitives — no OpenSSL dependency for core operations: PEM (RFC 7468 encode/decode), Big Number arithmetic (Karatsuba multiplication, Knuth division, Miller-Rabin primality, modpow, modinv, GCD). Foundation for RSA, X.509, TLS 1.2/1.3 implementation (Phase T4/T5 complete).

caglue pem decode -i key.pem -o key.der
→ PEM to DER
caglue bignum modpow --base 2 --exp 100 --mod 97
→ Modular exponentiation

✅ Linux x86_64 — ready (static binary)
✅ Linux aarch64 — ready (static binary)
✅ macOS 12+ (Apple Silicon / Intel) — 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
curl \ https://www.minzkn.com/public/release/caglue/caglue-latest-darwin-x86_64 \ -o caglue
→ macOS Intel
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 "explain this function" -f parser.c
→ Explain a specific file
caglue "find potential bugs" -f src/
→ Review a directory
caglue "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 --yes to auto-approve every action.

caglue --yes "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
caglue agent list
→ List available agent definitions

Agent files live in ~/.config/caglue/agents/*.md and ./.caglue/agents/*.md — define tools_whitelist, model_override, max_rounds, and custom system prompts per agent.

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 "explain this function" -f parser.c

Tools at a glance

caglue ships with ~100 built-in tools organized by category. Every tool has an --api-base-agnostic JSON schema, so the AI knows exactly what parameters each one expects.

📁 File I/O — read_file, write_file, edit_file, multi_edit, apply_context_patch, apply_unified_diff, delete_file, move_file, copy_file, mkdir, chmod, symlink
📂 File Discovery — glob, list_dir, tree, search_files, file_stat, file_hash, resolve_path, file_meta, repository_map
📦 Archive — archive_extract, archive_create, archive_list (zip/tar/tgz/tbz2/txz)
🔍 Diff — diff_files, diff_dirs
🌐 Web — web_fetch, web_save, web_search
⚡ Process — bash, 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 & Crypto — text_transform, regex_test, string_hash, random_bytes, uuid_v4
🔨 Build & Test — build, run_tests
🧠 Agent Meta — ask_user_question, notify_user, todo_write, memory_read, memory_write, memory_delete, memory_search, read_env, list_tools, tool_info, session_status, repository_map, 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
🗃️ 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
🔌 MCP — Model Context Protocol server integration (risk-classified tools)
🔍 LSP — clangd-powered code intelligence (lsp_*, auto-registered when clangd is available)

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: opencode zen (https://opencode.ai/zen/v1, model big-pickle). 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)

Full list: run caglue config list or see caglue --help.


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-server "npx @modelcontextprotocol/server-filesystem /tmp"
→ Connect an MCP server via CLI

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 support. Useful for local development, demos, or serving documentation.

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+

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 "explain this function" -f parser.c
→ Verbose debug output

댓글