chcode 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chcode-0.1.2/CHANGELOG.md +33 -0
- chcode-0.1.2/PKG-INFO +294 -0
- chcode-0.1.1/README_zh.md → chcode-0.1.2/README.md +27 -13
- chcode-0.1.1/README.md → chcode-0.1.2/README_en.md +27 -13
- {chcode-0.1.1 → chcode-0.1.2}/chcode/agent_setup.py +137 -6
- {chcode-0.1.1 → chcode-0.1.2}/chcode/agents/loader.py +12 -22
- {chcode-0.1.1 → chcode-0.1.2}/chcode/agents/runner.py +88 -27
- {chcode-0.1.1 → chcode-0.1.2}/chcode/chat.py +235 -268
- {chcode-0.1.1 → chcode-0.1.2}/chcode/cli.py +11 -16
- {chcode-0.1.1 → chcode-0.1.2}/chcode/config.py +192 -160
- {chcode-0.1.1 → chcode-0.1.2}/chcode/display.py +77 -44
- {chcode-0.1.1 → chcode-0.1.2}/chcode/prompts.py +36 -124
- chcode-0.1.2/chcode/utils/__init__.py +3 -0
- chcode-0.1.2/chcode/utils/frontmatter.py +32 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/git_manager.py +2 -42
- chcode-0.1.2/chcode/utils/json_utils.py +85 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/multimodal.py +17 -22
- {chcode-0.1.1/chcode → chcode-0.1.2/chcode/utils}/session.py +3 -14
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/skill_loader.py +11 -32
- {chcode-0.1.1/chcode → chcode-0.1.2/chcode/utils}/skill_manager.py +2 -4
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/text_utils.py +8 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/tools.py +61 -31
- {chcode-0.1.1 → chcode-0.1.2}/chcode/vision_config.py +83 -63
- {chcode-0.1.1 → chcode-0.1.2}/pyproject.toml +1 -1
- {chcode-0.1.1 → chcode-0.1.2}/tests/conftest.py +1 -1
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_agent_setup.py +1 -1
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_agent_setup_extended.py +53 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_chat_repl.py +176 -148
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_chat_repl_extended.py +174 -225
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_cli.py +2 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_cli_extended.py +40 -99
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_config.py +119 -140
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_config_extended.py +341 -54
- chcode-0.1.2/tests/test_config_pure.py +62 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_coverage_gaps.py +71 -116
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_display_extended.py +29 -1
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_git_manager_extended.py +1 -169
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_multimodal.py +31 -33
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_multimodal_middleware.py +18 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_prompts.py +37 -95
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_runner_extended.py +87 -9
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_session.py +1 -2
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_skill_loader_extended.py +23 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_skill_manager_extended.py +43 -44
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_tools_extended.py +25 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_vision_config.py +147 -6
- {chcode-0.1.1 → chcode-0.1.2}/uv.lock +1 -1
- chcode-0.1.1/PKG-INFO +0 -280
- chcode-0.1.1/chcode/utils/__init__.py +0 -3
- chcode-0.1.1/tests/test_config_pure.py +0 -79
- {chcode-0.1.1 → chcode-0.1.2}/.github/workflows/publish.yml +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/.github/workflows/test.yml +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/.gitignore +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/LICENSE +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/assets/chagent.png +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/assets/chcode.png +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/assets/test.mp4 +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/__init__.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/__main__.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/agents/__init__.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/agents/definitions.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/enhanced_chat_openai.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/git_checker.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/modelscope_ratelimit.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/__init__.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/output.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/provider.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/result.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/semantics.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/shell/session.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/chcode/utils/tool_result_pipeline.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/docs/plans/2026-04-23-vision-tool.md +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/__init__.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_chat_helpers.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_definitions.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_display.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_enhanced_chat_openai.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_enhanced_chat_openai_extended.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_git_checker.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_git_manager.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_loader.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_output.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_prompt_toolkit_ui.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_provider.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_result.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_runner.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_semantics.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_shell_session.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_shell_session_extended.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_skill_loader.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_tool_result_pipeline.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_tools.py +0 -0
- {chcode-0.1.1 → chcode-0.1.2}/tests/test_vision.py +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [0.1.2] - 2026-06-20
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- Config-driven multimodal detection: `is_multimodal_model` reads from `vision_model.json` instead of hardcoded patterns; new `add_vision_model()` with idempotent upsert (default/fallback roles)
|
|
13
|
+
|
|
14
|
+
### Refactored
|
|
15
|
+
|
|
16
|
+
- Per-model `context_length` in `metadata` (default 1M) replaces hardcoded `CONTEXT_WINDOW_SIZES` dict and `get_context_window_size()`
|
|
17
|
+
- `model_config_form` simplified: Base URL via `text()` instead of select; streamlined API key flow (keep/re-enter)
|
|
18
|
+
- `configure_new_model` prompts for context length before multimodal question; new `skip_method_select` param
|
|
19
|
+
- `edit_current_model` preserves existing `metadata` on form resubmit
|
|
20
|
+
- Subagent architecture: default Explore mode, parallel display rework, read-only safety, cross-session conflict fix
|
|
21
|
+
- LangSmith cross-platform config: Linux shell config file support; stderr guard suppresses errors instead of auto-disabling tracing
|
|
22
|
+
- Replace readline with prompt-toolkit `FileHistory` (50-entry cap); use native `prompt_async`
|
|
23
|
+
- Extract shared utilities, unify console/API key masking, add IPC event middleware
|
|
24
|
+
- `chat.py`: rewrite if/elif chains to match/case, remove dead code
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `configure_langsmith` project name `None` handling (Ctrl-C fallback to "chcode")
|
|
29
|
+
- Remove unused `error` marker from `additional_kwargs`
|
|
30
|
+
|
|
31
|
+
### Documentation
|
|
32
|
+
|
|
33
|
+
- Update README for subagent mode-aware features and project directory structure
|
chcode-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chcode
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Terminal-based AI coding agent with typer+rich
|
|
5
|
+
Project-URL: Homepage, https://github.com/ScarletMercy/chcode
|
|
6
|
+
Project-URL: Repository, https://github.com/ScarletMercy/chcode
|
|
7
|
+
Project-URL: Issues, https://github.com/ScarletMercy/chcode/issues
|
|
8
|
+
Author-email: Flymo Han <minimizeball@foxmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,cli,coding-agent,langchain,rich,typer
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
19
|
+
Requires-Python: >=3.13
|
|
20
|
+
Requires-Dist: aiofiles>=25.1.0
|
|
21
|
+
Requires-Dist: aiosqlite>=0.22.1
|
|
22
|
+
Requires-Dist: bs4>=0.0.2
|
|
23
|
+
Requires-Dist: charset-normalizer>=3.4.0
|
|
24
|
+
Requires-Dist: httpx>=0.28.0
|
|
25
|
+
Requires-Dist: langchain-openai>=1.1.10
|
|
26
|
+
Requires-Dist: langchain>=1.2.10
|
|
27
|
+
Requires-Dist: langgraph-checkpoint-sqlite>=3.0.3
|
|
28
|
+
Requires-Dist: markdownify>=0.14.0
|
|
29
|
+
Requires-Dist: pillow>=12.2.0
|
|
30
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
31
|
+
Requires-Dist: psutil>=6.0.0
|
|
32
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
33
|
+
Requires-Dist: questionary>=2.1.0
|
|
34
|
+
Requires-Dist: rich>=13.9.0
|
|
35
|
+
Requires-Dist: tavily>=1.1.0
|
|
36
|
+
Requires-Dist: typer>=0.15.0
|
|
37
|
+
Provides-Extra: test
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.25.0; extra == 'test'
|
|
39
|
+
Requires-Dist: pytest-cov>=6.0.0; extra == 'test'
|
|
40
|
+
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
|
|
41
|
+
Requires-Dist: pytest-timeout>=2.3.0; extra == 'test'
|
|
42
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# ChCode
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
███████╗ ██╗ ██╗ ███████╗ ██████╗ █████╗ ████████╗
|
|
49
|
+
██╔═════╝ ██║ ██║ ██╔═════╝ ██╔═══██╗ ██╔══██╗ ██╔═════╝
|
|
50
|
+
██║ ████████║ ██║ ██║ ██║ ██║ ██╗ ████████╗
|
|
51
|
+
██║ ██╔═══██║ ██║ ██║ ██║ ██║ ██╔╝ ██╔═════╝
|
|
52
|
+
████████╗ ██║ ██║ ████████╗ ╚██████╔╝ █████╔═╝ ████████╗
|
|
53
|
+
╚══════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚════╝ ╚══════╝
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
基于终端的 AI 编程代理,使用 LangChain + Typer + Rich 构建。
|
|
57
|
+
|
|
58
|
+
> **为什么叫 "ChCode"?** 最初的原型是一个 tkinter + LangChain 应用,名为 **chat-agent**(chagent)。当它演变为 CLI 工具后,名字变成了 **ChCode** — chat-agent 遇上 code。
|
|
59
|
+
|
|
60
|
+
<details>
|
|
61
|
+
<summary>📸 chagent — 最初的 tkinter 原型</summary>
|
|
62
|
+
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chagent.png" alt="chagent prototype" width="600"/>
|
|
63
|
+
</details>
|
|
64
|
+
|
|
65
|
+
> 7000+ 行 Python 代码,14 个内置工具,完整会话持久化,Git 感知工作流。
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
[English](README_en.md)
|
|
71
|
+
|
|
72
|
+
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chcode.png" alt="ChCode 主界面" width="800"/>
|
|
73
|
+
|
|
74
|
+
## 功能特性
|
|
75
|
+
|
|
76
|
+
### 模型管理
|
|
77
|
+
|
|
78
|
+
- 兼容**所有 OpenAI 兼容 API**(OpenAI、DeepSeek、Qwen、GLM、Claude 代理等)
|
|
79
|
+
- 内置 **ModelScope**、**LongCat** 等主流平台快捷配置
|
|
80
|
+
- **ModelScope**:每天 2000 次免费模型调用
|
|
81
|
+
- **LongCat**:每天最低 5000 万+ 免费 token
|
|
82
|
+
- 首次运行向导,**自动检测环境变量**(扫描 `OPENAI_API_KEY`、`DEEPSEEK_API_KEY`、`ZHIPU_API_KEY`、`ModelScopeToken` 等)
|
|
83
|
+
- 原生支持 **reasoning/thinking 模型** — 实时显示思考过程
|
|
84
|
+
- 运行时创建 / 编辑 / 切换模型
|
|
85
|
+
- 每个模型独立调参(temperature、top_p、top_k、max_completion_tokens、stop_sequences 等)
|
|
86
|
+
- **指数退避自动重试**(3/10/30/60s),持续失败时自动切换备用模型
|
|
87
|
+
|
|
88
|
+
### 视觉与多模态
|
|
89
|
+
|
|
90
|
+
- 通过 `/vision` 命令独立配置视觉模型(与主模型分离)
|
|
91
|
+
- 图片分析,支持**自动媒体编码**和 base64 嵌入
|
|
92
|
+
- **视频支持** — 直接将视频发送给视觉模型进行分析(MP4、MOV、AVI、MKV、WebM)
|
|
93
|
+
- 大尺寸图片自动缩放
|
|
94
|
+
- 支持的图片格式:PNG、JPG、JPEG、GIF、BMP、WebP、TIFF
|
|
95
|
+
|
|
96
|
+
### 会话与历史
|
|
97
|
+
|
|
98
|
+
- **持久化会话**,基于 SQLite 的检查点存储(LangGraph)
|
|
99
|
+
- 会话列表、切换、重命名、删除
|
|
100
|
+
- **上下文压缩** — 接近 token 上限时自动摘要
|
|
101
|
+
- 状态栏实时显示**上下文使用量**
|
|
102
|
+
|
|
103
|
+
### Git 集成
|
|
104
|
+
|
|
105
|
+
- 编辑消息时工作目录**自动回滚**
|
|
106
|
+
- 从任意消息**创建分支**(fork)
|
|
107
|
+
- 通过 `/messages` 编辑 / fork / 删除历史消息
|
|
108
|
+
- 状态栏显示检查点计数
|
|
109
|
+
|
|
110
|
+
### 人工审核
|
|
111
|
+
|
|
112
|
+
- **Common 模式** — 每次工具调用需要确认,编辑操作显示 diff 预览。仅可使用 Explore 和 Plan 子代理
|
|
113
|
+
- **YOLO 模式** — 自动批准所有操作。所有子代理可用,包括 General-purpose
|
|
114
|
+
- 通过 `Tab` 键或 `/mode` 命令切换
|
|
115
|
+
- 切换模式时自动更新可用子代理列表
|
|
116
|
+
|
|
117
|
+
### 工作环境隔离
|
|
118
|
+
|
|
119
|
+
- 每个项目独立的 `.chat/` 目录存放会话、技能、代理
|
|
120
|
+
- 全局 `~/.chat/` 存放共享技能和设置
|
|
121
|
+
- `/workdir` 切换项目根目录
|
|
122
|
+
|
|
123
|
+
### 跨平台
|
|
124
|
+
|
|
125
|
+
- **Windows** — 默认使用 Git Bash,回退到 PowerShell
|
|
126
|
+
- **Linux / Mac** — 原生 bash/zsh
|
|
127
|
+
- 持久化 Shell 会话,**自动追踪 CWD**
|
|
128
|
+
|
|
129
|
+
### 终端 UI
|
|
130
|
+
|
|
131
|
+
- 实时**状态栏** — 上下文使用率、Git 检查点数、ModelScope API 配额
|
|
132
|
+
- **流式输出**,逐 token 渲染
|
|
133
|
+
- 斜杠命令自动补全
|
|
134
|
+
- 彩色工具审核界面,文件编辑显示**行内 diff 预览**
|
|
135
|
+
|
|
136
|
+
### 可观测性
|
|
137
|
+
|
|
138
|
+
- **LangSmith 追踪** — 通过 `/langsmith` 命令开关
|
|
139
|
+
- 遇到 429 限流时自动禁用追踪并通知用户
|
|
140
|
+
|
|
141
|
+
### 子代理系统
|
|
142
|
+
|
|
143
|
+
- 三种内置代理类型:**Explore**(代码库搜索,只读)、**Plan**(架构设计,只读)、**General-purpose**(全能力编程)
|
|
144
|
+
- **模式感知可用性** — 普通模式:仅 Explore + Plan;YOLO 模式:全部三种 + 自定义代理
|
|
145
|
+
- **并行执行** — 同时启动多个代理处理独立任务,带实时旋转进度显示
|
|
146
|
+
- 子代理运行在**隔离上下文**中,保护主对话不被上下文污染
|
|
147
|
+
- 只读代理(Explore、Plan)具有 **bash 命令限制**,防止误修改
|
|
148
|
+
- **自定义代理** — 在 `.chat/agents/` 中定义自己的代理类型,配备专属工具和指令
|
|
149
|
+
|
|
150
|
+
### 技能系统
|
|
151
|
+
|
|
152
|
+
- 通过 `/skill` 安装 / 删除 / 管理技能
|
|
153
|
+
- 技能通过 LangChain 中间件注入系统提示
|
|
154
|
+
- 支持项目级和全局技能目录
|
|
155
|
+
|
|
156
|
+
### ModelScope 限额监控
|
|
157
|
+
|
|
158
|
+
- 状态栏实时显示 **API 配额**(每日剩余额度、每模型剩余额度)
|
|
159
|
+
- 使用 ModelScope 模型时自动启用
|
|
160
|
+
|
|
161
|
+
## 内置工具(14 个)
|
|
162
|
+
|
|
163
|
+
| 工具 | 说明 |
|
|
164
|
+
|------|------|
|
|
165
|
+
| `read` | 读取文件内容,支持行号和偏移量 |
|
|
166
|
+
| `write` | 创建或覆盖文件 |
|
|
167
|
+
| `edit` | 精准字符串替换编辑现有文件 |
|
|
168
|
+
| `glob` | 按文件名模式查找文件 |
|
|
169
|
+
| `grep` | 用正则搜索文件内容 |
|
|
170
|
+
| `list_dir` | 浏览目录结构 |
|
|
171
|
+
| `bash` | 执行 Shell 命令(Git Bash / PowerShell / bash) |
|
|
172
|
+
| `load_skill` | 通过中间件动态加载技能指令 |
|
|
173
|
+
| `web_fetch` | 抓取 URL 内容并转换为 Markdown |
|
|
174
|
+
| `web_search` | 通过 [Tavily](https://tavily.com) 进行网络搜索 |
|
|
175
|
+
| `ask_user` | 单选、多选、批量问题与用户交互 |
|
|
176
|
+
| `agent` | 启动子代理(Explore、Plan、YOLO 模式下含 General-purpose、custom),支持并行执行 |
|
|
177
|
+
| `todo_write` | 结构化任务追踪,适用于复杂多步骤工作 |
|
|
178
|
+
| `vision` | 通过视觉模型分析图片和视频 |
|
|
179
|
+
|
|
180
|
+
## 快速开始
|
|
181
|
+
|
|
182
|
+
### 安装
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# 稳定版(PyPI)— 三选一
|
|
186
|
+
pip install chcode # pip
|
|
187
|
+
uv tool install chcode # uv(推荐)
|
|
188
|
+
pipx install chcode # pipx
|
|
189
|
+
|
|
190
|
+
# 最新版(GitHub)— 二选一
|
|
191
|
+
uv tool install git+https://github.com/ScarletMercy/chcode.git # uv(推荐)
|
|
192
|
+
pipx install git+https://github.com/ScarletMercy/chcode.git # pipx
|
|
193
|
+
|
|
194
|
+
# 开发测试(从源码)
|
|
195
|
+
git clone https://github.com/ScarletMercy/chcode.git
|
|
196
|
+
cd chcode
|
|
197
|
+
pip install -e . # 或: uv sync && uv run chcode
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 运行
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# 启动交互式会话
|
|
204
|
+
chcode
|
|
205
|
+
|
|
206
|
+
# 以 YOLO 模式启动
|
|
207
|
+
chcode --yolo
|
|
208
|
+
|
|
209
|
+
# 模型管理
|
|
210
|
+
chcode config new # 添加新模型
|
|
211
|
+
chcode config edit # 编辑当前模型
|
|
212
|
+
chcode config switch # 切换模型
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 首次运行
|
|
216
|
+
|
|
217
|
+
首次启动时,ChCode 会:
|
|
218
|
+
|
|
219
|
+
1. 扫描环境变量中的已知 API Key
|
|
220
|
+
2. 引导你完成模型配置
|
|
221
|
+
3. 可选配置 Tavily 用于网络搜索
|
|
222
|
+
|
|
223
|
+
## 命令
|
|
224
|
+
|
|
225
|
+
| 命令 | 说明 |
|
|
226
|
+
|------|------|
|
|
227
|
+
| `/new` | 新建会话 |
|
|
228
|
+
| `/history` | 浏览和切换会话 |
|
|
229
|
+
| `/model` | 模型管理(新建 / 编辑 / 切换) |
|
|
230
|
+
| `/vision` | 视觉模型配置 |
|
|
231
|
+
| `/messages` | 编辑 / fork / 删除历史消息 |
|
|
232
|
+
| `/compress` | 压缩当前会话 |
|
|
233
|
+
| `/skill` | 管理技能 |
|
|
234
|
+
| `/search` | 配置 Tavily API Key |
|
|
235
|
+
| `/workdir` | 切换工作目录 |
|
|
236
|
+
| `/mode` | 切换 Common / YOLO 模式 |
|
|
237
|
+
| `/git` | 显示 Git 状态 |
|
|
238
|
+
| `/langsmith` | 开关 LangSmith 追踪 |
|
|
239
|
+
| `/tools` | 列出内置工具 |
|
|
240
|
+
| `/quit` | 退出 |
|
|
241
|
+
|
|
242
|
+
## 快捷键
|
|
243
|
+
|
|
244
|
+
| 按键 | 操作 |
|
|
245
|
+
|------|------|
|
|
246
|
+
| `Enter` | 发送消息 |
|
|
247
|
+
| `Ctrl+Enter` | 换行 |
|
|
248
|
+
| `Tab` | 切换 Common/YOLO 模式(输入为空时) |
|
|
249
|
+
| `Ctrl+C` | 中断生成 |
|
|
250
|
+
|
|
251
|
+
## 为什么不用 MCP?
|
|
252
|
+
|
|
253
|
+
ChCode 故意不集成 MCP(Model Context Protocol)。**技能 + CLI 工具**的组合覆盖了 95%+ 的真实编程代理场景。技能通过中间件注入结构化、可复用的指令 — 比 MCP 服务器更简单、更快、更轻量。
|
|
254
|
+
|
|
255
|
+
## 架构
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
chcode/
|
|
259
|
+
├── cli.py # Typer CLI 入口
|
|
260
|
+
├── chat.py # REPL 主循环、斜杠命令、人工审核
|
|
261
|
+
├── agent_setup.py # 代理构建、中间件、模型重试与回退
|
|
262
|
+
├── config.py # 模型配置、Tavily、环境变量检测
|
|
263
|
+
├── display.py # Rich 渲染、流式输出、状态栏
|
|
264
|
+
├── prompts.py # 交互式提示(选择/确认/文本)
|
|
265
|
+
├── vision_config.py # 视觉模型配置管理
|
|
266
|
+
├── agents/
|
|
267
|
+
│ ├── definitions.py # 代理类型(explore、plan、general)
|
|
268
|
+
│ ├── loader.py # 从 .chat/agents/ 加载自定义代理
|
|
269
|
+
│ └── runner.py # 子代理执行(含中间件)
|
|
270
|
+
└── utils/
|
|
271
|
+
├── tools.py # 内置工具
|
|
272
|
+
├── enhanced_chat_openai.py # 扩展 ChatOpenAI,支持 reasoning
|
|
273
|
+
├── frontmatter.py # YAML Frontmatter 解析
|
|
274
|
+
├── git_checker.py # Git 可用性检查
|
|
275
|
+
├── git_manager.py # Git 检查点管理
|
|
276
|
+
├── json_utils.py # JSON 原子读写 + mtime 缓存
|
|
277
|
+
├── modelscope_ratelimit.py # ModelScope API 限额监控
|
|
278
|
+
├── multimodal.py # 多模态模型检测与媒体编码
|
|
279
|
+
├── session.py # 会话管理器(SQLite)
|
|
280
|
+
├── skill_loader.py # 技能发现与加载
|
|
281
|
+
├── skill_manager.py # 技能安装/删除 UI
|
|
282
|
+
├── text_utils.py # 消息内容文本提取
|
|
283
|
+
├── tool_result_pipeline.py # 输出截断与预算控制
|
|
284
|
+
└── shell/
|
|
285
|
+
├── provider.py # Shell 提供者抽象(Bash/PowerShell)
|
|
286
|
+
├── session.py # 交互式 Shell 会话
|
|
287
|
+
├── output.py # 输出捕获与临时文件
|
|
288
|
+
├── result.py # 执行结果数据类
|
|
289
|
+
└── semantics.py # 输出语义分析(错误检测等)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## 许可证
|
|
293
|
+
|
|
294
|
+
MIT
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chagent.png" alt="chagent prototype" width="600"/>
|
|
19
19
|
</details>
|
|
20
20
|
|
|
21
|
-
>
|
|
21
|
+
> 7000+ 行 Python 代码,14 个内置工具,完整会话持久化,Git 感知工作流。
|
|
22
22
|
|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
[English](
|
|
26
|
+
[English](README_en.md)
|
|
27
27
|
|
|
28
28
|
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chcode.png" alt="ChCode 主界面" width="800"/>
|
|
29
29
|
|
|
@@ -65,9 +65,10 @@
|
|
|
65
65
|
|
|
66
66
|
### 人工审核
|
|
67
67
|
|
|
68
|
-
- **Common 模式** — 每次工具调用需要确认,编辑操作显示 diff
|
|
69
|
-
- **YOLO 模式** —
|
|
68
|
+
- **Common 模式** — 每次工具调用需要确认,编辑操作显示 diff 预览。仅可使用 Explore 和 Plan 子代理
|
|
69
|
+
- **YOLO 模式** — 自动批准所有操作。所有子代理可用,包括 General-purpose
|
|
70
70
|
- 通过 `Tab` 键或 `/mode` 命令切换
|
|
71
|
+
- 切换模式时自动更新可用子代理列表
|
|
71
72
|
|
|
72
73
|
### 工作环境隔离
|
|
73
74
|
|
|
@@ -95,9 +96,11 @@
|
|
|
95
96
|
|
|
96
97
|
### 子代理系统
|
|
97
98
|
|
|
98
|
-
- 三种内置代理类型:**Explore**(代码库搜索,只读)、**Plan
|
|
99
|
-
-
|
|
99
|
+
- 三种内置代理类型:**Explore**(代码库搜索,只读)、**Plan**(架构设计,只读)、**General-purpose**(全能力编程)
|
|
100
|
+
- **模式感知可用性** — 普通模式:仅 Explore + Plan;YOLO 模式:全部三种 + 自定义代理
|
|
101
|
+
- **并行执行** — 同时启动多个代理处理独立任务,带实时旋转进度显示
|
|
100
102
|
- 子代理运行在**隔离上下文**中,保护主对话不被上下文污染
|
|
103
|
+
- 只读代理(Explore、Plan)具有 **bash 命令限制**,防止误修改
|
|
101
104
|
- **自定义代理** — 在 `.chat/agents/` 中定义自己的代理类型,配备专属工具和指令
|
|
102
105
|
|
|
103
106
|
### 技能系统
|
|
@@ -126,7 +129,7 @@
|
|
|
126
129
|
| `web_fetch` | 抓取 URL 内容并转换为 Markdown |
|
|
127
130
|
| `web_search` | 通过 [Tavily](https://tavily.com) 进行网络搜索 |
|
|
128
131
|
| `ask_user` | 单选、多选、批量问题与用户交互 |
|
|
129
|
-
| `agent` | 启动子代理(
|
|
132
|
+
| `agent` | 启动子代理(Explore、Plan、YOLO 模式下含 General-purpose、custom),支持并行执行 |
|
|
130
133
|
| `todo_write` | 结构化任务追踪,适用于复杂多步骤工作 |
|
|
131
134
|
| `vision` | 通过视觉模型分析图片和视频 |
|
|
132
135
|
|
|
@@ -215,20 +218,31 @@ chcode/
|
|
|
215
218
|
├── config.py # 模型配置、Tavily、环境变量检测
|
|
216
219
|
├── display.py # Rich 渲染、流式输出、状态栏
|
|
217
220
|
├── prompts.py # 交互式提示(选择/确认/文本)
|
|
218
|
-
├──
|
|
219
|
-
├── skill_manager.py # 技能安装/删除 UI
|
|
221
|
+
├── vision_config.py # 视觉模型配置管理
|
|
220
222
|
├── agents/
|
|
221
223
|
│ ├── definitions.py # 代理类型(explore、plan、general)
|
|
222
224
|
│ ├── loader.py # 从 .chat/agents/ 加载自定义代理
|
|
223
225
|
│ └── runner.py # 子代理执行(含中间件)
|
|
224
226
|
└── utils/
|
|
225
|
-
├── tools.py #
|
|
226
|
-
├── shell/ # Shell 抽象层(Bash/PowerShell 提供者)
|
|
227
|
+
├── tools.py # 内置工具
|
|
227
228
|
├── enhanced_chat_openai.py # 扩展 ChatOpenAI,支持 reasoning
|
|
229
|
+
├── frontmatter.py # YAML Frontmatter 解析
|
|
230
|
+
├── git_checker.py # Git 可用性检查
|
|
228
231
|
├── git_manager.py # Git 检查点管理
|
|
229
|
-
├──
|
|
232
|
+
├── json_utils.py # JSON 原子读写 + mtime 缓存
|
|
230
233
|
├── modelscope_ratelimit.py # ModelScope API 限额监控
|
|
231
|
-
|
|
234
|
+
├── multimodal.py # 多模态模型检测与媒体编码
|
|
235
|
+
├── session.py # 会话管理器(SQLite)
|
|
236
|
+
├── skill_loader.py # 技能发现与加载
|
|
237
|
+
├── skill_manager.py # 技能安装/删除 UI
|
|
238
|
+
├── text_utils.py # 消息内容文本提取
|
|
239
|
+
├── tool_result_pipeline.py # 输出截断与预算控制
|
|
240
|
+
└── shell/
|
|
241
|
+
├── provider.py # Shell 提供者抽象(Bash/PowerShell)
|
|
242
|
+
├── session.py # 交互式 Shell 会话
|
|
243
|
+
├── output.py # 输出捕获与临时文件
|
|
244
|
+
├── result.py # 执行结果数据类
|
|
245
|
+
└── semantics.py # 输出语义分析(错误检测等)
|
|
232
246
|
```
|
|
233
247
|
|
|
234
248
|
## 许可证
|
|
@@ -18,12 +18,12 @@ Terminal-based AI coding agent, built with LangChain + Typer + Rich.
|
|
|
18
18
|
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chagent.png" alt="chagent prototype" width="600"/>
|
|
19
19
|
</details>
|
|
20
20
|
|
|
21
|
-
>
|
|
21
|
+
> 7000+ lines of Python, 14 built-in tools, full session persistence, git-aware workflow.
|
|
22
22
|
|
|
23
23
|

|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
[中文文档](
|
|
26
|
+
[中文文档](README.md)
|
|
27
27
|
|
|
28
28
|
<img src="https://raw.githubusercontent.com/ScarletMercy/chcode/main/assets/chcode.png" alt="ChCode main interface" width="800"/>
|
|
29
29
|
|
|
@@ -65,9 +65,10 @@ Terminal-based AI coding agent, built with LangChain + Typer + Rich.
|
|
|
65
65
|
|
|
66
66
|
### Human-in-the-Loop
|
|
67
67
|
|
|
68
|
-
- **Common mode** — every tool call requires approval, with diff preview for edits
|
|
69
|
-
- **YOLO mode** — auto-approve everything
|
|
68
|
+
- **Common mode** — every tool call requires approval, with diff preview for edits. Only Explore and Plan sub-agents available.
|
|
69
|
+
- **YOLO mode** — auto-approve everything. All sub-agents available including General-purpose.
|
|
70
70
|
- Toggle with `Tab` key or `/mode` command
|
|
71
|
+
- Available sub-agents update dynamically when switching modes
|
|
71
72
|
|
|
72
73
|
### Work Environment Isolation
|
|
73
74
|
|
|
@@ -95,9 +96,11 @@ Terminal-based AI coding agent, built with LangChain + Typer + Rich.
|
|
|
95
96
|
|
|
96
97
|
### Sub-Agent System
|
|
97
98
|
|
|
98
|
-
- Three built-in agent types: **Explore** (codebase search, read-only), **Plan** (architecture design), **General** (full-capability coding)
|
|
99
|
-
- **
|
|
99
|
+
- Three built-in agent types: **Explore** (codebase search, read-only), **Plan** (architecture design, read-only), **General-purpose** (full-capability coding)
|
|
100
|
+
- **Mode-aware availability** — Common mode: Explore + Plan only; YOLO mode: all three + custom agents
|
|
101
|
+
- **Parallel execution** — launch multiple agents concurrently for independent tasks, with live spinner progress display
|
|
100
102
|
- Sub-agents run with **isolated context**, protecting the main conversation from context pollution
|
|
103
|
+
- Read-only agents (Explore, Plan) have **bash command restrictions** to prevent accidental modifications
|
|
101
104
|
- **Custom agents** — define your own agent types in `.chat/agents/` with dedicated tools and instructions
|
|
102
105
|
|
|
103
106
|
### Skill System
|
|
@@ -126,7 +129,7 @@ Terminal-based AI coding agent, built with LangChain + Typer + Rich.
|
|
|
126
129
|
| `web_fetch` | Fetch and convert URL content to markdown |
|
|
127
130
|
| `web_search` | Web search via [Tavily](https://tavily.com) |
|
|
128
131
|
| `ask_user` | Single-select, multi-select, batch questions for user interaction |
|
|
129
|
-
| `agent` | Launch sub-agents (
|
|
132
|
+
| `agent` | Launch sub-agents (Explore, Plan, General-purpose in YOLO mode, custom), supports parallel execution |
|
|
130
133
|
| `todo_write` | Structured task tracking for complex multi-step work |
|
|
131
134
|
| `vision` | Analyze images and videos via ModelScope vision models |
|
|
132
135
|
|
|
@@ -215,20 +218,31 @@ chcode/
|
|
|
215
218
|
├── config.py # Model config, Tavily, env detection
|
|
216
219
|
├── display.py # Rich rendering, streaming, status bar
|
|
217
220
|
├── prompts.py # Interactive prompts (select/confirm/text)
|
|
218
|
-
├──
|
|
219
|
-
├── skill_manager.py # Skill install/delete UI
|
|
221
|
+
├── vision_config.py # Vision model configuration
|
|
220
222
|
├── agents/
|
|
221
223
|
│ ├── definitions.py # Agent types (explore, plan, general)
|
|
222
224
|
│ ├── loader.py # Load custom agents from .chat/agents/
|
|
223
225
|
│ └── runner.py # Sub-agent execution with middleware
|
|
224
226
|
└── utils/
|
|
225
|
-
├── tools.py #
|
|
226
|
-
├── shell/ # Shell abstraction (Bash/PowerShell providers)
|
|
227
|
+
├── tools.py # Built-in tools
|
|
227
228
|
├── enhanced_chat_openai.py # Extended ChatOpenAI with reasoning support
|
|
229
|
+
├── frontmatter.py # YAML Frontmatter parser
|
|
230
|
+
├── git_checker.py # Git availability check
|
|
228
231
|
├── git_manager.py # Git checkpoint management
|
|
229
|
-
├──
|
|
232
|
+
├── json_utils.py # JSON atomic read/write + mtime cache
|
|
230
233
|
├── modelscope_ratelimit.py # ModelScope API rate limit monitor
|
|
231
|
-
|
|
234
|
+
├── multimodal.py # Multimodal model detection and media encoding
|
|
235
|
+
├── session.py # Session manager (SQLite)
|
|
236
|
+
├── skill_loader.py # Skill discovery and loading
|
|
237
|
+
├── skill_manager.py # Skill install/delete UI
|
|
238
|
+
├── text_utils.py # Message content text extraction
|
|
239
|
+
├── tool_result_pipeline.py # Output truncation and budget enforcement
|
|
240
|
+
└── shell/
|
|
241
|
+
├── provider.py # Shell provider abstraction (Bash/PowerShell)
|
|
242
|
+
├── session.py # Interactive shell session
|
|
243
|
+
├── output.py # Output capture and temp files
|
|
244
|
+
├── result.py # Execution result dataclass
|
|
245
|
+
└── semantics.py # Output semantic analysis (error detection etc.)
|
|
232
246
|
```
|
|
233
247
|
|
|
234
248
|
## License
|