nanocode-cli 0.6.2__tar.gz → 0.6.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nanocode-cli
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: A small terminal coding agent written in Python
5
5
  Author-email: hit9 <hit9@icloud.com>
6
6
  License-Expression: BSD-3-Clause
@@ -53,6 +53,7 @@ nanocode is pre-1.0 software. Commands, configuration, and tool behavior may cha
53
53
  - **Stale-edit protection**: `line:hash` anchors reject edits when the target code has drifted.
54
54
  - **Project-aware navigation**: Use the symbol index to jump through outlines, references, implementors, call chains, and changed files quickly.
55
55
  - **Recoverable context**: Tool output stays bounded in the prompt, while raw `tr.N` results remain recallable.
56
+ - **Session recovery**: Resume saved work with `nanocode --resume`, including restored conversation history.
56
57
  - **Cache-aware context**: Stable sections stay early and noisy working state stays late to improve prompt-cache reuse.
57
58
  - **Focused working memory**: `Note` separates goal, plan, and known facts from noisy execution logs.
58
59
  - **MCP integration**: Connect to remote (HTTP) or local (stdio) Model Context Protocol servers and call their tools.
@@ -60,6 +61,8 @@ nanocode is pre-1.0 software. Commands, configuration, and tool behavior may cha
60
61
 
61
62
  ## Install
62
63
 
64
+ Install with uv:
65
+
63
66
  ```sh
64
67
  uv tool install nanocode-cli
65
68
  ```
@@ -77,9 +80,15 @@ uv sync --extra dev
77
80
  uv run nanocode
78
81
  ```
79
82
 
80
- ## Usage
83
+ ## Quick Start
84
+
85
+ Create a config file:
86
+
87
+ ```sh
88
+ nanocode --init-config
89
+ ```
81
90
 
82
- Start the CLI:
91
+ Edit `~/.nanocode/config.toml`, then start:
83
92
 
84
93
  ```sh
85
94
  nanocode
@@ -89,15 +98,38 @@ Useful arguments:
89
98
 
90
99
  - `--config <path>`: use a TOML config file.
91
100
  - `--init-config`: create a default config file.
101
+ - `--resume [UID]`: resume a saved session; without `UID`, resumes `latest`.
92
102
  - `--yolo`: skip confirmations for mutating tools.
103
+ - `--mcp <selector>`: choose which configured MCP servers to enable.
104
+ - `--debug`: write model I/O debug traces.
93
105
  - `-v`, `--version`: show the version.
94
106
 
95
- During a running turn, the `+>` prompt accepts follow-up input for the next model request.
107
+ During a running turn, type into the `+>` prompt to add follow-up input for the next model request.
108
+
109
+ ## Sessions
110
+
111
+ nanocode saves recoverable non-empty sessions under `[paths] data_dir` and prints a restore command on exit:
112
+
113
+ ```sh
114
+ Resume with: nanocode --resume <session-id>
115
+ ```
116
+
117
+ Resume by id, or use the latest saved session:
118
+
119
+ ```sh
120
+ nanocode --resume <session-id>
121
+ nanocode --resume latest
122
+ nanocode --resume last
123
+ ```
124
+
125
+ Restored sessions replay the visible conversation history once; tool summaries are shown, raw tool result bodies are not. `/status` shows the active session id. Old session files are cleaned up after `runtime.session_retention_days` days, defaulting to `7`; set it to `0` to disable cleanup.
126
+
127
+ ## CLI
96
128
 
97
- ## Commands
129
+ Commands:
98
130
 
99
131
  - `/help`: show commands and tools.
100
- - `/status`: show runtime status.
132
+ - `/status`: show runtime status, including the active session id.
101
133
  - `/config`: show active config.
102
134
  - `/api [auto|chat|anthropic]`: show or set provider API format.
103
135
  - `/debug [on|off]`: toggle model I/O debug traces.
