@hncode/hncode 0.1.9 → 0.1.10

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 CHANGED
@@ -1,87 +1,87 @@
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)
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,87 +1,87 @@
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)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hncode/hncode",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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",
package/src/tools/grep.js CHANGED
@@ -144,9 +144,12 @@ function emitContext(out, file, idx, lines, a) {
144
144
 
145
145
  function paginate(raw, args) {
146
146
  if (raw === '' || raw === undefined || raw === null) return 'No matches found.';
147
- let lines = raw.split('\n').filter((l) => l.length > 0);
147
+ // Split on either newline style and drop the trailing empty element a final
148
+ // CRLF leaves behind — `rg` always ends with one, and it rendered as a stray
149
+ // blank line under the last match.
150
+ let lines = raw.split(/\r?\n/).filter((l) => l.length > 0);
148
151
  if (args.offset) lines = lines.slice(args.offset);
149
152
  if (args.head_limit) lines = lines.slice(0, args.head_limit);
150
153
  if (lines.length === 0) return 'No matches found.';
151
- return lines.join('\n');
154
+ return lines.join('\n').replace(/\r/g, '');
152
155
  }
package/src/tui.js CHANGED
@@ -5230,6 +5230,10 @@ export async function startTUI(opts) {
5230
5230
 
5231
5231
  async function runAgent(text) {
5232
5232
  addChat({ role: 'user', text });
5233
+ // A message the user JUST SENT should always bring the newest content into
5234
+ // view, even if they were scrolled up reading history. (Queue/steer do NOT
5235
+ // come through here, so they keep the view exactly where the user left it.)
5236
+ state.scroll = 0;
5233
5237
  state.running = true;
5234
5238
  // Pick the Working… wording ONCE for this turn, so it does not change while
5235
5239
  // the gradient loops. The next turn picks a new one.