Skip to main content

Zima Blue CLI

Python License CI

"I chose blue. That intense blue." — Zima Blue

Zima Blue CLI is a personal Agent orchestration platform that lets you run a 7x24 autonomous AI Agent factory on your own computer.

Simply define Prompt templates and configuration parameters, and Zima will automatically invoke Kimi CLI to execute tasks and return structured results.

Define Prompt Template → Configure Parameters → Execute → Get Results

Table of Contents


Features

  • 🤖 Multi-Agent Support — Pluggable AI executors (currently Kimi and Claude)
  • 📋 Configuration Entities — Layered config design: Agent + Workflow + Variable + Env + PMG
  • 🚀 PJob Execution Layer — Declarative task configuration, one-command composition and execution
  • 📝 Jinja2 Templates — Flexible Prompt templates with variable substitution
  • 🔒 Secret Management — Supports environment variables, files, Vault, and other secret sources
  • 🧪 Full Test Coverage — Unit tests + integration tests (including real Kimi invocation tests)
  • 🧹 Auto Cleanup — Built-in cleanup scripts for cache and temporary files

Architecture

Configuration Entities

Zima uses a layered configuration design, enabling flexible task execution through composition:

Entity Purpose Example
Agent AI executor config (kimi/claude) code-reviewer
Workflow Prompt template (Jinja2) code-review-template
Variable Template variable values review-vars
Env Environment variables and secrets prod-env
PMG Dynamic parameter groups build-params
PJob Execution config (composes all above) daily-review-task
Schedule Daemon scheduling (32-cycle stages) weekday-review

Directory Structure

~/.zima/
├── configs/
│   ├── agents/           # Agent configurations
│   ├── workflows/        # Workflow templates
│   ├── variables/        # Variable configurations
│   ├── envs/             # Environment configurations
│   ├── pmgs/             # Parameter groups
│   ├── pjobs/            # Execution task configurations
│   └── schedules/        # Daemon scheduling configurations
├── daemon/               # Daemon runtime (PID, state, logs, JSONL history)
├── temp/pjobs/           # Ephemeral PJob working directories
├── history/pjobs.json    # Per-PJob execution history (max 100 each)
├── logs/                 # Execution logs
└── scenes.yaml           # Optional user-defined quickstart scenes

Execution Flow

# Composed execution
zima pjob run my-task    # Combines Agent + Workflow + Variable + Env

Important This project adopts an iterative design approach. Always refer to docs/architecture/ for the latest design, and use AGENTS.md at the repository root as the final authority for implementation.


Configuration

Zima reads configuration from one place only — the config root:

${ZIMA_HOME:-~/.zima}/configs/

Configs are one YAML file per entity, named after its code:

Subdirectory Entity
agents/ AI executor (kimi / claude / pi)
workflows/ Prompt template (Jinja2)
variables/ Template variable values
envs/ Environment variables and secret references
pmgs/ Dynamic CLI parameter groups
pjobs/ Executable task (composes the above)
schedules/ Daemon 32-cycle scheduling

YAML written anywhere else — for example a project directory — is not auto-discovered.

Two Ways to Configure

  • YAML path — copy a working pack from examples/webhook/ or examples/sdd/ into the config root, edit, validate, run. Best for agents, bulk setup, and version control:

    ZIMA_HOME="${ZIMA_HOME:-$HOME/.zima}"
    mkdir -p "$ZIMA_HOME/configs/"
    cp -r examples/webhook/{agents,workflows,variables,envs,pjobs} "$ZIMA_HOME/configs/"
    # edit the copied YAML files to taste, then:
    zima pjob validate claude-cr --check-render
    zima pjob run claude-cr
    
  • CLI path — zima quickstart bootstraps a complete task interactively; zima <kind> create --example prints a starter YAML; fine-grained commands handle small edits. validate is the shared quality gate for both paths.

Run-time overrides (zima pjob run <code> --set-var/--set-env/--set-param) apply to that execution only — they never write back to any YAML file.

Full entity reference, secret handling, and the validation workflow: Configuration Guide.


Quick Start

Installation

# Clone the repository
git clone https://github.com/zhuxixi/zima-blue-cli.git
cd zima-blue-cli

# Install dependencies
uv sync

Basic Usage

# Create an Agent
zima agent create --name "My Agent" --code my-agent --type kimi

# Run a PJob (after composing one)
zima pjob run <pjob-code>

# Inspect execution history
zima pjob history <pjob-code>

Quickstart Wizard

The fastest way to get started. One command creates all configs interactively:

zima quickstart

The wizard walks you through picking a task template, naming your setup, selecting an AI agent (Kimi / Claude), and auto-detects your git repo.

When done, run the generated PJob:

zima pjob run <generated-code> --dry-run  # preview
zima pjob run <generated-code>            # execute

Or Start from an Example Pack

Prefer editing YAML directly? Copy a complete, working setup and make it yours — examples/webhook/README.md walks through installing a full webhook-triggered code review pack (agents, workflows, variables, envs, pjobs) with a single cp -r. The Configuration Guide explains every file.

Manual Configuration (Power Users)

Tip: zima quickstart is the recommended entry point. The steps below are the manual config-by-config approach for power users.

# 1. Create an Agent
zima agent create --name "Code Reviewer" --code reviewer --type kimi

# 2. Create a Workflow template
zima workflow create --name "Review Template" --code review \
  --template "# Review: {{ task_name }}\n\n{{ description }}"

# 3. Create Variable configuration
zima variable create --name "Review Vars" --code review-vars
zima variable set review-vars task_name "Bug Fix Review"
zima variable set review-vars description "Check for memory leaks"

# 4. Create a PJob composition
zima pjob create --name "Code Review Task" --code review-task \
  --agent reviewer --workflow review --variable review-vars