@@ -107,13 +139,13 @@ During a running turn, the `+>` prompt accepts follow-up input for the next mode
107
139
  - `/provider [NAME]`: show or set provider.
108
140
  - `/model [MODEL]`: show or set model.
109
141
  - `/reason`: choose reasoning effort.
110
- - `/set KEY VALUE`: set provider/runtime values.
142
+ - `/set KEY VALUE`: set supported provider/runtime values for the current session.
111
143
  - `/yolo`: toggle tool confirmations.
112
144
  - `/exit`, `/quit`: exit.
113
145
 
114
146
  Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input supports history, completion, and `Ctrl-R` history search.
115
147
 
116
- ## Tools
148
+ Tools:
117
149
 
118
150
  - File: `Read`, `LineCount`, `List`, `Find`, `Search`.
119
151
  - Code index: `InspectCode`.
@@ -121,29 +153,30 @@ Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input
121
153
  - Shell: `Bash`, `Git`.
122
154
  - Tool results: `Recall`.
123
155
  - Working notes: `Note`.
124
- - MCP: `MCP` calls tools on configured MCP servers.
156
+ - Ask the user: `Question`.
157
+ - MCP: `MCP`.
125
158
 
126
159
  `Read`, `Search`, and `InspectCode` return line anchors where useful. `Edit` uses current `line:hash` anchors to reject stale edits.
127
160
 
128
161
  ## Configuration
129
162
 
130
- Run:
163
+ Default config location:
131
164
 
132
- ```sh
133
- nanocode --init-config
165
+ ```text
166
+ ~/.nanocode/config.toml
134
167
  ```
135
168
 
136
- Default config location is `~/.nanocode/config.toml`.
137
-
138
169
  Main fields:
139
170
 
140
171
  - `[provider] active = "name"`
141
172
  - `[provider.<name>]`: `url`, `key`, `model`, `api`, `prompt_cache_key`, `available_models`, `reasoning`, `chat_reasoning`, `temperature`, `timeout`
142
173
  - `[paths] data_dir`
143
- - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `yolo`
174
+ - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `check_updates`, `update_check_interval_hours`, `session_retention_days`, `yolo`, `debug`
144
175
 
145
176
  `api = "auto"` chooses between Chat Completions and Anthropic Messages using provider/model profiles. `prompt_cache_key = "auto"` derives a stable key from provider, model, workspace, and tool schema names.
146
177
 
178
+ Runtime flags such as `--yolo`, `--debug`, and `--mcp` apply to resumed sessions too. Saved sessions do not carry their old runtime config forward.
179
+
147
180
  ## MCP
148
181
 
149
182
  nanocode connects to [Model Context Protocol](https://modelcontextprotocol.io) servers and exposes their tools through the `MCP` tool. Configure each server under `[mcp.<name>]`. A server is either `url` (remote) or `command` (local), never both.
@@ -162,7 +195,7 @@ auth = "oauth" # browser login via /mcp login <serv
162
195
  enabled = true
163
196
  ```
164
197
 
165
- Local server over stdio (launched as a subprocess):
198
+ Local server over stdio:
166
199
 
