contree-cli 0.2.3__py3-none-any.whl

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,323 @@
1
+ Metadata-Version: 2.3
2
+ Name: contree-cli
3
+ Version: 0.2.3
4
+ Summary: ConTree simple CLI
5
+ Requires-Python: >=3.10
6
+ Project-URL: Homepage, https://contree.dev
7
+ Project-URL: Documentation, https://docs.contree.dev/cli/
8
+ Project-URL: Repository, https://github.com/nebius/contree-cli
9
+ Project-URL: Issues, https://github.com/nebius/contree-cli/issues
10
+ Project-URL: Changelog, https://github.com/nebius/contree-cli/releases
11
+ Description-Content-Type: text/markdown
12
+
13
+ # contree-cli
14
+
15
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
16
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](#zero-dependencies)
17
+ [![PyPI](https://img.shields.io/pypi/v/contree-cli.svg)](https://pypi.org/project/contree-cli/)
18
+
19
+ Command-line client for the [ConTree](https://contree.dev) sandboxing platform — secure, VM-isolated sandboxes with git-like branching for AI agents and developers.
20
+
21
+ ```bash
22
+ eval $(contree use tag:ubuntu:latest) # pick a base image for current session
23
+ contree run apt-get update -qq # each run snapshots the result
24
+ contree run apt-get install -y curl # builds on the previous snapshot
25
+ contree session branch experiment # branch the sandbox state
26
+ contree run -- make test # experiment freely
27
+ contree session checkout main # switch back instantly
28
+ contree session rollback 2 # or rewind two steps
29
+ ```
30
+
31
+ ## What is ConTree?
32
+
33
+ [ConTree](https://contree.dev) is a secure sandbox API that runs every command inside a VM-isolated instance and snapshots the full filesystem after each execution. These snapshots (called **images**) form a tree — branch from any checkpoint, explore paths in parallel, and roll back on failure.
34
+
35
+ **Built for AI agents that think ahead:**
36
+
37
+ - **Tree-search execution** — branch sandbox state so an agent can explore multiple solution paths in parallel and keep the best one
38
+ - **Instant rollback** — backtrack to any previous checkpoint without rebuilding from scratch
39
+ - **Safe code execution** — run untrusted or LLM-generated code inside VM-level isolation; crashes and side effects stay in the sandbox
40
+ - **Session continuity** — rewind and resume long-running agent workflows with full filesystem context preserved
41
+
42
+ `contree-cli` talks to the ConTree API. Install it, authenticate with your project token, and create sandboxes, run commands, inspect filesystems, and manage sessions — all from your terminal, shell scripts, or agent toolchains.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install contree-cli
48
+ ```
49
+
50
+ Or with [uv](https://docs.astral.sh/uv/):
51
+
52
+ ```bash
53
+ uv tool install contree-cli
54
+ ```
55
+
56
+ <details>
57
+ <summary>More options (pipx, from source)</summary>
58
+
59
+ ```bash
60
+ # pipx
61
+ pipx install contree-cli
62
+
63
+ # From source
64
+ git clone https://github.com/nebius/contree-cli.git
65
+ cd contree-cli
66
+ pip install .
67
+ ```
68
+
69
+ </details>
70
+
71
+ Verify:
72
+
73
+ ```bash
74
+ contree --help
75
+ ```
76
+
77
+ **Requirements:** Python 3.10+ and nothing else. Zero external dependencies — stdlib only.
78
+
79
+ ## Quick Start
80
+
81
+ ### 1. Authenticate
82
+
83
+ ```bash
84
+ contree auth
85
+ ```
86
+
87
+ You'll be prompted to enter your API token securely. The CLI verifies it and saves it to `~/.config/contree-cli/config.ini`.
88
+
89
+ ### 2. Start a session
90
+
91
+ ```bash
92
+ eval $(contree use tag:ubuntu:latest)
93
+ ```
94
+
95
+ This picks a base image and creates a session. The `eval` wrapper exports the session variable so subsequent commands share the same state.
96
+
97
+ ### 3. Run commands
98
+
99
+ ```bash
100
+ contree run uname -a # direct execution
101
+ contree run apt-get install -y curl # installs persist to next run
102
+ contree run -s -- 'echo $PATH' # shell mode for expansions
103
+ ```
104
+
105
+ Each non-disposable `run` produces a new image — a full filesystem checkpoint.
106
+
107
+ ### 4. Inspect without spawning
108
+
109
+ ```bash
110
+ contree ls /usr/bin # list files (no VM needed)
111
+ contree cat /etc/os-release # read files (no VM needed)
112
+ contree cp /app/output.log . # download to local machine
113
+ ```
114
+
115
+ ### 5. Branch and roll back
116
+
117
+ ```bash
118
+ contree session branch experiment # create a branch
119
+ contree run -- make test # experiment on it
120
+ contree session checkout main # switch back
121
+ contree session rollback 1 # undo last run
122
+ ```
123
+
124
+ ## Interactive Shell
125
+
126
+ `contree shell` starts a REPL where bare commands run in the sandbox automatically:
127
+
128
+ ```
129
+ $ contree shell
130
+ contree:/> apt-get update -qq
131
+ ...
132
+ contree:/> apt-get install -y curl
133
+ ...
134
+ contree:/> curl -sI https://example.com
135
+ HTTP/2 200
136
+ ...
137
+ contree:/> cd /etc
138
+ contree:/etc> cat os-release
139
+ PRETTY_NAME="Ubuntu 24.04 LTS"
140
+ ...
141
+ contree:/etc> contree session branch experiment
142
+ Created branch 'experiment'
143
+ contree:/etc> exit
144
+ ```
145
+
146
+ The shell provides tab completion for commands, paths, image tags, and operation IDs. `ls` and `cat` map to the fast API inspection commands by default. `vim`/`vi`/`nano` open `contree file edit` with your local `$EDITOR`.
147
+
148
+ ## Commands
149
+
150
+ | Command | Aliases | Description |
151
+ |---|---|---|
152
+ | `use IMAGE` | `ci` | Set or show current session image |
153
+ | `run [-- CMD]` | | Spawn a sandbox instance, execute command |
154
+ | `images [--prefix]` | `img` | List available images |
155
+ | `tag UUID TAG` | | Tag or untag an image |
156
+ | `ps` | | List operations (instances, imports) |
157
+ | `kill UUID` | | Cancel an operation (`--all` for all) |
158
+ | `show UUID` | | Show operation result |
159
+ | `ls [PATH]` | | List files in session image (no VM) |
160
+ | `cat PATH` | | Show file content from session image (no VM) |
161
+ | `cp PATH DEST` | | Download file from image to local path |
162
+ | `file edit PATH` | `e` | Edit remote file via local `$EDITOR` |
163
+ | `file cp SRC DEST` | | Upload local file into session image |
164
+ | `cd [PATH]` | | Change working directory in session |
165
+ | `session` | `s` | Show current session info |
166
+ | `session list` | `ls` | List all sessions |
167
+ | `session branch` | `br` | Create or list branches |
168
+ | `session checkout` | `co` | Switch active branch |
169
+ | `session rollback [N]` | `rb` | Revert N steps in history |
170
+ | `session show` | | Display session history DAG |
171
+ | `auth` | | Configure authentication (secure prompt) |
172
+ | `auth profiles` | | List saved profiles |
173
+ | `auth switch NAME` | | Switch active profile |
174
+ | `shell` | | Start interactive REPL |
175
+
176
+ See the full [command reference](https://docs.contree.dev/cli/commands/) for all flags and options.
177
+
178
+ ## Execution Modes
179
+
180
+ The `run` command supports four execution modes:
181
+
182
+ ```bash
183
+ # Direct — arguments are the command
184
+ contree run uname -a
185
+
186
+ # Shell — arguments joined, passed to sh -c
187
+ contree run -s -- 'echo $HOME && ls /'
188
+
189
+ # Interpreter — local script executed remotely
190
+ contree run -I ./deploy.sh
191
+
192
+ # Piped stdin — stdin forwarded to the command
193
+ echo 'SELECT 1' | contree run -- psql
194
+ ```
195
+
196
+ ### File injection
197
+
198
+ Mount local files into the sandbox:
199
+
200
+ ```bash
201
+ contree run --file ./app.py:/app/app.py -- python /app/app.py
202
+ contree run --file ./config.yaml --file ./data.csv -- ./process.sh
203
+ ```
204
+
205
+ File specs support permissions: `host_path[:remote_path][:uUID][:gGID][:mMODE]`
206
+
207
+ ### Shebang scripts
208
+
209
+ ```bash
210
+ #!/usr/bin/env -S contree run -I
211
+ apt-get update -qq
212
+ apt-get install -y curl
213
+ curl https://example.com
214
+ ```
215
+
216
+ Save as `setup.sh`, `chmod +x`, and run it directly.
217
+
218
+ ## Sessions and Branching
219
+
220
+ Sessions track your sandbox state with git-like branching and history:
221
+
222
+ ```
223
+ main: A ── B ── C ── D
224
+ \
225
+ experiment: E ── F
226
+ ```
227
+
228
+ Every `run` creates a checkpoint. Branch to explore alternatives. Roll back to any point. Switch branches instantly.
229
+
230
+ ```bash
231
+ contree session # show current state
232
+ contree session show # display history DAG
233
+ contree session branch feature # create branch from HEAD
234
+ contree session checkout feature # switch to it
235
+ contree session rollback 3 # go back 3 steps
236
+ contree session use other-session # import image from another session
237
+ ```
238
+
239
+ ## Output Formats
240
+
241
+ All commands support structured output via `-f`/`--format`:
242
+
243
+ ```bash
244
+ contree images -f json # JSON (one object per line)
245
+ contree images -f json-pretty # pretty-printed JSON array
246
+ contree ps -f csv # RFC 4180 CSV
247
+ contree ps -f tsv # tab-separated values
248
+ contree ls -f table # ASCII table
249
+ ```
250
+
251
+ Pipe JSON output into `jq`, feed CSV into spreadsheets, or parse programmatically in your agent toolchain.
252
+
253
+ ## Configuration
254
+
255
+ ### Config file
256
+
257
+ `~/.config/contree-cli/config.ini`:
258
+
259
+ ```ini
260
+ [DEFAULT]
261
+ profile = default
262
+
263
+ [profile:default]
264
+ token = eyJ...
265
+ url = https://contree.dev
266
+ ```
267
+
268
+ ### Multiple profiles
269
+
270
+ ```bash
271
+ contree auth --profile=staging # save staging token
272
+ contree auth --profile=prod # save production token
273
+ contree auth profiles # list all profiles
274
+ contree auth switch staging # switch active profile
275
+ ```
276
+
277
+ ### Environment variables
278
+
279
+ | Variable | Purpose |
280
+ |---|---|
281
+ | `CONTREE_TOKEN` | API bearer token (overrides config) |
282
+ | `CONTREE_URL` | API base URL (overrides config) |
283
+ | `CONTREE_PROFILE` | Active profile name |
284
+ | `CONTREE_SESSION` | Explicit session key (for multi-terminal workflows) |
285
+ | `CONTREE_SESSION_DB` | Path to session SQLite database |
286
+
287
+ Environment variables take precedence over the config file. `--token` and `--url` flags override everything.
288
+
289
+ ## Zero Dependencies
290
+
291
+ `contree-cli` uses only the Python standard library. No `requests`, no `click`, no `rich` — just `http.client`, `argparse`, `json`, `sqlite3`, and friends. It runs anywhere Python 3.10+ is available with nothing to install beyond the package itself.
292
+
293
+ ## Development
294
+
295
+ ```bash
296
+ git clone https://github.com/nebius/contree-cli.git
297
+ cd contree-cli
298
+ uv sync --group dev
299
+ ```
300
+
301
+ ```bash
302
+ make lint # ruff check --fix
303
+ make types # mypy strict mode
304
+ make check # lint + types
305
+ make tests # lint + types + pytest
306
+ ```
307
+
308
+ The project enforces strict mypy, ruff linting (E/F/W/I/UP/B/SIM/RUF rules), and full test coverage across 23+ test modules.
309
+
310
+ ## Documentation
311
+
312
+ Full documentation is available at **[docs.contree.dev/cli](https://docs.contree.dev/cli/)**, including:
313
+
314
+ - [Tutorial](https://docs.contree.dev/cli/tutorial/) — step-by-step from installation to automation
315
+ - [Command Reference](https://docs.contree.dev/cli/commands/) — every command, flag, and subcommand
316
+
317
+ ## Links
318
+
319
+ - [ConTree Platform](https://contree.dev)
320
+ - [Documentation](https://docs.contree.dev/cli/)
321
+ - [PyPI](https://pypi.org/project/contree-cli/)
322
+ - [Issues](https://github.com/nebius/contree-cli/issues)
323
+ - [Releases](https://github.com/nebius/contree-cli/releases)
@@ -0,0 +1,35 @@
1
+ contree_cli/__init__.py,sha256=kWY9HrMJZFOQCtp_sbnByckRnlfEn2yVBPQzPWbym5I,922
2
+ contree_cli/__main__.py,sha256=3ATWrPD7wSrbV45h1lZSktTXdlxwIwgibwp2zVWoq90,1703
3
+ contree_cli/arguments.py,sha256=qJfANiNbFOYjh3mNWDsX_v6AzLID7HVHqq-Tw3e_MIk,4380
4
+ contree_cli/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ contree_cli/cli/auth.py,sha256=7hKmUZ-5UZzOJKXcmsfV8gou_-ybMRCntutFX0iKU5E,3617
6
+ contree_cli/cli/cat.py,sha256=ItTREOPp4Cztl-IrHAFim9lvSQhKIal-_bEBWPExdbE,2154
7
+ contree_cli/cli/cd.py,sha256=dVrvKD3IyRRVv_zv-tdnAM9fdQ5-IEHGzQsPeqigal4,1311
8
+ contree_cli/cli/cp.py,sha256=EqS3SLGeSszqUOwdZN9vCuyA27TCdl7ImdJ8TQN5A8A,3335
9
+ contree_cli/cli/file.py,sha256=edRj_7SAijvExZqTWqZlswBZ478TjlFyMVWlQDD_HNs,5589
10
+ contree_cli/cli/images.py,sha256=vM57eKmWG4xGaAz9j6DRV8qdbw-Ufa9fBhZJhgrnScI,2627
11
+ contree_cli/cli/kill.py,sha256=ZM7XFMPN6-A9BOyiwQngeheyH_WqNR_lqd-9RJJBXlk,2555
12
+ contree_cli/cli/ls.py,sha256=M_P27Z102vZkq_vcfuU_lYa8Tfrk9Lh89WjAP9DK5EU,2493
13
+ contree_cli/cli/ps.py,sha256=YjfdWf5LlSX1CrTNBDMsmRlwwy6WjpPsp-YCczLSMHg,3737
14
+ contree_cli/cli/run.py,sha256=IGW9HU386_tRNS1jIsHKXLxoL2yJlj9QQ2AqUEpybLw,14849
15
+ contree_cli/cli/session.py,sha256=xDGNOdhFQ21I5cM0VqNPqQonhCK2L0SWiB-0Mfec_k4,7845
16
+ contree_cli/cli/show.py,sha256=ipQ5C2CEhuUKpBs5EG0EmML6WO2TOx-ecnJp8x7dnvg,2725
17
+ contree_cli/cli/tag.py,sha256=rD_5p-0CeqL_43_RdBx51woE8i5ZpnZNvFYQxgUA7XM,1384
18
+ contree_cli/cli/use.py,sha256=Rdppxho0RaggBSh2UwlhDfDJ-n5lq3wroEWaajstv6E,3401
19
+ contree_cli/client.py,sha256=zlbDn9lRX1AWGHFvzj2rV6MIsQmBunzAIP7yR8c4DCk,6403
20
+ contree_cli/config.py,sha256=8RGmVasZ2g5XF6ocRH24tE5eapd7C4jxwPekjAai6C8,3395
21
+ contree_cli/log.py,sha256=M7t7CwYGMkAM7y4VZM5wWEewOjTaxShB3z7CEnjbC0E,1291
22
+ contree_cli/mapped_file.py,sha256=qvXPD4r5LbrMD0VG0rWNc3gwFcA8vKKtbMKIaWcbNlA,3085
23
+ contree_cli/output.py,sha256=nnksLliHaAIYTBm4bDoUIWlcBtYsVxKt8fMG6iHQQBo,10950
24
+ contree_cli/session.py,sha256=dviGgQZgyqz3gDX6uRNAz3DZW8GaQDh4zgSg6FvoKSw,24503
25
+ contree_cli/shell/__init__.py,sha256=HyMGi1KzNv7Z2wdGx3fnMOByp5oxGGzEVKzgtVYBoHY,1692
26
+ contree_cli/shell/completer.py,sha256=4qg_PJdRPkWd9HYRvhuVYWW99IpLDGHosii0W-mWJt8,16653
27
+ contree_cli/shell/history.py,sha256=OOQ-9cEI7q85X5PXLT_73crHRdBcFeCjLBtAe12yHbA,1468
28
+ contree_cli/shell/parser.py,sha256=8yySuOk1ZnQbAPqSJTX5UA6W_L5Ks2a4bEkBzYqNWrA,3240
29
+ contree_cli/shell/repl.py,sha256=lEfXptszY7fTn8cMkc805o9p4liyMD8tei9bLAqYmCY,17290
30
+ contree_cli/shell/trie.py,sha256=ZY6vfWPQyI_hZKllhKfZ0vjW-tuX5X11hoRY-rXpa4w,3607
31
+ contree_cli/types.py,sha256=NsalGbym37z7cgJWTsWsP51Cn35mjnFB2OSmjPvNFgc,2617
32
+ contree_cli-0.2.3.dist-info/WHEEL,sha256=hbX8mDThv1n7VEIpQRy6c2yAFTw4iAQlEC53gDAhHSo,80
33
+ contree_cli-0.2.3.dist-info/entry_points.txt,sha256=qlYk-p3Il1r2Yo9pghiZmxHT1SO9yccE5DAmymwNHeU,55
34
+ contree_cli-0.2.3.dist-info/METADATA,sha256=HfRtFOuiDNRCBBlcNz72-yr5DgL2dUQzFY1fi385-Qs,10485
35
+ contree_cli-0.2.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.10.6
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ contree = contree_cli.__main__:main
3
+