@hncode/hncode 0.1.0 → 0.1.3
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.
- package/README.md +197 -330
- package/README_CN.md +186 -0
- package/package.json +10 -1
- package/TODO.md +0 -72
package/README.md
CHANGED
|
@@ -1,330 +1,197 @@
|
|
|
1
|
-
# hncode — AI Coding Agent CLI
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
A cyan-blue TUI coding agent inspired by kimi-code
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 🌟 Features
|
|
10
|
-
|
|
11
|
-
- **Cyan-blue TUI**: Raw terminal renderer for perfect Windows Terminal compatibility
|
|
12
|
-
- **Dual Protocol Support**: Works with both OpenAI-compatible APIs and Anthropic
|
|
13
|
-
- **Smart Context Management**: Auto-compaction at 85% usage, AI-summarized history retention
|
|
14
|
-
- **MCP-style Toolbelt**: Read, Write, Edit, Bash, Glob, Grep, TodoList, WebSearch, etc.
|
|
15
|
-
- **Plugin System**: Extend with custom tools, commands, and hooks
|
|
16
|
-
- **Session Persistence**: Resume conversations across sessions
|
|
17
|
-
- **Permission Modes**: Ask, YOLO, or Auto modes for different workflows
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 🚀 Installation
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
|
80
|
-
|
|
81
|
-
| `/
|
|
82
|
-
| `/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
###
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
// my-plugin.mjs
|
|
106
|
-
export function install(api) {
|
|
107
|
-
|
|
108
|
-
api.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
##
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
## ⚙️ 配置
|
|
202
|
-
|
|
203
|
-
创建 `~/.hncode/config.toml`:
|
|
204
|
-
|
|
205
|
-
```toml
|
|
206
|
-
default_model = "gpt-4o-mini"
|
|
207
|
-
|
|
208
|
-
[providers.openai]
|
|
209
|
-
base_url = "https://api.openai.com/v1"
|
|
210
|
-
api_key = "你的-api-key"
|
|
211
|
-
|
|
212
|
-
[models.gpt-4o-mini]
|
|
213
|
-
provider = "openai"
|
|
214
|
-
model = "gpt-4o-mini"
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
或使用环境变量:
|
|
218
|
-
```bash
|
|
219
|
-
export HNCODE_API_KEY="你的-key"
|
|
220
|
-
export HNCODE_PROVIDER="openai"
|
|
221
|
-
export HNCODE_MODEL="gpt-4o-mini"
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
## 📖 使用方法
|
|
227
|
-
|
|
228
|
-
### 基本命令
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
# 启动交互式会话
|
|
232
|
-
hncode
|
|
233
|
-
|
|
234
|
-
# 无头模式(单次提示)
|
|
235
|
-
hncode -p "修复 src/main.js 中的 bug"
|
|
236
|
-
|
|
237
|
-
# 继续之前的会话
|
|
238
|
-
hncode --continue
|
|
239
|
-
|
|
240
|
-
# 自动模式(不问问题)
|
|
241
|
-
hncode --auto
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### 斜杠命令
|
|
245
|
-
|
|
246
|
-
| 命令 | 描述 |
|
|
247
|
-
|------|------|
|
|
248
|
-
| `/compact [ratio]` | 压缩对话(AI 摘要 + 保留最近 20%) |
|
|
249
|
-
| `/model <name>` | 切换 LLM 模型 |
|
|
250
|
-
| `/sessions` | 浏览和恢复过往对话 |
|
|
251
|
-
| `/move <path>` | 将当前会话迁移到另一个目录 |
|
|
252
|
-
| `/auto` / `/ask` / `/yolo` | 切换权限模式 |
|
|
253
|
-
| `/plan` / `/focus` | 切换仅研究或完整编辑模式 |
|
|
254
|
-
| `/calm-mode` | 简洁回复(跳过叙述) |
|
|
255
|
-
| `/help` | 显示所有命令 |
|
|
256
|
-
|
|
257
|
-
### 高级功能
|
|
258
|
-
|
|
259
|
-
**Tab 补全**:
|
|
260
|
-
- 输入 `/` → 命令菜单
|
|
261
|
-
- 输入 `@` → 文件/文件夹补全
|
|
262
|
-
- 使用 Tab 导航,Enter 选择
|
|
263
|
-
|
|
264
|
-
**自动压缩**:
|
|
265
|
-
- 在 85% 上下文窗口时触发
|
|
266
|
-
- AI 摘要被丢弃的消息
|
|
267
|
-
- 保留最近 20% 的对话
|
|
268
|
-
|
|
269
|
-
**插件系统**:
|
|
270
|
-
将插件放在 `~/.hncode/plugins/`:
|
|
271
|
-
```javascript
|
|
272
|
-
// my-plugin.mjs
|
|
273
|
-
export function install(api) {
|
|
274
|
-
api.registerTool({ /* ... */ });
|
|
275
|
-
api.registerCommand({ name: 'mycmd', run: () => {} });
|
|
276
|
-
}
|
|
277
|
-
export default { name: 'my-plugin', version: '1.0.0' };
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
---
|
|
281
|
-
|
|
282
|
-
## 🛠 内置工具
|
|
283
|
-
|
|
284
|
-
- `Read`, `Write`, `Edit` - 文件操作
|
|
285
|
-
- `Bash` - 执行 Shell 命令
|
|
286
|
-
- `Glob`, `Grep` - 搜索文件
|
|
287
|
-
- `TodoList`, `TaskOutput` - 任务管理
|
|
288
|
-
- `FetchURL`, `WebSearch` - 网络访问
|
|
289
|
-
- `ReadMediaFile`, `FileLines` - 媒体处理
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
## 🎨 主题
|
|
294
|
-
|
|
295
|
-
支持的 theme:`auto`、`dark`、`light` 或自定义 RGB 颜色。
|
|
296
|
-
|
|
297
|
-
通过配置设置:
|
|
298
|
-
```toml
|
|
299
|
-
theme = "dark"
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
或在 TUI 中使用 `/theme <name>`。
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## 🤝 贡献
|
|
307
|
-
|
|
308
|
-
这个项目是通过 Vibe Coding 创建的。虽然它可能不够完美,但我欢迎您的反馈!
|
|
309
|
-
|
|
310
|
-
**欢迎:**
|
|
311
|
-
- 提交问题报告 bug 或提出建议
|
|
312
|
-
- Fork 并创建拉取请求
|
|
313
|
-
- 分享您使用 hncode 的体验
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## 🙏 致谢
|
|
318
|
-
|
|
319
|
-
hncode 从以下几个优秀项目中汲取了灵感:
|
|
320
|
-
|
|
321
|
-
- **[kimi-code-cli](https://github.com/mckaymatt/kimi-code-cli)** - 原始的青色蓝调终端界面 AI 编程助手,启发了本项目的设计和理念
|
|
322
|
-
- **[claude-code](https://github.com/anthropics/claude-code)** - 对话流程和工具交互模式
|
|
323
|
-
|
|
324
|
-
特别感谢这些项目背后的社区,它们推动了 AI 辅助编程的边界。
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
## 📄 许可证
|
|
329
|
-
|
|
330
|
-
MIT License - 详见 LICENSE 文件。
|
|
1
|
+
# hncode — AI Coding Agent CLI
|
|
2
|
+
|
|
3
|
+
> **This is a product of my Vibe Coding session. It may not be perfect, but if you have any suggestions, feel free to open an issue.**
|
|
4
|
+
|
|
5
|
+
A cyan-blue TUI coding agent inspired by [Kimi Code CLI](https://github.com/MoonshotAI/kimi-code), with OpenAI + Anthropic support, MCP-style toolbelt, and intelligent context management.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🌟 Features
|
|
10
|
+
|
|
11
|
+
- **Cyan-blue TUI**: Raw terminal renderer for perfect Windows Terminal compatibility
|
|
12
|
+
- **Dual Protocol Support**: Works with both OpenAI-compatible APIs and Anthropic
|
|
13
|
+
- **Smart Context Management**: Auto-compaction at 85% usage, AI-summarized history retention
|
|
14
|
+
- **MCP-style Toolbelt**: Read, Write, Edit, Bash, Glob, Grep, TodoList, WebSearch, etc.
|
|
15
|
+
- **Plugin System**: Extend with custom tools, commands, and hooks
|
|
16
|
+
- **Session Persistence**: Resume conversations across sessions
|
|
17
|
+
- **Permission Modes**: Ask, YOLO, or Auto modes for different workflows
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🚀 Installation
|
|
22
|
+
|
|
23
|
+
### Global Installation (Recommended)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g @hncode/hncode
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then run:
|
|
30
|
+
```bash
|
|
31
|
+
hncode
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using npx (No installation required)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx @hncode/hncode
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This will download and run the latest version without installing it globally.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ⚙️ Configuration
|
|
45
|
+
|
|
46
|
+
Create `~/.hncode/config.toml`:
|
|
47
|
+
|
|
48
|
+
```toml
|
|
49
|
+
default_model = "gpt-4o-mini"
|
|
50
|
+
|
|
51
|
+
[providers.openai]
|
|
52
|
+
base_url = "https://api.openai.com/v1"
|
|
53
|
+
api_key = "your-api-key-here"
|
|
54
|
+
|
|
55
|
+
[models.gpt-4o-mini]
|
|
56
|
+
provider = "openai"
|
|
57
|
+
model = "gpt-4o-mini"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or set environment variables:
|
|
61
|
+
```bash
|
|
62
|
+
export HNCODE_API_KEY="your-key"
|
|
63
|
+
export HNCODE_PROVIDER="openai"
|
|
64
|
+
export HNCODE_MODEL="gpt-4o-mini"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 📖 Usage
|
|
70
|
+
|
|
71
|
+
### Basic Commands
|
|
72
|
+
|
|
73
|
+
| Command | Description |
|
|
74
|
+
|---------|-------------|
|
|
75
|
+
| `/compact [ratio]` | Compact conversation (AI summary + keep last 20%) |
|
|
76
|
+
| `/model <name>` | Switch LLM model |
|
|
77
|
+
| `/sessions` | Browse and resume past conversations |
|
|
78
|
+
| `/move <path>` | Move current session to another directory |
|
|
79
|
+
| `/auto` / `/ask` / `/yolo` | Toggle permission mode |
|
|
80
|
+
| `/plan` / `/focus` | Toggle research-only or full-edit mode |
|
|
81
|
+
| `/calm-mode` | Terse replies (skip narration) |
|
|
82
|
+
| `/help` | Show all commands |
|
|
83
|
+
|
|
84
|
+
### Tab Completion
|
|
85
|
+
|
|
86
|
+
- Type `/` → command menu
|
|
87
|
+
- Type `@` → file/folder completion
|
|
88
|
+
- Use Tab to navigate, Enter to select
|
|
89
|
+
|
|
90
|
+
### Auto Compaction
|
|
91
|
+
|
|
92
|
+
- Triggers automatically when context usage reaches 85%
|
|
93
|
+
- AI summarizes dropped messages instead of simply deleting them
|
|
94
|
+
- Keeps the most recent 20% of conversation to maintain context coherence
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🔧 Plugin System
|
|
99
|
+
|
|
100
|
+
### Creating Plugins
|
|
101
|
+
|
|
102
|
+
Create `.js` or `.mjs` files in `~/.hncode/plugins/`:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
// my-plugin.mjs
|
|
106
|
+
export function install(api) {
|
|
107
|
+
// Register new tool
|
|
108
|
+
api.registerTool({
|
|
109
|
+
name: 'MyTool',
|
|
110
|
+
description: '...',
|
|
111
|
+
parameters: { /* schema */ },
|
|
112
|
+
async execute(args, ctx) { return result; }
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Register command
|
|
116
|
+
api.registerCommand({
|
|
117
|
+
name: 'mycmd',
|
|
118
|
+
description: '...',
|
|
119
|
+
run: (arg, ctx) => { /* ... */ }
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Register hook
|
|
123
|
+
api.registerHook('onTurnEnd', (turnInfo) => { /* ... */ });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default { name: 'my-plugin', version: '1.0.0' };
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### View Loaded Plugins
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
hncode /plugins
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 🛠 Tools
|
|
138
|
+
|
|
139
|
+
Built-in tools include:
|
|
140
|
+
- `Read`, `Write`, `Edit` - File operations
|
|
141
|
+
- `Bash` - Execute shell commands
|
|
142
|
+
- `Glob`, `Grep` - Search files
|
|
143
|
+
- `TodoList`, `TaskOutput` - Task management
|
|
144
|
+
- `FetchURL`, `WebSearch` - Internet access
|
|
145
|
+
- `ReadMediaFile`, `FileLines` - Media handling
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 🎨 Themes
|
|
150
|
+
|
|
151
|
+
Supported themes: `auto`, `dark`, `light`, or custom RGB colors.
|
|
152
|
+
|
|
153
|
+
Set via config:
|
|
154
|
+
```toml
|
|
155
|
+
theme = "dark"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Or use `/theme <name>` in TUI.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 🤝 Contributing
|
|
163
|
+
|
|
164
|
+
This project was created through Vibe Coding. While it may not be perfect, I welcome your feedback!
|
|
165
|
+
|
|
166
|
+
**Feel free to:**
|
|
167
|
+
- Submit issues for bugs or suggestions
|
|
168
|
+
- Fork and create pull requests
|
|
169
|
+
- Share your experience using hncode
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 🙏 Acknowledgments
|
|
174
|
+
|
|
175
|
+
hncode draws inspiration from several excellent projects:
|
|
176
|
+
|
|
177
|
+
- **[Kimi Code CLI](https://github.com/MoonshotAI/kimi-code)** - The original cyan-blue TUI coding agent that inspired this project's design and approach
|
|
178
|
+
- **[Claude Code](https://github.com/anthropics/claude-code)** - The conversation flow and tool interaction patterns
|
|
179
|
+
|
|
180
|
+
Special thanks to the communities behind these projects for pushing the boundaries of AI-assisted coding.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 📄 License
|
|
185
|
+
|
|
186
|
+
This project is licensed under the [GNU General Public License v3.0](LICENSE).
|
|
187
|
+
|
|
188
|
+
**In short:**
|
|
189
|
+
1. ✅ You can freely use, modify, and share this code
|
|
190
|
+
2. ✅ Must retain author attribution (NiceHello666) and link back to this repository
|
|
191
|
+
3. ❌ Cannot be used for commercial purposes (e.g., selling, as part of paid products)
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
**NPM Package**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
196
|
+
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|
|
197
|
+
**Chinese Version**: [README_CN.md](./README_CN.md)
|
package/README_CN.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# hncode — AI 编程助手命令行工具
|
|
2
|
+
|
|
3
|
+
> **这是我 Vibe Coding 的产物,可能不是特别好,但是如果有什么建议的话也欢迎提 issue**
|
|
4
|
+
|
|
5
|
+
一个基于命令行终端的 AI 编程助手,灵感源自 [Kimi Code CLI](https://github.com/MoonshotAI/kimi-code)。它提供青色蓝调 (Cyan-blue) 的 TUI 界面,支持 OpenAI 和 Anthropic 双协议,配备 MCP 风格的工具集和智能上下文管理。
|
|
6
|
+
|
|
7
|
+
## 🌟 核心特性
|
|
8
|
+
|
|
9
|
+
- **原生 TUI 渲染**: 使用原始终端序列号渲染,完美兼容 Windows Terminal,解决 blessed 等库在 Windows 上的兼容性问题
|
|
10
|
+
- **双协议支持**: 同时支持 OpenAI-compatible API 和 Anthropic API
|
|
11
|
+
- **智能上下文管理**:
|
|
12
|
+
- 85% 使用率时自动触发压缩
|
|
13
|
+
- AI 摘要保留的历史对话,而非简单丢弃
|
|
14
|
+
- 手动 `/compact` 命令支持自定义压缩比例
|
|
15
|
+
- **MCP 风格工具集**: Read, Write, Edit, Bash, Glob, Grep, TodoList, WebSearch, FetchURL 等
|
|
16
|
+
- **插件系统**: 可扩展的工具、命令和生命周期钩子
|
|
17
|
+
- **会话持久化**: 跨会话恢复对话
|
|
18
|
+
- **权限模式**: Ask, YOLO, Auto 三种工作流模式
|
|
19
|
+
|
|
20
|
+
## 🚀 安装
|
|
21
|
+
|
|
22
|
+
### 全局安装(推荐)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @hncode/hncode
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
然后运行:
|
|
29
|
+
```bash
|
|
30
|
+
hncode
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 使用 npx(无需安装)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx @hncode/hncode
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
这将下载并运行最新版本,而无需全局安装。
|
|
40
|
+
|
|
41
|
+
### 本地开发安装
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install @hncode/hncode
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## ⚙️ 配置
|
|
48
|
+
|
|
49
|
+
创建 `~/.hncode/config.toml`:
|
|
50
|
+
|
|
51
|
+
```toml
|
|
52
|
+
default_model = "gpt-4o-mini"
|
|
53
|
+
|
|
54
|
+
[providers.openai]
|
|
55
|
+
base_url = "https://api.openai.com/v1"
|
|
56
|
+
api_key = "your-api-key-here"
|
|
57
|
+
|
|
58
|
+
[models.gpt-4o-mini]
|
|
59
|
+
provider = "openai"
|
|
60
|
+
model = "gpt-4o-mini"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
或使用环境变量:
|
|
64
|
+
```bash
|
|
65
|
+
export HNCODE_API_KEY="your-key"
|
|
66
|
+
export HNCODE_PROVIDER="openai"
|
|
67
|
+
export HNCODE_MODEL="gpt-4o-mini"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 📖 使用
|
|
71
|
+
|
|
72
|
+
### 基本命令
|
|
73
|
+
|
|
74
|
+
| 命令 | 描述 |
|
|
75
|
+
|------|------|
|
|
76
|
+
| `/compact [ratio]` | 压缩对话(AI 摘要 + 保留最近 20%) |
|
|
77
|
+
| `/model <name>` | 切换 LLM 模型 |
|
|
78
|
+
| `/sessions` | 浏览和恢复过往对话 |
|
|
79
|
+
| `/move <path>` | 将当前会话迁移到另一个目录 |
|
|
80
|
+
| `/auto` / `/ask` / `/yolo` | 切换权限模式 |
|
|
81
|
+
| `/plan` / `/focus` | 切换仅研究或完整编辑模式 |
|
|
82
|
+
| `/calm-mode` | 简洁回复(跳过叙述) |
|
|
83
|
+
| `/help` | 显示所有命令 |
|
|
84
|
+
|
|
85
|
+
### Tab 补全
|
|
86
|
+
|
|
87
|
+
- 输入 `/` → 命令菜单
|
|
88
|
+
- 输入 `@` → 文件/文件夹补全
|
|
89
|
+
- 使用 Tab 导航,Enter 选择
|
|
90
|
+
|
|
91
|
+
### 自动压缩
|
|
92
|
+
|
|
93
|
+
- 当上下文使用率达到 85% 时自动触发
|
|
94
|
+
- AI 会摘要被丢弃的消息,而不是简单删除
|
|
95
|
+
- 保留最近的 20% 对话以保持上下文连贯性
|
|
96
|
+
|
|
97
|
+
## 🔧 插件系统
|
|
98
|
+
|
|
99
|
+
### 创建插件
|
|
100
|
+
|
|
101
|
+
在 `~/.hncode/plugins/` 目录下创建 `.js` 或 `.mjs` 文件:
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
// my-plugin.mjs
|
|
105
|
+
export function install(api) {
|
|
106
|
+
// 注册新工具
|
|
107
|
+
api.registerTool({
|
|
108
|
+
name: 'MyTool',
|
|
109
|
+
description: '...',
|
|
110
|
+
parameters: { /* schema */ },
|
|
111
|
+
async execute(args, ctx) { return result; }
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// 注册命令
|
|
115
|
+
api.registerCommand({
|
|
116
|
+
name: 'mycmd',
|
|
117
|
+
description: '...',
|
|
118
|
+
run: (arg, ctx) => { /* ... */ }
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// 注册钩子
|
|
122
|
+
api.registerHook('onTurnEnd', (turnInfo) => { /* ... */ });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default { name: 'my-plugin', version: '1.0.0' };
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 查看已加载插件
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
hncode /plugins
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 🛠 工具集
|
|
135
|
+
|
|
136
|
+
内置工具包括:
|
|
137
|
+
- `Read`, `Write`, `Edit` - 文件操作
|
|
138
|
+
- `Bash` - 执行 Shell 命令
|
|
139
|
+
- `Glob`, `Grep` - 搜索文件
|
|
140
|
+
- `TodoList`, `TaskOutput` - 任务管理
|
|
141
|
+
- `FetchURL`, `WebSearch` - 网络访问
|
|
142
|
+
- `ReadMediaFile`, `FileLines` - 媒体处理
|
|
143
|
+
|
|
144
|
+
## 🎨 主题
|
|
145
|
+
|
|
146
|
+
支持的 theme: `auto`, `dark`, `light`, 或自定义 RGB 颜色。
|
|
147
|
+
|
|
148
|
+
通过配置设置:
|
|
149
|
+
```toml
|
|
150
|
+
theme = "dark"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
或在 TUI 中使用 `/theme <name>`。
|
|
154
|
+
|
|
155
|
+
## 🤝 贡献
|
|
156
|
+
|
|
157
|
+
这个项目是通过 Vibe Coding 创建的。虽然它可能不够完美,但我欢迎您的反馈!
|
|
158
|
+
|
|
159
|
+
**欢迎:**
|
|
160
|
+
- 提交问题报告 bug 或提出建议
|
|
161
|
+
- Fork 并创建拉取请求
|
|
162
|
+
- 分享您使用 hncode 的体验
|
|
163
|
+
|
|
164
|
+
## 🙏 致谢
|
|
165
|
+
|
|
166
|
+
hncode 从以下几个优秀项目中汲取了灵感:
|
|
167
|
+
|
|
168
|
+
- **[Kimi Code CLI](https://github.com/MoonshotAI/kimi-code)** - 原始的青色蓝调终端界面 AI 编程助手,启发了本项目的设计和理念
|
|
169
|
+
- **[Claude Code](https://github.com/anthropics/claude-code)** - 对话流程和工具交互模式
|
|
170
|
+
|
|
171
|
+
特别感谢这些项目背后的社区,它们推动了 AI 辅助编程的边界。
|
|
172
|
+
|
|
173
|
+
## 📄 许可证
|
|
174
|
+
|
|
175
|
+
本项目的许可受 [GNU General Public License v3.0](LICENSE) 保护。
|
|
176
|
+
|
|
177
|
+
**简单来说:**
|
|
178
|
+
1. ✅ 你可以自由使用、修改和分享此代码
|
|
179
|
+
2. ✅ 必须保留原作者署名(NiceHello666)并链接回此仓库
|
|
180
|
+
3. ❌ 不得用于商业目的(例如出售、作为付费产品的一部分)
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
**NPM 包**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
185
|
+
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|
|
186
|
+
**English Version**: [README.md](./README.md)
|
package/package.json
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hncode/hncode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "hncode — A cyan-blue TUI AI coding agent with zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"hncode": "bin/hncode"
|
|
8
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md",
|
|
15
|
+
"README_CN.md",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
9
18
|
"scripts": {
|
|
10
19
|
"preinstall": "node bin/preinstall.js",
|
|
11
20
|
"install": "node bin/install.js"
|
package/TODO.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# hncode TODO
|
|
2
|
-
|
|
3
|
-
## Fixed
|
|
4
|
-
|
|
5
|
-
- [x] **Fix `args is not defined` in `/compact` command** — `src/tui.js:2508`
|
|
6
|
-
The `compact` case referenced an undefined variable `args`. Removed the
|
|
7
|
-
redundant `const raw = args.trim();` line; the function's existing
|
|
8
|
-
`const raw = (arg || '').trim();` (line ~2142) is used instead.
|
|
9
|
-
|
|
10
|
-
- [x] **Fix `/model` picker overflow above screen** — `src/tui.js:~1617-1620`
|
|
11
|
-
The picker's `overhead` calculation did not account for footer rows (the
|
|
12
|
-
"Thinking" options in the `/model` picker). Now includes `footerRows`
|
|
13
|
-
(0 or 2) in the overhead. Also added `MAX_PICKER = 12` constant to cap
|
|
14
|
-
visible items.
|
|
15
|
-
|
|
16
|
-
- [x] **Add `MAX_PICKER = 12` constant** — `src/tui.js:111`
|
|
17
|
-
Caps the number of visible picker items at 12, similar to `MAX_MENU = 6`.
|
|
18
|
-
|
|
19
|
-
- [x] **Reduce right-side width by 1 for queue panel and user message boxes**
|
|
20
|
-
- Queue panel text width: `w - 4` → `w - 6` (`src/tui.js:711`)
|
|
21
|
-
- User/queued message box width: `boxW = innerW` → `boxW = innerW - 2`
|
|
22
|
-
(`src/tui.js:1213`)
|
|
23
|
-
|
|
24
|
-
- [x] **Fix steer format: render as `steer` role (no box)** — `src/tui.js:3774`
|
|
25
|
-
Steered messages were added as `user` role (with a box). Changed to
|
|
26
|
-
`addChat({ role: 'steer', text })`. The `steer` role has no box, is
|
|
27
|
-
yellow, and shows the `❯` marker.
|
|
28
|
-
|
|
29
|
-
- [x] **Rename `/cool-mode` to `/calm-mode`** — `src/tui.js, src/config.js`
|
|
30
|
-
- Command: `cool-mode` → `calm-mode`
|
|
31
|
-
- Config key: `cool_mode` → `calm_mode`
|
|
32
|
-
- Config property: `coolMode` → `calmMode`
|
|
33
|
-
- Env var: `HNCODE_COOL_MODE` → `HNCODE_CALM_MODE`
|
|
34
|
-
- Constant: `COOL_MODE_INSTRUCTION` → `CALM_MODE_INSTRUCTION`
|
|
35
|
-
- Backward compat: legacy `cool_mode` key still read in config.js
|
|
36
|
-
|
|
37
|
-
- [x] **Fix `setConfigString is not defined` error** — `src/tui.js:27`
|
|
38
|
-
`setConfigString` was used but never imported from `./config.js`.
|
|
39
|
-
Added to the import statement.
|
|
40
|
-
|
|
41
|
-
- [x] **Fix editor ESC/arrow keys when running** — `src/tui.js:~3957`
|
|
42
|
-
When the editor (from `/set-system-prompt`) is open and a turn is running,
|
|
43
|
-
ESC interrupted the agent instead of closing the editor. Fixed by adding
|
|
44
|
-
`state.editor` to the `overlayOpen` check.
|
|
45
|
-
|
|
46
|
-
- [x] **Fix scroll jumping to session beginning** — `src/tui.js:~4772`
|
|
47
|
-
`anchorScroll()` used `state._anchorRows || 0` as the previous row count,
|
|
48
|
-
which caused a massive scroll jump on the first call after scrolling up.
|
|
49
|
-
Changed to only adjust scroll when `_anchorRows` is previously set.
|
|
50
|
-
|
|
51
|
-
- [x] **Add category tabs to `/model` picker** — `src/tui.js`
|
|
52
|
-
- Added `pickerCategory` and `pickerCategories` state fields
|
|
53
|
-
- `pickerFiltered()` now filters by active category
|
|
54
|
-
- Category tabs rendered above the item list ("All" + provider names)
|
|
55
|
-
- Tab key cycles through categories
|
|
56
|
-
- `/model` picker items now have a `category` field (the provider name)
|
|
57
|
-
- Hint updated to mention Tab for category switching
|
|
58
|
-
|
|
59
|
-
- [x] **Composer text selection via mouse drag** — `src/tui.js`
|
|
60
|
-
- Added `composerSel` state for selection range
|
|
61
|
-
- Mousedown on composer rows stores position for drag selection
|
|
62
|
-
- Mousemove extends the selection (highlighted in yellow)
|
|
63
|
-
- Mouseup clears the mousedown state
|
|
64
|
-
- Context menu includes "Copy" for composer selection
|
|
65
|
-
- Ctrl+Shift+C copies composer selection (before falling back to last answer)
|
|
66
|
-
- All key handlers (typing, arrows, backspace, etc.) clear the selection
|
|
67
|
-
- Added `highlightSelection()` helper function
|
|
68
|
-
|
|
69
|
-
- [x] **Fix `/provider` Enter to edit, remove Ctrl+E** — `src/tui.js`
|
|
70
|
-
- Enter on a regular provider now opens the edit form (was: selects provider)
|
|
71
|
-
- Ctrl+E handler removed from the generic key handler
|
|
72
|
-
- Hint updated: "Enter edit" instead of "Enter select · Ctrl+E edit"
|