diff --git a/.env.example b/.env.example index 074a9d2..a432048 100644 --- a/.env.example +++ b/.env.example @@ -45,6 +45,14 @@ ANTHROPIC_MODEL=claude-sonnet-4-20250514 MINI_CODE_LOG_LEVEL=WARNING # Options: DEBUG, INFO, WARNING, ERROR +# --- Command output encoding --- +# Encoding used to decode run_command output. Defaults to utf-8. +# On Chinese Windows, set to cp936 (or gbk) so legacy commands that output in +# the OEM code page (dir, systeminfo, batch scripts printing CJK) decode +# correctly instead of mojibake. Pick whichever matches the majority of your +# commands; a single value can't cover mixed utf-8 + cp936 output perfectly. +# MINI_CODE_COMMAND_ENCODING=cp936 + # --- Workspace (for Docker) --- MINI_CODE_WORKSPACE=. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9c3964..154c772 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,4 +39,4 @@ jobs: run: python -m pytest tests/test_packaging.py -q - name: Run test suite - run: python -m pytest -q + run: python -m pytest -q --tb=short diff --git a/.gitignore b/.gitignore index 16a5d65..4a25b14 100644 --- a/.gitignore +++ b/.gitignore @@ -46,10 +46,37 @@ Thumbs.db # Logs *.log +# Local secrets and provider credentials +.env +.env.* +!.env.example +paper_experiments/*.env +paper_experiments/*.env.local +paper_experiments/.secrets/ +!paper_experiments/env.local.example +paper_experiments/results/relative_event_target_pairs_cache.json + # Temporary files *.tmp *.bak +*.orig +*.swp +tmp_*.json +tmp_*.py +tmp_*.log + +# Local tool/runtime state +.claude/settings.local.json +.omx/ +.playwright-mcp/ +.mini-code-memory/*.json # MiniCode specific .mini-code/ minicode_session/ + +# Local caches / runtime tool state / dead backups (never commit) +.qwen/ +__pycache__/ +*.git.bak/ +.dead-modules-backup/ diff --git a/.qwen/settings.json b/.qwen/settings.json deleted file mode 100644 index ee25b53..0000000 --- a/.qwen/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "permissions": { - "allow": [ - "WebSearch" - ] - }, - "$version": 3 -} \ No newline at end of file diff --git a/.qwen/settings.json.orig b/.qwen/settings.json.orig deleted file mode 100644 index df5dcfe..0000000 --- a/.qwen/settings.json.orig +++ /dev/null @@ -1,7 +0,0 @@ -{ - "permissions": { - "allow": [ - "WebSearch" - ] - } -} \ No newline at end of file diff --git a/README.md b/README.md index a631c78..6071b6a 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,24 @@
-
+
-
+
- Memory / Session / Rewind / Readiness: the runtime is part of the product. + Real MiniCode frontend demo, not a mock: the landing page now reflects the current Python runtime and shows memory, session, rewind, and readiness as first-class product surfaces.
MiniCode Python is the Python runtime in the MiniCode family. It is built for local development where the agent needs to survive long sessions, keep its state inspectable, recover from bad edits, and show what it is doing while it works. If Claude Code represents the polished terminal-agent experience, MiniCode Python is the lightweight, local-first version that leans harder into runtime transparency, durable sessions, memory-backed continuity, rewindability, and verifiable behavior. +The screenshot above is rendered from the real MiniCode frontend demo. It highlights the four product promises we care about most on day one: memory that keeps context alive, sessions you can inspect and replay, rewind flows that make local edits safer, and readiness checks that tell you whether the runtime is actually ready to work. + ## At a Glance MiniCode Python is for you if you want: @@ -179,7 +181,7 @@ Current local verification result: Verification command: ```bash -python -m compileall -q minicode py-src\minicode tests +python -m compileall -q minicode tests pytest -q ``` @@ -229,7 +231,6 @@ What matters is not the diagram itself. What matters is that runtime state is tr | `docs/` | Architecture notes, optimization history, and productization reports. | | `openspec/` | Specs, archived change records, and build/verify planning artifacts. | | `.mini-code-memory/` | Workspace-level durable memory state created by the runtime. | -| `py-src/minicode/` | Compatibility and migration mirror. | ## Core Modules diff --git a/README.zh-CN.md b/README.zh-CN.md index 04c4cf2..8504f66 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,7 @@ # MiniCode Python- 一个面向本地开发的轻量级编码 Agent:不只是聊天壳子,而是可恢复、可回放、可检查的终端工作流。 + 一个面向本地开发的轻量级 coding agent:不只是聊天壳子,而是可恢复、可回放、可检查的终端工作流。
@@ -14,84 +14,86 @@
-
+
-
+
- Memory / Session / Rewind / Readiness:runtime 本身就是产品体验的一部分。 + 这不是示意图,而是真实的 MiniCode 前端 Demo:首页直接把 memory、session、rewind 和 readiness 作为一等产品能力展示出来。
-MiniCode Python 是 MiniCode 家族里的 Python 实现。它面向真实本地仓库中的长期开发流程:Agent 不只要会调模型和工具,还要能保存会话、回看轨迹、回退错误编辑,并且把自己为什么继续、为什么验证、为什么停止说清楚。 +MiniCode Python 是 MiniCode 家族里的 Python 运行时。它面向真实的本地开发场景:agent 不只是能调模型和工具,还要能跨长会话保留状态、回看历史、撤销错误编辑,并把自己的运行状态说清楚。 -如果要一句话概括,它更像一个“轻量级、本地优先、强调记忆连续性、可恢复性和可解释性”的 Claude Code 风格终端 Agent,而不是一个单纯的聊天式代码助手。 +如果把 Claude Code 看成成熟的终端 agent 产品体验,那么 MiniCode Python 更像它的轻量级、本地优先版本:更强调运行时透明性、可持续会话、记忆连续性、可回退编辑,以及可验证行为。 -## 一眼看懂 +上面的截图来自真实的 MiniCode 前端 Demo。它想表达的是我们最看重的四件事:memory 让上下文不断线,session 可以 inspect 和 replay,rewind 让本地编辑更安全,readiness 能告诉你运行时是不是真的 ready。 -如果你想要的是下面这些体验,那这个仓库就是给你的: +## At a Glance -- 一个像运行时系统而不是聊天窗口的终端编码 Agent; -- 可以 inspect、replay、resume、做摘要的持久会话; -- 一套能保护工作上下文、也能回注项目知识的记忆系统; -- 带 checkpoint、rewind preview、恢复路径的安全本地编辑; -- 对 verification、widening、provider readiness、失败原因都有显式信号。 +如果你想要的是下面这些体验,这个仓库就是给你的: + +- 一个更像运行时而不是聊天窗口的终端 coding agent; +- 可 inspect、可 replay、可 resume、可总结的持久会话; +- 能保护工作上下文、并在需要时回注项目知识的记忆系统; +- 带 checkpoint、rewind preview 和恢复路径的安全本地编辑; +- 对 verification、widening、provider readiness 和失败原因都有显式信号。 如果只记住一句话,可以记这个: -> MiniCode Python 的目标是本地可信度:你应该能看清它做了什么、把改动撤回来,也能理解它为什么停在这里。 +> MiniCode Python 的核心目标是本地可信度:你应该能看清它做了什么、把改动撤回来,也能理解它为什么停在这里。 -## 为什么这个仓库存在 +## Why This Repo Exists -很多 Coding Agent 的 README 会先讲模型、演示和功能列表。MiniCode Python 想解决的是另一类问题: +很多 coding-agent README 会先讲模型接入和功能清单。MiniCode Python 想解决的是另一类问题: -> 一个编码 Agent 不应该只是“会调用工具”,还应该是可观察、可恢复、可验证的运行时系统。 +> 运行时应该是可观察、可恢复、可测试的,而不只是“聪明”。 -这会直接改变产品重点: +这会直接改变产品优先级: -| 优先级 | 在这个仓库里意味着什么 | +| 优先级 | 在这个仓库里的含义 | | --- | --- | -| Session-first | 会话可以 inspect、replay、resume,也可以做摘要。 | -| Recovery-first | 文件编辑是可 checkpoint、可预演、可 rewind 的。 | -| Runtime-first | widening、verification、compaction、stop reason 都是显式的。 | -| Local-first | 整套体验围绕真实本地仓库、本地工具和终端工作流构建。 | +| Session-first | 会话可以 inspect、replay、resume 和 summary。 | +| Recovery-first | 文件编辑默认带 checkpoint、可 preview、可 rewind。 | +| Runtime-first | widening、verification、compaction 和 stop reason 都是显式的。 | +| Local-first | agent 围绕真实仓库、本地工具和终端工作流构建。 | -## 为什么用 MiniCode Python +## Why MiniCode Python -| 方向 | MiniCode Python 的重点 | +| 维度 | MiniCode Python 的侧重点 | | --- | --- | -| 持久会话 | 可以 inspect、replay、resume、为当前或历史 session 做摘要,而不是只看一段聊天记录。 | -| 记忆是一等公民 | 保护当前任务上下文、在需要时回注项目知识、在 compaction 时保留关键信息,并把有价值的反思长期保存下来。 | -| 安全恢复 | 自动 checkpoint、rewind preview、rewind safety group、saved-session rewind。 | -| 运行时控制 | `single`、`single-deep`、phase-aware 执行、widening、verification gate、结构化 stop reason。 | -| 可观测性 | runtime timeline、readiness report、provider 诊断、transcript summary、benchmark artifact。 | -| 本地产品面 | CLI 和 TUI 里有 `/session`、`/session-replay`、`/memory`、`/checkpoints`、`/rewind`、`/readiness` 这些真实可用入口。 | -| 可验证实现 | 根包上有活跃测试集支撑,不是“文档里写了以后会有”。 | +| Durable sessions | 可以用本地命令 inspect、replay、resume 和 summary 当前或已保存会话。 | +| Memory as a first-class system | 保护活跃任务上下文、回注项目知识、在压缩时保持记忆感知、并持续沉淀有价值反思。 | +| Safe recovery | 自动 checkpoint、rewind preview、rewind safety group,以及 saved-session rewind。 | +| Runtime control | `single` / `single-deep` profile、phase-aware 执行、widening、verification gate 和结构化 stop reason。 | +| Observable behavior | runtime timeline、readiness report、provider 诊断、transcript summary 和 benchmark artifact。 | +| Local product surface | CLI/TUI 命令已经包括 `/session`、`/session-replay`、`/memory`、`/checkpoints`、`/rewind`、`/readiness`。 | +| Verifiable implementation | 根包由活跃测试套件兜底,不是“文档先行”的空壳。 | -## 现在已经能做什么 +## What You Can Do Today -按当前仓库状态,你已经可以: +以当前仓库状态,你已经可以: -- 用 `minicode-py` 跑交互式终端 Agent; +- 用 `minicode-py` 跑交互式终端 agent; - 用 `minicode-headless` 跑单次命令; -- 用 `/session` 查看当前 live session; -- 用 `/sessions` 浏览当前 workspace 的历史会话; -- 用 `/session-replay` 回放当前或已保存会话; -- 用 `/memory` 查看当前 workspace 的记忆系统状态; +- 用 `/session` 查看当前会话快照; +- 用 `/sessions` 浏览当前工作区历史会话; +- 用 `/session-replay` 回放会话; +- 用 `/memory` 查看记忆层状态; - 用 `/checkpoints` 查看 checkpoint 历史; - 用 `/rewind-preview` 和 `/rewind` 预演或执行回退; -- 用 `/readiness` 查看 provider、fallback 和产品面 readiness。 +- 用 `/readiness` 检查 provider 和 fallback 是否就绪。 -## 3 分钟上手 +## 3-Minute Demo ### 0. 你需要什么 - Python 3.11+ -- 一个本地终端环境(Windows、macOS、Linux 都可以) -- 如果要真实调模型,需要准备 provider/model 凭据 +- Windows、macOS 或 Linux 上的本地终端 +- 如果要真实跑模型,需要可用的 provider/model 凭据 ### 1. 安装并启动 @@ -102,15 +104,15 @@ python -m pip install -e .[dev] minicode-py ``` -### 2. 先让它在仓库里干一件真实的事 +### 2. 让它做一个真实仓库任务 ```text Explain this repository and tell me which commands matter most for day-to-day use. ``` -正常情况下,这一步就会进入它的真实工作循环:看仓库、整理结论、给出下一步,并留下可以继续 inspect、replay、继续执行的 session。 +这里你应该看到标准的 MiniCode 工作流:先读仓库、解释发现,再让你 inspect、replay 或继续会话。 -### 3. 立刻检查运行时状态 +### 3. 检查运行时在做什么 ```text /session @@ -118,7 +120,7 @@ Explain this repository and tell me which commands matter most for day-to-day us /readiness ``` -### 4. 如果要回看或恢复 +### 4. 需要时回放或恢复 ```text /session-replay @@ -126,51 +128,51 @@ Explain this repository and tell me which commands matter most for day-to-day us /rewind-preview ``` -### 5. 需要单次无界面调用时 +### 5. 跑一次 headless 单轮模式 ```bash minicode-headless "Explain what this repo does." ``` -## 典型工作流 +## Typical Workflow ```mermaid flowchart LR - Start["开始本地任务"] --> Run["运行 minicode-py"] + Start["开始一个本地任务"] --> Run["运行 minicode-py"] Run --> Work["Agent 读取、编辑、测试并汇报"] Work --> Inspect["用 /session、/memory 或 /readiness 检查状态"] - Inspect --> Replay["用 /session-replay 回放轨迹"] - Inspect --> Recover["如果改坏了,用 /rewind 预演或恢复"] - Replay --> Continue["继续下一轮任务"] + Inspect --> Replay["用 /session-replay 回放"] + Inspect --> Recover["如果编辑出错,用 /rewind 预演或恢复"] + Replay --> Continue["继续下一轮工作"] Recover --> Continue ``` -真正重要的点很简单:MiniCode Python 不是想把运行时藏起来,而是让你能看到它、理解它、在它出错时把现场收回来。 +核心点很简单:MiniCode Python 不想把运行时藏起来。它让你看见工作过程、检查状态,并在出错时直接恢复,而不是自己手工善后。 -这个思路同样适用于记忆系统:正在进行的任务上下文会被保护,持久化的项目知识可以在需要时回注,compaction 不是盲目丢弃,而是可以借助 memory 重用有用信息。 +这套思路同样适用于 memory:活跃任务上下文会被保护,耐久项目知识会在需要时回注,compaction 也可以利用记忆而不是盲目丢上下文。 -## 日常最重要的命令 +## Everyday Commands -如果你第一次用,先记住这 6 个:`/session`、`/sessions`、`/session-replay`、`/memory`、`/rewind-preview`、`/readiness`。 +如果一开始只记六个命令,先记这几个:`/session`、`/sessions`、`/session-replay`、`/memory`、`/rewind-preview`、`/readiness`。 | 命令 | 作用 | | --- | --- | | `/session` | 查看当前 live session 快照。 | -| `/sessions` | 查看当前 workspace 下的已保存会话。 | -| `/session-replay` | 回放当前或历史会话,带 transcript 和 runtime 轨迹。 | +| `/sessions` | 列出当前 workspace 的已保存会话。 | +| `/session-replay` | 回放当前或已保存会话,包括 transcript 和 runtime 上下文。 | | `/memory` | 查看当前 workspace 的记忆系统状态。 | -| `/checkpoints` | 查看当前或历史 session 的 checkpoint 列表。 | -| `/rewind-preview` | 在真正改文件前先看 rewind 会恢复什么。 | -| `/rewind` | 按 latest、步数或 checkpoint id 回退文件修改。 | -| `/readiness` | 查看 runtime/provider readiness、fallback coverage 和产品面状态。 | +| `/checkpoints` | 查看当前或已保存会话的 checkpoint 历史。 | +| `/rewind-preview` | 在真正改文件前,先看 rewind 会恢复什么。 | +| `/rewind` | 按最新 edit group、步数或 checkpoint id 执行回退。 | +| `/readiness` | 检查 runtime/provider readiness、fallback coverage 和产品面状态。 | -## 当前状态 +## Current Status -这个仓库已经过了“原型演示”阶段,今天就是能拿来用的本地产品内核;只是离更完整、更顺手的轻量级 Claude Code 体验还有继续打磨空间。 +这个仓库已经过了纯 prototype 阶段。它现在更像一个可用的本地产品,但仍在继续朝“更成熟的轻量级 Claude Code 体验”收紧。 -当前有效包是 `pyproject.toml` 里配置的根包 `minicode-py`,也就是仓库根目录下的 `minicode/`。 +当前生效的主包是根目录 `minicode/`,由 `pyproject.toml` 里的 `minicode-py` 配置驱动。 -当前本地验证结果: +最近一次本地验证结果: ```text 1030 passed, 2 skipped, 3 warnings @@ -179,101 +181,100 @@ flowchart LR 验证命令: ```bash -python -m compileall -q minicode py-src\minicode tests +python -m compileall -q minicode tests pytest -q ``` -比较诚实地说,当前状态是: +实话实说,当前状态是: -- 核心 runtime、session、replay、checkpoint、rewind、readiness 已经比较成型; -- 记忆不是后补功能;working memory、project memory、memory injection、memory-aware compaction 已经在真实 runtime 路径上; -- provider 和 fallback 诊断比以前清楚很多; -- 真正的 provider 可用性仍然取决于你本地的凭据和通道配置; -- 它今天已经可用,但还在继续朝“更完整的轻量级 Claude Code”打磨。 +- runtime、session、replay、checkpoint、rewind、readiness 这些产品面已经比较稳; +- memory 不是外挂:working memory、project memory、memory injection 和 memory-aware compaction 已经进了主运行路径; +- provider 和 fallback 诊断已经比以前清楚很多; +- 真实 provider 是否可用,仍然取决于你本地的凭据和通道配置; +- 这个项目今天已经能用,但还在继续往更完整的轻量级 Claude Code 体验走。 那 `3` 个 warning 是 benchmark 测试里未注册的 `pytest.mark.benchmark`,不是功能失败。 -## 架构 +## Architecture ```mermaid flowchart LR User["用户任务"] --> Loop["agent_loop.py"] Loop --> Kernel["turn_kernel.py