22
33> 基于 Go + Bubble Tea 的本地 Coding Agent
44
5- ## NeoCode 是什么
6-
5+ ## NeoCode 是什么?
76NeoCode 是一个在终端中运行的 AI 编码助手,采用 ReAct(Reason-Act-Observe)循环模式,围绕以下主链路工作:
87
98` 用户输入 -> Agent 推理 -> 调用工具 -> 获取结果 -> 继续推理 -> UI 展示 `
109
1110它适合希望在本地工作流中完成代码理解、修改、调试与自动化操作的开发者。
1211
13- ## 有什么能力
14-
12+ ## 有什么能力?
1513- 终端原生 TUI 交互体验(Bubble Tea)
1614- Agent 可调用内置工具完成文件与命令相关任务
1715- 支持 Provider/Model 切换(内建 ` openai ` 、` gemini ` 、` openll ` 、` qiniu ` )
@@ -23,26 +21,21 @@ NeoCode 是一个在终端中运行的 AI 编码助手,采用 ReAct(Reason-A
2321## 怎么用(快速开始)
2422
2523### 1) 环境要求
26-
2724- Go ` 1.25+ `
2825- 可用的 API Key(如 OpenAI、Gemini、OpenLL、Qiniu)
2926
3027### 2) 一键安装
31-
3228macOS / Linux:
33-
3429``` bash
3530curl -fsSL https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.sh | bash
3631```
3732
3833Windows PowerShell:
39-
4034``` powershell
4135irm https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.ps1 | iex
4236```
4337
4438### 3) 从源码运行
45-
4639``` bash
4740git clone https://github.com/1024XEngineer/neo-code.git
4841cd neo-code
@@ -70,8 +63,9 @@ go run ./cmd/neocode gateway --http-listen 127.0.0.1:8080
7063安全限制:为防止跨站攻击,网关网络面默认开启严格的 Origin 校验。当前仅允许
7164` http://localhost ` 、` http://127.0.0.1 ` 、` http://[::1] ` 以及 ` app:// ` 前缀来源连入;
7265非允许来源的跨域调用会被拦截并返回 ` 403 ` 。
66+
7367注:上述白名单机制仅针对携带 ` Origin ` 头的浏览器跨站请求生效。若请求不携带 ` Origin ` 头
74- (例如 ` cURL ` 、Postman 或本地后端脚本直连),网关默认放行。
68+ (例如 ` curl ` 、Postman 或本地后端脚本直连),网关默认放行。
7569
7670URL Scheme 派发骨架命令(EPIC-GW-02A):
7771
@@ -93,7 +87,6 @@ export QINIU_API_KEY="your_key_here"
9387```
9488
9589Windows PowerShell:
96-
9790``` powershell
9891$env:OPENAI_API_KEY = "your_key_here"
9992$env:GEMINI_API_KEY = "your_key_here"
@@ -121,7 +114,6 @@ go run ./cmd/neocode --runtime-mode gateway
121114- 若 Gateway 不可达或握手失败会直接报错退出(Fail Fast),不会自动回退到 ` local `
122115
123116### 4) 首次使用与常用命令
124-
125117- ` /help ` :查看命令帮助
126118- ` /provider ` :打开 provider 选择器
127119- ` /model ` :打开 model 选择器
@@ -134,7 +126,6 @@ go run ./cmd/neocode --runtime-mode gateway
134126- ` & <command> ` :在当前工作区执行本地命令
135127
136128示例输入:
137-
138129``` text
139130请先阅读当前项目目录结构并给出模块职责摘要
140131帮我在 internal/runtime 下定位与 tool result 回灌相关逻辑
@@ -153,6 +144,13 @@ go run ./cmd/neocode --runtime-mode gateway
153144
154145详细配置请参考:[ docs/guides/configuration.md] ( docs/guides/configuration.md )
155146
147+ ## 内部结构补充
148+
149+ - ` internal/context ` :负责主会话 system prompt 的 section 组装、动态上下文注入与消息裁剪。
150+ - ` internal/runtime ` :负责 ReAct 主循环、tool 调用编排、compact 触发与 reminder 注入时机。
151+ - ` internal/subagent ` :负责子代理角色策略、执行约束与输出契约。
152+ - ` internal/promptasset ` :负责受版本管理的静态 prompt 模板资产,使用 ` go:embed ` 编译进程序,供 ` context ` 、` runtime ` 、` subagent ` 读取。
153+
156154## 文档导航
157155
158156- [ 配置指南] ( docs/guides/configuration.md )
@@ -172,17 +170,14 @@ go run ./cmd/neocode --runtime-mode gateway
1721702 . Fork 仓库并创建功能分支。
1731713 . 完成开发并确保改动聚焦、边界清晰。
1741724 . 本地自检:
175-
176173 ``` bash
177174 gofmt -w ./cmd ./internal
178175 go test ./...
179176 go build ./...
180177 ```
181-
1821785 . 提交 PR 到主仓库并说明变更目的、影响范围和验证方式。
183179
184180提交前请确认:
185-
186181- 不提交明文密钥、个人配置或会话数据
187182- 不提交无关改动与临时文件
188183
@@ -205,21 +200,22 @@ go run ./cmd/neocode --runtime-mode gateway
205200 - ` http_max_stream_connections=128 `
206201 - ` ipc_read/write_sec=30/30 `
207202 - ` http_read/write/shutdown_sec=15/15/2 `
208- - 详细设计文档:[ ` docs/gateway-detailed-design.md ` ] ( docs/gateway-detailed-design.md )
203+
204+ 详细设计文档:[ ` docs/gateway-detailed-design.md ` ] ( docs/gateway-detailed-design.md )
209205
210206### Gateway JSON-RPC 方法清单(当前实现)
211207
212208- ` gateway.authenticate ` :连接级鉴权握手
213209- ` gateway.ping ` :探活
214210- ` gateway.bindStream ` :会话流绑定
215- - ` gateway.run ` :发起一次运行
211+ - ` gateway.run ` :发起一次运行(Accepted-ACK,异步执行)
216212- ` gateway.compact ` :触发会话压缩
217- - ` gateway.cancel ` :取消当前活跃运行
213+ - ` gateway.cancel ` :按 ` run_id ` 精确取消目标运行( ` run_id ` 必填)
218214- ` gateway.listSessions ` :查询会话摘要列表
219215- ` gateway.loadSession ` :加载单个会话详情
220216- ` gateway.resolvePermission ` :提交权限审批结果
221217- ` wake.openUrl ` :处理 ` neocode:// ` 唤醒请求
222- - ` gateway.event ` :网关推送的通知事件 (notification)
218+ - ` gateway.event ` :网关推送通知事件 (notification)
223219
224220## License
225221
0 commit comments