{"id":50135073,"url":"https://github.com/minorcell/mini-claude-code","last_synced_at":"2026-05-23T21:04:52.124Z","repository":{"id":341030548,"uuid":"1167167098","full_name":"minorcell/mini-claude-code","owner":"minorcell","description":"Building a Mini Claude Code from Scratch (TypeScript)","archived":false,"fork":false,"pushed_at":"2026-05-06T08:59:37.000Z","size":282,"stargazers_count":56,"open_issues_count":2,"forks_count":19,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-06T10:50:02.727Z","etag":null,"topics":["agent","ai","claude-code","golang","loop","qiniu"],"latest_commit_sha":null,"homepage":"https://www.bilibili.com/video/BV1eiwRzPE4n","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minorcell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-26T02:22:59.000Z","updated_at":"2026-05-06T08:59:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/minorcell/mini-claude-code","commit_stats":null,"previous_names":["minorcell/mini-claude-code"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/minorcell/mini-claude-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minorcell%2Fmini-claude-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minorcell%2Fmini-claude-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minorcell%2Fmini-claude-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minorcell%2Fmini-claude-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minorcell","download_url":"https://codeload.github.com/minorcell/mini-claude-code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minorcell%2Fmini-claude-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33412084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T18:09:33.147Z","status":"ssl_error","status_checked_at":"2026-05-23T18:09:31.380Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","claude-code","golang","loop","qiniu"],"created_at":"2026-05-23T21:04:51.558Z","updated_at":"2026-05-23T21:04:52.119Z","avatar_url":"https://github.com/minorcell.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-claude-code\n\n\u003e 本仓库是一个面向 Agent 开发初学者的教学项目仓库，早期使用 TypeScript + AI SDK 实现，现在切换为 Golang + Openai ADK + BubbleTea 实现。\n\u003e\n\u003e Bilibili 视频教学：[Agent 到底是什么？从原理、开发到落地的一次真实分享；2026 年 3 月 14 日 - 华中科技大学](https://www.bilibili.com/video/BV1eiwRzPE4n/)\n\u003e\n\u003e Issue 风格教案：[完整教案 Issue #2](https://github.com/minorcell/mini-claude-code/issues/2)\n\u003e\n\u003e 交互式教学：[CellStack - 从0构建一个 Mini Claude Code](https://stack.mcell.top/topics/build-mini-claude-code)\n\n`mini-opencode` 是一个 Code Agent 项目。它基于 Go + Bubble Tea，提供终端内的代码读取、工具调用、shell 执行与 todo 管理能力，并将过程保留在同一个 TUI 会话里。\n\n## 仓库结构\n\n- `cmd/mini-opencode`：程序入口\n- `internal/config`：配置加载与默认值\n- `internal/core`：agent loop、session、逐步事件广播\n- `internal/provider`：统一模型接口，适配 `openai` / `openai-compatible` / `anthropic` / `gemini`\n- `internal/tools`：工具注册中心、工作区约束、安全拦截器、内置工具\n- `internal/tui`：Bubble Tea 交互界面\n- `docs/`：主线项目设计文档\n- `examples/`：教学示例（`agent-loop`、`mini-claude-code`）\n\n## 功能概览\n\n界面由三个区域组成：\n\n- `Conversation`：完整展示 user / assistant / tool 的叙事和结果\n- `Context`：展示会话状态、token 统计、step 进度、todo 侧栏\n- `Composer`：输入区，支持排队下一条消息和 `@文件` 候选补全\n\n## 快速开始\n\n```bash\ngo run ./cmd/mini-opencode\n```\n\n首次启动会自动生成 `~/.mini-opencode/config.yaml`。\n\n如果使用默认 OpenAI 配置，先设置：\n\n```bash\nexport OPENAI_API_KEY=\"your_api_key\"\n```\n\n跑测试：\n\n```bash\ngo test ./...\n```\n\n## 配置\n\n默认配置文件路径：\n\n```txt\n~/.mini-opencode/config.yaml\n```\n\n最小示例：\n\n```yaml\nworkspace: ~/code/my-project\nmax_tokens: 1024\nmax_steps: 24\ntemperature: 0.2\n\nprovider:\n  name: OpenAI\n  type: openai\n  url: https://api.openai.com/v1\n  env_api_key: OPENAI_API_KEY\n  model_id: gpt-4.1-mini\n```\n\n使用 DeepSeek 这类 OpenAI-compatible 网关时：\n\n```yaml\nprovider:\n  name: DeepSeek\n  type: openai-compatible\n  url: https://api.deepseek.com/v1\n  env_api_key: DEEPSEEK_API_KEY\n  model_id: deepseek-chat\n```\n\n`provider.type` 支持：\n\n- `openai`\n- `openai-compatible`\n- `anthropic`\n- `gemini`\n\n默认值规则：\n\n- `openai -\u003e url=https://api.openai.com/v1 env_api_key=OPENAI_API_KEY model_id=gpt-4.1-mini`\n- `anthropic -\u003e url=https://api.anthropic.com/v1 env_api_key=ANTHROPIC_API_KEY model_id=claude-3-7-sonnet-latest`\n- `gemini -\u003e url=https://generativelanguage.googleapis.com/v1beta env_api_key=GEMINI_API_KEY model_id=gemini-2.0-flash`\n- `openai-compatible -\u003e 不预设 url / env_api_key / model_id，需要显式配置`\n\n补充说明：\n\n- `provider.name` 只是界面显示名，不参与协议分发\n- `workspace` 为空时默认使用启动程序时的工作目录\n- `workspace`、`provider.url`、`provider.model_id` 支持环境变量展开\n- `provider.type` 会自动规范化别名，例如 `compatible` 会折叠成 `openai-compatible`\n\n## 内置工具\n\n| 工具 | 说明 |\n| --- | --- |\n| `read` | 读取文件，返回带行号内容，支持 `offset` / `limit` / `max_bytes` |\n| `write` | 写入文件，自动创建父目录，支持覆盖或追加 |\n| `edit` | 精确替换已有内容，默认要求 `old_content` 唯一 |\n| `list` | 列目录，支持递归和显示隐藏文件 |\n| `glob` | 按 Go 标准 glob 规则匹配文件名 |\n| `grep` | 在文件内容中搜索文本或正则，返回 `file:line: content` |\n| `bash` | 在工作区内执行 `/bin/sh -lc` 命令 |\n| `todo` | 维护任务 todo 列表，右侧 `Context` 会渲染状态 |\n| `webfetch` | 抓取 HTTP(S) 页面或接口，HTML 会被剥离为纯文本 |\n\n## 交互方式\n\n- `Enter`：发送消息；如果 turn 还在运行，会排队 1 条后续消息\n- `Ctrl+J`：在 Composer 里插入换行\n- `Esc`：如果有已排队草稿，恢复到 Composer\n- `Esc Esc`：中断正在运行的 turn\n- `@`：在 Composer 中触发工作区文件候选\n- `Up` / `Down`：选择文件候选\n- `Tab` 或 `Enter`：接受所选文件候选\n- 鼠标滚轮：滚动 `Conversation` 记录\n- `Ctrl+C`：退出程序\n\n## 已知边界\n\n- `glob` 走的是 Go `filepath.Glob` 语义，不支持把 `**` 当成递归 doublestar\n- 右侧 `Context` 用于展示 token、step、todo 等状态信息；详细工具输出显示在 `Conversation`\n- `bash` 默认超时 20 秒，最大 2 分钟，输出上限 64KB\n- `read` 和 `webfetch` 的内容上限都是 64KB\n\n## Contributors\n![](https://hub-io-mcells-projects.vercel.app/r/minorcell/mini-claude-code)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminorcell%2Fmini-claude-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminorcell%2Fmini-claude-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminorcell%2Fmini-claude-code/lists"}