@hncode/hncode 0.1.1 → 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.
Files changed (3) hide show
  1. package/README.md +54 -197
  2. package/README_CN.md +186 -0
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # hncode — AI Coding Agent CLI
2
2
 
3
- > **这是我 Vibe Coding 的产物,可能不是特别好,但是如果有什么建议的话也欢迎提 issue**
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
4
 
5
- A cyan-blue TUI coding agent inspired by kimi-code-cli, with OpenAI + Anthropic support, MCP-style toolbelt, and intelligent context management.
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
6
 
7
7
  ---
8
8
 
@@ -70,22 +70,6 @@ export HNCODE_MODEL="gpt-4o-mini"
70
70
 
71
71
  ### Basic Commands
72
72
 
73
- ```bash
74
- # Start interactive session
75
- hncode
76
-
77
- # Headless mode (one prompt)
78
- hncode -p "Fix the bug in src/main.js"
79
-
80
- # Continue previous session
81
- hncode --continue
82
-
83
- # Auto mode (no questions)
84
- hncode --auto
85
- ```
86
-
87
- ### Slash Commands
88
-
89
73
  | Command | Description |
90
74
  |---------|-------------|
91
75
  | `/compact [ratio]` | Compact conversation (AI summary + keep last 20%) |
@@ -97,29 +81,57 @@ hncode --auto
97
81
  | `/calm-mode` | Terse replies (skip narration) |
98
82
  | `/help` | Show all commands |
99
83
 
100
- ### Advanced Features
84
+ ### Tab Completion
101
85
 
102
- **Tab Completion**:
103
86
  - Type `/` → command menu
104
87
  - Type `@` → file/folder completion
105
- - Use Tab to navigate and Enter to select
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
106
99
 
107
- **Auto Compaction**:
108
- - Triggers at 85% context window
109
- - AI summarizes dropped messages
110
- - Keeps most recent 20% of conversation
100
+ ### Creating Plugins
101
+
102
+ Create `.js` or `.mjs` files in `~/.hncode/plugins/`:
111
103
 
112
- **Plugin System**:
113
- Place plugins in `~/.hncode/plugins/`:
114
104
  ```javascript
115
105
  // my-plugin.mjs
116
106
  export function install(api) {
117
- api.registerTool({ /* ... */ });
118
- api.registerCommand({ name: 'mycmd', run: () => {} });
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) => { /* ... */ });
119
124
  }
125
+
120
126
  export default { name: 'my-plugin', version: '1.0.0' };
121
127
  ```
122
128
 
129
+ ### View Loaded Plugins
130
+
131
+ ```bash
132
+ hncode /plugins
133
+ ```
134
+
123
135
  ---
124
136
 
125
137
  ## 🛠 Tools
@@ -134,7 +146,7 @@ Built-in tools include:
134
146
 
135
147
  ---
136
148
 
137
- ## 🎨 Theme
149
+ ## 🎨 Themes
138
150
 
139
151
  Supported themes: `auto`, `dark`, `light`, or custom RGB colors.
140
152
 
@@ -143,7 +155,7 @@ Set via config:
143
155
  theme = "dark"
144
156
  ```
145
157
 
146
- Or `/theme <name>` in TUI.
158
+ Or use `/theme <name>` in TUI.
147
159
 
148
160
  ---
149
161
 
@@ -151,7 +163,7 @@ Or `/theme <name>` in TUI.
151
163
 
152
164
  This project was created through Vibe Coding. While it may not be perfect, I welcome your feedback!
153
165
 
154
- **Please feel free to:**
166
+ **Feel free to:**
155
167
  - Submit issues for bugs or suggestions
156
168
  - Fork and create pull requests
157
169
  - Share your experience using hncode
@@ -162,8 +174,8 @@ This project was created through Vibe Coding. While it may not be perfect, I wel
162
174
 
163
175
  hncode draws inspiration from several excellent projects:
164
176
 
165
- - **[kimi-code-cli](https://github.com/mckaymatt/kimi-code-cli)** - The original cyan-blue TUI coding agent that inspired this project's design and approach
166
- - **[claude-code](https://github.com/anthropics/claude-code)** - The conversation flow and tool interaction patterns
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
167
179
 
168
180
  Special thanks to the communities behind these projects for pushing the boundaries of AI-assisted coding.
169
181
 
@@ -171,170 +183,15 @@ Special thanks to the communities behind these projects for pushing the boundari
171
183
 
172
184
  ## 📄 License
173
185
 
174
- MIT License - See LICENSE file for details.
175
-
176
- ---
177
-
178
- # hncode — AI 编程助手命令行工具
179
-
180
- > **这是我 Vibe Coding 的产物,可能不是特别好,但是如果有什么建议的话也欢迎提 issue**
181
-
182
- 一个青色蓝调终端界面的 AI 编程助手,灵感来自 kimi-code-cli,支持 OpenAI 和 Anthropic API,配备 MCP 风格的工具集和智能上下文管理。
183
-
184
- ---
185
-
186
- ## 🌟 功能特性
186
+ This project is licensed under the [GNU General Public License v3.0](LICENSE).
187
187
 
188
- - **青色蓝调 TUI**: 原生终端渲染器,完美兼容 Windows Terminal
189
- - **双协议支持**: 同时支持 OpenAI 兼容 API 和 Anthropic
190
- - **智能上下文管理**: 85% 使用率时自动压缩,AI 摘要保留历史对话
191
- - **MCP 风格工具集**: Read、Write、Edit、Bash、Glob、Grep、TodoList、WebSearch 等
192
- - **插件系统**: 通过自定义工具、命令和钩子扩展功能
193
- - **会话持久化**: 跨会话恢复对话
194
- - **权限模式**: Ask、YOLO、Auto 三种工作流模式
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)
195
192
 
196
193
  ---
197
194
 
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 文件。
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hncode/hncode",
3
- "version": "0.1.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
6
  "main": "src/index.js",
@@ -12,6 +12,7 @@
12
12
  "src/",
13
13
  "LICENSE",
14
14
  "README.md",
15
+ "README_CN.md",
15
16
  "package.json"
16
17
  ],
17
18
  "scripts": {