MANGOPI CLIv0.1.31
中文EN github ↗
ai coding agentAI 编码智能体 single file单文件 · zero deps零依赖

Terminal AI,
just code.

A single-file Python agent for the terminal. Three-tier model routing, a thinking-framework proxy, multimodal + web search. All in stdlib. Just code. 单文件 Python 终端智能体。三档模型路由、思考框架代理、多模态 + Web Search。纯标准库实现。只管写代码。

~/projects/api-server/ mangopi-cli · terminal
$mangopi-cli
Mango Cli v0.1.29 | smart-routing[3] | ~/projects/api-server
→ high: deepseek-v4-reasoning
 
help me refactor utils.py to use dataclasses帮我把 utils.py 重构为 dataclass
· Tool call
› read src/utils.py
› grep pool_size src/
✓ Identified 3 class definitions
· Tool call
› edit src/utils.py -3 +8
-class User:
+@dataclass
+class User:
✓ Applied successfully
 
round: 2 | tokens: 1.2k in / 0.8k out | ctx: 5% | task done
— 01

At a glance概览

0
dependencies依赖
12
built-in tools内置工具
3
routing tiers路由档位
8
thinking frameworks思考框架
providers (openai-compat)模型接入
— 02

Loop Engineering.循环工程

A 3-agent collaborative pipeline that implements, verifies, and self-corrects — replacing the legacy flat goal-state machine with a CI/CD-like loop. 三代理协作流水线,集实施、验证与自我纠偏于一体——用类 CI/CD 循环取代了旧版扁平目标状态机。

— 01

Implementer实施者

Designs & writes code. Explicitly forbidden from running tests — "that's the Verifier's job."设计并编写代码,明确禁止自我测试——"那是 Verifier 的事"。

— 02

Verifier验证者

Inspects changed files, runs actual test commands, judges PASS/FAIL at the architecture level.检查改动文件,执行实际测试命令,在架构层面判定 PASS/FAIL。

— 03

Updater修正者

On failure, analyzes the Verifier's report and produces a refined prompt (50–200 words) for the next iteration.失败时分析 Verifier 报告,生成 refined prompt(50–200 词)注入下一轮。

— 04

Auto-cleanup自动清理

Session files under .mangocli/loops/ are discarded after the loop — no state leaks..mangocli/loops/ 下的会话文件在循环退出后自动清理,无状态泄露。

One command to iterate一条命令启动迭代

Start with /loop followed by your goal. The pipeline runs up to 5 iterations, short-circuiting on the first VERIFY: PASS. 输入 /loop 加目标描述即可启动。流水线最多运行 5 轮迭代,首次 VERIFY: PASS 即提前结束。

 /loop "refactor utils.py to use dataclasses"
# Implementer → Verifier → (Updater → Implementer)* → PASS
— 03

Smart Provider Routing.智能模型路由

Three tiers, auto-selected per turn. Cheap models handle reads; the heavyweight only shows up when the task is genuinely complex. No mid-loop switching. 三档模型,按回合自动选择。轻量模型负责读取;只有真正复杂的任务才调用重模型。中间不切换。

tier / low
flash

Read / search / list. The default for trivial tasks.读取 / 搜索 / 列表。轻量任务的默认档。

tier / medium
standard

Edit / fix / multi-file. Most turns land here.编辑 / 修复 / 多文件。多数回合在此档。

tier / high
reasoning

Design / refactor / complex debug. Triggered by LLM scoring.设计 / 重构 / 复杂调试。由 LLM 打分触发。

Configure in .mangocli/providers.json.mangocli/providers.json 配置

Each provider declares a tier (low / medium / high) and routing. Thresholds are tunable. Startup shows the model count; each turn prints the model that was picked. 每个 provider 声明档位(low / medium /high)和阈值。启动时显示模型数量,每回合打印所选模型。

