-Requires **Python 3.11+**. Version **0.2.0a1** is for evaluating the architecture and developing plugins. Two models passed live Anspire gateway acceptance; native multi-provider acceptance and the total-source reduction target remain incomplete. See the [acceptance evidence](docs/acceptance-2026-10-11.md).
+
-## Get started
+MiniAgent is an **ultra-lightweight Python Agent / Harness with the essentials built in**, centered on just **531 lines of core code**. It supports common agent capabilities such as tool calling, session memory, context management and plugin extensions. **Use it directly, learn how agents work, or customize it to build your own.**
-```bash
-git clone https://github.com/ZhuLinsen/MiniAgent.git
-cd MiniAgent
-python -m pip install .
-```
-
-Create `.env` in the project and fill in your provider key and model ID. Replace `` below. For Qwen use `dashscope:` and `DASHSCOPE_API_KEY`; for Claude use `anthropic:` and `ANTHROPIC_API_KEY`.
+## Key features
-Alternatively run `miniagent --connect`. An interactive first launch with a missing model or credential opens the guide. In the REPL, `/connect` configures a provider and `/models` selects a model. See [connections and credentials](docs/model-connections.md).
+- 🧠 **Essential capabilities**: native tool calling, streaming, session memory, context compaction, Skills, MCP, plugin management and permission controls form a working Agent / Harness.
+- 🚀 **Ready to use**: connect a model and run coding and automation tasks through the CLI, or embed the runtime in an existing project through the Python API.
+- 📖 **Learn by exploring**: the core is just **531 lines across 4 files**, covering model calls, tool execution and plugin management. Read and run the code to understand how an Agent / Harness works.
+- 🧩 **Build your own**: customize prompts and Skills, add tools and services through Plugin. Reuse the existing session and permission mechanisms as you develop your own agent.
-Select a model explicitly. Noninteractive calls with only a key or API URL fail before client creation. Precedence is `--model`, JSON `llm.model`, `LLM_MODEL`, then the saved connection default.
+## Quick start
-```dotenv
-DEEPSEEK_API_KEY=your-provider-key
-LLM_MODEL=deepseek:
-```
+Requires Python 3.11+. A virtual environment is recommended.
```bash
-miniagent --policy readonly --prompt "Inspect the project structure and explain its entry points"
+git clone https://github.com/ZhuLinsen/MiniAgent.git
+cd MiniAgent
+python -m pip install -e ".[credentials]"
miniagent
```
-Writes, Shell and MCP calls require confirmation by default. Noninteractive confirmation denies execution. Use `--policy trusted` for automation you explicitly trust. Managed file tools hide `.env*` (except `.env.example`), `.git` and private-key files unless `--allow-sensitive-files` is explicitly supplied. Shell, Python plugins and MCP servers are trusted code outside the managed file boundary.
+The first launch guides you through connecting a model. Then enter a task. File changes and Shell calls require confirmation by default.
-## Capabilities
+You can also pass a task on the command line:
+
+```bash
+miniagent --policy readonly --prompt "Explain this project and find its main code and tests"
+```
-- Native tool calls and streamed text; one async model boundary with provider credential isolation.
-- Instance-owned tool registry; plugin dependency ordering, activation rollback and reverse cleanup.
-- `read / write / edit / grep / glob / bash` with workspace checks and authorization.
-- JSONL sessions, context compaction that preserves whole tool groups, and inspection before resuming uncertain effects.
-- Reversible Skill execution whitelists and optional official MCP SDK stdio integration.
+Use `/help` for commands, `/models` to switch models, `/skills reviewer` for code review and `/session` to inspect the session. [Model setup](docs/model-connections.md)
-CLI commands: `/help`, `/connect`, `/models`, `/model`, `/plugins`, `/skills`, `/session`, `/stream`. `/plugins` currently lists loaded plugins. `--session ` resumes a session; `/session new` creates one. Switching models creates a fresh session.
+## Use from Python
-## Python API
+Create an agent, attach its tools and give it a task:
```python
from miniagent import Harness
from miniagent.plugins import coding_tools
from miniagent.policy import Policy
-from miniagent.session import Session
-app = Harness(model="deepseek:", policy=Policy(mode="readonly"),
- session=Session("task.jsonl"))
+app = Harness(model="provider:model-id", policy=Policy(mode="readonly"))
app.use(coding_tools())
-print(app.run("Inspect the project structure"))
+print(app.run("Read the project structure and explain its entry points"))
```
-In an existing event loop use `await app.arun(...)` and `async with app` for resource ownership. One task per Harness; plugins and Skills change only while idle.
+Replace `provider:model-id` with your model and configure its credential. For async use, call `await app.arun(...)` inside `async with app`.
-## A custom plugin
+Harness manages the model/tool loop, plugin setup and cleanup, and sessions. Register your tools, shared services and event listeners through `Plugin`. [Plugins and complete examples →](docs/lean-harness.md)
-```python
-from miniagent import Harness, Plugin
-from miniagent.policy import Policy
-from miniagent.tools.registry import Tool
+## Demos
-def calculator(ctx):
- ctx.tool(Tool("add_one", "Add one", {"type": "object",
- "properties": {"n": {"type": "integer"}}, "required": ["n"]},
- lambda n: n + 1))
+**Edit code and run tests** · Fix calculator.py while leaving the tests unchanged.
-app = Harness(model="deepseek:", policy=Policy(mode="trusted"))
-app.use(Plugin("calculator", calculator))
-print(app.run("Use add_one to add 1 to 2"))
-```
+
+
+Rendered from a real CLI recording with condensed playback timing; the terminal styling comes from the presentation branch. [Still image](docs/assets/coding-session.png) · [Full recording and reproduction](docs/demo.md)
-This example explicitly trusts the custom tool. The [runtime guide](docs/lean-harness.md) covers model configuration, MCP installation and plugins, Skill switching, recovery and compatibility.
+### Windows automation
-## Validation and version boundaries
+
+
Open a browser and search
Create a Word document
+
Open a browser and search for the MiniAgent GitHub repository.
Write an overview of AI agents, save it as a Word document and format it.
+
+
+
+
+
+
+These recordings are from the original version; click either to enlarge. The current version uses Shell / Python or MCP for local automation. See [Windows examples and setup](docs/demo.md#windows-案例).
+
+## Project structure
+
+The core lives in [agent.py](miniagent/agent.py), [harness.py](miniagent/harness.py), [llm.py](miniagent/llm.py) and [tools/registry.py](miniagent/tools/registry.py). Sessions, Skills and MCP have their own modules.
+
+```text
+miniagent/
+├── agent.py # Agent loop · 72 lines
+├── harness.py # Plugins, services and lifecycle · 256 lines
+├── llm.py # Model calls and streaming · 149 lines
+├── tools/
+│ ├── registry.py # Tool registration and execution checks · 54 lines
+│ └── code_tools.py # File and code tools
+├── plugins.py # Built-in tools and Shell plugin
+├── session.py # Session persistence and context compaction
+├── skills.py # Skills loading and configuration
+├── policy.py # Execution permissions and file access checks
+├── extensions/ # MCP integration
+└── cli.py # CLI entry point
+```
-CI covers Windows/Linux, Python 3.11/3.12, offline regression, native-runtime static checks, dependency audit, builds and installed-wheel verification without MCP/Legacy extras. Local HTTP fixtures exercise OpenAI, DeepSeek, DashScope/Qwen and Anthropic SDK multi-turn tool protocols. They do not establish live API compatibility.
+The core totals **531 lines**; all first-party package Python totals **5,056 lines**, including legacy compatibility code. Counts include comments and blank lines and exclude third-party dependencies. Run `python scripts/source_stats.py` to verify. [Counting script](scripts/source_stats.py)
-`python scripts/source_stats.py` reports the four-file core, runtime mechanisms including Policy/tool plugin/Session, and **all official Python source** separately. Teaching and extension compatibility code remains; the 2000–2800 total-line target is not achieved. No live model task screenshot or performance comparison is claimed; simulated output is not presented as a real demo.
+## Docs and contributing
-Use `miniagent --legacy` for the teaching CLI and install `miniagent[legacy]` for basic/system tools. The old implicit MCP API was removed; migrate to `mcp_plugin` as documented. Automatic dependency recovery, long-term Memory and Streamable HTTP are outside this alpha delivery.
+[Guide](docs/lean-harness.md) · [Model setup](docs/model-connections.md) · [Demo notes](docs/demo.md) · [Changelog](docs/CHANGELOG.md) · [Legacy migration](docs/legacy-migration.md)
-## Acknowledgments and license
+Issues, task examples and pull requests are welcome. Read [AGENTS.md](AGENTS.md) before contributing. Currently Alpha; Shell, plugins and MCP run on the host, and permission prompts do not provide sandbox isolation.
-Coding tools are inspired by [nanocode](https://github.com/1rgs/nanocode). Licensed under [Apache License 2.0](LICENSE).
+[Apache License 2.0](LICENSE)
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 5bb744e..4ff24b0 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+- [文档] 重写中英文 README,突出小核心、常用能力及使用/学习/定制三种用途;恢复 Windows 案例,加入已有终端回放与来源说明,按主线校正源码行数和公开能力,不改变运行时。
+
- [修复] Gemini 凭据别名统一解析并以规范账户保存,兼容读取旧复合账户;/models 与 /connect 共用密钥误填保护;显式 MINIAGENT_HOME 不再提前解析系统用户目录。
- [改进] 服务商菜单按名称、标识和编号逐行显示,减少重复长说明;首次配置错误保留脱敏后的可操作原因,复用现有 Rich 输出。
- [文档] AGENTS.md 固化核心简单、DSH 常用能力、易用美观与便于传播,PR 模板和轻量 CI 校验引用同一规则源,CLAUDE.md 以软链接复用。
diff --git a/docs/assets/coding-replay.gif b/docs/assets/coding-replay.gif
new file mode 100644
index 0000000..adaa692
Binary files /dev/null and b/docs/assets/coding-replay.gif differ
diff --git a/docs/assets/coding-session.json b/docs/assets/coding-session.json
new file mode 100644
index 0000000..8b9d8fa
--- /dev/null
+++ b/docs/assets/coding-session.json
@@ -0,0 +1,22 @@
+{
+ "captured_on": "2026-10-17",
+ "python": "3.12.10",
+ "platform": "Windows",
+ "base_revision": "64c1fcbcb0b3168168d969a74b6c85e5ec4fa429",
+ "runtime_file": "miniagent/cli_runtime.py",
+ "runtime_sha256": "e932d82ba79fc7bed5f9f9db7bc32b5acbd4fe763030bead0d8a916e532b0a67",
+ "model": "anspire:qwen3.5-flash",
+ "request_count": 4,
+ "total_tokens": 5068,
+ "tool_sequence": [
+ "read",
+ "edit",
+ "bash"
+ ],
+ "independent_test_passed": true,
+ "test_file_unchanged": true,
+ "test_file_sha256": "ecac6ee2c37366de5b12b4b9b487d89292643259514f22696f884cf0e7d93260",
+ "source_after": "def add(a, b):\n return a + b\n",
+ "recording": "Real CLI Rich Console output rendered as SVG and PNG; no backend substitution",
+ "scope": "Small isolated repair fixture; not a benchmark or native vendor acceptance"
+}
diff --git a/docs/assets/coding-session.png b/docs/assets/coding-session.png
new file mode 100644
index 0000000..6a30c1a
Binary files /dev/null and b/docs/assets/coding-session.png differ
diff --git a/docs/assets/coding-session.svg b/docs/assets/coding-session.svg
new file mode 100644
index 0000000..4a913c0
--- /dev/null
+++ b/docs/assets/coding-session.svg
@@ -0,0 +1,157 @@
+
diff --git a/docs/assets/coding-session.txt b/docs/assets/coding-session.txt
new file mode 100644
index 0000000..29b68c2
--- /dev/null
+++ b/docs/assets/coding-session.txt
@@ -0,0 +1,24 @@
+┌──────────────────────────────────────────────────────────────────────────────┐
+│ │
+│ MiniAgent / Python harness + agent │
+│ anspire:qwen3.5-flash · trusted │
+│ Workspace: demo-workspace · Session: 7e10faa2 │
+│ │
+└──────────────────────────────────────────────────────────────────────────────┘
+┌──────────────────────────────────── You ─────────────────────────────────────┐
+│ Read calculator.py. Fix add using the edit tool, then run python -m unittest │
+│ -v with bash. Do not modify test_calculator.py. Summarize the fix and test │
+│ result in two short lines. │
+└──────────────────────────────────────────────────────────────────────────────┘
+ usage: 1085 tokens
+ • read path='calculator.py'
+ done read · 0.00s
+ usage: 1241 tokens
+ • edit path='calculator.py' old=<12 chars> new=<12 chars>
+ done edit · 0.00s
+ usage: 1310 tokens
+ • bash cmd=<21 chars>
+ done bash · 0.11s
+ usage: 1432 tokens
+Fixed add() function by changing return a - b to return a + b. Test passed: 1
+test ran, OK.
diff --git a/docs/assets/miniagent-banner.svg b/docs/assets/miniagent-banner.svg
new file mode 100644
index 0000000..c0110dc
--- /dev/null
+++ b/docs/assets/miniagent-banner.svg
@@ -0,0 +1,20 @@
+
diff --git a/docs/demo.md b/docs/demo.md
new file mode 100644
index 0000000..01a8458
--- /dev/null
+++ b/docs/demo.md
@@ -0,0 +1,58 @@
+# MiniAgent 演示说明 / Demo notes
+
+## 终端任务回放
+
+首页动图来自 2026-10-17 的真实 CLI 任务记录:Windows、Python 3.12、MiniAgent 0.2.0a1。运行基于 main `64c1fcb`,加入展示分支的终端样式;该样式尚未进入主线。记录与素材保留于[原提交](https://github.com/ZhuLinsen/MiniAgent/tree/634b94ec8d9c55b8270807e8387f74ec3beb4de4)。
+
+Agent 读取有错误的 `calculator.py`,将加法函数中的减法修正,再执行原有单元测试。模型之外另跑一次测试确认通过,测试文件 SHA-256 保持不变。此次运行调用真实模型和工具,使用 Anspire 网关的 `qwen3.5-flash`,共 4 次请求、5,068 tokens。
+
+- [原始终端文本](assets/coding-session.txt)
+- [运行元数据](assets/coding-session.json)
+- [静态 PNG](assets/coding-session.png) / [SVG](assets/coding-session.svg)
+
+GIF 根据原始文本逐段绘制,保留提示、工具顺序和回答,压缩了播放间隔。这是一项小型函数修复演示,不是响应速度或复杂仓库任务的基准测试。
+
+The GIF replays a real CLI task recorded on the presentation branch, based on main `64c1fcb`. Its terminal styling is not yet part of main. Playback timing is condensed; the transcript, tool results and model answer are preserved. This is a small repair example, not a latency or coding benchmark.
+
+## 复现任务
+
+按 README 安装并连接模型,在新的工作目录创建下面两个文件。
+
+`calculator.py`:
+
+```python
+def add(a, b):
+ return a - b
+```
+
+`test_calculator.py`:
+
+```python
+import unittest
+from calculator import add
+
+class TestAdd(unittest.TestCase):
+ def test_add(self):
+ self.assertEqual(add(2, 3), 5)
+ self.assertEqual(add(-1, 2), 1)
+```
+
+在该目录运行 `python -m unittest -v`,确认测试失败。然后启动 `miniagent`,输入:
+
+> 读取 calculator.py,修复 add 函数并运行 python -m unittest -v。不要修改 test_calculator.py。说明修改内容和测试结果。
+
+按交互提示确认文件修改和命令执行。完成后独立运行同一条测试命令,并核对测试文件未被修改。实际模型输出可能不同。
+
+原录制使用的[任务准备脚本](https://github.com/ZhuLinsen/MiniAgent/blob/634b94ec8d9c55b8270807e8387f74ec3beb4de4/scripts/prepare_demo.py)、[终端录制脚本](https://github.com/ZhuLinsen/MiniAgent/blob/634b94ec8d9c55b8270807e8387f74ec3beb4de4/scripts/capture_terminal.py)和[回放渲染脚本](https://github.com/ZhuLinsen/MiniAgent/blob/634b94ec8d9c55b8270807e8387f74ec3beb4de4/scripts/render_terminal_replay.py)保留在对应提交。
+
+To repeat the task, create the two files above in a new directory, confirm that the tests fail, then ask MiniAgent to fix `add` without changing the test file. Approve the proposed edits and commands, rerun the tests independently, and verify that the test file is unchanged. Recording and rendering scripts are linked to their original revision.
+
+## Windows 案例
+
+首页的浏览器与 Word GIF 来自项目原版 Windows 实录。本次保留原图,未重新录制;它们不代表当前原生 CLI 的完整桌面回归结果。
+
+当前原生 CLI 可通过 Shell 调用 Python、本机程序或配置好的 MCP 工具。浏览器操作可以使用 Python 的 `webbrowser` 打开网页;进一步点击、读取页面或操作表单,需要相应的自动化脚本或 MCP 服务。
+
+生成 Word 文件可以安装 `python-docx`,再让 Agent 编写脚本生成 `.docx`。直接操作 Word 窗口则需要已安装的 Word、可交互桌面和相应自动化依赖。旧版工具入口见[迁移说明](legacy-migration.md)。
+
+These Windows GIFs are original-version recordings. The native CLI calls local Python/Shell programs or configured MCP tools; browser interaction and Word automation need their own software and dependencies. The recordings are not a fresh native-CLI desktop validation.