167
200
  ```toml
168
201
  [mcp.filesystem]
@@ -181,16 +214,16 @@ Manage servers at runtime:
181
214
  - `/mcp refresh [server]`: rediscover servers.
182
215
  - `/mcp login <server>` / `/mcp logout <server>`: OAuth login and logout.
183
216
 
184
- ## Tested Providers
217
+ ## Providers
185
218
 
186
219
  The following providers have been tested with nanocode:
187
220
 
188
221
  - **deepseek**: DeepSeek API
189
222
  - **opencode**: OpenCode API
190
- - **aliyun**: Alibaba Cloud (Tongyi Qianwen) API via Chat Completions
223
+ - **aliyun**: Alibaba Cloud Tongyi Qianwen API via Chat Completions
191
224
  - **llama.cpp**: Local inference via llama.cpp server
192
225
 
193
- ## Context Design
226
+ ## Context Model
194
227
 
195
228
  Each model request is built manually from explicit messages. Stable context comes first, conversation stays as messages, working memory follows, and the latest file state is appended at the end.
196
229
 
@@ -201,16 +234,16 @@ model request
201
234
  | concise agent contract and tool rules |
202
235
  +--------------------------------------------------+
203
236
  | user |
204
- | Environment |
237
+ | Environment |
205
238
  +--------------------------------------------------+
206
- | user/assistant |
207
- | conversation, compacted summaries, tools |
239
+ | user/assistant |
240
+ | conversation, compacted summaries, tools |
208
241
  +--------------------------------------------------+
209
242
  | user |
210
- | Memory: goal, plan, known, date |
243
+ | Memory: goal, plan, known, date |
211
244
  +--------------------------------------------------+
212
245
  | user |
213
- | FILE STATE: latest Read/Edit file view |
246
+ | FILE STATE: latest Read/Edit file view |
214
247
  +--------------------------------------------------+
215
248
  ```
216
249
 
@@ -17,6 +17,7 @@ nanocode is pre-1.0 software. Commands, configuration, and tool behavior may cha
17
17
  - **Stale-edit protection**: `line:hash` anchors reject edits when the target code has drifted.
18
18
  - **Project-aware navigation**: Use the symbol index to jump through outlines, references, implementors, call chains, and changed files quickly.
19
19
  - **Recoverable context**: Tool output stays bounded in the prompt, while raw `tr.N` results remain recallable.
20
+ - **Session recovery**: Resume saved work with `nanocode --resume`, including restored conversation history.
20
21
  - **Cache-aware context**: Stable sections stay early and noisy working state stays late to improve prompt-cache reuse.
21
22
  - **Focused working memory**: `Note` separates goal, plan, and known facts from noisy execution logs.
22
23
  - **MCP integration**: Connect to remote (HTTP) or local (stdio) Model Context Protocol servers and call their tools.
@@ -24,6 +25,8 @@ nanocode is pre-1.0 software. Commands, configuration, and tool behavior may cha
24
25
 
25
26
  ## Install
26
27
 
28
+ Install with uv:
29
+
27
30
  ```sh
28
31
  uv tool install nanocode-cli
29
32
  ```
@@ -41,9 +44,15 @@ uv sync --extra dev
41
44
  uv run nanocode
42
45
  ```
43
46
 
44
- ## Usage
47
+ ## Quick Start
48
+
49
+ Create a config file:
50
+
51
+ ```sh
52
+ nanocode --init-config
53
+ ```
45
54
 
46
- Start the CLI:
55
+ Edit `~/.nanocode/config.toml`, then start:
47
56
 
48
57
  ```sh
49
58
  nanocode
@@ -53,15 +62,38 @@ Useful arguments:
53
62
 
54
63
  - `--config <path>`: use a TOML config file.
55
64
  - `--init-config`: create a default config file.
65
+ - `--resume [UID]`: resume a saved session; without `UID`, resumes `latest`.
56
66
  - `--yolo`: skip confirmations for mutating tools.
67
+ - `--mcp <selector>`: choose which configured MCP servers to enable.
68
+ - `--debug`: write model I/O debug traces.
57
69
  - `-v`, `--version`: show the version.
58
70
 
59
- During a running turn, the `+>` prompt accepts follow-up input for the next model request.
71
+ During a running turn, type into the `+>` prompt to add follow-up input for the next model request.
72
+
73
+ ## Sessions
74
+
75
+ nanocode saves recoverable non-empty sessions under `[paths] data_dir` and prints a restore command on exit:
76
+
77
+ ```sh
78
+ Resume with: nanocode --resume <session-id>
79
+ ```
80
+
81
+ Resume by id, or use the latest saved session:
82
+
83
+ ```sh
84
+ nanocode --resume <session-id>
85
+ nanocode --resume latest
86
+ nanocode --resume last
87
+ ```
88
+
89
+ Restored sessions replay the visible conversation history once; tool summaries are shown, raw tool result bodies are not. `/status` shows the active session id. Old session files are cleaned up after `runtime.session_retention_days` days, defaulting to `7`; set it to `0` to disable cleanup.
90
+
91
+ ## CLI
60
92
 
