nanocode-cli 0.4.9__tar.gz → 0.5.0__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.
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/MANIFEST.in +1 -0
- nanocode_cli-0.5.0/PKG-INFO +163 -0
- nanocode_cli-0.5.0/README.md +129 -0
- nanocode_cli-0.5.0/nanocode.py +3901 -0
- nanocode_cli-0.5.0/nanocode_cli.egg-info/PKG-INFO +163 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/nanocode_cli.egg-info/requires.txt +2 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/pyproject.toml +4 -2
- nanocode_cli-0.4.9/PKG-INFO +0 -147
- nanocode_cli-0.4.9/README.md +0 -115
- nanocode_cli-0.4.9/nanocode.py +0 -8249
- nanocode_cli-0.4.9/nanocode_cli.egg-info/PKG-INFO +0 -147
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/LICENSE +0 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/nanocode_cli.egg-info/SOURCES.txt +0 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/nanocode_cli.egg-info/dependency_links.txt +0 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/nanocode_cli.egg-info/entry_points.txt +0 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/nanocode_cli.egg-info/top_level.txt +0 -0
- {nanocode_cli-0.4.9 → nanocode_cli-0.5.0}/setup.cfg +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nanocode-cli
|
|
3
|
+
Version: 0.5.0
|
|
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: Topic :: Software Development
|
|
20
|
+
Classifier: Topic :: Terminals
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: anthropic>=0.64.0
|
|
25
|
+
Requires-Dist: code-symbol-index>=0.1.13
|
|
26
|
+
Requires-Dist: openai>=2.37.0
|
|
27
|
+
Requires-Dist: prompt-toolkit>=3.0
|
|
28
|
+
Requires-Dist: rich>=13.0
|
|
29
|
+
Requires-Dist: socksio>=1.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# nanocode
|
|
36
|
+
|
|
37
|
+
A small terminal coding agent written in Python.
|
|
38
|
+
|
|
39
|
+
nanocode is pre-1.0 software. Commands, configuration, and tool behavior may change before a stable release.
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **Snapshot context**: Every turn starts from a clean workspace snapshot instead of a bloated chat replay.
|
|
46
|
+
- **File memory**: Recent reads and edits stay available as focused, line-numbered file ranges.
|
|
47
|
+
- **Anchored edits**: `line:hash` anchors catch stale edits before they touch the wrong code.
|
|
48
|
+
- **Symbol index**: Jump from names to outlines, references, and changed files without searching blindly.
|
|
49
|
+
- **Tool recall**: Big outputs are bounded in the prompt but still recallable later by `tr.N`.
|
|
50
|
+
- **Terminal-native UI**: Model picking, history search, confirmations, live command output, and status all stay in the terminal.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
uv tool install nanocode-cli
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For local development:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
uv sync --extra dev
|
|
62
|
+
uv run nanocode
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Start the CLI:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
nanocode
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Useful arguments:
|
|
74
|
+
|
|
75
|
+
- `--config <path>`: use a TOML config file.
|
|
76
|
+
- `--init-config`: create a default config file.
|
|
77
|
+
- `--yolo`: skip confirmations for mutating tools.
|
|
78
|
+
- `-v`, `--version`: show the version.
|
|
79
|
+
|
|
80
|
+
## Commands
|
|
81
|
+
|
|
82
|
+
- `/help`: show commands and tools.
|
|
83
|
+
- `/status`: show runtime status.
|
|
84
|
+
- `/config`: show active config.
|
|
85
|
+
- `/api [auto|chat|anthropic]`: show or set provider API format.
|
|
86
|
+
- `/debug [on|off]`: toggle model I/O debug traces.
|
|
87
|
+
- `/compact`: compact context now.
|
|
88
|
+
- `/index [force]`: sync or rebuild the code symbol index.
|
|
89
|
+
- `/provider [NAME]`: show or set provider.
|
|
90
|
+
- `/model [MODEL]`: show or set model.
|
|
91
|
+
- `/reason`: choose reasoning effort.
|
|
92
|
+
- `/set KEY VALUE`: set provider/runtime values.
|
|
93
|
+
- `/yolo`: toggle tool confirmations.
|
|
94
|
+
- `/exit`, `/quit`: exit.
|
|
95
|
+
|
|
96
|
+
Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input supports history, completion, and `Ctrl-R` history search.
|
|
97
|
+
|
|
98
|
+
## Tools
|
|
99
|
+
|
|
100
|
+
- File: `Read`, `LineCount`, `List`, `Search`.
|
|
101
|
+
- Code index: `InspectCode`.
|
|
102
|
+
- Edit: `CreateFile`, `Edit`.
|
|
103
|
+
- Shell: `Bash`, `Git`.
|
|
104
|
+
- Tool results: `Recall`, `Forget`.
|
|
105
|
+
|
|
106
|
+
`Read`, `Search`, and `InspectCode` return line anchors where useful. `Edit` uses current `line:hash` anchors to reject stale edits.
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
Run:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
nanocode --init-config
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Default config location is `~/.nanocode/config.toml`.
|
|
117
|
+
|
|
118
|
+
Main fields:
|
|
119
|
+
|
|
120
|
+
- `[provider] active = "name"`
|
|
121
|
+
- `[provider.<name>]`: `url`, `key`, `model`, `api`, `prompt_cache_key`, `available_models`, `reasoning`, `chat_reasoning`, `temperature`, `timeout`
|
|
122
|
+
- `[paths] data_dir`
|
|
123
|
+
- `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `yolo`
|
|
124
|
+
|
|
125
|
+
`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.
|
|
126
|
+
|
|
127
|
+
## Context Design
|
|
128
|
+
|
|
129
|
+
Each model request is built manually as one system message and one user message. The user message is a structured context snapshot, ordered from stable sections to volatile sections so provider prompt caching can reuse the prefix.
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
model request
|
|
133
|
+
+--------------------------------------------------+
|
|
134
|
+
| system |
|
|
135
|
+
| concise agent contract and tool rules |
|
|
136
|
+
+--------------------------------------------------+
|
|
137
|
+
| user |
|
|
138
|
+
| Environment |
|
|
139
|
+
| State |
|
|
140
|
+
| Summary |
|
|
141
|
+
| Recent Conversation |
|
|
142
|
+
| Tool Result Index |
|
|
143
|
+
| File Context |
|
|
144
|
+
| Discovery Context |
|
|
145
|
+
| Error Feedback |
|
|
146
|
+
| Latest Tool Results |
|
|
147
|
+
| Current User Request |
|
|
148
|
+
+--------------------------------------------------+
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Core rules:
|
|
152
|
+
|
|
153
|
+
- File Context is rebuilt dynamically from active `Read` and `Edit` results.
|
|
154
|
+
- Newer file lines overwrite older lines; edit invalidations clear stale ranges.
|
|
155
|
+
- File lines are checked against current file stat or line hash before being shown.
|
|
156
|
+
- Discovery Context contains `Search` and `InspectCode` leads, not source truth.
|
|
157
|
+
- Large tool outputs are bounded in context and can be recalled by `tr.N`.
|
|
158
|
+
- Error Feedback keeps only recent failed tool calls.
|
|
159
|
+
- `Forget` removes stale result keys from the active tool result store.
|
|
160
|
+
|
|
161
|
+
## Safety
|
|
162
|
+
|
|
163
|
+
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
|
+
# nanocode
|
|
2
|
+
|
|
3
|
+
A small terminal coding agent written in Python.
|
|
4
|
+
|
|
5
|
+
nanocode is pre-1.0 software. Commands, configuration, and tool behavior may change before a stable release.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Snapshot context**: Every turn starts from a clean workspace snapshot instead of a bloated chat replay.
|
|
12
|
+
- **File memory**: Recent reads and edits stay available as focused, line-numbered file ranges.
|
|
13
|
+
- **Anchored edits**: `line:hash` anchors catch stale edits before they touch the wrong code.
|
|
14
|
+
- **Symbol index**: Jump from names to outlines, references, and changed files without searching blindly.
|
|
15
|
+
- **Tool recall**: Big outputs are bounded in the prompt but still recallable later by `tr.N`.
|
|
16
|
+
- **Terminal-native UI**: Model picking, history search, confirmations, live command output, and status all stay in the terminal.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
uv tool install nanocode-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For local development:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
uv sync --extra dev
|
|
28
|
+
uv run nanocode
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Start the CLI:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
nanocode
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Useful arguments:
|
|
40
|
+
|
|
41
|
+
- `--config <path>`: use a TOML config file.
|
|
42
|
+
- `--init-config`: create a default config file.
|
|
43
|
+
- `--yolo`: skip confirmations for mutating tools.
|
|
44
|
+
- `-v`, `--version`: show the version.
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
- `/help`: show commands and tools.
|
|
49
|
+
- `/status`: show runtime status.
|
|
50
|
+
- `/config`: show active config.
|
|
51
|
+
- `/api [auto|chat|anthropic]`: show or set provider API format.
|
|
52
|
+
- `/debug [on|off]`: toggle model I/O debug traces.
|
|
53
|
+
- `/compact`: compact context now.
|
|
54
|
+
- `/index [force]`: sync or rebuild the code symbol index.
|
|
55
|
+
- `/provider [NAME]`: show or set provider.
|
|
56
|
+
- `/model [MODEL]`: show or set model.
|
|
57
|
+
- `/reason`: choose reasoning effort.
|
|
58
|
+
- `/set KEY VALUE`: set provider/runtime values.
|
|
59
|
+
- `/yolo`: toggle tool confirmations.
|
|
60
|
+
- `/exit`, `/quit`: exit.
|
|
61
|
+
|
|
62
|
+
Interactive selectors support `j`/`k`, arrows, `/` search, Enter, and Esc. Input supports history, completion, and `Ctrl-R` history search.
|
|
63
|
+
|
|
64
|
+
## Tools
|
|
65
|
+
|
|
66
|
+
- File: `Read`, `LineCount`, `List`, `Search`.
|
|
67
|
+
- Code index: `InspectCode`.
|
|
68
|
+
- Edit: `CreateFile`, `Edit`.
|
|
69
|
+
- Shell: `Bash`, `Git`.
|
|
70
|
+
- Tool results: `Recall`, `Forget`.
|
|
71
|
+
|
|
72
|
+
`Read`, `Search`, and `InspectCode` return line anchors where useful. `Edit` uses current `line:hash` anchors to reject stale edits.
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
Run:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
nanocode --init-config
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Default config location is `~/.nanocode/config.toml`.
|
|
83
|
+
|
|
84
|
+
Main fields:
|
|
85
|
+
|
|
86
|
+
- `[provider] active = "name"`
|
|
87
|
+
- `[provider.<name>]`: `url`, `key`, `model`, `api`, `prompt_cache_key`, `available_models`, `reasoning`, `chat_reasoning`, `temperature`, `timeout`
|
|
88
|
+
- `[paths] data_dir`
|
|
89
|
+
- `[runtime] shell_timeout`, `max_agent_steps`, `max_context_tokens`, `yolo`
|
|
90
|
+
|
|
91
|
+
`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.
|
|
92
|
+
|
|
93
|
+
## Context Design
|
|
94
|
+
|
|
95
|
+
Each model request is built manually as one system message and one user message. The user message is a structured context snapshot, ordered from stable sections to volatile sections so provider prompt caching can reuse the prefix.
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
model request
|
|
99
|
+
+--------------------------------------------------+
|
|
100
|
+
| system |
|
|
101
|
+
| concise agent contract and tool rules |
|
|
102
|
+
+--------------------------------------------------+
|
|
103
|
+
| user |
|
|
104
|
+
| Environment |
|
|
105
|
+
| State |
|
|
106
|
+
| Summary |
|
|
107
|
+
| Recent Conversation |
|
|
108
|
+
| Tool Result Index |
|
|
109
|
+
| File Context |
|
|
110
|
+
| Discovery Context |
|
|
111
|
+
| Error Feedback |
|
|
112
|
+
| Latest Tool Results |
|
|
113
|
+
| Current User Request |
|
|
114
|
+
+--------------------------------------------------+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Core rules:
|
|
118
|
+
|
|
119
|
+
- File Context is rebuilt dynamically from active `Read` and `Edit` results.
|
|
120
|
+
- Newer file lines overwrite older lines; edit invalidations clear stale ranges.
|
|
121
|
+
- File lines are checked against current file stat or line hash before being shown.
|
|
122
|
+
- Discovery Context contains `Search` and `InspectCode` leads, not source truth.
|
|
123
|
+
- Large tool outputs are bounded in context and can be recalled by `tr.N`.
|
|
124
|
+
- Error Feedback keeps only recent failed tool calls.
|
|
125
|
+
- `Forget` removes stale result keys from the active tool result store.
|
|
126
|
+
|
|
127
|
+
## Safety
|
|
128
|
+
|
|
129
|
+
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.
|