Metadata-Version: 2.4
Name: spark-agent
Version: 0.15.0
Summary: Spark [Ember] — local-first coding agent with a Codex-style loop
License: MIT
Keywords: ai,agent,coding,local-first,llm,chatbot
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: agent-client-protocol<0.13,>=0.12
Requires-Dist: chromadb>=1.0
Requires-Dist: instructor<2.0,>=1.4
Requires-Dist: litellm<2.0,>=1.0
Requires-Dist: llama-index-core<1.0,>=0.12
Requires-Dist: llama-index-llms-openai-like<1.0,>=0.3
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: langgraph<2.0,>=1.0.10
Requires-Dist: langgraph-checkpoint-sqlite<4.0,>=3.1.1
Requires-Dist: aiosqlite<0.23,>=0.20
Requires-Dist: croniter<8.0,>=7.0
Requires-Dist: mcp<2.0,>=1.0; python_version >= "3.10"
Requires-Dist: nbformat<6.0,>=5.10
Requires-Dist: pydantic<3.0,>=2.7
Requires-Dist: pydantic-settings<3.0,>=2.0
Requires-Dist: textual<1.0,>=0.80
Requires-Dist: tomlkit<1.0,>=0.13
Requires-Dist: tree-sitter<0.27,>=0.25
Requires-Dist: tree-sitter-javascript<0.26,>=0.23
Requires-Dist: tree-sitter-python<0.26,>=0.23
Requires-Dist: tree-sitter-typescript<0.24,>=0.23
Requires-Dist: typer<1.0,>=0.12
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.7; extra == "dev"
Requires-Dist: import-linter>=2.0; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: bandit>=1.7; extra == "dev"
Requires-Dist: pre-commit>=3.6; extra == "dev"
Requires-Dist: playwright>=1.49; extra == "dev"
Provides-Extra: openapi
Requires-Dist: fastapi>=0.110; extra == "openapi"
Provides-Extra: platform
Requires-Dist: fastapi>=0.162; extra == "platform"
Requires-Dist: uvicorn>=0.54; extra == "platform"
Requires-Dist: sse-starlette>=3.5; extra == "platform"
Requires-Dist: tiktoken>=0.14; extra == "platform"
Requires-Dist: tenacity>=9.2; extra == "platform"
Requires-Dist: SQLAlchemy>=2.1; extra == "platform"
Requires-Dist: pathspec>=1.1; extra == "platform"
Requires-Dist: wcmatch>=12.0; extra == "platform"
Requires-Dist: psutil>=7.2; extra == "platform"
Provides-Extra: enterprise
Requires-Dist: fastapi>=0.162; extra == "enterprise"
Requires-Dist: uvicorn>=0.54; extra == "enterprise"
Requires-Dist: SQLAlchemy>=2.1; extra == "enterprise"
Requires-Dist: alembic>=1.14; extra == "enterprise"
Requires-Dist: authlib>=1.9; extra == "enterprise"
Requires-Dist: casbin>=1.43; extra == "enterprise"
Requires-Dist: pyjwt>=2.10; extra == "enterprise"
Requires-Dist: python-multipart>=0.0.9; extra == "enterprise"
Provides-Extra: postgres
Requires-Dist: asyncpg>=0.30; extra == "postgres"
Requires-Dist: psycopg[binary]>=3.2; extra == "postgres"
Provides-Extra: office
Requires-Dist: python-docx>=1.1; extra == "office"
Requires-Dist: openpyxl>=3.1; extra == "office"
Requires-Dist: python-pptx>=1.0; extra == "office"
Requires-Dist: pypdf>=5.0; extra == "office"
Requires-Dist: pypdfium2>=4.0; extra == "office"
Requires-Dist: rapidocr-onnxruntime>=1.4; extra == "office"
Requires-Dist: extract-msg>=0.58; extra == "office"
Requires-Dist: reportlab>=4.0; extra == "office"
Provides-Extra: asr
Requires-Dist: faster-whisper>=1.2; extra == "asr"
Requires-Dist: av<19,>=15; extra == "asr"
Provides-Extra: notebook
Requires-Dist: nbclient<1.0,>=0.11; extra == "notebook"
Provides-Extra: search
Requires-Dist: ddgs>=9.16; extra == "search"
Requires-Dist: trafilatura>=2.3; extra == "search"
Provides-Extra: telemetry
Requires-Dist: opentelemetry-api>=1.28; extra == "telemetry"
Requires-Dist: opentelemetry-sdk>=1.28; extra == "telemetry"
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.28; extra == "telemetry"
Provides-Extra: pty
Requires-Dist: ptyprocess>=0.7; sys_platform != "win32" and extra == "pty"
Requires-Dist: pywinpty>=3.1; sys_platform == "win32" and extra == "pty"
Provides-Extra: desktop
Requires-Dist: pywebview>=5.0; extra == "desktop"
Dynamic: license-file