61
- ## Commands
93
+ Commands:
62
94
 
63
95
  - `/help`: show commands and tools.
64
- - `/status`: show runtime status.
96
+ - `/status`: show runtime status, including the active session id.
65
97
  - `/config`: show active config.
66
98
  - `/api [auto|chat|anthropic]`: show or set provider API format.
67
99
  - `/debug [on|off]`: toggle model I/O debug traces.
@@ -71,13 +103,13 @@ During a running turn, the `+>` prompt accepts follow-up input for the next mode
71
103
  - `/provider [NAME]`: show or set provider.
72
104
  - `/model [MODEL]`: show or set model.
73
105
  - `/reason`: choose reasoning effort.
74
- - `/set KEY VALUE`: set provider/runtime values.
106
+ - `/set KEY VALUE`: set supported provider/runtime values for the current session.
75
107
  - `/yolo`: toggle tool confirmations.
76
108
  - `/exit`, `/quit`: exit.
77
109
 
78
110
  Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input supports history, completion, and `Ctrl-R` history search.
79
111
 
80
- ## Tools
112
+ Tools:
81
113
 
82
114
  - File: `Read`, `LineCount`, `List`, `Find`, `Search`.
83
115
  - Code index: `InspectCode`.
@@ -85,29 +117,30 @@ Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input
85
117
  - Shell: `Bash`, `Git`.
86
118
  - Tool results: `Recall`.
87
119
  - Working notes: `Note`.
88
- - MCP: `MCP` calls tools on configured MCP servers.
120
+ - Ask the user: `Question`.
121
+ - MCP: `MCP`.
89
122
 
90
123
  `Read`, `Search`, and `InspectCode` return line anchors where useful. `Edit` uses current `line:hash` anchors to reject stale edits.
91
124
 
92
125
  ## Configuration
93
126
 
94
- Run:
127
+ Default config location:
95
128
 
96
- ```sh
97
- nanocode --init-config
129
+ ```text
130
+ ~/.nanocode/config.toml
98
131
  ```
99
132
 
100
- Default config location is `~/.nanocode/config.toml`.
101
-
102
133
  Main fields:
103
134
 
104
135
  - `[provider] active = "name"`
105
136
  - `[provider.<name>]`: `url`, `key`, `model`, `api`, `prompt_cache_key`, `available_models`, `reasoning`, `chat_reasoning`, `temperature`, `timeout`
106
137
  - `[paths] data_dir`
107
- - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `yolo`
138
+ - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `check_updates`, `update_check_interval_hours`, `session_retention_days`, `yolo`, `debug`
108
139
 
109
140
  `api = "auto"` chooses between Chat Completions and Anthropic Messages using provider/model profiles. `prompt_cache_key = "auto"` derives a stable key from provider, model, workspace, and tool schema names.
110
141
 
142
+ Runtime flags such as `--yolo`, `--debug`, and `--mcp` apply to resumed sessions too. Saved sessions do not carry their old runtime config forward.
143
+
111
144
  ## MCP
112
145
 
113
146
  nanocode connects to [Model Context Protocol](https://modelcontextprotocol.io) servers and exposes their tools through the `MCP` tool. Configure each server under `[mcp.<name>]`. A server is either `url` (remote) or `command` (local), never both.
@@ -126,7 +159,7 @@ auth = "oauth" # browser login via /mcp login <serv
126
159
  enabled = true
127
160
  ```
128
161
 
129
- Local server over stdio (launched as a subprocess):
162
+ Local server over stdio:
130
163
 
