KeiSeiKit-1.0/docs/encyclopedia/multi-cli-agents.md
KeiSei84 3be9a8bf71
Some checks are pending
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / preflight (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / vps-smoke (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:frustration-matrix,kei-frustration-loop,kei-skill-importer,kei-projects-index,kei-projects-watcher,kei-gdrive-import,kei-leak-matrix,kei-skills,kei-gateway,kei-cron-scheduler,kei-export-trajectories,kei-backend-daytona,kei-d… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-compute-baremetal,kei-compute-vultr,kei-compute-linode,kei-compute-digitalocean,kei-svc-systemd,kei-llm-bridge-mlx name:hosted-sleep-compute]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-diff,kei-scheduler,kei-watch,kei-prune,kei-discover,kei-brain-view,kei-hibernate,kei-ledger-sign,kei-fork name:wave13-15]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-git-gitea,kei-git-forgejo,kei-git-gitlab,kei-git-bitbucket,kei-memory-sled,kei-memory-redis,kei-memory-postgres,kei-memory-sqlite,kei-auth-google,kei-auth-apple,kei-auth-magiclink,kei-auth-webauthn,kei-notify-slack,kei-n… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-ledger,kei-migrate,kei-changelog,kei-memory,kei-store,kei-conflict-scan,kei-refactor-engine,kei-graph-check,kei-shared,kei-dna-index,kei-pet name:core]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-machine-probe,kei-llm-ollama,kei-llm-llamacpp,kei-llm-mlx,kei-llm-router,kei-model name:llm-stack]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-router,kei-sage,kei-task,kei-chat-store,kei-crossdomain,kei-search-core,kei-content-store,kei-social-store,kei-curator,kei-auth,kei-artifact name:mcp-lbm]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:keisei,kei-forge,kei-runtime,kei-runtime-core,kei-atom-discovery,kei-agent-runtime,kei-capability,kei-provision,kei-entity-store,kei-pipe,kei-cache,kei-spawn,kei-replay name:atom-substrate]) (push) Blocked by required conditions
feat(multi-cli): kei run-via <backend> — agents over external LLM CLIs
Adds a uniform launcher that lets any KeiSeiKit agent run on whichever
LLM CLI you have a subscription to. Pick by familiarity, pricing, or
to get a second opinion on the same prompt.

Backends (locally installed, by subscription):
  claude   Claude Code     (claude -p)
  grok     xAI Grok        (grok --print; native --agent supported)
  agy      Antigravity     (agy --print)              alias: antigravity
  copilot  GitHub Copilot  (copilot --prompt)
  kimi     Moonshot Kimi   (stdin, TUI primary)
  codex    OpenAI Codex    (codex -p)                 register-only

Files:
  _primitives/cli-backends.toml         SSoT backend table
  scripts/kei-agent-cli.sh              launcher; loads ~/.claude/agents/<n>.md,
                                        strips frontmatter, composes with task,
                                        execs backend non-interactive
  bin/kei                               new arm: run-via | via | run | agent-via
  docs/encyclopedia/multi-cli-agents.md user-facing docs + usage

Auto-installed via lib-scaffold.sh:77 glob (no install code change needed).

Test plan:
  kei run-via list                                 # status + agents
  kei run-via grok critic "review src/auth.rs"     # via Grok
  kei run-via agy critic "review src/auth.rs"      # via Antigravity
  kei run-via copilot critic "review src/auth.rs"  # via Copilot
  KEI_NATIVE_AGENT=1 kei run-via grok critic "..."  # native --agent
2026-05-26 15:05:02 +08:00

3.6 KiB

Multi-CLI agent invocation

Cross-LLM agent execution. Same agent definition, different backend.

KeiSeiKit agents are markdown files. Any LLM CLI that takes a prompt can host them — kei run-via is the launcher that bridges them.

Backends

Registered in _primitives/cli-backends.toml (SSoT). Installed locally via your own subscription / package manager:

Backend CLI binary Non-interactive flag Native --agent Notes
claude claude -p yes Claude Code (Anthropic)
grok grok --print yes xAI Grok Build TUI
agy agy --print no Google Antigravity (alias: antigravity)
copilot copilot --prompt no GitHub Copilot CLI (@github/copilot)
kimi kimi stdin no Moonshot Kimi (primarily TUI/ACP)
codex codex -p no OpenAI Codex (register-only)

Run kei run-via list to see which are installed on the current machine and to list available agent names.

Usage

# Invoke the 'critic' agent through Grok with a task:
kei run-via grok critic "review src/auth.rs for variant analysis"

# Same agent, different backend:
kei run-via agy critic "review src/auth.rs"
kei run-via copilot critic "review src/auth.rs"
kei run-via claude critic "review src/auth.rs"

# Point at an arbitrary agent .md (not in ~/.claude/agents/):
kei run-via grok --file=/tmp/my-agent.md "do the thing"

# Backend's native --agent flag (grok/claude only):
KEI_NATIVE_AGENT=1 kei run-via grok critic "review src/auth.rs"

How it works

  1. Reads ~/.claude/agents/<agent-name>.md (assembler-generated prompt).
  2. Strips YAML frontmatter.
  3. Composes with task as: <agent prompt>\n\n---\n\nTASK FOR THIS RUN:\n<task>.
  4. Execs the backend's non-interactive CLI with the composed prompt.

No agent file is modified. No new tokens are issued. Subscription authentication is whatever each CLI uses (its own login / config dir).

When to use each

This is a tool, not a recommendation. Each backend has different strengths; the substrate is agnostic about which you pick. Pick by:

  • Familiarity — the CLI you already use day-to-day.
  • Subscription cost — burn the one with cheaper marginal cost first.
  • Specific feature — e.g. grok --agent for native sub-agent switching mid-conversation; agy --sandbox for terminal restriction.
  • Independent second opinion — same agent, different model, see if conclusions diverge.

Adding a new backend

  1. Add a [backend.<name>] table to _primitives/cli-backends.toml.
  2. Add a case arm in scripts/kei-agent-cli.sh backend_bin() and backend_invoke() for the new CLI's print-flag.
  3. Add a row to the table above.

What it is NOT

  • Not a router — picks no backend for you; you ask, it dispatches.
  • Not a federation — each backend runs independently with its own context; there is no cross-backend state.
  • Not a wrapper around the backend's tool surface — what the CLI can do (Bash, file edits, MCP, etc.) is determined by that CLI, not KeiSeiKit. The substrate only ships the prompt.
  • _primitives/_rust/kei-llm-router/ — Beta-posterior router for programmatic model selection inside Rust code (a different layer).
  • _primitives/_rust/kei-mcp/ — MCP server that exposes KeiSeiKit primitives to ANY MCP-compatible client (Cursor / Continue / Zed / Aider / Cline / Windsurf / OpenClaw).