@hncode/hncode 0.1.7 → 0.1.9
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 +87 -198
- package/README_CN.md +87 -187
- package/package.json +1 -1
- package/src/agent.js +13 -22
- package/src/clipboard.js +116 -13
- package/src/colors.js +16 -8
- package/src/index.js +1 -1
- package/src/tui.js +200 -169
package/README.md
CHANGED
|
@@ -1,198 +1,87 @@
|
|
|
1
|
-
# hncode — AI Coding Agent
|
|
2
|
-
|
|
3
|
-
English | [简体中文](
|
|
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
|
|
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
|
-
|
|
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
|
-
- 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)
|
|
1
|
+
# hncode — AI Coding Agent TUI
|
|
2
|
+
|
|
3
|
+
English | [简体中文](https://github.com/NiceHello666/hncode/blob/main/README_CN.md) | [Wiki](https://github.com/NiceHello666/hncode/blob/main/README_WIKI.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 terminal user interface (TUI) coding agent inspired by [Kimi Code](https://github.com/MoonshotAI/kimi-code), with OpenAI + Anthropic support, an 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
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📖 Documentation
|
|
45
|
+
|
|
46
|
+
This file is a quick overview. For the **full documentation** — every command, config option, architecture notes, and the plugin/development guide — see the Wiki:
|
|
47
|
+
|
|
48
|
+
- **[Wiki (English)](https://github.com/NiceHello666/hncode/blob/main/README_WIKI.md)**
|
|
49
|
+
- **[Wiki (简体中文)](https://github.com/NiceHello666/hncode/blob/main/README_WIKI_CN.md)**
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🤝 Contributing
|
|
54
|
+
|
|
55
|
+
This project was created through Vibe Coding. While it may not be perfect, I welcome your feedback!
|
|
56
|
+
|
|
57
|
+
**Feel free to:**
|
|
58
|
+
- Submit issues for bugs or suggestions
|
|
59
|
+
- Fork and create pull requests
|
|
60
|
+
- Share your experience using hncode
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🙏 Acknowledgments
|
|
65
|
+
|
|
66
|
+
hncode draws inspiration from several excellent projects:
|
|
67
|
+
|
|
68
|
+
- **[Kimi Code](https://github.com/MoonshotAI/kimi-code)** - The original cyan-blue TUI coding agent that inspired this project's design and approach
|
|
69
|
+
- **[Claude Code](https://github.com/anthropics/claude-code)** - The conversation flow and tool interaction patterns
|
|
70
|
+
|
|
71
|
+
Special thanks to the communities behind these projects for pushing the boundaries of AI-assisted coding.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📄 License
|
|
76
|
+
|
|
77
|
+
This project is licensed under the [GNU General Public License v3.0](https://github.com/NiceHello666/hncode/blob/main/LICENSE).
|
|
78
|
+
|
|
79
|
+
**In short:**
|
|
80
|
+
1. ✅ You can freely use, modify, and share this code
|
|
81
|
+
2. ✅ Must retain author attribution (NiceHello666) and link back to this repository
|
|
82
|
+
3. ❌ Cannot be used for commercial purposes (e.g., selling, as part of paid products)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
**NPM Package**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
87
|
+
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|
package/README_CN.md
CHANGED
|
@@ -1,187 +1,87 @@
|
|
|
1
|
-
# hncode — AI
|
|
2
|
-
|
|
3
|
-
[English](
|
|
4
|
-
|
|
5
|
-
> **这是我 Vibe Coding 的产物,可能不是特别好,但是如果有什么建议的话也欢迎提 issue**
|
|
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
|
-
|
|
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
|
-
- 使用 Tab 导航,Enter 选择
|
|
92
|
-
|
|
93
|
-
### 自动压缩
|
|
94
|
-
|
|
95
|
-
- 当上下文使用率达到 85% 时自动触发
|
|
96
|
-
- AI 会摘要被丢弃的消息,而不是简单删除
|
|
97
|
-
- 保留最近的 20% 对话以保持上下文连贯性
|
|
98
|
-
|
|
99
|
-
## 🔧 插件系统
|
|
100
|
-
|
|
101
|
-
### 创建插件
|
|
102
|
-
|
|
103
|
-
在 `~/.hncode/plugins/` 目录下创建 `.js` 或 `.mjs` 文件:
|
|
104
|
-
|
|
105
|
-
```javascript
|
|
106
|
-
// my-plugin.mjs
|
|
107
|
-
export function install(api) {
|
|
108
|
-
// 注册新工具
|
|
109
|
-
api.registerTool({
|
|
110
|
-
name: 'MyTool',
|
|
111
|
-
description: '...',
|
|
112
|
-
parameters: { /* schema */ },
|
|
113
|
-
async execute(args, ctx) { return result; }
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// 注册命令
|
|
117
|
-
api.registerCommand({
|
|
118
|
-
name: 'mycmd',
|
|
119
|
-
description: '...',
|
|
120
|
-
run: (arg, ctx) => { /* ... */ }
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// 注册钩子
|
|
124
|
-
api.registerHook('onTurnEnd', (turnInfo) => { /* ... */ });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export default { name: 'my-plugin', version: '1.0.0' };
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### 查看已加载插件
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
hncode /plugins
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## 🛠 工具集
|
|
137
|
-
|
|
138
|
-
内置工具包括:
|
|
139
|
-
- `Read`, `Write`, `Edit` - 文件操作
|
|
140
|
-
- `Bash` - 执行 Shell 命令
|
|
141
|
-
- `Glob`, `Grep` - 搜索文件
|
|
142
|
-
- `TodoList`, `TaskOutput` - 任务管理
|
|
143
|
-
- `FetchURL`, `WebSearch` - 网络访问
|
|
144
|
-
- `ReadMediaFile`, `FileLines` - 媒体处理
|
|
145
|
-
|
|
146
|
-
## 🎨 主题
|
|
147
|
-
|
|
148
|
-
支持的 theme: `auto`, `dark`, `light`, 或自定义 RGB 颜色。
|
|
149
|
-
|
|
150
|
-
通过配置设置:
|
|
151
|
-
```toml
|
|
152
|
-
theme = "dark"
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
或在 TUI 中使用 `/theme <name>`。
|
|
156
|
-
|
|
157
|
-
## 🤝 贡献
|
|
158
|
-
|
|
159
|
-
这个项目是通过 Vibe Coding 创建的。虽然它可能不够完美,但我欢迎您的反馈!
|
|
160
|
-
|
|
161
|
-
**欢迎:**
|
|
162
|
-
- 提交问题报告 bug 或提出建议
|
|
163
|
-
- Fork 并创建拉取请求
|
|
164
|
-
- 分享您使用 hncode 的体验
|
|
165
|
-
|
|
166
|
-
## 🙏 致谢
|
|
167
|
-
|
|
168
|
-
hncode 从以下几个优秀项目中汲取了灵感:
|
|
169
|
-
|
|
170
|
-
- **[Kimi Code CLI](https://github.com/MoonshotAI/kimi-code)** - 原始的青色蓝调终端界面 AI 编程助手,启发了本项目的设计和理念
|
|
171
|
-
- **[Claude Code](https://github.com/anthropics/claude-code)** - 对话流程和工具交互模式
|
|
172
|
-
|
|
173
|
-
特别感谢这些项目背后的社区,它们推动了 AI 辅助编程的边界。
|
|
174
|
-
|
|
175
|
-
## 📄 许可证
|
|
176
|
-
|
|
177
|
-
本项目的许可受 [GNU General Public License v3.0](LICENSE) 保护。
|
|
178
|
-
|
|
179
|
-
**简单来说:**
|
|
180
|
-
1. ✅ 你可以自由使用、修改和分享此代码
|
|
181
|
-
2. ✅ 必须保留原作者署名(NiceHello666)并链接回此仓库
|
|
182
|
-
3. ❌ 不得用于商业目的(例如出售、作为付费产品的一部分)
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
**NPM 包**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
187
|
-
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|
|
1
|
+
# hncode — AI 编程助手 TUI
|
|
2
|
+
|
|
3
|
+
[English](https://github.com/NiceHello666/hncode/blob/main/README.md) | 简体中文 | [Wiki](https://github.com/NiceHello666/hncode/blob/main/README_WIKI_CN.md)
|
|
4
|
+
|
|
5
|
+
> **这是我 Vibe Coding 的产物,可能不是特别好,但是如果有什么建议的话也欢迎提 issue**
|
|
6
|
+
|
|
7
|
+
一个基于终端用户界面(TUI)的 AI 编程助手,灵感源自 [Kimi Code](https://github.com/MoonshotAI/kimi-code)。它提供青色蓝调 (Cyan-blue) 的 TUI 界面,支持 OpenAI 和 Anthropic 双协议,配备 MCP 风格的工具集和智能上下文管理。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🌟 核心特性
|
|
12
|
+
|
|
13
|
+
- **原生 TUI 渲染**: 使用原始终端序列渲染,完美兼容 Windows Terminal,解决 blessed 等库在 Windows 上的兼容性问题
|
|
14
|
+
- **双协议支持**: 同时支持 OpenAI-compatible API 和 Anthropic API
|
|
15
|
+
- **智能上下文管理**: 85% 使用率时自动压缩,AI 摘要保留历史对话
|
|
16
|
+
- **MCP 风格工具集**: Read, Write, Edit, Bash, Glob, Grep, TodoList, WebSearch, FetchURL 等
|
|
17
|
+
- **插件系统**: 可扩展的工具、命令和生命周期钩子
|
|
18
|
+
- **会话持久化**: 跨会话恢复对话
|
|
19
|
+
- **权限模式**: Ask, YOLO, Auto 三种工作流模式
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🚀 安装
|
|
24
|
+
|
|
25
|
+
### 全局安装(推荐)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @hncode/hncode
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
然后运行:
|
|
32
|
+
```bash
|
|
33
|
+
hncode
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 使用 npx(无需安装)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @hncode/hncode
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📖 文档
|
|
45
|
+
|
|
46
|
+
本文件只是简要介绍。**完整文档**(所有命令、配置项、架构说明、插件与开发指南)请见 Wiki:
|
|
47
|
+
|
|
48
|
+
- **[Wiki(英文)](https://github.com/NiceHello666/hncode/blob/main/README_WIKI.md)**
|
|
49
|
+
- **[Wiki(简体中文)](https://github.com/NiceHello666/hncode/blob/main/README_WIKI_CN.md)**
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🤝 贡献
|
|
54
|
+
|
|
55
|
+
这个项目是通过 Vibe Coding 创建的。虽然它可能不够完美,但我欢迎您的反馈!
|
|
56
|
+
|
|
57
|
+
**欢迎:**
|
|
58
|
+
- 提交问题报告 bug 或提出建议
|
|
59
|
+
- Fork 并创建拉取请求
|
|
60
|
+
- 分享您使用 hncode 的体验
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🙏 致谢
|
|
65
|
+
|
|
66
|
+
hncode 从以下几个优秀项目中汲取了灵感:
|
|
67
|
+
|
|
68
|
+
- **[Kimi Code](https://github.com/MoonshotAI/kimi-code)** - 原始的青色蓝调终端界面 AI 编程助手,启发了本项目的设计和理念
|
|
69
|
+
- **[Claude Code](https://github.com/anthropics/claude-code)** - 对话流程和工具交互模式
|
|
70
|
+
|
|
71
|
+
特别感谢这些项目背后的社区,它们推动了 AI 辅助编程的边界。
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📄 许可证
|
|
76
|
+
|
|
77
|
+
本项目的许可受 [GNU General Public License v3.0](https://github.com/NiceHello666/hncode/blob/main/LICENSE) 保护。
|
|
78
|
+
|
|
79
|
+
**简单来说:**
|
|
80
|
+
1. ✅ 你可以自由使用、修改和分享此代码
|
|
81
|
+
2. ✅ 必须保留原作者署名(NiceHello666)并链接回此仓库
|
|
82
|
+
3. ❌ 不得用于商业目的(例如出售、作为付费产品的一部分)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
**NPM 包**: [@hncode/hncode](https://www.npmjs.com/package/@hncode/hncode)
|
|
87
|
+
**GitHub**: [NiceHello666/hncode](https://github.com/NiceHello666/hncode)
|
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -24,35 +24,26 @@ export function nudgeMessage(why) {
|
|
|
24
24
|
// Final instruction appended to the system prompt (see SYSTEM_PROMPT).
|
|
25
25
|
// (The wording lives in SYSTEM_PROMPT itself, under "Finishing a turn".)
|
|
26
26
|
|
|
27
|
-
export const SYSTEM_PROMPT = `You are hncode, a coding agent
|
|
28
|
-
You
|
|
27
|
+
export const SYSTEM_PROMPT = `You are hncode, a coding agent in the user's terminal on ${process.platform}.
|
|
28
|
+
You work inside a workspace directory using the tools provided.
|
|
29
29
|
|
|
30
30
|
Tools:
|
|
31
|
+
- Read a file before editing it; never guess contents or edit code you haven't read.
|
|
31
32
|
- Prefer Edit over Write for existing files.
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
After 2 failed attempts on the same goal, STOP and report the blocker.
|
|
35
|
-
- Independent tool calls can run in parallel, but never parallelize calls with dependencies.
|
|
33
|
+
- If a tool fails, read the error and fix your approach. After 2 failed attempts on the same goal, stop and report the blocker.
|
|
34
|
+
- Independent tool calls may run in parallel; never parallelize dependent ones.
|
|
36
35
|
|
|
37
36
|
Scope:
|
|
38
|
-
- Do what was asked. Do not refactor
|
|
39
|
-
- If the request is ambiguous, ask one short clarifying question
|
|
40
|
-
-
|
|
37
|
+
- Do only what was asked. Do not refactor or "improve" unrelated code.
|
|
38
|
+
- If the request is ambiguous, ask one short clarifying question.
|
|
39
|
+
- State any assumption you make.
|
|
41
40
|
|
|
42
41
|
Finishing:
|
|
43
|
-
- Never stop silently after a tool call.
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
reference. If you didn't run a command or read back the file, you don't know it worked.
|
|
49
|
-
- Be brief. No filler, no restating the request.
|
|
50
|
-
- After tools succeed, don't re-explain what the tool did. Report only the outcome.
|
|
51
|
-
|
|
52
|
-
Finishing a turn:
|
|
53
|
-
- End every turn with a written answer. Never stop right after a tool call, and never
|
|
54
|
-
stop with reasoning only: either keep calling tools until the task is done, or write
|
|
55
|
-
the summary. A turn that ends without an answer is flagged back to you with a reminder.
|
|
42
|
+
- Never stop silently after a tool call; end every turn with a written answer in the user's language.
|
|
43
|
+
- Report briefly: what changed, and how you verified it. If something failed, say what you tried and what you need.
|
|
44
|
+
- Never claim success without evidence. Cite file:line for referenced code.
|
|
45
|
+
- Be concise. No filler, no restating the request or explaining tool output that already spoke for itself.
|
|
46
|
+
- If context is running low, call /compact to shrink history.
|
|
56
47
|
`;
|
|
57
48
|
|
|
58
49
|
export class Agent {
|