ghostdock 0.0.7 → 0.0.9

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.
package/dist/cli.md ADDED
@@ -0,0 +1,733 @@
1
+ # Ghostdock CLI
2
+
3
+ Command-line access to your Ghostdock account — built for agents, but usable by humans too.
4
+ Authenticate once, then call Ghostdock's tools without leaving the terminal.
5
+
6
+ This document is written for an agent (or human) driving the CLI directly. It is also published at
7
+ `https://ghostdock.brainchimps.com/cli.md` so an agent can `curl`/fetch it without cloning this repo.
8
+
9
+ ## Install / run
10
+
11
+ No install required — run it with `npx`:
12
+
13
+ ```bash
14
+ npx ghostdock --help
15
+ ```
16
+
17
+ Or install it globally:
18
+
19
+ ```bash
20
+ npm install -g ghostdock
21
+ ghostdock --help
22
+ ```
23
+
24
+ A global install also gives you `gdock`, a short name for the same CLI. Help
25
+ and hints use whichever name you typed. With `npx`, use `npx ghostdock`:
26
+ `npx gdock` does not work.
27
+
28
+ Inside this monorepo (for development), run from the repo root or `packages/cli`:
29
+
30
+ ```bash
31
+ bun run --cwd packages/cli build # bundles src/index.ts -> dist/index.js
32
+ bun run --cwd packages/cli dev -- --help # run from source without building
33
+ ```
34
+
35
+ ## Output: for people, and `--json` for scripts and agents
36
+
37
+ Every command prints for people by default: one line per event, a symbol, then the message.
38
+
39
+ ```
40
+ $ ghostdock sandboxes list
41
+ ⚓ Marketing site quiet-harbor running
42
+ ◌ teal-jetty stopped
43
+ $ ghostdock sites publish ./dist
44
+ ↗ https://foggy-teal-bollard.static.ghostdock.app
45
+ ✓ Published site foggy-teal-bollard.
46
+ ```
47
+
48
+ `⚓` ready, `✓` done, `↗` a URL, `◌` stopped or gone, `✗` failed, `▂▄▆` in progress. Every line
49
+ carries the name and id the next command needs.
50
+
51
+ Commands that wait show a progress line on stderr while they run. Starting a sandbox
52
+ (`sandboxes create`, `sandboxes wake`) prints how long each step took, measured on the server, each
53
+ step with its own time:
54
+
55
+ ```
56
+ $ ghostdock sandboxes wake quiet-harbor
57
+ ⚓ quiet-harbor running
58
+ ⚓ sandbox started in 125ms
59
+ ✓ container started in 3.0s
60
+ ```
61
+
62
+ The container line is missing when no container was started, or when the host is older and did
63
+ not report it. `sandboxes status` prints the same lines for the last start. With `--json` they are
64
+ the `boot` field: `{ trigger, sandbox: { startedAt, readyAt, ms }, container: { … } | null }`, or
65
+ `null` when the command started nothing.
66
+
67
+ **Scripts and agents pass `--json`.** It prints the result as one JSON document on stdout, with
68
+ every field, and nothing else there. It works on every command and anywhere on the line:
69
+
70
+ ```bash
71
+ ghostdock sandboxes list --json | jq -r '.sandboxes[].name'
72
+ ```
73
+
74
+ - **stdout is the result, stderr is everything else**: notices (`Using organization acme …`),
75
+ hints and errors. Piping stdout never picks up a notice.
76
+ - **Errors** print as `✗ <what went wrong and what to try>` on stderr and exit non-zero, with or
77
+ without `--json`.
78
+ - **Colour** only on a terminal: piped output and `NO_COLOR=1` get the same text without colour
79
+ codes. `FORCE_COLOR=1` turns it back on.
80
+
81
+ ## Global flags
82
+
83
+ ```
84
+ ghostdock --version
85
+ ghostdock --base-url <url> <command>
86
+ ghostdock <command> --json
87
+ ```
88
+
89
+ - `--version` / `-v` — print CLI version and exit
90
+ - `--base-url <url>` — API origin for this invocation (wins over `GHOSTDOCK_BASE_URL`)
91
+ - `--json` — print the result as one JSON document on stdout (see Output above)
92
+
93
+ ## Commands
94
+
95
+ Commands are grouped by resource, like `gh` or `kubectl`: `ghostdock <resource> <action>`.
96
+
97
+ <!-- generated:command-groups:start (bun run sync:cli-reference; do not edit) -->
98
+ ```
99
+ ghostdock apps Published apps of an organization.
100
+ ghostdock env Manage organization environment variables and secrets.
101
+ ghostdock images Organization image catalog: OCI bookmarks, Dockerfiles and Compose files.
102
+ ghostdock login Sign in and store a device access token for this CLI.
103
+ ghostdock logout Revoke the device session and remove stored credentials.
104
+ ghostdock network The private network: reach your sandboxes by address and name from this machine.
105
+ ghostdock organizations Organizations you belong to.
106
+ ghostdock projects Deployable projects, their deployments and environment.
107
+ ghostdock providers Sandbox providers of an organization.
108
+ ghostdock registry Log in to the organization container registry.
109
+ ghostdock sandboxes Create, run and manage sandboxes.
110
+ ghostdock sites Static sites on the CDN.
111
+ ghostdock skills List and read Agent Skills (same catalog as MCP skill://index.json).
112
+ ghostdock snapshots Sandbox snapshots.
113
+ ghostdock tools List available agent tools.
114
+ ghostdock whoami Show the account this CLI is currently authenticated as.
115
+ ```
116
+ <!-- generated:command-groups:end -->
117
+
118
+ Run `ghostdock <command> --help` at any level for its subcommands or flags, e.g.
119
+ `ghostdock sandboxes --help` or `ghostdock sandboxes urls create --help`.
120
+
121
+ Most commands are generated from the tool catalog — see **Invoking a tool** below. Every command
122
+ is listed in the [command index](#command-index); [`cli-reference.md`](cli-reference.md) has each
123
+ one's full description and flags.
124
+
125
+ ### Choosing an organization
126
+
127
+ Every organization-scoped command acts on one organization, taken from the first of:
128
+
129
+ 1. `--org <id-or-slug>` on the command
130
+ 2. the `GHOSTDOCK_ORG` environment variable
131
+ 3. the default set with `ghostdock organizations use <id-or-slug>`
132
+
133
+ ```bash
134
+ ghostdock organizations use acme # default for this directory (login sets one when it can)
135
+ ghostdock sandboxes list # stderr: Using organization acme (default, …)
136
+ ghostdock sandboxes list --org beta # --org always wins
137
+ ghostdock organizations current # which organization, and where it comes from
138
+ ghostdock organizations use --clear
139
+ ```
140
+
141
+ When the organization does not come from `--org`, the command says which one it uses on stderr,
142
+ so a default never acts silently. The default is stored next to the credentials
143
+ (`./.ghostdock/settings.json`), so it belongs to that directory's login. **Scripts and CI should
144
+ pass `--org` or set `GHOSTDOCK_ORG`** rather than depend on (or change) a stored default, and use
145
+ the organization id: renaming an organization changes its slug, not its id.
146
+
147
+ ### `ghostdock login`
148
+
149
+ Ghostdock uses a device-authorization flow: no password is ever typed into the terminal.
150
+
151
+ **Default (print-and-exit) — best when a human is present to click the link:**
152
+
153
+ ```bash
154
+ ghostdock login
155
+ ```
156
+
157
+ This prints a URL to open in a browser and exits `0` immediately — it does not prompt for input or
158
+ poll for approval. Approve the request in the browser, then complete login with
159
+ **`ghostdock login --code <paste-code>`**, redeeming the one-time code from the browser's
160
+ "Having trouble? Show code" link (see below).
161
+
162
+ Each `login` invocation starts a **new** device session. A later `login --wait` does **not** resume
163
+ polling for a prior plain `login`. To block until approval, run **`ghostdock login --wait` up
164
+ front** instead of plain `login`.
165
+
166
+ **`--wait` — poll until approved:**
167
+
168
+ ```bash
169
+ ghostdock login --wait
170
+ # or with a custom timeout (seconds, default 300):
171
+ ghostdock login --wait --timeout 120
172
+ ```
173
+
174
+ Prints the same URL, then polls the server every few seconds until the login is approved, denied,
175
+ or the timeout elapses. Exits `0` on success, non-zero otherwise.
176
+
177
+ **`--code` — paste-code fallback:**
178
+
179
+ If the CLI can't poll (e.g. it's running in a sandbox with no long-lived process, or the browser
180
+ approval happened on a different machine), the browser's "Having trouble? Show code" link reveals a
181
+ short one-time code. Redeem it directly:
182
+
183
+ ```bash
184
+ ghostdock login --code <paste-code>
185
+ ```
186
+
187
+ On success, credentials are written and the command exits `0`. If the code hasn't been approved
188
+ yet, it exits `1` — approve it in the browser first.
189
+
190
+ **Default organization after login.** Once logged in (with `--wait` or `--code`), `login` sets the
191
+ default organization when that is unambiguous:
192
+
193
+ - `--org <id-or-slug>` sets that one, e.g. `ghostdock login --wait --org acme`. If you are not a
194
+ member of it, no default is set and `login` exits `1`.
195
+ - A default that is still one of your organizations stays as it is.
196
+ - With exactly one organization, that one becomes the default.
197
+ - With several, a person at a terminal picks one from a numbered list (Enter skips). Without a
198
+ terminal (agents, CI) nothing is asked: `login` lists them and points to
199
+ `ghostdock organizations use`.
200
+
201
+ See [Choosing an organization](#choosing-an-organization) for how commands pick it up.
202
+
203
+ ### `ghostdock logout`
204
+
205
+ ```bash
206
+ ghostdock logout
207
+ ```
208
+
209
+ Revokes the device session on the server (best-effort — still clears local credentials even if the
210
+ server call fails, e.g. when offline) and deletes the local credentials file.
211
+
212
+ ### `ghostdock whoami`
213
+
214
+ ```bash
215
+ ghostdock whoami
216
+ ```
217
+
218
+ Prints who the stored access token belongs to and which server it talks to (`--json`:
219
+ `{ "userId": ..., "baseUrl": ... }`).
220
+ Transparently refreshes an expired access token using the stored refresh token before failing.
221
+ Exits `1` with a message if not logged in or the session can't be refreshed.
222
+
223
+ ### `ghostdock tools`
224
+
225
+ Lists the tool catalog for the authenticated account:
226
+
227
+ ```bash
228
+ ghostdock tools # name + description, one per line
229
+ ghostdock tools --json # the full catalog (including each tool's JSON Schema) as JSON
230
+ ```
231
+
232
+ Requires login — prints a hint and exits `1` if there's no valid session.
233
+
234
+ ### `ghostdock skills`
235
+
236
+ Lists and reads **Agent Skills** for the authenticated account — the same catalog MCP
237
+ clients discover at `skill://index.json` (SEP-2640 / Agent Skills discovery 0.2.0).
238
+ Prefer resources. The MCP tools `skills_list` and `skills_get` are fallbacks for clients that
239
+ cannot use `resources/list` and `resources/read` — skip them if those work.
240
+
241
+ ```bash
242
+ ghostdock skills list # name, description, and skill:// URI per skill
243
+ ghostdock skills list --json # official discovery index ($schema + skills[])
244
+ ghostdock skills get skill://github/SKILL.md # print SKILL.md
245
+ ghostdock skills get github # same, by name
246
+ ghostdock skills get org_1/release-notes # organization skill
247
+ ```
248
+
249
+ `--json` on `get` prints `{ uri, name, description, markdown }`. If the same name exists
250
+ in more than one organization, pass the `skill://` URI from the index.
251
+
252
+ Requires login — prints a hint and exits `1` if there's no valid session.
253
+
254
+ ### Invoking a tool
255
+
256
+ Every catalog tool is a command at its own path, with one `--flag` per schema property
257
+ (`sandboxProviderId` -> `--sandbox-provider-id`). The one thing a command acts on is positional instead:
258
+ `ghostdock sandboxes stop <sandbox-id>`, `ghostdock sandboxes urls delete <url-id>`,
259
+ `ghostdock env get <name>`. The organization is always the `--org` flag, by id or slug: a slug is easier to type, an id keeps
260
+ working after the organization is renamed (renaming changes the slug). The MCP tool name is the same path joined with
261
+ underscores: `ghostdock sandboxes urls create` calls the `sandboxes_urls_create` tool. Run
262
+ `ghostdock <command> --help` to see a command's full description, its flags and which are
263
+ required; a group's `--help` lists its commands with one line each. Output is a line per item
264
+ for people; `--json` prints the tool's result as it comes back over MCP.
265
+
266
+ ```bash
267
+ ghostdock organizations list
268
+ # • Acme org_123
269
+ ghostdock organizations list --json
270
+ # {"organizations": [{"id": "org_123", "name": "Acme", "slug": "acme"}]}
271
+ ```
272
+
273
+ Number/boolean flags are parsed from their string form; array/object flags take a raw JSON string
274
+ (e.g. `--tags '["a","b"]'`). Requires login — prints a hint and exits `1` if there's no valid
275
+ session, or the server's error message (e.g. "Not a member of this organization") on a `4xx`.
276
+
277
+ The tool list embedded in the CLI binary is generated at build time from the server's tool catalog
278
+ (`bun run sync-catalog` in `packages/cli`), so `--help` and flag parsing work offline; invoking a
279
+ tool still requires a network call and a valid session.
280
+
281
+ Command descriptions are short on purpose. Concepts and workflows live in the built-in Agent
282
+ Skills, the same documents MCP agents read:
283
+
284
+ ```bash
285
+ ghostdock skills get sandboxes # sources, manifests, lifecycle, providers, URLs and TCP
286
+ ghostdock skills get sandbox-boot # processes that must come back after idle-stop
287
+ ghostdock skills get environment # organization entries, bindings, local entries, secrets
288
+ ghostdock skills get publishing # sites publish vs projects publish, outcomes, redeploys
289
+ ghostdock skills get incus-setup # connecting your own Incus host
290
+ ```
291
+
292
+ ### Sandboxes
293
+
294
+ Read `ghostdock skills get sandboxes` before your first sandbox: what it can boot from, manifests,
295
+ idle-stop and auto-delete, providers, URLs.
296
+
297
+ Every sandbox has a name like `quiet-harbor`, unique within its organization, and every command
298
+ that takes a sandbox accepts it with the organization (`--org`, `GHOSTDOCK_ORG` or the default).
299
+ The long `sandboxId` in `--json` output works too, in the same organization. A name never changes
300
+ while the sandbox exists, so scripts can keep it; once a sandbox is deleted, its name may be given to
301
+ a new one later. The display name is a separate label you can edit. For example, create a sandbox,
302
+ then expose a URL:
303
+
304
+ ```bash
305
+ ghostdock sandboxes create --org org_123 --display-name "Marketing site"
306
+ ghostdock sandboxes urls create quiet-harbor --port 8080 --auto-wake true --public true
307
+ ```
308
+
309
+ #### Environment in a sandbox
310
+
311
+ A sandbox exports **nothing** by default (unless you boot from an organization snapshot or catalog
312
+ image whose manifest supplies defaults). `environment` has three parts: `organization` (plain same-name opt-ins from the
313
+ catalogue, see [`ghostdock env`](#ghostdock-env)), `bindings` (slot ← org entry remaps), and `local` (sandbox-only variables/secrets). A local entry overrides an
314
+ organization export of the same name. Prefer the CLI when setting secret values so they are not
315
+ pasted into the agent conversation.
316
+
317
+ ```bash
318
+ # At create time, in one call:
319
+ ghostdock sandboxes create --org org_123 \
320
+ --environment '{"organization":["VITE_API_URL","BUILD_TOKEN"],"bindings":[{"name":"DATABASE_URL","organization":"PROD_DATABASE_URL"}],"local":[{"name":"API_KEY","value":"sk_live","kind":"secret"}]}'
321
+
322
+ # Afterwards:
323
+ ghostdock sandboxes env get quiet-harbor
324
+ ghostdock sandboxes env select quiet-harbor --environment '["VITE_API_URL"]' \
325
+ --bindings '[{"name":"DATABASE_URL","organization":"PROD_DATABASE_URL"}]'
326
+ ghostdock sandboxes env select quiet-harbor --environment '[]' # clears plain + remaps (omit bindings)
327
+ ghostdock sandboxes env set API_KEY --sandbox-id quiet-harbor --value sk_live --kind secret
328
+ ghostdock sandboxes env delete API_KEY --sandbox-id quiet-harbor
329
+ ```
330
+
331
+ Values arrive as real environment variables, so read them with `process.env` / `$VAR` inside the
332
+ sandbox. **Do not pass secrets in `sandboxes commands run` strings** — the command text is retained and
333
+ readable through `sandboxes commands logs`. `sandboxes env get` reports every organization entry
334
+ (selected + overriddenByLocal) and the sandbox's own local entries; `sandboxes status` reports
335
+ just the resolved names.
336
+
337
+ New shell commands and SSH sessions see a change immediately. Processes already running keep the
338
+ values they booted with until restarted (pass `--restart` to `sandboxes env select` /
339
+ `sandboxes env set` / `sandboxes env delete` to restart a running sandbox
340
+ instead).
341
+
342
+ ### Images
343
+
344
+ Organization image catalog: OCI bookmarks (`images add`), stored Dockerfiles
345
+ (`images add-dockerfile`), and refs currently in use on sandboxes. `images list` and `images get`
346
+ cover the same catalog family as those add tools — each org row includes `kind`, a redacted
347
+ `manifest` (from `ghostdock.*` Docker/OCI labels), `requiredEnvironment`, and `requiredUrls` (same
348
+ shape as snapshots). `sandboxes create` with `--source '{"type":"image","id":"..."}'` boots a catalog
349
+ row by id and applies its manifest (URLs + env) like an organization snapshot.
350
+
351
+ ```bash
352
+ ghostdock images list --org org_123
353
+ ghostdock images get img_abc --org org_123
354
+ ghostdock images add --org org_123 --ref ghcr.io/acme/app:latest --label "Acme app"
355
+ ghostdock images add-dockerfile --org org_123 --name my-stack --dockerfile "$(cat Dockerfile)"
356
+ ghostdock sandboxes create --org org_123 \
357
+ --source '{"type":"image","id":"img_abc"}' \
358
+ --environment '{"local":[{"name":"API_KEY","kind":"secret","value":"sk_test"}]}'
359
+ ```
360
+
361
+ Booting with `--source '{"type":"dockerfile","content":"..."}'` parses labels inline without
362
+ persisting a catalog row. That JSON source is Dockerfile text only: COPY/ADD of local files fails.
363
+ `--source '{"type":"compose","files":{"compose.yaml":"..."}}'` boots Docker-in-Docker from those
364
+ inline files (must include `docker-compose.yml`/`yaml` or `compose.yml`/`yaml`) and runs
365
+ `docker compose up`; `ghostdock.*` service labels become the create-time manifest. A directory or
366
+ ZIP — Dockerfile build context, or a Compose project with extra files — is
367
+ [`ghostdock sandboxes build`](#ghostdock-sandboxes-build), not this command. Any OCI ref may still
368
+ be passed as `{ type: "image", ref }` even when it does not appear in `images list`. Catalog compose
369
+ rows still boot via `{ type: "image", id }`.
370
+
371
+ ### `ghostdock sites publish`
372
+
373
+ Publish a local directory or ZIP to the CDN (durable public URL, no sandbox):
374
+
375
+ ```bash
376
+ ghostdock sites publish --org org_123 ./dist
377
+ ghostdock sites publish --org org_123 --zip ./site.zip
378
+ ```
379
+
380
+ MCP `sites publish` is for small inline payloads. Use this command for a real directory or large ZIP.
381
+
382
+ ### `ghostdock projects publish`
383
+
384
+ Inspect a local source tree and publish (CDN when pre-built static, otherwise Compose from a DeploymentSpec).
385
+ Required secrets without values return `awaiting_configuration` instead of a live URL.
386
+ Re-invoke with `--environment` (same JSON shape as `sandboxes create`) after configuring.
387
+ On `build_failed`, `start_failed`, or `verify_failed`, inspect the kept sandbox (unless verification tore it down), then re-invoke with `--spec` (JSON `DeploymentSpec`). The spec is executed on a fresh sandbox and stored for later replay. Do not pass `--spec` with `--replan`. Every terminal outcome stores the upload and returns authenticated `fileUrls`. Detected tests always run after the stack is up; pass `--require-verify` to refuse a deploy when they fail.
388
+
389
+ ```bash
390
+ ghostdock projects publish --org org_123 ./app
391
+ ghostdock projects publish --org org_123 --auto-stop-interval-minutes -1 --zip ./app.zip
392
+ ghostdock projects publish --org org_123 --project-id proj_123 ./app
393
+ ghostdock projects publish --org org_123 ./app \
394
+ --environment '{"organization":["DATABASE_URL"],"local":[{"name":"API_KEY","value":"sk_live","kind":"secret"}]}'
395
+ ghostdock projects publish --org org_123 ./app --spec '{"version":1,"run":{"kind":"static","outputDir":"."},"env":[]}'
396
+ ghostdock projects publish --org org_123 --require-verify ./app
397
+ ghostdock projects publish --org org_123 --sandbox-provider-id prov_123 ./app
398
+ ```
399
+
400
+ MCP `projects publish` is for small inline payloads. Use this command for a real directory or large ZIP.
401
+
402
+ ### `ghostdock sandboxes build`
403
+
404
+ Create a sandbox from a local Dockerfile or Compose directory. The CLI zips the directory (or sends
405
+ `--zip`) and the server builds it. MCP `sandboxes create` stays inline text only.
406
+
407
+ ```bash
408
+ ghostdock sandboxes build --org org_123 --kind dockerfile ./app
409
+ ghostdock sandboxes build --org org_123 --kind compose --zip ./stack.zip
410
+ ghostdock sandboxes build --org org_123 --kind dockerfile \
411
+ --sandbox-provider-id prov_123 --display-name "API" ./app
412
+ ```
413
+
414
+ The Dockerfile (`Dockerfile` or `dockerfile`) or a compose file (`docker-compose.yml`/`yaml`,
415
+ `compose.yml`/`yaml`) must sit at the directory root, or at the root of the ZIP. A ZIP that wraps
416
+ the project in one folder is unwrapped. Pass one directory or `--zip`, not both.
417
+
418
+ ### `ghostdock sandboxes files upload`
419
+
420
+ `sandboxes files upload` is convenient for small payloads. For a local directory,
421
+ multiple files, or a large ZIP, use the dedicated multipart upload command instead:
422
+
423
+ ```bash
424
+ ghostdock sandboxes files upload quiet-harbor ./dist
425
+ ghostdock sandboxes files upload quiet-harbor ./index.html ./assets
426
+ ghostdock sandboxes files upload quiet-harbor --zip ./site.zip
427
+ ```
428
+
429
+ Each positional path may be a file or directory. Directory contents are uploaded recursively,
430
+ preserving their relative paths; a file is uploaded by its basename. A `sandboxes files upload` call needs
431
+ at least one path or `--zip`. Uploading to a stopped sandbox resumes it automatically.
432
+
433
+ ### `ghostdock env`
434
+
435
+ Manage the environment variables and secrets an organization offers to its sandboxes and projects.
436
+ A sandbox inherits nothing automatically — select the entries it needs on that sandbox.
437
+
438
+ ```bash
439
+ ghostdock env list --org org_123
440
+ ghostdock env get VITE_API_URL --org org_123
441
+ ghostdock env set VITE_API_URL --org org_123 --value https://api.example.com
442
+ ghostdock env delete VITE_API_URL --org org_123
443
+ ```
444
+
445
+ **Variables vs secrets.** A variable is readable by anyone who can see the organization; `env list`
446
+ prints its value inline. A secret can be set and replaced but never read back — it shows as
447
+ `<secret>` in `env list` and `env get` refuses it. Pass `--secret` to create one:
448
+
449
+ ```bash
450
+ # Keeps the value out of shell history and the process list
451
+ printf %s "$STRIPE_KEY" | ghostdock env set STRIPE_SECRET_KEY --org org_123 --secret --value-stdin
452
+ ```
453
+
454
+ `--secret` is only required when creating; updating an existing entry keeps its kind. To convert one,
455
+ pass `--kind variable` or `--kind secret` explicitly along with the new value:
456
+
457
+ ```bash
458
+ ghostdock env set STRIPE_SECRET_KEY --org org_123 --kind variable --value not-secret-anymore
459
+ # Warning: STRIPE_SECRET_KEY was a secret and is now a variable — its value is readable by everyone in the organization.
460
+ ```
461
+
462
+ Converting never reveals the old secret: `set` always replaces the value, so the value you supply in
463
+ that call is the one that becomes readable. The command prints what changed either way.
464
+
465
+ `env get` prints the bare value so it can be captured in a shell (`API=$(ghostdock env get
466
+ VITE_API_URL --org org_123)`). It also returns values too large for `env list`, which
467
+ withholds anything over 1024 characters rather than truncating it — a printed value is always the
468
+ complete value.
469
+
470
+ With `--json`, `list`, `get` and `set` print the tool's result instead. These commands wrap the
471
+ `env list`, `env get`, `env set` and
472
+ `env delete` tools, which are also available directly (and over MCP).
473
+
474
+ Names must be valid environment variable names, and names the sandbox runtime owns (`PATH`,
475
+ `HOME`, anything starting with `GHOSTDOCK_`, …) are rejected. Prefix a name with `VITE_`
476
+ only when browser code must read it: Vite inlines those into the published bundle, so a `VITE_`
477
+ secret is public.
478
+
479
+ ### `ghostdock network`
480
+
481
+ Reach your organization's sandboxes from this machine by private address and name, over
482
+ WireGuard ([ADR 0027](../../docs/adr/0027-private-sandbox-network.md)). Everything on a
483
+ sandbox's address is reachable: a container that publishes port 80 answers on
484
+ `http://quiet-harbor.gdock.internal/`, as it would on `localhost` inside the sandbox.
485
+ Nothing reaches your machine from a sandbox.
486
+
487
+ ```bash
488
+ ghostdock network connect --org acme # asks for sudo once: wg-quick up and split DNS
489
+ ghostdock network ls --org acme # sandboxes with their addresses and names
490
+ curl http://quiet-harbor.acme.ghostdock.internal:8080/
491
+ curl http://quiet-harbor.gdock.internal:8080/ # short name: the organization connect used
492
+ ghostdock network use beta # short names in another organization, no sudo
493
+ ghostdock network status
494
+ ghostdock network disconnect
495
+ ```
496
+
497
+ - **Needs `wg-quick`** (`brew install wireguard-tools`, `apt install wireguard-tools`). macOS
498
+ and Linux. On Windows, run the CLI in WSL: then only tools inside WSL reach sandboxes.
499
+ - **One key per machine**, kept in `~/.config/ghostdock/network/` (or `GHOSTDOCK_NETWORK_DIR`).
500
+ Only the public key is sent. The device belongs to the login it was connected with:
501
+ `ghostdock logout` takes it out of the network, and so does not connecting for 90 days.
502
+ - **Names**: `<sandbox>.<org>.ghostdock.internal` always, and `<sandbox>.gdock.internal` in the
503
+ organization this machine is pinned to (the one `connect` resolved, changed with
504
+ `network use`). The pin is per machine, not per directory. Only AAAA records exist: the
505
+ network is IPv6, and the sandbox sees IPv4.
506
+ - `ghostdock network devices` lists your devices, `ghostdock network devices remove <id>`
507
+ removes one.
508
+
509
+ ## Command index
510
+
511
+ Every command with its arguments and what it does. Run `ghostdock <command> --help` for its flags,
512
+ or read [`cli-reference.md`](cli-reference.md) for every command's full description and flags.
513
+
514
+ <!-- generated:command-index:start (bun run sync:cli-reference; do not edit) -->
515
+ #### apps
516
+
517
+ | Command | What it does |
518
+ | --- | --- |
519
+ | `ghostdock apps list [flags]` | List the live published apps (sites) of an organization, with their URLs. |
520
+
521
+ #### env
522
+
523
+ | Command | What it does |
524
+ | --- | --- |
525
+ | `ghostdock env delete <name> [flags]` | Delete a variable or secret. |
526
+ | `ghostdock env get <name> [flags]` | Print one variable value in full (secrets cannot be read). |
527
+ | `ghostdock env list [flags]` | List variables and secrets. |
528
+ | `ghostdock env set <name> [flags]` | Create or replace a variable or secret. |
529
+
530
+ #### images
531
+
532
+ | Command | What it does |
533
+ | --- | --- |
534
+ | `ghostdock images add --ref <string> [flags]` | Bookmark an OCI image ref in the organization’s image catalog. |
535
+ | `ghostdock images add-compose --name <string> --files <object> [flags]` | Add Compose files to the organization’s image catalog. |
536
+ | `ghostdock images add-dockerfile --name <string> --dockerfile <string> [flags]` | Add a Dockerfile to the organization’s image catalog. |
537
+ | `ghostdock images get <image-id> [flags]` | Get one catalog image with its spec, manifest and requirements. |
538
+ | `ghostdock images list [flags]` | List the images an organization can boot sandboxes from. |
539
+ | `ghostdock images remove <image-id> [flags]` | Remove an image from the organization’s catalog. |
540
+ | `ghostdock images update-compose <image-id> [flags]` | Replace a catalog Compose image’s files and/or name. |
541
+ | `ghostdock images update-dockerfile <image-id> --dockerfile <string> [flags]` | Replace a catalog Dockerfile, optionally renaming it. |
542
+
543
+ #### login
544
+
545
+ | Command | What it does |
546
+ | --- | --- |
547
+ | `ghostdock login [flags]` | Sign in and store a device access token for this CLI. |
548
+
549
+ #### logout
550
+
551
+ | Command | What it does |
552
+ | --- | --- |
553
+ | `ghostdock logout` | Revoke the device session and remove stored credentials. |
554
+
555
+ #### network
556
+
557
+ | Command | What it does |
558
+ | --- | --- |
559
+ | `ghostdock network connect [flags]` | Put this machine into the private network: WireGuard and split DNS. |
560
+ | `ghostdock network devices <command>` | Your devices in the private network. |
561
+ | `ghostdock network devices remove <id>` | Remove one of your devices from the private network. |
562
+ | `ghostdock network disconnect` | Take this machine out of the private network. |
563
+ | `ghostdock network ls [flags]` | Sandboxes of an organization with their private addresses and names. |
564
+ | `ghostdock network status` | Whether this machine is connected, and as which device. |
565
+ | `ghostdock network use [org] [flags]` | Choose the organization <sandbox>.gdock.internal names resolve in on this… |
566
+
567
+ #### organizations
568
+
569
+ | Command | What it does |
570
+ | --- | --- |
571
+ | `ghostdock organizations current [flags]` | Show which organization commands use, and where it comes from. |
572
+ | `ghostdock organizations list` | List the organizations you belong to, with their ids and slugs. |
573
+ | `ghostdock organizations use [org] [flags]` | Set the default organization for commands run in this directory. |
574
+
575
+ #### projects
576
+
577
+ | Command | What it does |
578
+ | --- | --- |
579
+ | `ghostdock projects create --display-name <string> [flags]` | Create an empty project. |
580
+ | `ghostdock projects deployments get <deployment-id> --project-id <string> [flags]` | Get one deploy attempt, with links to its stored files. |
581
+ | `ghostdock projects deployments list <project-id> [flags]` | List a project’s deploy attempts, newest first. |
582
+ | `ghostdock projects env delete <name> --project-id <string> [flags]` | Delete one of a project’s own variables or secrets. |
583
+ | `ghostdock projects env get <project-id> [flags]` | Get a project’s stored environment. |
584
+ | `ghostdock projects env select <project-id> --environment <array> [flags]` | Replace the organization entries a project exports. |
585
+ | `ghostdock projects env set <name> --project-id <string> --value <string> --kind <string> [flags]` | Create or replace one of a project’s own variables or secrets. |
586
+ | `ghostdock projects get <project-id> [flags]` | Get a project with its latest attempt and live deployment. |
587
+ | `ghostdock projects list [flags]` | List an organization’s projects. |
588
+ | `ghostdock projects publish [path] [flags]` | Inspect local source with the deploy agent and publish to the CDN or a sandbox. |
589
+ | `ghostdock projects redeploy <project-id> [flags]` | Deploy a project’s stored source again, with its current environment. |
590
+ | `ghostdock projects update <project-id> --display-name <string> [flags]` | Rename a project. |
591
+
592
+ #### providers
593
+
594
+ | Command | What it does |
595
+ | --- | --- |
596
+ | `ghostdock providers disconnect <sandbox-provider-id> [flags]` | Disconnect one of the organization’s own sandbox providers. |
597
+ | `ghostdock providers list [flags]` | List the sandbox providers an organization can create sandboxes on. |
598
+ | `ghostdock providers rename <sandbox-provider-id> --name <string> [flags]` | Rename one of the organization’s own sandbox providers. |
599
+ | `ghostdock providers set-default <sandbox-provider-id> [flags]` | Set the provider used when a create omits sandboxProviderId. |
600
+ | `ghostdock providers start-incus [flags]` | Start connecting an Incus host as a sandbox provider. |
601
+ | `ghostdock providers verify-incus <sandbox-provider-id> [flags]` | Check or finish connecting an Incus host. |
602
+
603
+ #### registry
604
+
605
+ | Command | What it does |
606
+ | --- | --- |
607
+ | `ghostdock registry credentials [flags]` | Print registry host, username, and the one-hour password. |
608
+ | `ghostdock registry login [flags]` | Fetch a one-hour password and run docker login --password-stdin. |
609
+
610
+ #### sandboxes
611
+
612
+ | Command | What it does |
613
+ | --- | --- |
614
+ | `ghostdock sandboxes build [path] --kind <value> [flags]` | Create a sandbox from a local Dockerfile or Compose directory. |
615
+ | `ghostdock sandboxes commands get <command-id> --sandbox-id <string> --session-id <string> [flags]` | Get a shell command’s status and exit code. |
616
+ | `ghostdock sandboxes commands kill <command-id> --sandbox-id <string> --session-id <string> [flags]` | Interrupt a running shell command. |
617
+ | `ghostdock sandboxes commands logs <command-id> --sandbox-id <string> --session-id <string> [flags]` | Get a page of a shell command’s stdout and stderr. |
618
+ | `ghostdock sandboxes commands run <sandbox-id> --command <string> [flags]` | Run a shell command in a sandbox. |
619
+ | `ghostdock sandboxes create --source <object> [flags]` | Create a sandbox from a snapshot, OCI image, Dockerfile or Compose files. |
620
+ | `ghostdock sandboxes delete <sandbox-id> [flags]` | Permanently delete a sandbox and its files. |
621
+ | `ghostdock sandboxes env delete <name> --sandbox-id <string> [flags]` | Delete one of a sandbox’s own variables or secrets. |
622
+ | `ghostdock sandboxes env get <sandbox-id> [flags]` | Get a sandbox’s environment: selections, bindings and local entries. |
623
+ | `ghostdock sandboxes env select <sandbox-id> --environment <array> [flags]` | Replace the organization entries a sandbox exports. |
624
+ | `ghostdock sandboxes env set <name> --sandbox-id <string> --value <string> [flags]` | Create or replace one of a sandbox’s own variables or secrets. |
625
+ | `ghostdock sandboxes files list <sandbox-id> [flags]` | List the files in a sandbox directory (default /workspace). |
626
+ | `ghostdock sandboxes files read <path> --sandbox-id <string> [flags]` | Read a file from a sandbox: utf8 text, or base64 for small binaries. |
627
+ | `ghostdock sandboxes files upload <sandbox-id> [path] [flags]` | Upload local files or directories to a sandbox using multipart form data. |
628
+ | `ghostdock sandboxes list [flags]` | List the sandboxes of an organization, including whether each is ephemeral. |
629
+ | `ghostdock sandboxes mcps create <sandbox-id> --name <string> --port <integer> [flags]` | Expose an MCP server running in a sandbox. |
630
+ | `ghostdock sandboxes mcps delete <mcp-id>` | Delete an MCP endpoint of a sandbox. |
631
+ | `ghostdock sandboxes mcps list <sandbox-id> [flags]` | List the MCP endpoints a sandbox exposes (name, port, path, autoWake). |
632
+ | `ghostdock sandboxes mcps update <mcp-id> [flags]` | Change an MCP endpoint’s name, port, path or autoWake setting. |
633
+ | `ghostdock sandboxes resize <sandbox-id> [flags]` | Change a sandbox’s CPU and/or memory. |
634
+ | `ghostdock sandboxes resize-disk <sandbox-id> --disk-gib <number> [flags]` | Grow a sandbox’s disk. |
635
+ | `ghostdock sandboxes set-boot <sandbox-id> --command <string> [flags]` | Register a command that starts now and again after every restart. |
636
+ | `ghostdock sandboxes shells close <session-id> --sandbox-id <string> [flags]` | Close a shell session. |
637
+ | `ghostdock sandboxes shells create <sandbox-id> [flags]` | Open a shell session that keeps cwd and environment between commands. |
638
+ | `ghostdock sandboxes ssh get <sandbox-id> [flags]` | Get temporary SSH access to a sandbox (command and token, 60 minutes). |
639
+ | `ghostdock sandboxes ssh revoke <sandbox-id> [flags]` | Revoke a sandbox’s active SSH access. |
640
+ | `ghostdock sandboxes status <sandbox-id> [flags]` | Get a sandbox’s status and lifecycle deadlines without waking it. |
641
+ | `ghostdock sandboxes stop <sandbox-id> [flags]` | Stop a running sandbox without deleting its files. |
642
+ | `ghostdock sandboxes tools call <name> --sandbox-id <string> --arguments <object> [flags]` | Call a tool on an MCP server inside a sandbox. |
643
+ | `ghostdock sandboxes tools list <sandbox-id> [flags]` | List the tools of the MCP servers a sandbox exposes. |
644
+ | `ghostdock sandboxes update <sandbox-id> [flags]` | Change a sandbox’s display name, idle-stop or auto-delete interval. |
645
+ | `ghostdock sandboxes urls create <sandbox-id> --port <integer> [flags]` | Expose a sandbox port as a URL. |
646
+ | `ghostdock sandboxes urls delete <url-id>` | Delete a sandbox URL. |
647
+ | `ghostdock sandboxes urls list <sandbox-id> [flags]` | List the URLs that expose a sandbox’s ports, with protocol, access and title. |
648
+ | `ghostdock sandboxes urls update <url-id> [flags]` | Change a sandbox URL’s port, protocol, autoWake, public setting or title. |
649
+ | `ghostdock sandboxes wake <sandbox-id> [flags]` | Start a stopped sandbox, or reset the idle-stop countdown of a running one. |
650
+
651
+ #### sites
652
+
653
+ | Command | What it does |
654
+ | --- | --- |
655
+ | `ghostdock sites publish [path] [flags]` | Publish a local directory or ZIP to the CDN. |
656
+ | `ghostdock sites unpublish <site-id> [flags]` | Take a published static site offline. |
657
+
658
+ #### skills
659
+
660
+ | Command | What it does |
661
+ | --- | --- |
662
+ | `ghostdock skills get <uri>` | Print one SKILL.md (URI from the discovery index, or a skill name). |
663
+ | `ghostdock skills list` | List the Agent Skills discovery index. |
664
+
665
+ #### snapshots
666
+
667
+ | Command | What it does |
668
+ | --- | --- |
669
+ | `ghostdock snapshots create <sandbox-id> --name <string> [flags]` | Save a sandbox’s filesystem as a reusable organization snapshot. |
670
+ | `ghostdock snapshots delete <snapshot-id> [flags]` | Permanently delete an organization snapshot (provider artifact and record). |
671
+ | `ghostdock snapshots get <snapshot-id> [flags]` | Get one snapshot with its manifest and required environment, URLs and MCPs. |
672
+ | `ghostdock snapshots list [flags]` | List the snapshots an organization can boot sandboxes from. |
673
+ | `ghostdock snapshots update-manifest <snapshot-id> --manifest <object> [flags]` | Replace a snapshot’s manifest (URLs, environment, MCPs). |
674
+
675
+ #### tools
676
+
677
+ | Command | What it does |
678
+ | --- | --- |
679
+ | `ghostdock tools` | List available agent tools. |
680
+
681
+ #### whoami
682
+
683
+ | Command | What it does |
684
+ | --- | --- |
685
+ | `ghostdock whoami` | Show the account this CLI is currently authenticated as. |
686
+ <!-- generated:command-index:end -->
687
+
688
+ ## CLI settings
689
+
690
+ Environment variables read by the CLI process itself. For an organization's environment variables
691
+ and secrets, see [`ghostdock env`](#ghostdock-env).
692
+
693
+ | Variable | Purpose | Default |
694
+ | ------------------------------- | ------------------------------------------------------------- | --------------------------------- |
695
+ | `GHOSTDOCK_BASE_URL` | API origin the CLI talks to. Override for local dev / self-hosted instances. | Local/dev builds default to `http://localhost:3000`. npm-published builds default to the production API origin baked at publish time. Override with `--base-url` or this env var. |
696
+ | `GHOSTDOCK_ORG` | Organization (id or slug) for commands run without `--org`. Takes precedence over the default from `organizations use`. | unset |
697
+ | `GHOSTDOCK_CREDENTIALS_PATH` | Absolute path to the credentials file, overriding the default. `settings.json` (the default organization) sits in the same directory. | `./.ghostdock/credentials.json` (relative to the current working directory) |
698
+
699
+ Example for local development against a Nuxt dev server:
700
+
701
+ ```bash
702
+ ghostdock --base-url http://localhost:3000 login --wait
703
+ # or
704
+ GHOSTDOCK_BASE_URL=http://localhost:3000 ghostdock login --wait
705
+ ```
706
+
707
+ ## Credentials file
708
+
709
+ Credentials are stored as JSON at `./.ghostdock/credentials.json` (relative to the directory the
710
+ CLI is run from), with file permissions restricted to the owner (`0600`):
711
+
712
+ ```json
713
+ {
714
+ "accessToken": "ext_at_...",
715
+ "refreshToken": "ext_rt_...",
716
+ "accessExpiresAt": "2026-07-30T12:00:00.000Z"
717
+ }
718
+ ```
719
+
720
+ **Add `.ghostdock/` to your project's `.gitignore`.** These are live tokens — never commit them.
721
+ This repository's own `.gitignore` already ignores `.ghostdock/` for local development/testing of
722
+ the CLI itself.
723
+
724
+ Access tokens are short-lived (1 hour); the CLI refreshes them automatically using the refresh token
725
+ (30-day rolling expiry) whenever a request gets a `401`. If both tokens are invalid or revoked (e.g.
726
+ after `ghostdock logout` from another session), re-run `ghostdock login`.
727
+
728
+ ## Exit codes
729
+
730
+ - `0` — success (including the default `login` after only printing the URL — approval is still
731
+ pending, that's expected).
732
+ - `1` — failure: not logged in, session expired and unrefreshable, login denied/expired/timed out,
733
+ a missing/invalid tool flag, or a tool invocation error (e.g. not a member of the organization).