@hncode/hncode 0.1.1 → 0.1.4
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/LICENSE +219 -219
- package/README.md +198 -340
- package/README_CN.md +187 -0
- package/bin/install.js +95 -95
- package/bin/preinstall.js +41 -41
- package/package.json +35 -34
- package/src/tui.js +19 -3
package/README.md
CHANGED
|
@@ -1,340 +1,198 @@
|
|
|
1
|
-
# hncode — AI Coding Agent CLI
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
export
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
api.registerCommand({
|
|
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
|
-
```bash
|
|
201
|
-
npm install -g hncode
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
或直接使用:
|
|
205
|
-
```bash
|
|
206
|
-
npx hncode
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## ⚙️ 配置
|
|
212
|
-
|
|
213
|
-
创建 `~/.hncode/config.toml`:
|
|
214
|
-
|
|
215
|
-
```toml
|
|
216
|
-
default_model = "gpt-4o-mini"
|
|
217
|
-
|
|
218
|
-
[providers.openai]
|
|
219
|
-
base_url = "https://api.openai.com/v1"
|
|
220
|
-
api_key = "你的-api-key"
|
|
221
|
-
|
|
222
|
-
[models.gpt-4o-mini]
|
|
223
|
-
provider = "openai"
|
|
224
|
-
model = "gpt-4o-mini"
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
或使用环境变量:
|
|
228
|
-
```bash
|
|
229
|
-
export HNCODE_API_KEY="你的-key"
|
|
230
|
-
export HNCODE_PROVIDER="openai"
|
|
231
|
-
export HNCODE_MODEL="gpt-4o-mini"
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
## 📖 使用方法
|
|
237
|
-
|
|
238
|
-
### 基本命令
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
# 启动交互式会话
|
|
242
|
-
hncode
|
|
243
|
-
|
|
244
|
-
# 无头模式(单次提示)
|
|
245
|
-
hncode -p "修复 src/main.js 中的 bug"
|
|
246
|
-
|
|
247
|
-
# 继续之前的会话
|
|
248
|
-
hncode --continue
|
|
249
|
-
|
|
250
|
-
# 自动模式(不问问题)
|
|
251
|
-
hncode --auto
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### 斜杠命令
|
|
255
|
-
|
|
256
|
-
| 命令 | 描述 |
|
|
257
|
-
|------|------|
|
|
258
|
-
| `/compact [ratio]` | 压缩对话(AI 摘要 + 保留最近 20%) |
|
|
259
|
-
| `/model <name>` | 切换 LLM 模型 |
|
|
260
|
-
| `/sessions` | 浏览和恢复过往对话 |
|
|
261
|
-
| `/move <path>` | 将当前会话迁移到另一个目录 |
|
|
262
|
-
| `/auto` / `/ask` / `/yolo` | 切换权限模式 |
|
|
263
|
-
| `/plan` / `/focus` | 切换仅研究或完整编辑模式 |
|
|
264
|
-
| `/calm-mode` | 简洁回复(跳过叙述) |
|
|
265
|
-
| `/help` | 显示所有命令 |
|
|
266
|
-
|
|
267
|
-
### 高级功能
|
|
268
|
-
|
|
269
|
-
**Tab 补全**:
|
|
270
|
-
- 输入 `/` → 命令菜单
|
|
271
|
-
- 输入 `@` → 文件/文件夹补全
|
|
272
|
-
- 使用 Tab 导航,Enter 选择
|
|
273
|
-
|
|
274
|
-
**自动压缩**:
|
|
275
|
-
- 在 85% 上下文窗口时触发
|
|
276
|
-
- AI 摘要被丢弃的消息
|
|
277
|
-
- 保留最近 20% 的对话
|
|
278
|
-
|
|
279
|
-
**插件系统**:
|
|
280
|
-
将插件放在 `~/.hncode/plugins/`:
|
|
281
|
-
```javascript
|
|
282
|
-
// my-plugin.mjs
|
|
283
|
-
export function install(api) {
|
|
284
|
-
api.registerTool({ /* ... */ });
|
|
285
|
-
api.registerCommand({ name: 'mycmd', run: () => {} });
|
|
286
|
-
}
|
|
287
|
-
export default { name: 'my-plugin', version: '1.0.0' };
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## 🛠 内置工具
|
|
293
|
-
|
|
294
|
-
- `Read`, `Write`, `Edit` - 文件操作
|
|
295
|
-
- `Bash` - 执行 Shell 命令
|
|
296
|
-
- `Glob`, `Grep` - 搜索文件
|
|
297
|
-
- `TodoList`, `TaskOutput` - 任务管理
|
|
298
|
-
- `FetchURL`, `WebSearch` - 网络访问
|
|
299
|
-
- `ReadMediaFile`, `FileLines` - 媒体处理
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
## 🎨 主题
|
|
304
|
-
|
|
305
|
-
支持的 theme:`auto`、`dark`、`light` 或自定义 RGB 颜色。
|
|
306
|
-
|
|
307
|
-
通过配置设置:
|
|
308
|
-
```toml
|
|
309
|
-
theme = "dark"
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
或在 TUI 中使用 `/theme <name>`。
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
|
-
## 🤝 贡献
|
|
317
|
-
|
|
318
|
-
这个项目是通过 Vibe Coding 创建的。虽然它可能不够完美,但我欢迎您的反馈!
|
|
319
|
-
|
|
320
|
-
**欢迎:**
|
|
321
|
-
- 提交问题报告 bug 或提出建议
|
|
322
|
-
- Fork 并创建拉取请求
|
|
323
|
-
- 分享您使用 hncode 的体验
|
|
324
|
-
|
|
325
|
-
---
|
|
326
|
-
|
|
327
|
-
## 🙏 致谢
|
|
328
|
-
|
|
329
|
-
hncode 从以下几个优秀项目中汲取了灵感:
|
|
330
|
-
|
|
331
|
-
- **[kimi-code-cli](https://github.com/mckaymatt/kimi-code-cli)** - 原始的青色蓝调终端界面 AI 编程助手,启发了本项目的设计和理念
|
|
332
|
-
- **[claude-code](https://github.com/anthropics/claude-code)** - 对话流程和工具交互模式
|
|
333
|
-
|
|
334
|
-
特别感谢这些项目背后的社区,它们推动了 AI 辅助编程的边界。
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## 📄 许可证
|
|
339
|
-
|
|
340
|
-
MIT License - 详见 LICENSE 文件。
|
|
1
|
+
# hncode — AI Coding Agent CLI
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README_CN.md)
|
|
4
|
+
|
|
5
|
+
> **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.**
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🌟 Features
|
|
12
|
+
|
|
13
|
+
- **Cyan-blue TUI**: Raw terminal renderer for perfect Windows Terminal compatibility
|
|
14
|
+
- **Dual Protocol Support**: Works with both OpenAI-compatible APIs and Anthropic
|
|
15
|
+
- **Smart Context Management**: Auto-compaction at 85% usage, AI-summarized history retention
|
|
16
|
+
- **MCP-style Toolbelt**: Read, Write, Edit, Bash, Glob, Grep, TodoList, WebSearch, etc.
|
|
17
|
+
- **Plugin System**: Extend with custom tools, commands, and hooks
|
|
18
|
+
- **Session Persistence**: Resume conversations across sessions
|
|
19
|
+
- **Permission Modes**: Ask, YOLO, or Auto modes for different workflows
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🚀 Installation
|
|
24
|
+
|
|
25
|
+
### Global Installation (Recommended)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @hncode/hncode
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then run:
|
|
32
|
+
```bash
|
|
33
|
+
hncode
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Using npx (No installation required)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @hncode/hncode
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This will download and run the latest version without installing it globally.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ⚙️ Configuration
|
|
47
|
+
|
|
48
|
+
Create `~/.hncode/config.toml`:
|
|
49
|
+
|
|
50
|
+
```toml
|
|
51
|
+
default_model = "gpt-4o-mini"
|
|
52
|
+
|
|
53
|
+
[providers.openai]
|
|
54
|
+
base_url = "https://api.openai.com/v1"
|
|
55
|
+
api_key = "your-api-key-here"
|
|
56
|
+
|
|
57
|
+
[models.gpt-4o-mini]
|
|
58
|
+
provider = "openai"
|
|
59
|
+
model = "gpt-4o-mini"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or set environment variables:
|
|
63
|
+
```bash
|
|
64
|
+
export HNCODE_API_KEY="your-key"
|
|
65
|
+
export HNCODE_PROVIDER="openai"
|
|
66
|
+
export HNCODE_MODEL="gpt-4o-mini"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 📖 Usage
|
|
72
|
+
|
|
73
|
+
### Basic Commands
|
|
74
|
+
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| `/compact [ratio]` | Compact conversation (AI summary + keep last 20%) |
|
|
78
|
+
| `/model <name>` | Switch LLM model |
|
|
79
|
+
| `/sessions` | Browse and resume past conversations |
|
|
80
|
+
| `/move <path>` | Move current session to another directory |
|
|
81
|
+
| `/auto` / `/ask` / `/yolo` | Toggle permission mode |
|
|
82
|
+
| `/plan` / `/focus` | Toggle research-only or full-edit mode |
|
|
83
|
+
| `/calm-mode` | Terse replies (skip narration) |
|
|
84
|
+
| `/help` | Show all commands |
|
|
85
|
+
|
|
86
|
+
### Tab Completion
|
|
87
|
+
|
|
88
|
+
- Type `/` → command menu
|
|
89
|
+
- Type `@` → file/folder completion
|
|
90
|
+
- Use Tab to navigate, Enter to select
|
|
91
|
+
|
|
92
|
+
### Auto Compaction
|
|
93
|
+
|
|
94
|
+
- Triggers automatically when context usage reaches 85%
|
|
95
|
+
- AI summarizes dropped messages instead of simply deleting them
|
|
96
|
+
- Keeps the most recent 20% of conversation to maintain context coherence
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🔧 Plugin System
|
|
101
|
+
|
|
102
|
+
### Creating Plugins
|
|
103
|
+
|
|
104
|
+
Create `.js` or `.mjs` files in `~/.hncode/plugins/`:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
// my-plugin.mjs
|
|
108
|
+
export function install(api) {
|
|
109
|
+
// Register new tool
|
|
110
|
+
api.registerTool({
|
|
111
|
+
name: 'MyTool',
|
|
112
|
+
description: '...',
|
|
113
|
+
parameters: { /* schema */ },
|
|
114
|
+
async execute(args, ctx) { return result; }
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Register command
|
|
118
|
+
api.registerCommand({
|
|
119
|
+
name: 'mycmd',
|
|
120
|
+
description: '...',
|
|
121
|
+
run: (arg, ctx) => { /* ... */ }
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Register hook
|
|
125
|
+
api.registerHook('onTurnEnd', (turnInfo) => { /* ... */ });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default { name: 'my-plugin', version: '1.0.0' };
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### View Loaded Plugins
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
hncode /plugins
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🛠 Tools
|
|
140
|
+
|
|
141
|
+
Built-in tools include:
|
|
142
|
+
- `Read`, `Write`, `Edit` - File operations
|
|
143
|
+
- `Bash` - Execute shell commands
|
|
144
|
+
- `Glob`, `Grep` - Search files
|
|
145
|
+
- `TodoList`, `TaskOutput` - Task management
|
|
146
|
+
- `FetchURL`, `WebSearch` - Internet access
|
|
147
|
+
- `ReadMediaFile`, `FileLines` - Media handling
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 🎨 Themes
|
|
152
|
+
|
|
153
|
+
Supported themes: `auto`, `dark`, `light`, or custom RGB colors.
|
|
154
|
+
|
|
155
|
+
Set via config:
|
|
156
|
+
```toml
|
|
157
|
+
theme = "dark"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Or use `/theme <name>` in TUI.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 🤝 Contributing
|
|
165
|
+
|
|
166
|
+
This project was created through Vibe Coding. While it may not be perfect, I welcome your feedback!
|
|
167
|
+
|
|
168
|
+
**Feel free to:**
|
|
169
|
+
- Submit issues for bugs or suggestions
|
|
170
|
+
- Fork and create pull requests
|
|
171
|
+
- Share your experience using hncode
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 🙏 Acknowledgments
|
|
176
|
+
|
|
177
|
+
hncode draws inspiration from several excellent projects:
|
|
178
|
+
|
|
179
|
+
- **[Kimi Code CLI](https://github.com/MoonshotAI/kimi-code)** - The original cyan-blue TUI coding agent that inspired this project's design and approach
|
|
180
|
+
- **[Claude Code](https://github.com/anthropics/claude-code)** - The conversation flow and tool interaction patterns
|
|
181
|
+
|
|
182
|
+
Special thanks to the communities behind these projects for pushing the boundaries of AI-assisted coding.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 📄 License
|
|
187
|
+
|
|
188
|
+
This project is licensed under the [GNU General Public License v3.0](LICENSE).
|
|
189
|
+
|
|
190
|
+
**In short:**
|
|
191
|
+
1. ✅ You can freely use, modify, and share this code
|
|
192
|
+
2. ✅ Must retain author attribution (NiceHello666) and link back to this repository
|
|
193
|
+
3. ❌ Cannot be used for commercial purposes (e.g., selling, as part of paid products)
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
**NPM Package**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
198
|
+
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|