131
164
  ```toml
132
165
  [mcp.filesystem]
@@ -145,16 +178,16 @@ Manage servers at runtime:
145
178
  - `/mcp refresh [server]`: rediscover servers.
146
179
  - `/mcp login <server>` / `/mcp logout <server>`: OAuth login and logout.
147
180
 
148
- ## Tested Providers
181
+ ## Providers
149
182
 
150
183
  The following providers have been tested with nanocode:
151
184
 
152
185
  - **deepseek**: DeepSeek API
153
186
  - **opencode**: OpenCode API
154
- - **aliyun**: Alibaba Cloud (Tongyi Qianwen) API via Chat Completions
187
+ - **aliyun**: Alibaba Cloud Tongyi Qianwen API via Chat Completions
155
188
  - **llama.cpp**: Local inference via llama.cpp server
156
189
 
157
- ## Context Design
190
+ ## Context Model
158
191
 
159
192
  Each model request is built manually from explicit messages. Stable context comes first, conversation stays as messages, working memory follows, and the latest file state is appended at the end.
160
193
 
@@ -165,16 +198,16 @@ model request
165
198
  | concise agent contract and tool rules |
166
199
  +--------------------------------------------------+
167
200
  | user |
168
- | Environment |
201
+ | Environment |
169
202
  +--------------------------------------------------+
170
- | user/assistant |
171
- | conversation, compacted summaries, tools |
203
+ | user/assistant |
204
+ | conversation, compacted summaries, tools |
172
205
  +--------------------------------------------------+
173
206
  | user |
174
- | Memory: goal, plan, known, date |
207
+ | Memory: goal, plan, known, date |
175
208
  +--------------------------------------------------+
176
209
  | user |
177
- | FILE STATE: latest Read/Edit file view |
210
+ | FILE STATE: latest Read/Edit file view |
178
211
  +--------------------------------------------------+
179
212
  ```
180
213
 
@@ -15,8 +15,9 @@ nanocode 仍是 1.0 前的软件。稳定版发布前,命令、配置和工具
15
15
  - **实时回合控制**:代理还在工作时,也可以追加输入,不打断当前工具流程。
16
16
  - **文件状态大脑**:`Read` 和 `Edit` 会构建当前重要文件的带行号视图。
17
17
  - **过期编辑保护**:`line:hash` 锚点会在目标代码漂移后拒绝错误编辑。
18
- - **项目级导航**:通过符号索引快速查看 outline、references 和变更文件。
18
+ - **项目级导航**:通过符号索引快速查看 outline、references、implementors、call chains 和变更文件。
19
19
  - **可恢复上下文**:prompt 中的工具输出保持有界,原始 `tr.N` 结果仍可按需召回。
20
+ - **Session 恢复**:通过 `nanocode --resume` 恢复已保存工作,包括重新展示的会话历史。
20
21
  - **缓存友好上下文**:稳定内容靠前,嘈杂的工作状态靠后,提高 prompt cache 复用率。
21
22
  - **聚焦工作记忆**:`Note` 把 goal、plan、known facts 从嘈杂执行日志中拆出来。
22
23
  - **MCP 集成**:连接远程(HTTP)或本地(stdio)的 Model Context Protocol 服务器并调用其工具。
@@ -24,6 +25,8 @@ nanocode 仍是 1.0 前的软件。稳定版发布前,命令、配置和工具
24
25
 
25
26
  ## 安装
26
27
 
28
+ 使用 uv 安装:
29
+
27
30
  ```sh
28
31
  uv tool install nanocode-cli
29
32
  ```
@@ -41,9 +44,15 @@ uv sync --extra dev
41
44
  uv run nanocode
42
45
  ```
43
46
 
44
- ## 使用
47
+ ## 快速开始
48
+
49
+ 创建配置文件:
50
+
51
+ ```sh
52
+ nanocode --init-config
53
+ ```
45
54
 
46
- 启动 CLI:
55
+ 编辑 `~/.nanocode/config.toml`,然后启动:
47
56
 
48
57
  ```sh
