diff --git a/README.md b/README.md index 200ed89..4e97112 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@
- A Python reimplementation of the Claude Code agent architecture โ local models, full control. + A Python reimplementation of the Claude Code agent architecture โ local models, full control, zero dependencies.
--- +## ๐ข What's New + +> **April 2026 โ Major Update** + +| | Feature | Details | +|---|---------|---------| +| ๐ | **Interactive Chat Mode** | New `agent-chat` command โ multi-turn REPL with `/exit` to quit | +| ๐ | **Streaming Output** | Token-by-token streaming with `--stream` flag | +| ๐ | **Plugin Runtime** | Full manifest-based plugin system โ hooks, tool aliases, virtual tools, tool blocking | +| ๐ | **Nested Agent Delegation** | Delegate subtasks to child agents with dependency-aware topological batching | +| ๐ | **Agent Manager** | Lineage tracking, group membership, batch summaries for nested agents | +| ๐ | **Cost Tracking & Budgets** | Token budgets, cost budgets, tool-call limits, model-call limits, session-turn limits | +| ๐ | **Structured Output** | JSON schema response mode with `--response-schema-file` | +| ๐ | **Context Compaction** | Auto-snip, auto-compact, and reactive compaction on prompt-too-long errors | +| ๐ | **File History Replay** | Journaling of file edits with snapshot IDs, replay summaries on session resume | +| ๐ | **Truncation Continuation** | Automatic continuation when model response is cut off (`finish_reason=length`) | +| ๐ | **Ollama Support** | Works out of the box with Ollama's OpenAI-compatible API | +| ๐ | **LiteLLM Proxy Support** | Route through LiteLLM Proxy to any provider | +| ๐ | **OpenRouter Support** | Cloud API gateway โ access OpenAI, Anthropic, Google models via one endpoint | +| ๐ | **Query Engine** | Runtime event counters, transcript summaries, orchestration reports | +| ๐ | **Testing Guide** | Comprehensive [TESTING_GUIDE.md](TESTING_GUIDE.md) with commands for every feature | +| ๐ | **Parity Checklist** | Full [PARITY_CHECKLIST.md](PARITY_CHECKLIST.md) tracking implementation status vs npm source | + +--- + ## ๐ About This repository reimplements the [Claude Code](https://docs.anthropic.com/en/docs/claude-code) npm agent architecture **entirely in Python**, designed to run with **local open-source models** via an OpenAI-compatible API server. @@ -26,6 +52,8 @@ This repository reimplements the [Claude Code](https://docs.anthropic.com/en/doc Built on the public porting workspace from [instructkr/claw-code](https://github.com/instructkr/claw-code), the active development lives at [HarnessLab/claw-code-agent](https://github.com/HarnessLab/claw-code-agent). > **Goal:** Not to ship the original npm source, but to reimplement the full agent flow in Python โ prompt assembly, context building, slash commands, tool calling, session persistence, and local model execution. +> +> **Zero external dependencies** โ just Python's standard library.
- Built with ๐ Python ยท Powered by ๐ HarnessLab Team.
+ Built with ๐ Python ยท Powered by ๐ HarnessLab Team.
@@ -38,48 +66,73 @@ Built on the public porting workspace from [instructkr/claw-code](https://github
| Feature | Description |
|---------|-------------|
| ๐ค **Agent Loop** | Full agentic coding loop with tool calling and iterative reasoning |
+| ๐ฌ **Interactive Chat** | Multi-turn REPL via `agent-chat` with session continuity |
| ๐งฐ **Core Tools** | File read / write / edit, glob search, grep search, shell execution |
+| ๐ **Plugin Runtime** | Manifest-based plugins with hooks, aliases, virtual tools, and tool blocking |
+| ๐ช **Nested Delegation** | Delegate subtasks to child agents with dependency-aware topological batching |
+| ๐ก **Streaming** | Token-by-token streaming output with `--stream` |
| ๐ฌ **Slash Commands** | Local commands: `/help`, `/context`, `/tools`, `/memory`, `/status`, `/model`, and more |
-| ๐ง **Context Engine** | Automatic context building with CLAUDE.md discovery and usage reporting |
-| ๐ **Session Persistence** | Save and resume agent sessions across runs |
+| ๐ง **Context Engine** | Automatic context building with CLAUDE.md discovery, compaction, and snipping |
+| ๐ **Session Persistence** | Save and resume agent sessions with file-history replay |
+| ๐ฐ **Cost & Budget Control** | Token budgets, cost limits, tool-call caps, model-call caps |
+| ๐ **Structured Output** | JSON schema response mode for programmatic use |
| ๐ **Permission System** | Granular control: `--allow-write`, `--allow-shell`, `--unsafe` |
-| ๐๏ธ **OpenAI-Compatible Runtime** | Python client targets an OpenAI-compatible API, with `vLLM` as the documented setup |
+| ๐๏ธ **OpenAI-Compatible** | Works with vLLM, Ollama, LiteLLM Proxy, OpenRouter โ any OpenAI-compatible API |
| ๐ **Qwen3-Coder** | First-class support for `Qwen3-Coder-30B-A3B-Instruct` via vLLM |
+| ๐ฆ **Zero Dependencies** | Pure Python standard library โ nothing to install |
---
## ๐ Roadmap
-### Testing
+### ๐ Documentation
-- See [TESTING_GUIDE.md](TESTING_GUIDE.md) for concrete commands to verify the current implementation feature by feature.
+| Document | Description |
+|----------|-------------|
+| [TESTING_GUIDE.md](TESTING_GUIDE.md) | Step-by-step commands to verify every feature |
+| [PARITY_CHECKLIST.md](PARITY_CHECKLIST.md) | Full implementation status vs the npm source |
-### Done
+### โ
Done
- [x] Python CLI agent loop
+- [x] Interactive chat mode (`agent-chat`) with multi-turn REPL
- [x] OpenAI-compatible local model backend
- [x] Qwen3-Coder support through vLLM with `qwen3_xml` tool parser
+- [x] Ollama, LiteLLM Proxy, and OpenRouter backends
- [x] Core tools: `list_dir`, `read_file`, `write_file`, `edit_file`, `glob_search`, `grep_search`, `bash`
- [x] Context building and `/context`-style usage reporting
- [x] Slash commands: `/help`, `/context`, `/context-raw`, `/prompt`, `/permissions`, `/model`, `/tools`, `/memory`, `/status`, `/clear`
- [x] Session persistence and `agent-resume` flow
- [x] Permission system (read-only, write, shell, unsafe tiers)
+- [x] Streaming token-by-token assistant output
+- [x] Truncated-response continuation flow
+- [x] Auto-snip and auto-compact context reduction
+- [x] Reactive compaction retry on prompt-too-long errors
+- [x] Cost tracking and usage budget enforcement
+- [x] Token, tool-call, model-call, and session-turn budgets
+- [x] Structured output / JSON schema response mode
+- [x] File history journaling with snapshot IDs and replay summaries
+- [x] Nested agent delegation with dependency-aware topological batching
+- [x] Agent manager with lineage tracking and group membership
+- [x] Plugin runtime: manifest discovery, hooks, aliases, virtual tools, tool blocking
+- [x] Plugin lifecycle hooks: resume, persist, delegate phases
+- [x] Plugin session-state persistence and resume restoration
+- [x] Query engine facade driving the real Python runtime
+- [x] Compaction metadata with lineage IDs and revision summaries
- [x] Unit tests for the Python runtime
- [x] `pyproject.toml` packaging with `setuptools`
-### In Progress
+### ๐ฒ In Progress
-- [ ] Full MCP support
-- [ ] Full plugin system
-- [ ] Full slash-command parity
+- [ ] Full MCP server support
+- [ ] Full slash-command parity with npm runtime
- [ ] Full interactive REPL / TUI behavior
-- [ ] Exact tokenizer / context accounting
-- [ ] Hooks parity
-- [ ] Remote modes parity
-- [ ] Voice / VIM parity
-- [ ] Some deeper runtime details from the npm source
-- [ ] Cost tracking and budget limits
-
+- [ ] Exact tokenizer-accurate context accounting
+- [ ] Hooks system parity
+- [ ] Remote runtime modes (SSH, teleport, deep-link)
+- [ ] Voice and VIM modes
+- [ ] Editor and platform integrations
+- [ ] Background and team features
---
@@ -88,11 +141,13 @@ Built on the public porting workspace from [instructkr/claw-code](https://github
```text
claw-code/
โโโ README.md
+โโโ TESTING_GUIDE.md # How to test every feature
+โโโ PARITY_CHECKLIST.md # Implementation status vs npm source
โโโ pyproject.toml
โโโ .gitignore
โโโ images/
โ โโโ logo.png
-โโโ src/ # Python implementation
+โโโ src/ # Python implementation (75+ modules)
โ โโโ main.py # CLI entry point & argument parsing
โ โโโ agent_runtime.py # Core agent loop (LocalCodingAgent)
โ โโโ agent_tools.py # Tool definitions & execution engine
@@ -101,14 +156,19 @@ claw-code/
โ โโโ agent_context_usage.py # Context usage estimation & reporting
โ โโโ agent_session.py # Session state management
โ โโโ agent_slash_commands.py # Local slash command processing
+โ โโโ agent_manager.py # Nested agent lineage & group tracking
โ โโโ agent_types.py # Shared dataclasses & type definitions
-โ โโโ openai_compat.py # OpenAI-compatible API client
+โ โโโ openai_compat.py # OpenAI-compatible API client (streaming)
+โ โโโ plugin_runtime.py # Plugin manifest, hooks, aliases, virtual tools
+โ โโโ agent_plugin_cache.py # Plugin discovery & prompt injection cache
โ โโโ session_store.py # Session serialization & persistence
+โ โโโ transcript.py # Transcript block export & mutation tracking
+โ โโโ query_engine.py # Query engine facade & runtime orchestration
โ โโโ permissions.py # Tool permission filtering
+โ โโโ cost_tracker.py # Cost & budget enforcement
โ โโโ tools.py # Mirrored tool inventory
โ โโโ commands.py # Mirrored command inventory
-โ โโโ ... # 75+ modules across 30+ packages
-โ โโโ plugins/ # Plugin subsystem (WIP)
+โ โโโ plugins/ # Plugin subsystem
โ โโโ hooks/ # Hook system (WIP)
โ โโโ remote/ # Remote runtime modes (WIP)
โ โโโ voice/ # Voice mode (WIP)
@@ -119,6 +179,8 @@ claw-code/
โโโ test_agent_context_usage.py
โโโ test_agent_prompting.py
โโโ test_agent_slash_commands.py
+ โโโ test_main.py
+ โโโ test_query_engine_runtime.py
โโโ test_porting_workspace.py
```
@@ -129,6 +191,7 @@ claw-code/
| Requirement | Details |
|-------------|---------|
| ๐ Python | `3.10` or higher |
+| ๐ Dependencies | **None** โ pure Python standard library |
| ๐ฅ๏ธ Model Server | `vLLM`, `Ollama`, `LiteLLM Proxy`, or `OpenRouter`, with tool calling support |
| ๐ง Model | [`Qwen/Qwen3-Coder-30B-A3B-Instruct`](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct) (recommended) |
@@ -285,6 +348,14 @@ python3 -m src.main agent \
python3 -m src.main agent \
"Run pwd and ls src, then summarize the result." \
--cwd . --allow-shell
+
+# Interactive chat mode
+python3 -m src.main agent-chat --cwd .
+
+# Streaming output
+python3 -m src.main agent \
+ "Explain the current architecture." \
+ --cwd . --stream
```
---
@@ -296,6 +367,7 @@ python3 -m src.main agent \
| Command | Description |
|---------|-------------|
| `agent