"providers": [
  {"name": "low",    "model": "deepseek-v4-flash",    "tier": "low"},
  {"name": "medium", "model": "deepseek-v4",          "tier": "medium"},
  {"name": "high",   "model": "deepseek-v4-reasoning", "tier": "high"}
]
— 04

Flash-ext Proxy.Flash-ext 代理

An intelligent model enhancement layer — wraps itself as an OpenAI-compatible API exposing a "model endpoint," then enhances the upstream model through thinking guidance + information augmentation. 智能模型增强层——将自己包装成 OpenAI 兼容的 API 服务,对外暴露"模型接口",再通过思考引导 + 信息辅助增强底层模型。

— 01

Two-path routing双路径路由

Fast path (0ms, keyword match) or deep path (~300ms, Flash-ext's own LLM analyzes session state).快速路径(0ms,关键词匹配)或深思路径(~300ms,Flash-ext 自己的 LLM 分析会话状态)。

— 02

Eight frameworks八个框架

debug / design / explain / optimize / implement / investigate / verify / reevaluate. Auto-selected by phase + tool pattern.debug / design / explain / optimize / implement / investigate / verify / reevaluate。由阶段和工具模式自动选择。

— 03

Loop detection循环检测

Catches same-tool and alternating failure loops. Triggers the reevaluate framework before the agent burns through context.检测同工具连续失败与交替失败模式。在 agent 烧光上下文前触发 reevaluate 框架。

— 04

Cognitive only仅增强认知

Never touches file I/O or bash. Only enhances the model's reasoning before the request reaches upstream.不触碰文件 I/O 或 shell。仅在请求到达上游前增强模型推理。

Run the server启动服务

Point any OpenAI-compatible client at http://127.0.0.1:8080/v1/chat/completions. Optionally enable memory and web search. 将任意 OpenAI 兼容客户端指向 http://127.0.0.1:8080/v1/chat/completions。可选择性启用记忆和搜索。

$ python mangopi_cli.py --flash-ext --debug
# Optional
$ python mangopi_cli.py --flash-ext --memory --web-search
— 05

All features.全部特性

— 01

Zero Dependencies零依赖

Pure Python stdlib — urllib, json, subprocess. No pip install. Single .py file.纯 Python 标准库 — urllib, json, subprocess。无需 pip 安装,单个 .py 文件。

— 02

Agentic LoopAgentic 循环

Autonomous tool-calling loop: read → think → edit → verify. Multi-step reasoning, no manual intervention.自主工具调用循环:读取→思考→编辑→验证。多步推理无需人工干预。

— 03

Smart Context智能上下文

Three-tier compact: micro (expire stale tool results), session-memory, fallback (strip + trim). Auto at 80%.三级压缩:micro(过期工具结果)、session-memory、fallback(剥离+裁剪)。80% 自动触发。

— 04

Multimodal多模态

Drop a screenshot into the conversation. read auto-routes png/jpg/gif/webp to the model's vision.将截图拖入对话。read 自动将 png/jpg/gif/webp 路由至模型视觉。

— 05

Web SearchWeb 搜索

web_search tool queries the live web via Bocha AI Search when the model needs fresh docs.web_search 工具通过 Bocha AI Search 查询实时网络。

— 06

Session Persist会话持久化

JSON in .mangocli/session/. Auto-backup on corruption. Resume anywhere.会话保存在 .mangocli/session/。损坏自动备份。断点续聊。

— 07

Safety Checks安全检查

rm -rf / sudo / chmod 777 detection. User confirmation before destructive commands. Path sandbox.检测 rm -rf / sudo / chmod 777。危险命令执行前需用户确认。路径沙盒。

— 08

Skill System技能系统

Reusable workflow bundles via SKILL.md. Install in ~/.mangocli/skills/, invoke via use_skill.通过 SKILL.md 复用工作流。安装至 ~/.mangocli/skills/,通过 use_skill 调用。

— 06

Ideal for.适用人群

— 01

Terminal-first devs终端流开发者

Prefer the shell over GUI tools.比起 GUI 工具更爱 shell。

— 02

Framework skeptics重型框架厌恶者

Dislike heavy AI frameworks and dependency trees.不喜欢臃肿的 AI 框架与依赖树。

— 03

Hackers & tinkerers黑客与折腾者

Want to peek under the hood and customize everything.想掀开引擎盖、一切都自己改。

— 04

Local-first enthusiasts本地优先主义者

Want code & data to stay on their machine.希望代码与数据留在本机。

— 05

Custom agent builders智能体构建者

Build bespoke agents on a clean, auditable base.在干净基座上构建定制智能体。

— 06

Multi-model teams多模型团队

Mix cheap + strong models per task to control API cost.按任务混用轻量与重型模型,控制 API 成本。

— 07

Design philosophy.设计哲学

Seeking a perfect balance between code size, complexity, and the functionality & effectiveness of the agent. 在代码体积、复杂度和智能体功能与效能之间,追求完美的平衡
  • Easier to audit易于审计
  • Easier to hack易于魔改
  • Easier to fork易于分叉
  • Easier to understand易于理解
  • Easier to run locally易于本地运行
— 08

Any provider.任意模型接入

DeepSeek
— DEFAULT

Auto-detected. Enables thinking/reasoning via extra_body.自动检测,通过 extra_body 启用 reasoning。

OpenAI

Full OpenAI-compatible. Any /v1/chat/completions endpoint.完整兼容 OpenAI,任意 /v1/chat/completions 端点。

MiniMax

Detected by model name. Exposes reasoning_split.通过模型名检测,暴露 reasoning_split。

+ Any Compat+ 任意兼容

Qwen, Moonshot, kimi, glm — anything that speaks OpenAI protocol.Qwen、Moonshot、kimi、glm — 任何兼容 OpenAI 协议的接口。

— 09

12 tools.12 个工具

read

File or image (png/jpg/gif/webp auto-routes to vision)文件或图片(png/jpg/gif/webp 自动路由至视觉)

write

Write or overwrite写入或覆写

edit

Exact string replace + diff精确字符串替换 + diff

search

Glob patterns, sorted by mtimeGlob 模式,按修改时间排序

grep

Recursive regex content search递归正则内容搜索

bash

Shell exec (60s timeout)Shell 执行(60s 超时)

view_image

Load local image into vision context加载本地图片至视觉上下文

web_search

Bocha AI Search live webBocha AI 实时搜索

use_skill

Load installed SKILL.md加载已安装技能

search_memory

Multi-keyword markdown search多关键词 markdown 搜索

append_memory

Append long-term memory追加长期记忆

attempt_completion

Task completion signal任务完成信号

/q

Quit退出

/n

New session新会话

/c

Compact手动压缩

/l <goal>

Loop engineering (replaces /goal)循环工程(替代 /goal)

/h

Help帮助

— 10

Install.安装

— PyPI

pip install

Recommended. Requires Python 3.10+.推荐方式。需 Python 3.10+。

$ pip install mangopi-cli
$ mangopi-cli
— SOURCE

git clone

Clone and run. Zero setup.克隆即运行,零配置。

$ git clone git@github.com:w4n9H/mangopi-cli.git
$ cd mangopi-cli
$ python mangopi_cli.py
— 11

Config.配置

MANGO_KEY API keyAPI 密钥
MANGO_API_URL Endpoint端点 deepseek
MANGO_MODEL Model name模型名 v4-flash
MANGO_ROUTING Enable smart routing启用智能路由 off
MANGO_MAX_CONTEXT Max tokens最大 token 1M
MANGO_LANG UI language界面语言 en
$ export MANGO_KEY="your-key"
$ export MANGO_API_URL="https://api.deepseek.com"
$ export MANGO_MODEL="deepseek-v4-flash"

# smart routing
$ export MANGO_ROUTING="on"