Skip to content

Commit 30effcc

Browse files
authored
Merge pull request #373 from phantom5099/main
refactor(provider): 将 provider 收缩为最小协议适配层
2 parents d1c71fe + 5fe2d69 commit 30effcc

113 files changed

Lines changed: 6700 additions & 5048 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
> 基于 Go + Bubble Tea 的本地 Coding Agent
44
5-
## NeoCode 是什么
6-
5+
## NeoCode 是什么?
76
NeoCode 是一个在终端中运行的 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-
3228
macOS / Linux:
33-
3429
```bash
3530
curl -fsSL https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.sh | bash
3631
```
3732

3833
Windows PowerShell:
39-
4034
```powershell
4135
irm https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.ps1 | iex
4236
```
4337

4438
### 3) 从源码运行
45-
4639
```bash
4740
git clone https://github.com/1024XEngineer/neo-code.git
4841
cd 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

7670
URL Scheme 派发骨架命令(EPIC-GW-02A):
7771

@@ -93,7 +87,6 @@ export QINIU_API_KEY="your_key_here"
9387
```
9488

9589
Windows PowerShell:
96-
9790
```powershell
9891
$env:OPENAI_API_KEY = "your_key_here"
9992
$env:GEMINI_API_KEY = "your_key_here"
@@ -108,7 +101,6 @@ go run ./cmd/neocode --workdir /path/to/workspace
108101
```
109102

110103
### 4) 首次使用与常用命令
111-
112104
- `/help`:查看命令帮助
113105
- `/provider`:打开 provider 选择器
114106
- `/model`:打开 model 选择器
@@ -121,7 +113,6 @@ go run ./cmd/neocode --workdir /path/to/workspace
121113
- `& <command>`:在当前工作区执行本地命令
122114

123115
示例输入:
124-
125116
```text
126117
请先阅读当前项目目录结构并给出模块职责摘要
127118
帮我在 internal/runtime 下定位与 tool result 回灌相关逻辑
@@ -165,17 +156,14 @@ go run ./cmd/neocode --workdir /path/to/workspace
165156
2. Fork 仓库并创建功能分支。
166157
3. 完成开发并确保改动聚焦、边界清晰。
167158
4. 本地自检:
168-
169159
```bash
170160
gofmt -w ./cmd ./internal
171161
go test ./...
172162
go build ./...
173163
```
174-
175164
5. 提交 PR 到主仓库并说明变更目的、影响范围和验证方式。
176165

177166
提交前请确认:
178-
179167
- 不提交明文密钥、个人配置或会话数据
180168
- 不提交无关改动与临时文件
181169

@@ -198,21 +186,22 @@ go run ./cmd/neocode --workdir /path/to/workspace
198186
- `http_max_stream_connections=128`
199187
- `ipc_read/write_sec=30/30`
200188
- `http_read/write/shutdown_sec=15/15/2`
201-
- 详细设计文档:[`docs/gateway-detailed-design.md`](docs/gateway-detailed-design.md)
189+
190+
详细设计文档:[`docs/gateway-detailed-design.md`](docs/gateway-detailed-design.md)
202191

203192
### Gateway JSON-RPC 方法清单(当前实现)
204193

205194
- `gateway.authenticate`:连接级鉴权握手
206195
- `gateway.ping`:探活
207196
- `gateway.bindStream`:会话流绑定
208-
- `gateway.run`:发起一次运行
197+
- `gateway.run`:发起一次运行(Accepted-ACK,异步执行)
209198
- `gateway.compact`:触发会话压缩
210-
- `gateway.cancel`取消当前活跃运行
199+
- `gateway.cancel``run_id` 精确取消目标运行(`run_id` 必填)
211200
- `gateway.listSessions`:查询会话摘要列表
212201
- `gateway.loadSession`:加载单个会话详情
213202
- `gateway.resolvePermission`:提交权限审批结果
214203
- `wake.openUrl`:处理 `neocode://` 唤醒请求
215-
- `gateway.event`网关推送的通知事件(notification)
204+
- `gateway.event`网关推送通知事件(notification)
216205

217206
## License
218207

docs/config-management-detail-design.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ custom provider 来自:
6969
```
7070

7171
当前只接受明确受支持的字段;未知字段会直接报错,不做“旧格式自动迁移”。
72+
`provider.yaml` 只支持平铺字段:`name/driver/base_url/api_key_env/model_source/chat_endpoint_path/discovery_endpoint_path/models`
7273

7374
## 加载流程
7475

0 commit comments

Comments
 (0)