diff --git a/README.md b/README.md index 79a647d..b1801df 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,113 @@ -# MiniAgent +

+ MiniAgent +

-**小内核,实用 Agent。** 一个以插件为核心的 Python Agent Harness,组合模型、工具、Skills、MCP 和可恢复会话。 +

🚀 五分钟上手 Harness / Agent,打造自己的命令行 Manus。

-[English](README_EN.md) · [运行与迁移指南](docs/lean-harness.md) · [变更记录](docs/CHANGELOG.md) · [CI](https://github.com/ZhuLinsen/MiniAgent/actions/workflows/ci.yml) +

+ CI + Python 3.11+ + Apache 2.0 + Alpha +

-需要 **Python 3.11+**。当前版本为 **0.2.0a1**:适合评估新架构和开发插件;已通过两款模型的 Anspire 网关验收,原厂多 Provider 验收及总体源码精简仍未完成。详见[验收证据](docs/acceptance-2026-10-11.md)。 +

English · 核心特性 · 快速开始 · Python API · 演示 · 项目结构

-## 三步开始 +MiniAgent 是一个**超轻量、常用功能齐备的 Python Agent / Harness**,核心仅 **531 行代码**。支持工具调用、会话记忆、上下文管理与插件扩展等主流 Agent 常用能力,**可以直接使用,也适合快速入门学习、定制修改和二次开发。** -```bash -git clone https://github.com/ZhuLinsen/MiniAgent.git -cd MiniAgent -python -m pip install . -``` - -在项目内创建 `.env`,填入自己的 Provider 密钥和模型 ID。下面的 `` 必须替换;Qwen 使用 `dashscope:` 和 `DASHSCOPE_API_KEY`,Claude 使用 `anthropic:` 和 `ANTHROPIC_API_KEY`。 +## 核心特性 -也可以直接运行 `miniagent --connect` 交互配置;首次交互启动缺少模型或凭据时会自动引导。REPL 的 `/connect` 配置服务商,`/models` 选择模型;详见[连接与凭据说明](docs/model-connections.md)。 +- 🧠 **功能齐备**:原生工具调用、流式输出、会话记忆、上下文压缩、Skills、MCP、插件管理与权限控制,组成可运行的 Agent / Harness。 +- 🚀 **直接使用**:连接模型后即可通过 CLI 执行编程与自动化任务,也能通过 Python API 嵌入现有项目。 +- 📖 **快速入门**:核心仅 **531 行、4 个文件**,从模型调用、工具执行到插件管理,适合通过阅读和运行源码理解 Agent / Harness 的工作原理。 +- 🧩 **定制开发**:修改提示词与 Skills,通过 Plugin 接入自己的工具和服务;复用已有的会话与权限机制,开发自己的 Agent。 -必须显式选择模型;非交互调用只设置密钥或 API 地址时,CLI 会在创建客户端前提示缺少模型。优先级为 `--model`、JSON 中的 `llm.model`、`LLM_MODEL`、已保存的连接默认值。 +## 快速开始 -```dotenv -DEEPSEEK_API_KEY=your-provider-key -LLM_MODEL=deepseek: -``` +需要 Python 3.11+,建议在虚拟环境中安装。 ```bash -miniagent --policy readonly --prompt "检查当前项目结构,说明主要入口" +git clone https://github.com/ZhuLinsen/MiniAgent.git +cd MiniAgent +python -m pip install -e ".[credentials]" miniagent ``` -默认需要确认文件修改、Shell 和 MCP 调用;非交互模式拒绝确认。`--policy trusted` 适用于你明确信任的自动化任务。托管文件工具默认隐藏 `.env*`(`.env.example` 除外)、`.git` 和私钥文件,只有显式使用 `--allow-sensitive-files` 才开放。Shell、Python 插件和 MCP 服务属于可信代码,不受文件工具边界隔离。 +第一次启动时,按提示连接模型,然后直接输入任务。默认在修改文件和执行 Shell 前询问是否允许。 -## 核心能力 +也可以从命令行传入任务: + +```bash +miniagent --policy readonly --prompt "看看这个项目是做什么的,主要代码和测试在哪里" +``` -- 原生工具调用和流式文本;统一异步模型边界及 Provider 密钥隔离。 -- 实例独立的工具注册表;插件依赖排序、失败回滚和逆序资源清理。 -- `read / write / edit / grep / glob / bash` 编程工具,支持工作区约束和授权。 -- JSONL 会话、完整工具组的上下文压缩,以及异常副作用的人工核查恢复。 -- 可切换的 Skill 执行白名单;官方 MCP SDK stdio 接入(可选安装)。 +`/help` 查看命令,`/models` 切换模型,`/skills reviewer` 切换到代码审查角色,`/session` 查看会话。[模型配置](docs/model-connections.md) -CLI 可用 `/help`、`/connect`、`/models`、`/model`、`/plugins`、`/skills`、`/session`、`/stream`;`/plugins` 当前仅列出已加载插件。`--session ` 恢复已有会话,`/session new` 新建会话。模型切换会新建会话。 +## 作为 Python 调用 -## Python API +在程序里创建一个 Agent,挂上工具,然后交给它任务: ```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("检查项目结构")) +print(app.run("看看项目的目录结构,说明主要入口")) ``` -已有事件循环中使用 `await app.arun(...)`,并通过 `async with app` 管理资源。一个 Harness 同时只运行一个任务;插件和 Skill 仅在空闲时修改。 +将 `provider:model-id` 换成自己的模型,并配置对应凭据。异步调用使用 `async with app` 和 `await app.arun(...)`。 -## 一个自定义插件 +Harness 负责模型与工具之间的循环、插件启动和清理,以及会话管理。自己的工具、共享服务和事件监听都通过 `Plugin` 接入。[插件与完整示例 →](docs/lean-harness.md) -```python -from miniagent import Harness, Plugin -from miniagent.policy import Policy -from miniagent.tools.registry import Tool +## 演示 -def calculator(ctx): - ctx.tool(Tool("add_one", "Add one", {"type": "object", - "properties": {"n": {"type": "integer"}}, "required": ["n"]}, - lambda n: n + 1)) +**修改代码,运行测试** · 修复 calculator.py 的加法函数,不改测试文件。 -app = Harness(model="deepseek:", policy=Policy(mode="trusted")) -app.use(Plugin("calculator", calculator)) -print(app.run("调用 add_one 给 2 加 1")) -``` +![MiniAgent 读取文件、修复函数并运行测试的终端回放](docs/assets/coding-replay.gif) + +由真实 CLI 记录生成,压缩了播放间隔;终端样式来自展示分支。[静态图](docs/assets/coding-session.png) · [完整记录与复现](docs/demo.md) -这是显式信任自定义工具的示例。更多模型配置、MCP 安装与插件示例、Skill 切换、恢复步骤和兼容边界见 [运行指南](docs/lean-harness.md)。 +### Windows 自动化 -## 验证与版本边界 + + + + + + + +
打开浏览器并搜索生成 Word 文档
打开浏览器,搜索 MiniAgent 的 GitHub 仓库。写一篇 AI Agent 介绍,保存为 Word 文档并排版。
Windows 浏览器搜索演示Windows Word 文档演示
+ +这两段保留项目原版录屏,点击可看大图。当前版本通过 Shell / Python 或 MCP 完成本机自动化,见 [Windows 案例与环境准备](docs/demo.md#windows-案例)。 + +## 项目结构 + +核心集中在 [agent.py](miniagent/agent.py)、[harness.py](miniagent/harness.py)、[llm.py](miniagent/llm.py) 和 [tools/registry.py](miniagent/tools/registry.py),会话、Skills 与 MCP 各自独立。 + +```text +miniagent/ +├── agent.py # Agent 循环 · 72 行 +├── harness.py # 插件、服务与生命周期 · 256 行 +├── llm.py # 模型调用与流式输出 · 149 行 +├── tools/ +│ ├── registry.py # 工具注册与执行检查 · 54 行 +│ └── code_tools.py # 文件与代码工具 +├── plugins.py # 内置工具与 Shell 插件 +├── session.py # 会话持久化与上下文压缩 +├── skills.py # Skills 加载与配置 +├── policy.py # 执行权限与文件访问检查 +├── extensions/ # MCP 接入 +└── cli.py # 命令行入口 +``` -CI 覆盖 Windows/Linux、Python 3.11/3.12、离线回归、原生运行时静态检查、依赖审计、构建,以及不安装 MCP/Legacy 扩展的 wheel 验证。OpenAI、DeepSeek、DashScope/Qwen、Anthropic 的 SDK 多轮工具协议使用本地 HTTP 测试;它们不代表真实 API 验收。 +四文件核心 **531 行**;全部官方包 Python **5,056 行**(含旧版兼容代码)。行数包含注释和空行,不含第三方依赖。运行 `python scripts/source_stats.py` 可复核。[统计脚本](scripts/source_stats.py) -`python scripts/source_stats.py` 分别报告四文件内核、含 Policy/工具插件/Session 的运行机制、以及**全部官方 Python 源码**。旧教学与扩展兼容代码仍保留,总体 2000~2800 行目标尚未达到。未提供真实模型任务截图或性能对比,不以模拟输出替代真实演示。 +## 文档与贡献 -旧教学 CLI 使用 `miniagent --legacy`;基础/系统工具需安装 `miniagent[legacy]`。旧隐式 MCP API 已移除,按指南迁移到 `mcp_plugin`。动态依赖恢复、长期 Memory 和 Streamable HTTP 不属于本次 alpha 交付。 +[使用指南](docs/lean-harness.md) · [模型配置](docs/model-connections.md) · [演示说明](docs/demo.md) · [更新记录](docs/CHANGELOG.md) · [旧版迁移](docs/legacy-migration.md) -## 致谢与许可证 +欢迎提交问题、使用案例和 PR。开发前请阅读 [AGENTS.md](AGENTS.md)。当前为 Alpha 版本;Shell、插件和 MCP 在本机执行,权限确认不等于沙箱隔离。 -编程工具设计参考 [nanocode](https://github.com/1rgs/nanocode)。本项目使用 [Apache License 2.0](LICENSE)。 +[Apache License 2.0](LICENSE) diff --git a/README_EN.md b/README_EN.md index 15ba756..4f8901d 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,90 +1,113 @@ -# MiniAgent +

+ MiniAgent +

-**Tiny Core. Real Agent Capabilities.** A plugin-first Python Agent Harness that combines models, tools, Skills, MCP and resumable sessions. +

🚀 Get started with Harness / Agent in five minutes and build your own command-line Manus.

-[中文](README.md) · [Runtime and migration guide](docs/lean-harness.md) · [Changelog](docs/CHANGELOG.md) · [CI](https://github.com/ZhuLinsen/MiniAgent/actions/workflows/ci.yml) +

+ CI + Python 3.11+ + Apache 2.0 + Alpha +

-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). +

中文 · Key features · Quick start · Python API · Demos · Project structure

-## 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")) -``` +![Terminal replay of MiniAgent reading files, fixing a function and running tests](docs/assets/coding-replay.gif) + +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 searchCreate 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.
Windows browser search demoWindows Word document demo
+ +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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MiniAgent · actual CLI output + + + + + + + + + + ┌──────────────────────────────────────────────────────────────────────────────┐ +││ +│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/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 @@ + + MiniAgent — Python native harness + agent + An amber and coral terminal mark and MiniAgent wordmark on a dark terminal card. Original editable artwork, inspired by the author's AlphaEvo identity. + + + + + + + + + + MiniAgent + MiniAgent + MiniAgent + + + PYTHON NATIVE · HARNESS + AGENT + + 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.