# 5. Run the task
zima pjob run review-task

# 6. View execution history
zima pjob history review-task

The CLI commands above write the same YAML files you would edit by hand — both paths land in the config root. See the Configuration Guide to manage them as plain YAML instead.

Cleanup

# Cleanup temp and history (cross-platform)
uv run python scripts/cleanup.py --auto

Webhook-Triggered Automatic Code Review

Zima can listen for GitHub webhooks and automatically trigger PJob-based code reviews when a PR is labeled with zima:needs-review.

# Prefer the ZIMA_WEBHOOK_SECRET env var so the secret is not visible in `ps`.
export ZIMA_WEBHOOK_SECRET=your-webhook-secret
zima webhook-server \
  --smee-url https://smee.io/YOUR_CHANNEL \
  --pjob claude-cr \
  --pjob kimi-cr

A secret is required by default (fail-closed). For local loopback testing only, pass --allow-no-secret to run without HMAC verification.

When a pull request is labeled zima:needs-review, the configured PJobs (e.g., claude-cr and kimi-cr) are triggered automatically.

See examples/webhook/README.md for sample configs and GitHub webhook setup.


CLI Commands

# Run & manage tasks
zima pjob run <code>            # execute (runs in background by default)
zima pjob run <code> --dry-run  # preview prompt, command, env — no execution
zima pjob status <code>         # status + recent history for one task
zima pjob ps                    # all currently running tasks
zima pjob cancel <code>         # cancel running execution(s)
zima pjob history <code>        # execution history and stats

# Validate configuration — the shared quality gate
zima agent validate <code>                # per entity: agent | workflow | variable | env | pmg | pjob | schedule
zima pjob validate <code> --check-render  # cross-entity refs + template render

# Runtime services
zima daemon start|stop|status|logs
zima webhook-server --pjob <code> [--smee-url <url>]

# Bootstrap
zima quickstart                 # interactive wizard: a complete task from scratch

Full CLI reference: docs/cli-reference.md (generated from the live command tree — regenerate with uv run python scripts/generate_cli_docs.py after changing commands).


Documentation

docs/
├── vision/           # Project vision and story
├── architecture/     # Latest architecture design ⭐ authoritative
│   └── data-and-runtime-reference.md  # Data models, runtime interfaces, execution flow
├── design/           # Feature design documents (historical, written pre-implementation)
├── guides/           # User-facing guides
│   └── configuration.md               # ⭐ YAML configuration guide
├── history/          # Historical designs (reference only)
├── decisions/        # Architecture Decision Records (ADR; 004-single-execution ⭐ current)
└── reports/          # Generated reports

Use Cases

  • SOP Tasks: DevOps scripts, data processing, report generation
  • R&D Tasks: Test coverage, code refactoring (workflow-driven via Prompt)
  • CI/CD Integration: Build steps that return structured results
  • Scheduled Tasks: Periodic automation via cron

AI Coding Pipeline

Zima automates the issue-driven AI coding pipeline — from code review through deployment — using configurable PJob compositions.

Pipeline Stages

issue → brainstorm/spec → plan → impl → create-PR → CR → post-fix → post-merge → integration-test → deploy-prod

Automation Coverage

Stage Status PJob
brainstorm/spec ❌ Manual (by design) —
plan ❌ Not implemented —
impl ❌ Not implemented —
create-PR ❌ Not implemented —
CR ✅ Active jfox-kc-code-review-job, jfox-zc-code-review-job
post-fix ❌ Not implemented —
post-merge ❌ Not implemented —
integration-test ❌ Not implemented —
deploy-prod ❌ Not implemented —

Supported PJobs

PJob Code Description Stage
jfox-kc-code-review-job Code review via Kimi CLI CR
jfox-zc-code-review-job Code review via Zhipu-driven Claude Code CR

Claude Code Marketplace

This repository doubles as a Claude Code plugin marketplace named zima-blue. The plugins here are the Claude Code-side counterparts of zima daemon's automation — install them in your Claude Code session and zima can drive them via scheduled prompts.

Install

/plugin marketplace add zhuxixi/zima-blue-cli
/plugin install pr-automation@zima-blue

Plugins

Plugin Purpose Skills
pr-automation GitHub PR automation driven by zima daemon github-code-review-batch

More plugins (e.g. pr-monitor) will be added under the same marketplace as zima's automation surface grows.


Development

See AGENTS.md for development conventions, coding style, and design principles.

Naming Origin

Zima Blue is inspired by Alastair Reynolds' science fiction short story Zima Blue.

The story follows an artist-robot who, after millennia of upgrades and evolution, ultimately returns to its original form as a simple pool-cleaning robot — symbolizing returning to essence and self-evolution.


License

This project is licensed under the MIT License.

Release files for zima-blue-cli 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zima-blue-cli 0.9.0
File Size Uploaded
zima_blue_cli-0.9.0.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for zima-blue-cli 0.9.0
File Interpreter ABI Platform
zima_blue_cli-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.3 MB

Release files / zima_blue_cli-0.9.0.tar.gz

Download URL zima_blue_cli-0.9.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
4ba2447a35a4e9a8541ed55065b16d9ae5f19bc048911d8c6e6e9eed275f19be
BLAKE2b-256 checksum
How to use checksums
76e80f34d512801eb7024614fafbfdef05311b67b1368724306fdb3388bca621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.0

Release files / zima_blue_cli-0.9.0-py3-none-any.whl

Download URL zima_blue_cli-0.9.0-py3-none-any.whl
Size 177.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46686e2c62c0e02517a5b77f17c24f5b4e9b11349a31f82f91aa1db0b155c94f
BLAKE2b-256 checksum
How to use checksums
151a6c99e700395b9111be4575ebd73deae571150ef519e608ddc14f4b70c1f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.0

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page