nanocode-cli 0.9.0__tar.gz → 0.9.2__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.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: nanocode-cli
3
+ Version: 0.9.2
4
+ Summary: A small terminal coding agent written in Python
5
+ Author-email: hit9 <hit9@icloud.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/hit9/nanocode
8
+ Project-URL: Repository, https://github.com/hit9/nanocode
9
+ Project-URL: Issues, https://github.com/hit9/nanocode/issues
10
+ Keywords: ai,coding-assistant,cli,terminal
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Topic :: Software Development
22
+ Classifier: Topic :: Terminals
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: anthropic>=0.64.0
27
+ Requires-Dist: code-symbol-index>=0.3.5
28
+ Requires-Dist: json-repair
29
+ Requires-Dist: fastmcp-slim[client]<4,>=3
30
+ Requires-Dist: openai>=2.37.0
31
+ Requires-Dist: prompt-toolkit>=3.0
32
+ Requires-Dist: rich>=13.0
33
+ Requires-Dist: socksio>=1.0.0
34
+ Requires-Dist: websockets>=15.0.1
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ <h1 align="center">nanocode-cli</h1>
41
+
42
+ <p align="center">
43
+ A coding agent I use, maintain, and customize in one Python file.
44
+ </p>
45
+
46
+ <p align="center">
47
+ <img src="snapshots/nanocode1.gif" alt="nanocode demo" width="600">
48
+ </p>
49
+ <p align="center"><sub>Editing code and running tools in one interactive session.</sub></p>
50
+
51
+ <p align="center"><a href="README.zh-CN.md">中文</a></p>
52
+
53
+ ## Install
54
+
55
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
56
+
57
+ ```sh
58
+ uv tool install nanocode-cli
59
+ nanocode --init-config
60
+ ```
61
+
62
+ Configure any OpenAI-compatible provider in `~/.nanocode/config.toml`. For example, [DeepSeek Flash](https://api-docs.deepseek.com/):
63
+
64
+ ```toml
65
+ [provider]
66
+ active = "default"
67
+
68
+ [provider.default]
69
+ url = "https://api.deepseek.com"
70
+ key = "API_KEY"
71
+ model = "deepseek-v4-flash"
72
+ ```
73
+
74
+ Replace `url`, `key`, and `model` with the values from your provider.
75
+
76
+ Then start:
77
+
78
+ ```sh
79
+ nanocode
80
+ ```
81
+
82
+ Upgrade: `nanocode upgrade`
83
+
84
+ Common flags:
85
+
86
+ - `--resume [UID]`: resume a saved session; without UID, resumes latest
87
+ - `--yolo`: skip tool confirmations
88
+ - `--mcp <selector>`: choose which MCP servers to enable
89
+ - `--config <path>`: use a specific TOML config file
90
+
91
+ ## A working personal agent
92
+
93
+ nanocode does not introduce a new kind of coding agent. It combines familiar features—reading and editing files, running commands, follow-ups, sessions, diffs, MCP, and skills—into a tool I use personally.
94
+
95
+ It works on real repositories, including its own: I use nanocode to build and maintain nanocode. Everything ships in one Python module, so I can change the behavior directly whenever I want the workflow to work differently.
96
+
97
+ <p align="center">
98
+ <img src="snapshots/nanocode2.gif" alt="nanocode session" width="600">
99
+ </p>
100
+ <p align="center"><sub>Resuming a saved session with its conversation and tool history.</sub></p>
101
+
102
+ ## Highlights
103
+
104
+ - **Live follow-ups:** type while the agent works; queued input joins the next model request or can interrupt the current one.
105
+ - **Anchored edits:** structured edits use `line:hash` anchors and reject stale file content instead of guessing.
106
+ - **Resumable sessions:** conversation, completed tool calls, diffs, and working memory survive interruption and `--resume`.
107
+ - **Built-in diff viewer:** `/diff` shows changes from the latest user round and the net session result.
108
+ - **Prompt-cache aware:** stable instructions, environment, and tool schemas preserve reusable request prefixes.
109
+ - **Provider compatibility:** tested with DeepSeek, OpenCode, Alibaba Cloud, and ZenMux; other OpenAI-compatible endpoints should work in principle. Anthropic APIs, remote/local MCP servers, and Markdown skills are also supported.
110
+
111
+ ## Common commands
112
+
113
+ | Command | Description |
114
+ |---|---|
115
+ | `/help` | Show the complete command and tool reference |
116
+ | `/status` | Runtime status: token usage, context %, cache hit rate |
117
+ | `/context` | Model context frame — environment and memory (goal/plan/known/check) |
118
+ | `/diff` | Latest edit diffs and net session diff (interactive, tabbed) |
119
+ | `/compact` | Compact context now |
120
+ | `/mcp` | Manage MCP servers and tools |
121
+ | `/model [MODEL]` | Show or switch model |
122
+ | `/yolo` | Toggle tool confirmations |
123
+
124
+ Run `/help` for every command, tool, and shortcut. Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc; input supports history completion and `Ctrl-R` search.
125
+
126
+ ## Configuration
127
+
128
+ Config file: `~/.nanocode/config.toml`
129
+
130
+ The generated file documents common provider and runtime options. Multiple `[provider.<name>]` sections are supported; select one with `[provider] active = "name"`. Use `/config` to inspect the active configuration and `/help` for runtime commands.
131
+
132
+ ## MCP
133
+
134
+ Connect to [Model Context Protocol](https://modelcontextprotocol.io) servers and expose their tools through `MCP`.
135
+
136
+ Remote server (HTTP):
137
+
138
+ ```toml
139
+ [mcp.example]
140
+ url = "https://example.com/mcp"
141
+ bearer_token_env_var = "EXAMPLE_MCP_TOKEN" # optional
142
+ enabled = true
143
+ ```
144
+
145
+ Local server (stdio):
146
+
147
+ ```toml
148
+ [mcp.filesystem]
149
+ command = "npx"
150
+ args = ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
151
+ enabled = true
152
+ ```
153
+
154
+ Runtime management: `/mcp` to view status, `/mcp tools [server]` to list tools, `/mcp login/logout <server>` for OAuth.
155
+
156
+ ## Skills
157
+
158
+ Skills are instruction packs the agent loads on demand. Each skill is a folder with a `SKILL.md`.
159
+
160
+ - **Discovery**: `.nanocode/skills/` (project) and `~/.nanocode/skills/` (user); project wins on name clash
161
+ - **Model view**: only a name + description index sits in context; the full body loads on `Skill(name)` call
162
+ - **Inline reference**: type `$name` in a message (Tab-completes) to inject that skill's instructions
163
+ - **Bundled scripts**: `{skill_dir}` expands to the skill's absolute path for running via `Bash`
164
+ - **Built-in**: ships with a `nanocode-help` skill containing a self-contained manual and auto-generated command/tool/config lists
165
+
166
+ ## Safety
167
+
168
+ **Use at your own risk.** nanocode can edit files and run shell commands in the environment where it is started. It does not provide sandbox protection. Run it inside your own sandbox, container, VM, or other isolated environment when needed.
@@ -0,0 +1,129 @@
1
+ <h1 align="center">nanocode-cli</h1>
2
+
3
+ <p align="center">
4
+ A coding agent I use, maintain, and customize in one Python file.
5
+ </p>
6
+
7
+ <p align="center">
8
+ <img src="snapshots/nanocode1.gif" alt="nanocode demo" width="600">
9
+ </p>
10
+ <p align="center"><sub>Editing code and running tools in one interactive session.</sub></p>
11
+
12
+ <p align="center"><a href="README.zh-CN.md">中文</a></p>
13
+
14
+ ## Install
15
+
16
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
17
+
18
+ ```sh
19
+ uv tool install nanocode-cli
20
+ nanocode --init-config
21
+ ```
22
+
23
+ Configure any OpenAI-compatible provider in `~/.nanocode/config.toml`. For example, [DeepSeek Flash](https://api-docs.deepseek.com/):
24
+
25
+ ```toml
26
+ [provider]
27
+ active = "default"
28
+
29
+ [provider.default]
30
+ url = "https://api.deepseek.com"
31
+ key = "API_KEY"
32
+ model = "deepseek-v4-flash"
33
+ ```
34
+
35
+ Replace `url`, `key`, and `model` with the values from your provider.
36
+
37
+ Then start:
38
+
39
+ ```sh
40
+ nanocode
41
+ ```
42
+
43
+ Upgrade: `nanocode upgrade`
44
+
45
+ Common flags:
46
+
47
+ - `--resume [UID]`: resume a saved session; without UID, resumes latest
48
+ - `--yolo`: skip tool confirmations
49
+ - `--mcp <selector>`: choose which MCP servers to enable
50
+ - `--config <path>`: use a specific TOML config file
51
+
52
+ ## A working personal agent
53
+
54
+ nanocode does not introduce a new kind of coding agent. It combines familiar features—reading and editing files, running commands, follow-ups, sessions, diffs, MCP, and skills—into a tool I use personally.
55
+
56
+ It works on real repositories, including its own: I use nanocode to build and maintain nanocode. Everything ships in one Python module, so I can change the behavior directly whenever I want the workflow to work differently.
57
+
58
+ <p align="center">
59
+ <img src="snapshots/nanocode2.gif" alt="nanocode session" width="600">
60
+ </p>
61
+ <p align="center"><sub>Resuming a saved session with its conversation and tool history.</sub></p>
62
+
63
+ ## Highlights
64
+
65
+ - **Live follow-ups:** type while the agent works; queued input joins the next model request or can interrupt the current one.
66
+ - **Anchored edits:** structured edits use `line:hash` anchors and reject stale file content instead of guessing.
67
+ - **Resumable sessions:** conversation, completed tool calls, diffs, and working memory survive interruption and `--resume`.
68
+ - **Built-in diff viewer:** `/diff` shows changes from the latest user round and the net session result.
69
+ - **Prompt-cache aware:** stable instructions, environment, and tool schemas preserve reusable request prefixes.
70
+ - **Provider compatibility:** tested with DeepSeek, OpenCode, Alibaba Cloud, and ZenMux; other OpenAI-compatible endpoints should work in principle. Anthropic APIs, remote/local MCP servers, and Markdown skills are also supported.
71
+
72
+ ## Common commands
73
+
74
+ | Command | Description |
75
+ |---|---|
76
+ | `/help` | Show the complete command and tool reference |
77
+ | `/status` | Runtime status: token usage, context %, cache hit rate |
78
+ | `/context` | Model context frame — environment and memory (goal/plan/known/check) |
79
+ | `/diff` | Latest edit diffs and net session diff (interactive, tabbed) |
80
+ | `/compact` | Compact context now |
81
+ | `/mcp` | Manage MCP servers and tools |
82
+ | `/model [MODEL]` | Show or switch model |
83
+ | `/yolo` | Toggle tool confirmations |
84
+
85
+ Run `/help` for every command, tool, and shortcut. Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc; input supports history completion and `Ctrl-R` search.
86
+
87
+ ## Configuration
88
+
89
+ Config file: `~/.nanocode/config.toml`
90
+
91
+ The generated file documents common provider and runtime options. Multiple `[provider.<name>]` sections are supported; select one with `[provider] active = "name"`. Use `/config` to inspect the active configuration and `/help` for runtime commands.
92
+
93
+ ## MCP
94
+
95
+ Connect to [Model Context Protocol](https://modelcontextprotocol.io) servers and expose their tools through `MCP`.
96
+
97
+ Remote server (HTTP):
98
+
99
+ ```toml
100
+ [mcp.example]
101
+ url = "https://example.com/mcp"
102
+ bearer_token_env_var = "EXAMPLE_MCP_TOKEN" # optional
103
+ enabled = true
104
+ ```
105
+
106
+ Local server (stdio):
107
+
108
+ ```toml
109
+ [mcp.filesystem]
110
+ command = "npx"
111
+ args = ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
112
+ enabled = true
113
+ ```
114
+
115
+ Runtime management: `/mcp` to view status, `/mcp tools [server]` to list tools, `/mcp login/logout <server>` for OAuth.
116
+
117
+ ## Skills
118
+
119
+ Skills are instruction packs the agent loads on demand. Each skill is a folder with a `SKILL.md`.
120
+
121
+ - **Discovery**: `.nanocode/skills/` (project) and `~/.nanocode/skills/` (user); project wins on name clash
122
+ - **Model view**: only a name + description index sits in context; the full body loads on `Skill(name)` call
123
+ - **Inline reference**: type `$name` in a message (Tab-completes) to inject that skill's instructions
124
+ - **Bundled scripts**: `{skill_dir}` expands to the skill's absolute path for running via `Bash`
125
+ - **Built-in**: ships with a `nanocode-help` skill containing a self-contained manual and auto-generated command/tool/config lists
126
+
127
+ ## Safety
128
+
129
+ **Use at your own risk.** nanocode can edit files and run shell commands in the environment where it is started. It does not provide sandbox protection. Run it inside your own sandbox, container, VM, or other isolated environment when needed.
@@ -0,0 +1,129 @@
1
+ <h1 align="center">nanocode-cli</h1>
2
+
3
+ <p align="center">
4
+ 一个由我使用、维护和定制的 coding agent,集中在一个 Python 文件中。
5
+ </p>
6
+
7
+ <p align="center">
8
+ <img src="snapshots/nanocode1.gif" alt="nanocode demo" width="600">
9
+ </p>
10
+ <p align="center"><sub>在一个交互式 session 中编辑代码并运行工具。</sub></p>
11
+
12
+ <p align="center"><a href="README.md">English</a></p>
13
+
14
+ ## 安装
15
+
16
+ 需要 Python 3.11+ 和 [uv](https://docs.astral.sh/uv/)。
17
+
18
+ ```sh
19
+ uv tool install nanocode-cli
20
+ nanocode --init-config
21
+ ```
22
+
23
+ 在 `~/.nanocode/config.toml` 中配置任意 OpenAI-compatible provider。例如使用 [DeepSeek Flash](https://api-docs.deepseek.com/):
24
+
25
+ ```toml
26
+ [provider]
27
+ active = "default"
28
+
29
+ [provider.default]
30
+ url = "https://api.deepseek.com"
31
+ key = "API_KEY"
32
+ model = "deepseek-v4-flash"
33
+ ```
34
+
35
+ 将 `url`、`key` 和 `model` 替换为你的 provider 所提供的值。
36
+
37
+ 然后启动:
38
+
39
+ ```sh
40
+ nanocode
41
+ ```
42
+
43
+ 升级:`nanocode upgrade`
44
+
45
+ 常用参数:
46
+
47
+ - `--resume [UID]`:恢复已保存的 session,不传 UID 恢复最近一次
48
+ - `--yolo`:跳过工具确认,直接执行
49
+ - `--mcp <selector>`:选择启用哪些 MCP 服务器
50
+ - `--config <path>`:使用指定的 TOML 配置文件
51
+
52
+ ## 一个能实际工作的个人 Agent
53
+
54
+ nanocode 并没有发明一种新的 coding agent。它把读取和编辑文件、运行命令、follow-up、session、diff、MCP 和 skill 这些常见能力组合成一个我个人使用的工具。
55
+
56
+ 它可以在真实代码仓库中工作,也包括它自己的仓库:我正在用 nanocode 构建和维护 nanocode。所有实现都集中在一个 Python 模块中,所以只要我想改变工作方式,就可以直接修改它的行为。
57
+
58
+ <p align="center">
59
+ <img src="snapshots/nanocode2.gif" alt="nanocode session" width="600">
60
+ </p>
61
+ <p align="center"><sub>恢复保存的 session,包括对话和工具调用历史。</sub></p>
62
+
63
+ ## 亮点
64
+
65
+ - **实时 follow-up:** Agent 工作时仍可输入;排队消息进入下一次模型请求,也可以中断当前请求立即发送。
66
+ - **锚点编辑:** 结构化编辑使用 `line:hash` 锚点,遇到过期文件内容时拒绝执行,而不是猜测。
67
+ - **可恢复 session:** 对话、已完成的工具调用、diff 和工作记忆在中断后仍可通过 `--resume` 恢复。
68
+ - **内置 diff viewer:** `/diff` 显示最新用户 round 的变更和整个 session 的净结果。
69
+ - **Prompt-cache 友好:** 稳定的指令、环境信息和工具 schema 保持可复用的请求前缀。
70
+ - **Provider 兼容性:** 已测试 DeepSeek、OpenCode、阿里云和 ZenMux;理论上其他 OpenAI-compatible endpoint 也可以工作。此外还支持 Anthropic API、远程/本地 MCP server 和 Markdown skill。
71
+
72
+ ## 常用命令
73
+
74
+ | 命令 | 用途 |
75
+ |---|---|
76
+ | `/help` | 显示完整命令和工具参考 |
77
+ | `/status` | 运行状态:token 用量、context 占比、缓存命中率 |
78
+ | `/context` | 模型上下文帧——环境、记忆(goal/plan/known/check) |
79
+ | `/diff` | 最新编辑 diff 和 session 整体净 diff(交互式,支持标签切换) |
80
+ | `/compact` | 立即压缩上下文 |
81
+ | `/mcp` | 管理 MCP 服务器和工具 |
82
+ | `/model [MODEL]` | 显示或切换模型 |
83
+ | `/yolo` | 切换工具确认 |
84
+
85
+ 运行 `/help` 查看全部命令、工具和快捷键。交互选择器支持 `j`/`k`、方向键、`/` 搜索、Enter 和 Esc;输入支持历史补全和 `Ctrl-R` 历史搜索。
86
+
87
+ ## 配置
88
+
89
+ 配置文件:`~/.nanocode/config.toml`
90
+
91
+ 生成的配置文件会说明常用 provider 和 runtime 选项。可以定义多个 `[provider.<name>]`,再通过 `[provider] active = "name"` 选择。使用 `/config` 查看当前配置,使用 `/help` 查看运行时命令。
92
+
93
+ ## MCP
94
+
95
+ 连接 [Model Context Protocol](https://modelcontextprotocol.io) 服务器,通过 `MCP` 工具暴露其能力。
96
+
97
+ 远程服务器(HTTP):
98
+
99
+ ```toml
100
+ [mcp.example]
101
+ url = "https://example.com/mcp"
102
+ bearer_token_env_var = "EXAMPLE_MCP_TOKEN" # 可选
103
+ enabled = true
104
+ ```
105
+
106
+ 本地服务器(stdio):
107
+
108
+ ```toml
109
+ [mcp.filesystem]
110
+ command = "npx"
111
+ args = ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
112
+ enabled = true
113
+ ```
114
+
115
+ 运行时管理:`/mcp` 查看状态,`/mcp tools [server]` 列出工具,`/mcp login/logout <server>` 管理 OAuth。
116
+
117
+ ## Skills
118
+
119
+ Skills 是 agent 按需加载的指令包。每个 skill 是一个包含 `SKILL.md` 的文件夹。
120
+
121
+ - **发现**:`.nanocode/skills/`(项目级)和 `~/.nanocode/skills/`(用户级),同名时项目优先
122
+ - **模型视角**:上下文只放 name + description 索引,正文在 `Skill(name)` 调用时加载
123
+ - **内联引用**:消息中 `$name` 直接引用(Tab 补全)
124
+ - **随附脚本**:`{skill_dir}` 展开为 skill 目录绝对路径,可通过 `Bash` 运行
125
+ - **内置**:默认自带 `nanocode-help` skill,包含使用手册和自动生成的命令/工具/配置清单
126
+
127
+ ## 安全
128
+
129
+ **使用风险自负。** nanocode 会在启动它的环境中编辑文件和执行 shell 命令。它不提供 sandbox 保护。需要隔离时,请在你自己的 sandbox、容器、虚拟机或其他隔离环境中运行。