> 🌐 **English** | [中文](README_zh.md)

# Spark

**Local-first AI coding agent and office workbench — with guardrails you can audit.**

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-brightgreen.svg)](https://www.python.org/)
[![Node 18+](https://img.shields.io/badge/node-18%2B-339933.svg)](https://nodejs.org/)
[![CI](https://github.com/badhope/spark/actions/workflows/ci.yml/badge.svg)](https://github.com/badhope/spark/actions/workflows/ci.yml)
[![Security](https://github.com/badhope/spark/actions/workflows/security.yml/badge.svg)](https://github.com/badhope/spark/actions/workflows/security.yml)

One agent loop, eight surfaces, one permission model. Spark runs coding tasks,
office workflows and an enterprise control plane on the same auditable core:
approval before writes, sandboxed execution, checkpoint rollback, and a provider
layer that works with any OpenAI-compatible endpoint.

```bash
# Linux / macOS — SHA256-verified
curl -fsSL https://raw.githubusercontent.com/badhope/spark/main/scripts/install.sh | sh

# Windows (PowerShell)
irm https://raw.githubusercontent.com/badhope/spark/main/scripts/install.ps1 | iex

spark init    # point it at any OpenAI-compatible endpoint
spark web     # browser UI (auto-picks a free port)
```

No API key? Spark starts in **demo mode** with a scripted mock model. Add a key
in settings and the next turn uses the real model — no restart.

<p align="center">
  <img src="assets/screenshots/11-chat.png" alt="Spark chat with reasoning, tool calls and a live context meter" width="100%">
</p>

## Why Spark

- **Auditable execution.** Six approval modes × four sandbox levels. Wildcard
  rules across user/project/local scopes, where `deny` always wins. Protected
  credential paths and token-level shell checks.
- **Recoverable by design.** Every turn snapshots the workspace (tar.gz +
  manifest verification). Roll back files and conversation together — also in
  non-git directories.
- **Task-as-branch.** `task_begin` → `task_step_commit` → `task_finish`. Green
  tests gate each commit; a red run abandons the branch.
- **Enterprise control plane.** `/api/v1` with tenants, projects, tasks,
  artifacts and audit. SQLite for local development; PostgreSQL, Keycloak OIDC
  and Casbin for production.
- **Office workbench with real files.** `/office` turns meeting transcripts and
  documents into cited minutes, action items, reports and spreadsheets, then
  exports Markdown, Word, Excel, PowerPoint and PDF. Import docx/xlsx/pptx/pdf,
  email, images and scanned PDFs (local OCR); transcribe meeting recordings on
  the machine (Whisper — the audio never leaves it); optional AI summaries when
  a model is configured. `SPARK_CONTROL_BRAND_*` puts your own name, colour and
  logo on the output without touching the content or the citations.
- **Provider freedom.** Any OpenAI-compatible endpoint, fallback model chain,
  credential pool and a separate small model for auxiliary calls.

## Quick start

```bash
spark                         # terminal TUI
spark web                     # browser UI on 127.0.0.1
spark desktop                 # native window, loopback only
spark enterprise              # enterprise /api/v1 control plane
spark exec "task" --json      # NDJSON event stream for scripts and CI
spark review                  # audit the uncommitted diff
spark wiki --refresh          # regenerate the local code wiki
spark doctor                  # diagnose config, credentials and runtime
```

The office workbench is served by the enterprise control plane:

```bash
spark enterprise --host 127.0.0.1 --port 18800
# http://127.0.0.1:18800/office
```

`spark exec` streams one JSON object per line and ends with
`{"type":"final","text":"…"}`, so it pipes straight into `jq`.

## Eight surfaces

| Form | Command | Use case |
|---|---|---|
| Web UI | `spark web` | Chat, file viewer, terminal, execution graph |
| Enterprise API | `spark enterprise` | `/api/v1` control plane and `/office` |
| Desktop | `spark desktop` | Native pywebview window, loopback only |
| TUI | `spark` | Pure terminal / SSH |
| CLI | `spark exec "task" --json` | Automation, CI, piping |
| IDE (ACP) | `spark acp` | Zed and other ACP clients — [docs/ACP.md](docs/ACP.md) |
| MCP server | `spark mcp-serve` | Expose built-in tools to other MCP clients |
| A2A server | `spark a2a-serve` | Agent-to-agent delegation — [docs/A2A.md](docs/A2A.md) |

## Guardrails

Three layers, each narrowing the previous one:

1. **Approval** — from `plan-only` (plan, change nothing) to `full-auto`.
   The default `suggest` asks before any write or command.
2. **Sandbox** — `sandbox-only` / `workspace` (default) / `full-access` /
   `unrestricted`. Path escapes and protected paths are refused outright.
3. **Rules** — `[[permission_rules]]` match tool + resource across three
   scopes. A cloned repository can tighten permissions, never grant itself more.

OS-level isolation is layered on top: bwrap on Linux, a Job Object on Windows
(process-tree kill-on-close plus a memory ceiling), `sandbox-exec` on macOS.
Where a platform cannot enforce something, the tool result says so instead of
pretending.

## Verified locally

```bash
pytest -q                                  # 1493 passed, 3 skipped
ruff check src tests scripts
mypy src/spark --ignore-missing-imports
bandit -r src/spark -ll -ii -c bandit.yaml
lint-imports                               # architecture contracts
```

CI additionally runs secret scanning, an OpenAPI snapshot freshness check, a
coverage floor, a Windows-reserved-path check, packaging checks, and a
mock-mode agent eval suite on Linux and Windows.

## Documentation

| Document | Contents |
|---|---|
| [docs/INSTALL.md](docs/INSTALL.md) | Install, package, desktop build, auto-update, uninstall |
| [docs/CONFIG.md](docs/CONFIG.md) | Every config key and environment variable |
| [docs/API.md](docs/API.md) | HTTP API and SSE event protocol |
| [docs/ENTERPRISE.md](docs/ENTERPRISE.md) | `/api/v1`, `/office`, PostgreSQL, Keycloak, Casbin, Alembic |
| [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | Layering and module boundaries |
| [docs/FEATURES.md](docs/FEATURES.md) | Feature-by-feature implementation map |
| [docs/A2A.md](docs/A2A.md) | A2A agent card, streaming, task lifecycle |
| [docs/competitive-comparison.md](docs/competitive-comparison.md) | How it compares to Qoder / ZCode / opencode / Codex CLI |
| [docs/reviews/](docs/reviews/) | Audit reports with findings, fixes and honest limits |
| [vscode-spark/](vscode-spark/) | VS Code extension |

## Platform requirements

- Python 3.11+ — or the bundled executable, no Python needed
- Node.js 18+ for frontend development only (release builds ship compiled assets)
- Windows / macOS / Linux

---

**License:** MIT · **Author:** badhope