49
58
  nanocode
@@ -53,15 +62,38 @@ nanocode
53
62
 
54
63
  - `--config <path>`:使用指定 TOML 配置文件。
55
64
  - `--init-config`:创建默认配置文件。
65
+ - `--resume [UID]`:恢复已保存的 session;不传 `UID` 时恢复 `latest`。
56
66
  - `--yolo`:跳过会修改环境的工具确认。
67
+ - `--mcp <selector>`:选择启用哪些已配置的 MCP 服务器。
68
+ - `--debug`:写入模型 I/O debug trace。
57
69
  - `-v`, `--version`:显示版本。
58
70
 
59
- 代理运行中,`+>` 提示符可以接收追加输入,并在下一次模型请求中发送。
71
+ 代理运行中,可以在 `+>` 提示符里输入追加内容,发送到下一次模型请求。
60
72
 
61
- ## 命令
73
+ ## Sessions
74
+
75
+ nanocode 会把有可恢复内容的非空 session 保存到 `[paths] data_dir` 下,并在退出时打印恢复命令:
76
+
77
+ ```sh
78
+ Resume with: nanocode --resume <session-id>
79
+ ```
80
+
81
+ 按 id 恢复,或恢复最近保存的 session:
82
+
83
+ ```sh
84
+ nanocode --resume <session-id>
85
+ nanocode --resume latest
86
+ nanocode --resume last
87
+ ```
88
+
89
+ 恢复后会在启动时重放一次可见会话历史;工具摘要会显示,但不会打印原始 tool result 正文。`/status` 会显示当前 session id。早于 `runtime.session_retention_days` 的 session 文件会在启动时清理,默认 `7` 天;设置为 `0` 可关闭清理。
90
+
91
+ ## CLI
92
+
93
+ 命令:
62
94
 
63
95
  - `/help`:显示命令和工具。
64
- - `/status`:显示运行状态。
96
+ - `/status`:显示运行状态,包括当前 session id。
65
97
  - `/config`:显示当前配置。
66
98
  - `/api [auto|chat|anthropic]`:显示或设置 provider API 格式。
67
99
  - `/debug [on|off]`:切换模型 I/O debug trace。
@@ -71,13 +103,13 @@ nanocode
71
103
  - `/provider [NAME]`:显示或设置 provider。
72
104
  - `/model [MODEL]`:显示或设置模型。
73
105
  - `/reason`:选择 reasoning effort。
74
- - `/set KEY VALUE`:设置 provider/runtime 值。
106
+ - `/set KEY VALUE`:设置当前 session 支持的 provider/runtime 值。
75
107
  - `/yolo`:切换工具确认。
76
108
  - `/exit`, `/quit`:退出。
77
109
 
78
110
  交互选择器支持 `j`/`k`、方向键、`/` 搜索、Enter 和 Esc。输入框支持历史、补全和 `Ctrl-R` 历史搜索。
79
111
 
80
- ## 工具
112
+ 工具:
81
113
 
82
114
  - 文件:`Read`, `LineCount`, `List`, `Find`, `Search`。
83
115
  - 代码索引:`InspectCode`。
@@ -85,29 +117,30 @@ nanocode
85
117
  - Shell:`Bash`, `Git`。
86
118
  - 工具结果:`Recall`。
87
119
  - 工作笔记:`Note`。
88
- - MCP:`MCP` 调用已配置 MCP 服务器上的工具。
120
+ - 询问用户:`Question`。
121
+ - MCP:`MCP`。
89
122
 
90
123
  `Read`、`Search` 和 `InspectCode` 会在合适时返回行锚点。`Edit` 使用当前 `line:hash` 锚点拒绝过期编辑。
91
124
 
92
125
  ## 配置
93
126
 
94
- 运行:
127
+ 默认配置位置:
95
128
 
