Skip to content

Commit b701a11

Browse files
committed
rename: NanoCoder -> CoreCoder
Renamed to avoid confusion with Nano-Collective/nanocoder (1.6k stars, same space). All GitHub links from the old repo redirect automatically. Changes: - Package: nanocoderagent -> corecoder - CLI command: nanocoder -> corecoder - Env vars: NANOCODER_* -> CORECODER_* - Config dir: ~/.nanocoder -> ~/.corecoder - Version bump: 0.1.0 -> 0.2.0
1 parent 6e2ec57 commit b701a11

34 files changed

Lines changed: 129 additions & 123 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build/
1111
venv/
1212
.mypy_cache/
1313
.ruff_cache/
14-
.nanocoder_history
14+
.corecoder_history
1515
.DS_Store
1616
dist/
1717
.pytest_cache/

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
# NanoCoder
1+
# CoreCoder
22

3-
[![PyPI](https://img.shields.io/pypi/v/nanocoderagent)](https://pypi.org/project/nanocoderagent/)
3+
> Formerly **NanoCoder** — renamed to avoid confusion with [Nano-Collective/nanocoder](https://github.com/Nano-Collective/nanocoder). All links from the old repo redirect here automatically.
4+
5+
6+
[![PyPI](https://img.shields.io/pypi/v/corecoder)](https://pypi.org/project/corecoder/)
47
[![Python](https://img.shields.io/badge/python-3.10+-blue)](https://python.org)
58
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6-
[![Tests](https://github.com/he-yufeng/NanoCoder/actions/workflows/ci.yml/badge.svg)](https://github.com/he-yufeng/NanoCoder/actions)
9+
[![Tests](https://github.com/he-yufeng/CoreCoder/actions/workflows/ci.yml/badge.svg)](https://github.com/he-yufeng/CoreCoder/actions)
710

811
[中文](README_CN.md) | [English](README.md) | [Claude Code Architecture Deep Dive (7 articles)](article/)
912

1013
**512,000 lines of TypeScript → 950 lines of Python.**
1114

1215
I spent two days reverse-engineering the leaked Claude Code source — all half a million lines. Then I stripped it down to the load-bearing walls and rebuilt them in Python. The result: **every key architectural pattern from Claude Code, in a codebase you can read in one sitting.**
1316

14-
NanoCoder is not another AI coding tool. It's a **blueprint** — the [nanoGPT](https://github.com/karpathy/nanoGPT) of coding agents. Read it, fork it, build your own.
17+
CoreCoder is not another AI coding tool. It's a **blueprint** — the [nanoGPT](https://github.com/karpathy/nanoGPT) of coding agents. Read it, fork it, build your own.
1518

1619
---
1720

1821
```
19-
$ nanocoder -m kimi-k2.5
22+
$ corecoder -m kimi-k2.5
2023
2124
You > read main.py and fix the broken import
2225
@@ -36,7 +39,7 @@ Fixed: halper → helper.
3639

3740
Claude Code's 512K lines distilled to 7 patterns that actually matter:
3841

39-
| Pattern | Claude Code | NanoCoder |
42+
| Pattern | Claude Code | CoreCoder |
4043
|---|---|---|
4144
| Search-and-replace editing (unique match + diff) | FileEditTool | `tools/edit.py` — 70 lines |
4245
| Parallel tool execution | StreamingToolExecutor (530 lines) | `agent.py` — ThreadPool |
@@ -51,46 +54,46 @@ Every pattern is a real, runnable implementation — not a diagram or a blog pos
5154
## Install
5255

5356
```bash
54-
pip install nanocoderagent
57+
pip install corecoder
5558
```
5659

5760
Pick your model — any OpenAI-compatible API works. You can `export` env vars or drop a `.env` file in your project root:
5861

5962
```bash
6063
# Kimi K2.5
6164
export OPENAI_API_KEY=your-key OPENAI_BASE_URL=https://api.moonshot.ai/v1
62-
nanocoder -m kimi-k2.5
65+
corecoder -m kimi-k2.5
6366

6467
# Claude Opus 4.6 (via OpenRouter)
6568
export OPENAI_API_KEY=your-key OPENAI_BASE_URL=https://openrouter.ai/api/v1
66-
nanocoder -m anthropic/claude-opus-4-6
69+
corecoder -m anthropic/claude-opus-4-6
6770

6871
# OpenAI GPT-5
6972
export OPENAI_API_KEY=sk-...
70-
nanocoder -m gpt-5
73+
corecoder -m gpt-5
7174

7275
# DeepSeek V3
7376
export OPENAI_API_KEY=sk-... OPENAI_BASE_URL=https://api.deepseek.com
74-
nanocoder -m deepseek-chat
77+
corecoder -m deepseek-chat
7578

7679
# Qwen 3.5
7780
export OPENAI_API_KEY=sk-... OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
78-
nanocoder -m qwen-max
81+
corecoder -m qwen-max
7982

8083
# Ollama (local)
8184
export OPENAI_API_KEY=ollama OPENAI_BASE_URL=http://localhost:11434/v1
82-
nanocoder -m qwen3:32b
85+
corecoder -m qwen3:32b
8386

8487
# One-shot mode
85-
nanocoder -p "add error handling to parse_config()"
88+
corecoder -p "add error handling to parse_config()"
8689
```
8790

8891
## Architecture
8992

9093
The whole thing fits in your head:
9194

9295
```
93-
nanocoder/
96+
corecoder/
9497
├── cli.py REPL + commands 160 lines
9598
├── agent.py Agent loop + parallel tools 120 lines
9699
├── llm.py Streaming client + retry 150 lines
@@ -111,7 +114,7 @@ nanocoder/
111114
## Use as a Library
112115

113116
```python
114-
from nanocoder import Agent, LLM
117+
from corecoder import Agent, LLM
115118

116119
llm = LLM(model="kimi-k2.5", api_key="your-key", base_url="https://api.moonshot.ai/v1")
117120
agent = Agent(llm=llm)
@@ -121,7 +124,7 @@ response = agent.chat("find all TODO comments in this project and list them")
121124
## Add Your Own Tools (~20 lines)
122125

123126
```python
124-
from nanocoder.tools.base import Tool
127+
from corecoder.tools.base import Tool
125128

126129
class HttpTool(Tool):
127130
name = "http"
@@ -147,7 +150,7 @@ quit Exit
147150

148151
## How It Compares
149152

150-
| | Claude Code | Claw-Code | Aider | NanoCoder |
153+
| | Claude Code | Claw-Code | Aider | CoreCoder |
151154
|---|---|---|---|---|
152155
| Code | 512K lines (closed) | 100K+ lines | 50K+ lines | **1,300 lines** |
153156
| Models | Anthropic only | Multi | Multi | **Any OpenAI-compatible** |
@@ -156,7 +159,7 @@ quit Exit
156159

157160
## The Deep Dive
158161

159-
I wrote [7 articles](article/) breaking down Claude Code's architecture — the agent loop, tool system, context compression, streaming executor, multi-agent, and 44 hidden feature flags. If you want to understand *why* NanoCoder is designed this way, start there.
162+
I wrote [7 articles](article/) breaking down Claude Code's architecture — the agent loop, tool system, context compression, streaming executor, multi-agent, and 44 hidden feature flags. If you want to understand *why* CoreCoder is designed this way, start there.
160163

161164
## License
162165

README_CN.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
# NanoCoder
1+
# CoreCoder
2+
3+
> 原名 **NanoCoder**,为避免与 [Nano-Collective/nanocoder](https://github.com/Nano-Collective/nanocoder) 混淆而改名。旧链接自动跳转到这里。
4+
25

36
[English](README.md) | [中文](README_CN.md) | [Claude Code 源码深度导读(7 篇)](article/)
47

5-
[![PyPI](https://img.shields.io/pypi/v/nanocoderagent)](https://pypi.org/project/nanocoderagent/)
8+
[![PyPI](https://img.shields.io/pypi/v/corecoder)](https://pypi.org/project/corecoder/)
69
[![Python](https://img.shields.io/badge/python-3.10+-blue)](https://python.org)
710
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
8-
[![Tests](https://github.com/he-yufeng/NanoCoder/actions/workflows/ci.yml/badge.svg)](https://github.com/he-yufeng/NanoCoder/actions)
11+
[![Tests](https://github.com/he-yufeng/CoreCoder/actions/workflows/ci.yml/badge.svg)](https://github.com/he-yufeng/CoreCoder/actions)
912

1013
**51万行 TypeScript → 950 行 Python。**
1114

1215
我逆向了 Claude Code 泄露的全部源码,然后把不承重的部分全扔掉,用 Python 重建了核心。成果:**Claude Code 的每一个关键架构模式,浓缩在一个下午能读完的代码库里。**
1316

14-
NanoCoder 不仅是一个 AI 编程工具。它是一份**蓝图**,编程 Agent 领域的 [nanoGPT](https://github.com/karpathy/nanoGPT)。读懂它,fork 它,然后造你自己的。
17+
CoreCoder 不仅是一个 AI 编程工具。它是一份**蓝图**,编程 Agent 领域的 [nanoGPT](https://github.com/karpathy/nanoGPT)。读懂它,fork 它,然后造你自己的。
1518

1619
---
1720

1821
```
19-
$ nanocoder -m kimi-k2.5
22+
$ corecoder -m kimi-k2.5
2023
2124
You > 读一下 main.py,修掉拼错的 import
2225
@@ -36,7 +39,7 @@ You > 读一下 main.py,修掉拼错的 import
3639

3740
Claude Code 51 万行源码提炼出来的 7 个核心模式:
3841

39-
| 设计模式 | Claude Code | NanoCoder |
42+
| 设计模式 | Claude Code | CoreCoder |
4043
|---|---|---|
4144
| 搜索替换编辑(唯一匹配 + diff) | FileEditTool | `tools/edit.py` — 70 行 |
4245
| 并行工具执行 | StreamingToolExecutor(530行) | `agent.py` — ThreadPool |
@@ -51,46 +54,46 @@ Claude Code 51 万行源码提炼出来的 7 个核心模式:
5154
## 安装
5255

5356
```bash
54-
pip install nanocoderagent
57+
pip install corecoder
5558
```
5659

5760
选你的模型,任何 OpenAI 兼容 API 都行。可以 `export` 环境变量,也可以在项目根目录放一个 `.env` 文件:
5861

5962
```bash
6063
# Kimi K2.5
6164
export OPENAI_API_KEY=你的key OPENAI_BASE_URL=https://api.moonshot.ai/v1
62-
nanocoder -m kimi-k2.5
65+
corecoder -m kimi-k2.5
6366

6467
# Claude Opus 4.6(通过 OpenRouter)
6568
export OPENAI_API_KEY=你的key OPENAI_BASE_URL=https://openrouter.ai/api/v1
66-
nanocoder -m anthropic/claude-opus-4-6
69+
corecoder -m anthropic/claude-opus-4-6
6770

6871
# OpenAI GPT-5
6972
export OPENAI_API_KEY=sk-...
70-
nanocoder -m gpt-5
73+
corecoder -m gpt-5
7174

7275
# DeepSeek V3
7376
export OPENAI_API_KEY=sk-... OPENAI_BASE_URL=https://api.deepseek.com
74-
nanocoder -m deepseek-chat
77+
corecoder -m deepseek-chat
7578

7679
# Qwen 3.5
7780
export OPENAI_API_KEY=sk-... OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
78-
nanocoder -m qwen-max
81+
corecoder -m qwen-max
7982

8083
# Ollama(本地)
8184
export OPENAI_API_KEY=ollama OPENAI_BASE_URL=http://localhost:11434/v1
82-
nanocoder -m qwen3:32b
85+
corecoder -m qwen3:32b
8386

8487
# 单次模式
85-
nanocoder -p "给 parse_config() 加上错误处理"
88+
corecoder -p "给 parse_config() 加上错误处理"
8689
```
8790

8891
## 架构
8992

9093
整个项目一目了然:
9194

9295
```
93-
nanocoder/
96+
corecoder/
9497
├── cli.py REPL + 命令 160 行
9598
├── agent.py Agent 循环 + 并行执行 120 行
9699
├── llm.py 流式客户端 + 重试 150 行
@@ -111,7 +114,7 @@ nanocoder/
111114
## 当库用
112115

113116
```python
114-
from nanocoder import Agent, LLM
117+
from corecoder import Agent, LLM
115118

116119
llm = LLM(model="kimi-k2.5", api_key="your-key", base_url="https://api.moonshot.ai/v1")
117120
agent = Agent(llm=llm)
@@ -121,7 +124,7 @@ response = agent.chat("找出项目里所有 TODO 注释并列出来")
121124
## 加自定义工具(约 20 行)
122125

123126
```python
124-
from nanocoder.tools.base import Tool
127+
from corecoder.tools.base import Tool
125128

126129
class HttpTool(Tool):
127130
name = "http"
@@ -147,7 +150,7 @@ quit 退出
147150

148151
## 对比
149152

150-
| | Claude Code | Claw-Code | Aider | NanoCoder |
153+
| | Claude Code | Claw-Code | Aider | CoreCoder |
151154
|---|---|---|---|---|
152155
| 代码量 | 51万行(闭源) | 10万+行 | 5万+行 | **1300 行** |
153156
| 模型 | 仅 Anthropic | 多模型 | 多模型 | **任意 OpenAI 兼容** |
@@ -156,7 +159,7 @@ quit 退出
156159

157160
## 源码导读
158161

159-
我还写了 [7 篇 Claude Code 架构深度导读](article/):Agent 循环、工具系统、上下文压缩、流式执行、多 Agent、隐藏功能。想知道 NanoCoder 为什么这样设计,从那里开始。
162+
我还写了 [7 篇 Claude Code 架构深度导读](article/):Agent 循环、工具系统、上下文压缩、流式执行、多 Agent、隐藏功能。想知道 CoreCoder 为什么这样设计,从那里开始。
160163

161164
## License
162165

article/00-index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
## 配套项目
2020

21-
这些文章中讨论的核心架构模式,我用 1300 行 Python 做了一个可运行的参考实现:[NanoCoder](https://github.com/he-yufeng/NanoCoder)。代码和文章可以对照着看。
21+
这些文章中讨论的核心架构模式,我用 1300 行 Python 做了一个可运行的参考实现:[CoreCoder](https://github.com/he-yufeng/CoreCoder)。代码和文章可以对照着看。
2222

2323
## 完整版
2424

25-
如果你想要更详尽的版本(16 篇、16 万字、覆盖构建系统到 MCP 协议的每个子系统),完整导读在[这里](https://github.com/he-yufeng/NanoCoder/tree/main/docs)
25+
如果你想要更详尽的版本(16 篇、16 万字、覆盖构建系统到 MCP 协议的每个子系统),完整导读在[这里](https://github.com/he-yufeng/CoreCoder/tree/main/docs)
2626

2727
---
2828

article/01-architecture-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ src/coordinator/ → 多 Agent 编排
136136
- 第六篇:多 Agent 协作系统
137137
- 第七篇:Feature Flag 背后的未发布功能
138138

139-
我还用 1300 行 Python 复刻了这些核心设计模式:[NanoCoder](https://github.com/he-yufeng/NanoCoder)。每篇文章里会对照源码和 NanoCoder 的实现来讲。
139+
我还用 1300 行 Python 复刻了这些核心设计模式:[CoreCoder](https://github.com/he-yufeng/CoreCoder)。每篇文章里会对照源码和 CoreCoder 的实现来讲。
140140

141141
---
142142

article/02-agent-loop.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function buildSystemPrompt(context) {
9393

9494
有意思的一点:源码里有大量 `@[MODEL LAUNCH]` 注释,每一个都是"当某个新模型发布时需要修改的地方"。其中关于 Capybara 的有好几条,包括"v8 版本的虚假声明率 29-30%,需要在 prompt 层面修补"。说明新模型的行为矫正是在系统提示词层面做的,不是在模型层面。
9595

96-
NanoCoder`prompt.py` 是这个机制的极简版(35 行):根据当前工作目录、OS 信息、可用工具列表动态拼接。没有模型特定修正和 Skill 加载,但核心思路一样。
96+
CoreCoder`prompt.py` 是这个机制的极简版(35 行):根据当前工作目录、OS 信息、可用工具列表动态拼接。没有模型特定修正和 Skill 加载,但核心思路一样。
9797

9898
---
9999

@@ -153,7 +153,7 @@ class StreamingToolExecutor {
153153

154154
效果:假设 LLM 一次返回三个工具调用——读文件 A(200ms)、读文件 B(150ms)、跑测试(2s)。串行执行总共 2350ms。StreamingToolExecutor 下,三个工具在 LLM 还在生成的时候就已经开始跑了,实际延迟接近于 max(200, 150, 2000) = 2000ms,甚至更短(因为工具执行时间被 LLM 生成时间"吸收"了)。
155155

156-
NanoCoder 用了一个折中方案:不做流式解析,但当 LLM 一次返回多个 tool_calls 时,用 `ThreadPoolExecutor` 并行执行。损失了"在 LLM 生成期间就开始执行"的优势,但保留了"多工具并行"的收益。大概十几行代码。
156+
CoreCoder 用了一个折中方案:不做流式解析,但当 LLM 一次返回多个 tool_calls 时,用 `ThreadPoolExecutor` 并行执行。损失了"在 LLM 生成期间就开始执行"的优势,但保留了"多工具并行"的收益。大概十几行代码。
157157

158158
---
159159

@@ -184,7 +184,7 @@ NanoCoder 用了一个折中方案:不做流式解析,但当 LLM 一次返
184184

185185
这才是"agentic"的核心含义:Agent 遇到问题时自己想办法,而不是转头问人。
186186

187-
NanoCoder`agent.py` 实现了工具异常捕获喂回 LLM 和 max_rounds 限制,但没有做 API 层面的重试和 fallback(这些在不同 LLM provider 之间差异太大,放在上层处理更合适)。
187+
CoreCoder`agent.py` 实现了工具异常捕获喂回 LLM 和 max_rounds 限制,但没有做 API 层面的重试和 fallback(这些在不同 LLM provider 之间差异太大,放在上层处理更合适)。
188188

189189
---
190190

@@ -206,7 +206,7 @@ type QueryEngineConfig = {
206206
}
207207
```
208208
209-
NanoCoder`max_rounds=50` 做了轮次限制,没做美元预算(多 provider 环境下费率不统一,不好算)。
209+
CoreCoder`max_rounds=50` 做了轮次限制,没做美元预算(多 provider 环境下费率不统一,不好算)。
210210
211211
---
212212
@@ -230,8 +230,8 @@ NanoCoder 用 `max_rounds=50` 做了轮次限制,没做美元预算(多 prov
230230
4. **轮次预算**,防止 LLM 无限循环
231231
5. **系统提示词动态拼装**,同一个 Agent 在不同环境下有不同行为
232232
233-
这些设计模式我在 NanoCoder 里都做了最小实现(`agent.py` 110 行)。如果你想看它们在生产代码里长什么样,`query.ts` 是最好的教材。
233+
这些设计模式我在 CoreCoder 里都做了最小实现(`agent.py` 110 行)。如果你想看它们在生产代码里长什么样,`query.ts` 是最好的教材。
234234
235235
---
236236
237-
> 本文是 [Claude Code 源码导读](00-index.md) 系列第 2 篇。配套实现:[NanoCoder](https://github.com/he-yufeng/NanoCoder)
237+
> 本文是 [Claude Code 源码导读](00-index.md) 系列第 2 篇。配套实现:[CoreCoder](https://github.com/he-yufeng/CoreCoder)

article/03-tool-system.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LLM 不需要知道行号,不需要输出整个文件,不需要生成 diff
5757

5858
这个约束的妙处在于:它把"编辑文件"这个本质模糊的操作变成了一个**确定性**操作。不管 LLM 的记忆力有多差,只要它能给出一段唯一的文本,编辑就一定是准确的。
5959

60-
NanoCoder 完整实现了这个模式(`tools/edit.py`,70 行),而且加了 unified diff 输出——每次编辑后你能看到 `--- a/file +++ b/file` 格式的变更对比。
60+
CoreCoder 完整实现了这个模式(`tools/edit.py`,70 行),而且加了 unified diff 输出——每次编辑后你能看到 `--- a/file +++ b/file` 格式的变更对比。
6161

6262
---
6363

@@ -142,7 +142,7 @@ BashTool 单文件 1143 行。它做的远不止 `subprocess.run(command)`:
142142
143143
**sed 检测。** 检测到 `sed -i` 命令时,UI 从 "Bash" 样式切换成文件编辑样式。因为 `sed -i` 本质上是在编辑文件,应该像 edit_file 一样展示 diff。
144144
145-
NanoCoder 的 BashTool 是 80 行的精简版:输出截断(头尾保留)、超时控制、9 个危险命令正则检测(`rm -rf /`、fork bomb、`curl | bash` 等)。覆盖了最核心的安全需求。
145+
CoreCoder 的 BashTool 是 80 行的精简版:输出截断(头尾保留)、超时控制、9 个危险命令正则检测(`rm -rf /`、fork bomb、`curl | bash` 等)。覆盖了最核心的安全需求。
146146
147147
---
148148
@@ -162,8 +162,8 @@ const tools = [
162162

163163
部分工具是"懒加载"的——标记了 `shouldDefer: true` 的工具默认不在工具列表里,只有当 LLM 触发了 `ToolSearch` 之后才被发现并加载。这避免了工具列表过长导致 LLM 选择困难(工具太多 LLM 会犹豫不决,影响响应速度和准确率)。
164164

165-
NanoCoder 用的是最简单的静态列表。但接口设计留了扩展口——`Agent.__init__` 接受 `tools` 参数,传什么用什么。
165+
CoreCoder 用的是最简单的静态列表。但接口设计留了扩展口——`Agent.__init__` 接受 `tools` 参数,传什么用什么。
166166

167167
---
168168

169-
> 本文是 [Claude Code 源码导读](00-index.md) 系列第 3 篇。配套实现:[NanoCoder](https://github.com/he-yufeng/NanoCoder)
169+
> 本文是 [Claude Code 源码导读](00-index.md) 系列第 3 篇。配套实现:[CoreCoder](https://github.com/he-yufeng/CoreCoder)

0 commit comments

Comments
 (0)