96
- ```sh
97
- nanocode --init-config
129
+ ```text
130
+ ~/.nanocode/config.toml
98
131
  ```
99
132
 
100
- 默认配置位置是 `~/.nanocode/config.toml`。
101
-
102
133
  主要字段:
103
134
 
104
135
  - `[provider] active = "name"`
105
136
  - `[provider.<name>]`:`url`, `key`, `model`, `api`, `prompt_cache_key`, `available_models`, `reasoning`, `chat_reasoning`, `temperature`, `timeout`
106
137
  - `[paths] data_dir`
107
- - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `yolo`
138
+ - `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `check_updates`, `update_check_interval_hours`, `session_retention_days`, `yolo`, `debug`
108
139
 
109
140
  `api = "auto"` 会根据 provider/model profile 在 Chat Completions 和 Anthropic Messages 之间选择。`prompt_cache_key = "auto"` 会根据 provider、model、workspace 和工具 schema 名称生成稳定 key。
110
141
 
142
+ `--yolo`、`--debug` 和 `--mcp` 等 runtime flags 对恢复的 session 同样生效。保存的 session 不会携带旧 runtime config。
143
+
111
144
  ## MCP
112
145
 
113
146
  nanocode 可连接 [Model Context Protocol](https://modelcontextprotocol.io) 服务器,并通过 `MCP` 工具暴露其工具。每个服务器配置在 `[mcp.<name>]` 下,且只能二选一:`url`(远程)或 `command`(本地)。
@@ -126,7 +159,7 @@ auth = "oauth" # 通过 /mcp login <server> 在浏
126
159
  enabled = true
127
160
  ```
128
161
 
129
- 通过 stdio 的本地服务器(作为子进程启动):
162
+ 通过 stdio 的本地服务器:
130
163
 
131
164
  ```toml
132
165
  [mcp.filesystem]
@@ -145,15 +178,16 @@ HTTP 鉴权选项(`auth`、`bearer_token_env_var`、`env_http_headers`)只
145
178
  - `/mcp refresh [server]`:重新发现服务器。
146
179
  - `/mcp login <server>` / `/mcp logout <server>`:OAuth 登录和登出。
147
180
 
148
- ## 已测试的 Provider
181
+ ## Providers
149
182
 
150
183
  以下 provider 已在 nanocode 中测试通过:
151
184
 
152
- - **deepseek**: DeepSeek API
153
- - **opencode**: OpenCode API
154
- - **aliyun**: 阿里云通义千问 API(Chat Completions)
155
- - **llama.cpp**: 通过 llama.cpp 服务端本地推理
156
- ## 上下文设计
185
+ - **deepseek**:DeepSeek API
186
+ - **opencode**:OpenCode API
187
+ - **aliyun**:阿里云通义千问 API(Chat Completions)
188
+ - **llama.cpp**:通过 llama.cpp 服务端本地推理
189
+
190
+ ## 上下文模型
157
191
 
158
192
  每次模型请求都由 nanocode 手动构建成明确的 messages。稳定上下文在前,会话作为 messages 保留,工作记忆随后,最新文件状态放在末尾。
159
193
 
@@ -164,16 +198,16 @@ model request
164
198
  | concise agent contract and tool rules |
165
199
  +--------------------------------------------------+
166
200
  | user |
167
- | Environment |
201
+ | Environment |
168
202
  +--------------------------------------------------+
169
- | user/assistant |
170
- | conversation, compacted summaries, tools |
203
+ | user/assistant |
204
+ | conversation, compacted summaries, tools |
171
205
  +--------------------------------------------------+
172
206
  | user |
173
- | Memory: goal, plan, known, date |
207
+ | Memory: goal, plan, known, date |
174
208
  +--------------------------------------------------+
175
209
  | user |
176
- | FILE STATE: latest Read/Edit file view |
210
+ | FILE STATE: latest Read/Edit file view |
177
211
  +--------------------------------------------------+
178
212
  ```
179
213