diff --git a/README.md b/README.md index 7e57299066..408e7cf2e9 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,15 @@ Put OpenCode (or Hermes) on this Mac's own models: ```bash curl -fsSL https://api.darkbloom.dev/install.sh | bash exec $SHELL -l # or open a new Terminal window, so your shell finds darkbloom -darkbloom start --opencode # or --hermes +darkbloom --opencode # or --hermes ``` -`start` asks how this Mac serves: **Only me**, **Darkbloom network** or +It asks how this Mac serves: **Only me**, **Darkbloom network** or **Both, me first**. Press Enter for Both, me first: it asks which models to serve, serves them in the background and sets OpenCode up. Only me serves the models already on this Mac, in that Terminal window. Darkbloom network gives OpenCode no address on this Mac. Then, in OpenCode, `/models` → Darkbloom. Two -Macs: run `darkbloom cluster` on each, then `darkbloom start --opencode` on the +Macs: run `darkbloom cluster` on each, then `darkbloom --opencode` on the leading Mac. diff --git a/changelog.d/darkbloom-opencode-hermes-shortcuts.md b/changelog.d/darkbloom-opencode-hermes-shortcuts.md new file mode 100644 index 0000000000..a4a13c56af --- /dev/null +++ b/changelog.d/darkbloom-opencode-hermes-shortcuts.md @@ -0,0 +1,11 @@ +### `darkbloom --opencode` and `darkbloom --hermes` + +- `darkbloom --opencode` is `darkbloom start --opencode`, and `darkbloom --hermes` is `darkbloom start --hermes`; + both together work too. Any other `start` option goes with them, in any order (`darkbloom --opencode --me-first`, + `darkbloom --me-first --opencode`), and `start`'s errors and refusals apply. `darkbloom start --opencode` keeps + working; `--help`, `--version`, plain `darkbloom` and every subcommand are unchanged, and a mistyped flag + (`darkbloom --opencod`) gets the usual unknown-option error. +- `darkbloom --help` shows the two shortcuts, one line each. +- The lines that name the command say the short form: `darkbloom local`'s `tools:` line, the line `--port` prints + when it replaces a saved port, the refusals, the tool step's lines, the installer's closing lines, and the comment + above the `darkbloom` block in OpenCode's and Hermes' configs (a config set up before keeps its line). diff --git a/changelog.d/install-next-start-opencode.md b/changelog.d/install-next-start-opencode.md index dd5466ab8d..be2486225c 100644 --- a/changelog.d/install-next-start-opencode.md +++ b/changelog.d/install-next-start-opencode.md @@ -1,8 +1,8 @@ -### The installer ends with `darkbloom start --opencode` +### The installer ends with `darkbloom --opencode` -- The installer's last lines say that `darkbloom start` asks how this Mac serves (Only me, Darkbloom network, or - Both, me first), that `--opencode` then sets OpenCode up (`/models` → Darkbloom; `--hermes` for Hermes), and that - two Macs pair with `darkbloom cluster` on each. The last line is the command to run next, with its full path so it - works before the shell picks up the new `PATH` line: `Next: ~/.darkbloom/bin/darkbloom start --opencode`. Before, it - listed `doctor`, `models catalog`, `models download`, `login` and `start`. +- The installer's last lines say that `darkbloom --opencode` asks how this Mac serves (Only me, Darkbloom network, or + Both, me first), then sets OpenCode up (`/models` → Darkbloom; `darkbloom --hermes` for Hermes), and that two Macs + pair with `darkbloom cluster` on each. The last line is the command to run next, with its full path so it works + before the shell picks up the new `PATH` line: `Next: ~/.darkbloom/bin/darkbloom --opencode`. Before, it listed + `doctor`, `models catalog`, `models download`, `login` and `start`. - `curl … | bash` prints these lines once the platform's copy of the installer is updated. diff --git a/changelog.d/local-one-port-per-mac.md b/changelog.d/local-one-port-per-mac.md index 965126a534..303de9924e 100644 --- a/changelog.d/local-one-port-per-mac.md +++ b/changelog.d/local-one-port-per-mac.md @@ -2,7 +2,7 @@ - Every local API this Mac serves takes the same port: Only me and Both, me first from the start question, a saved choice, `--me-first`, `--local`, `--local-endpoint` and the Darkbloom app's starts, its local mode included. The first one saves it as `[local] port`, and every later start uses it, so the address your tools were given (`http://127.0.0.1:/v1`, with the key in `~/.darkbloom/local_token`) never moves. Before, `--local`, `--local-endpoint` and the app took 8000 while the start question took 8001. - A Mac whose local API already serves keeps that port and saves it: the running API's port, else the one its installed background service serves on. A Mac updated from 0.10.10, whose local API serves on 8000 (the app's setup, "Alongside the network", "Local only", `--local-endpoint`, `--local`), keeps 8000: ``Local API port: 8000 (saved; this Mac's local API already uses it).`` Only a Mac with no local API at all takes the first free port from 8001, never 8000 or 47420–47423. -- A saved port always wins, and is never moved. `--port ` replaces it and is saved too: ``Local API port: 8007 (saved, instead of 8005: tools set up for 8005 need `darkbloom start --opencode` or `--hermes` again).`` +- A saved port always wins, and is never moved. `--port ` replaces it and is saved too: ``Local API port: 8007 (saved, instead of 8005: tools set up for 8005 need `darkbloom --opencode` or `--hermes` again).`` - A Mac without `[local]` started without a terminal still serves exactly as before: the Darkbloom network, with no local API and no port. - When the local API of Both, me first can't listen, `darkbloom status` no longer reads "Darkbloom network only": it says ``Serving: Darkbloom and you, me first — the local API isn't up: port 8001 is in use (`darkbloom start --port 8002`)``, and `darkbloom local` says the same. Only me names the next free port the same way. On a Mac in a two-Mac cluster these lines name `darkbloom start --solo --port `, or `darkbloom restart` for the pair's own API. - The app's local mode runs as launchd's `--foreground` service on that port, saves a new port only once the service started, and its log no longer shows the local key. diff --git a/changelog.d/opencode-hermes-integrations.md b/changelog.d/opencode-hermes-integrations.md index f2e1c237d2..d4a003f112 100644 --- a/changelog.d/opencode-hermes-integrations.md +++ b/changelog.d/opencode-hermes-integrations.md @@ -1,7 +1,7 @@ -### OpenCode and Hermes: the config writers for `start --opencode` and `--hermes` +### OpenCode and Hermes: the config writers for `--opencode` and `--hermes` - The writers that make OpenCode 2 and Hermes Agent ready to use Darkbloom as a provider, called by - `darkbloom start --opencode` / `--hermes`. + `darkbloom --opencode` / `--hermes`. - OpenCode gets a `providers.darkbloom` block in its global `opencode.jsonc` (or an existing `opencode.json`): the local endpoint at its live port from `local.json`, the models with their names, context and output limits and capabilities, and `max_tokens` as the output-cap field (OpenCode otherwise sends `max_completion_tokens`, which the diff --git a/changelog.d/paired-mac-start-starts-the-pair.md b/changelog.d/paired-mac-start-starts-the-pair.md index b9ab6c384f..3f68a5f5a7 100644 --- a/changelog.d/paired-mac-start-starts-the-pair.md +++ b/changelog.d/paired-mac-start-starts-the-pair.md @@ -5,6 +5,6 @@ - The desktop app's **Start serving** has no `--solo`, so on a paired Mac it now starts the pair, as a plain `darkbloom start` does, in every state of the pair. It never serves that Mac alone and never waits for an answer. The pair serves its own model: when the app named another, the start ends with ``This Mac serves in a pair: started the pair with ; `darkbloom cluster` changes its model.``, which the app shows. Since 0.10.9 it served the Mac alone while the pair didn't run there, and was refused while the pair ran. - The lines that name the way back now say `darkbloom start` for the pair and `darkbloom start --solo` for serving alone: `darkbloom status` for a part that stopped because the other Mac stopped answering, the `Next:` line of `cluster status`, `restart` on a Mac where nothing serves, and the line `start --solo` prints. They no longer send you to `darkbloom cluster` to start the pair. - `darkbloom start --solo`, `restart` and `update` on a Mac with a leftover part of the pair now say that its saved start is cleared only once it is. They first say that they are stopping the leftover part. If a cluster command is running, they wait for it; when it is still running after 10 minutes, nothing is stopped or cleared, and they no longer say it was. -- No start asks a question without a terminal. On pair-2, a `darkbloom start --opencode` that got no answer waited forever on "Serve on this Mac alone / Start the pair"; that question is gone. On a paired Mac, a start without a terminal, with or without `--opencode` or `--hermes`, starts the pair and reads nothing. Where a start can't go on without asking, it says in one line what to add. +- No start asks a question without a terminal. On pair-2, a start with `--opencode` that got no answer waited forever on "Serve on this Mac alone / Start the pair"; that question is gone. On a paired Mac, a start without a terminal, with or without `--opencode` or `--hermes`, starts the pair and reads nothing. Where a start can't go on without asking, it says in one line what to add. - A start for **Darkbloom network** or **Both, me first** that names no models (`--model `, `--all`) can't pick them without a terminal. On any Mac it now says so in one line and stops (exit 64), before anything is stopped or started, instead of printing the numbered model list and waiting for an answer that may never come. **Only me** serves the models already on the Mac and is unchanged. - `darkbloom status` on a paired Mac now says plainly when the Mac serves alone instead of the pair: a line under the pair's block names single-Mac serving and its process, and its own `Daemon:`, `Serving:` and `Trust:` lines follow. Before, it said only "Single-Mac serving: running beside the pair" at the end, and the `Serving:` line needed `status --solo`. diff --git a/changelog.d/start-opencode-hermes.md b/changelog.d/start-opencode-hermes.md index da0d68948b..ab587d36cd 100644 --- a/changelog.d/start-opencode-hermes.md +++ b/changelog.d/start-opencode-hermes.md @@ -1,8 +1,8 @@ -### `darkbloom start --opencode` and `--hermes` +### One flag sets OpenCode or Hermes up: `--opencode` and `--hermes` - One flag sets OpenCode 2 or Hermes Agent up to use Darkbloom, as `ollama launch` and `omlx launch` do: - `darkbloom start --opencode`, `--hermes`, or both. If this Mac's local API already runs, nothing restarts; otherwise - `start` runs as usual and the tools are set up once its local API answers. + `darkbloom --opencode`, `darkbloom --hermes`, or both. If this Mac's local API already runs, nothing restarts; + otherwise `start` runs as usual and the tools are set up once its local API answers. - It prints the file it changed, the backup and a one-line undo, then where your requests go and the two variables other OpenAI clients need (naming the key file, never the key). No line, and no tool file, holds the key. - A Hermes older than v0.20.2 is set up with one warning line: it can't read the key until `hermes update`. diff --git a/docs/README.md b/docs/README.md index ca19ca0b35..d3e9d92201 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # Darkbloom Provider Documentation -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 This repository documents the Swift provider, local native inference and landing. Backend, console and admin source, development and operating guides @@ -9,7 +9,7 @@ belong to ## Operate A Provider -- [Quickstart](provider/quickstart.md): install, then `darkbloom start --opencode` for OpenCode or Hermes on this Mac's own models +- [Quickstart](provider/quickstart.md): install, then `darkbloom --opencode` for OpenCode or Hermes on this Mac's own models - [Use your Mac yourself, first](provider/local-first.md): Only me, Darkbloom network, or Both, me first; what each runs, costs and earns, and switching - [The local API](provider/direct-mode.md) for any OpenAI client, and [network self-route](provider/self-route.md) - [Installation](provider/installation.md): what the installer checks, updates, uninstall diff --git a/docs/architecture/tool-integrations.md b/docs/architecture/tool-integrations.md index 670fc093e1..0a0c6faa16 100644 --- a/docs/architecture/tool-integrations.md +++ b/docs/architecture/tool-integrations.md @@ -1,10 +1,10 @@ # OpenCode and Hermes config writers -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 How Darkbloom points OpenCode 2 and Hermes Agent at its local API (Only me or Both, me first) by editing their own config files: the endpoint and key file, the models, the two planners and the safe-edit rules. This explanation is for provider -developers. `darkbloom start --opencode` / `--hermes` call them (`ToolIntegrationStep`, +developers. `darkbloom --opencode` / `--hermes` (`start` with the flag) call them (`ToolIntegrationStep`, `provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift`); for users, see [Use it from OpenCode or Hermes](../provider/local-first.md#use-it-from-opencode-or-hermes). @@ -105,7 +105,7 @@ flowchart LR | Need | Why | |---|---| -| Hermes v0.20.2 or later (release tag v2026.8.16) | `key_cmd` came in NousResearch/hermes-agent#86891. An older Hermes ignores it and sends its no-key placeholder, so Darkbloom answers every request with 401. `HermesVersion.keyCommandWarning` turns `hermes --version`'s first line into the one warning line `start --hermes` prints for an older Hermes | +| Hermes v0.20.2 or later (release tag v2026.8.16) | `key_cmd` came in NousResearch/hermes-agent#86891. An older Hermes ignores it and sends its no-key placeholder, so Darkbloom answers every request with 401. `HermesVersion.keyCommandWarning` turns `hermes --version`'s first line into the one warning line `darkbloom --hermes` prints for an older Hermes | | Config v12 (`providers:` as a mapping, with `transport` and `default_model`) | Hermes' current format; `hermes update` migrates an older `custom_providers:` list | | `max_tokens` after a model switch | Open Hermes bug #124289 (fix #124290 not merged): a named provider's `extra_body` is dropped on `/model --provider ` and on bare-named fallbacks, so those turns get the engine's 4,096-token default. New chats, and switches that name `custom:`, keep it | | The profile Hermes reads | After `hermes profile use `, Hermes reads `~/.hermes/profiles//config.yaml`; the writer edits `$HERMES_HOME/config.yaml`, else `~/.hermes/config.yaml`, and the result names the file it edited | diff --git a/docs/operations/provider-release.md b/docs/operations/provider-release.md index fedf3fe6d4..51c3ee9156 100644 --- a/docs/operations/provider-release.md +++ b/docs/operations/provider-release.md @@ -1,6 +1,6 @@ # Release A Provider Version -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 Build, sign, notarize and publish an explicitly authorized provider artifact. The pipeline registers its exact official identity through the external platform @@ -379,7 +379,8 @@ selects the same names from the version that `/v1/releases/latest` returns (`scripts/install.sh`, `select_provider_identity`). The installer must work as `curl | bash`, so it keeps its own copy of the names; the test compares that copy with the JSON. Every command it prints uses the selected `cliName`, through its -last line, `Next: ~/./bin/ start --opencode`; the platform +last line, `Next: ~/./bin/ --opencode` +(`scripts/test-install-identity.py` checks it for both identities); the platform serves its own snapshot of the script, so a change to these lines reaches `curl | bash` only once that snapshot is updated. diff --git a/docs/provider/cli-reference.md b/docs/provider/cli-reference.md index 4d2f2beb0c..f8cfba844f 100644 --- a/docs/provider/cli-reference.md +++ b/docs/provider/cli-reference.md @@ -142,6 +142,7 @@ upgrade warning. It is independent of `DARKBLOOM_NO_UPDATE_CHECK`. | Option | Type | Default | Effect | Source | |---|---|---|---|---| | `-c`, `--config ` | `String?` | `~/.config/darkbloom/provider.toml` | Provider TOML path. Accepted by the commands marked ✓ below | `provider-swift/Sources/darkbloom/Darkbloom.swift` (`ConfigOptions`); `provider-swift/Sources/ProviderCore/Config/ProviderConfig.swift` (`defaultConfigPath`) | +| `--opencode`, `--hermes` | flag | — | With no subcommand, `darkbloom --opencode` is `darkbloom start --opencode` (likewise `--hermes`, or both): every other `start` option goes with it, in any order (`darkbloom --opencode --me-first`), and `start`'s errors and refusals apply. `start --opencode` keeps working; a subcommand keeps its own options (`darkbloom status --opencode` is refused). `darkbloom --help` shows both in one line each ([Set up OpenCode or Hermes](#set-up-opencode-or-hermes)) | `provider-swift/Sources/darkbloom/Darkbloom.swift` (`Darkbloom.expandingToolShortcuts`), applied by `main.swift` before it parses or hosts | | `--version` | flag | — | Prints `ProviderCore.version` | `Darkbloom.configuration` | | `-h`, `--help` | flag | — | Help; `darkbloom` with no subcommand prints help | `Darkbloom.run` | @@ -298,7 +299,7 @@ LaunchAgent with the arguments `--local-endpoint` has always used address the tools were given never moves: 1. `--port `: used as given, and saved when it isn't the saved port: ``Local API port: 8007 (saved, instead of 8005: tools set up for 8005 need - `darkbloom start --opencode` or `--hermes` again).`` + `darkbloom --opencode` or `--hermes` again).`` 2. `[local] port`: used as it is, never probed or moved, even `8000` or a port another program holds (the local API then says why it isn't up). 3. Otherwise the port this Mac's local API already uses: its running API's @@ -365,8 +366,10 @@ LaunchAgent with the arguments `--local-endpoint` has always used #### Set up OpenCode or Hermes -`--opencode` and `--hermes` point the tools at this Mac's local API with the -config writers ([OpenCode and Hermes config writers](../architecture/tool-integrations.md); +`--opencode` and `--hermes`, usually run as `darkbloom --opencode` / +`darkbloom --hermes` ([global options](#global-options)), point the tools at +this Mac's local API with the config writers +([OpenCode and Hermes config writers](../architecture/tool-integrations.md); `ToolIntegrationStep`, `provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift`). They run once, at `start`: @@ -896,7 +899,7 @@ serves that endpoint, two lines follow `pid:`: `serving:` (how it serves, in the start summary's words) and `requests:` (where your requests go) (`Local.servingLines`). A server without a key says `requests: this Mac only (…)` under its API key line instead, and only `serving:` follows `pid:`. A -keyed server adds `tools: darkbloom start --opencode · --hermes`. `--json` +keyed server adds `tools: darkbloom --opencode · --hermes` (`Local.toolsLine`). `--json` is unchanged. ### `darkbloom route key` diff --git a/docs/provider/direct-mode.md b/docs/provider/direct-mode.md index 955a117865..15e52658a2 100644 --- a/docs/provider/direct-mode.md +++ b/docs/provider/direct-mode.md @@ -12,7 +12,7 @@ account key saved, one it can't take can go on to your other Macs, free, and with `my-macs-first` to the Darkbloom network, billed ([the local router](#when-this-mac-cant-take-a-request-the-local-router)). In a terminal, `darkbloom start` asks once which you want ([Use your Mac yourself, -first](./local-first.md)); `darkbloom start --opencode` also sets OpenCode up +first](./local-first.md)); `darkbloom --opencode` also sets OpenCode up ([Use it from OpenCode or Hermes](./local-first.md#use-it-from-opencode-or-hermes)). Chat completions accept `stop` as a string or string array and pass explicit @@ -445,7 +445,7 @@ writes too (`StandaloneServer.startLifecycleControl`). | `401 Unauthorized` | Send `Authorization: Bearer $(cat ~/.darkbloom/local_token)`; the token in `local.json` is authoritative | | `413` on a chat request with images | Body above `localInferenceMaxUploadBytes`; downscale or send fewer images | | `darkbloom local` says no server is running but a process is listening | The listener is not a Darkbloom server (foreign process on the port) or a stale `local.json` was cleaned; restart with a free port | -| ``the local API isn't up: port 8001 is in use (`darkbloom start --port 8002`)`` (`status`, `local`) | Another program listens on this Mac's local API port. Free it and run `darkbloom restart`, or run the command it names: the new port is saved, and tools set up for the old one need `darkbloom start --opencode` or `--hermes` again | +| ``the local API isn't up: port 8001 is in use (`darkbloom start --port 8002`)`` (`status`, `local`) | Another program listens on this Mac's local API port. Free it and run `darkbloom restart`, or run the command it names: the new port is saved, and tools set up for the old one need `darkbloom --opencode` or `--hermes` again | | Model not in `/v1/models` | Only models with an engine-v2 adapter are advertised; `darkbloom models list` | | Endpoint unreachable from another machine | Default bind is loopback; `--bind 0.0.0.0` and open the port, then set a reverse proxy with TLS | | A DevNet build (`darkbloom-dev`) fails a request for a model it hasn't loaded with ``The production Darkbloom on this Mac holds this Mac's GPU: … no model of this build loads here until production stops serving`` | The production app serves on this Mac, and two models don't fit one Mac's memory: a DevNet build refuses each cold load at its start, before any eviction, weight hash or reservation (`StandaloneServer.ensureModelLoaded`, `ClusterGPUHold.productionServesHere`). A model it loaded before production started keeps serving. Retry once production stops serving here; production's own build never refuses this way | diff --git a/docs/provider/installation.md b/docs/provider/installation.md index 506a2e6739..b2807206aa 100644 --- a/docs/provider/installation.md +++ b/docs/provider/installation.md @@ -1,11 +1,11 @@ # Install, update, and uninstall the provider -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 How to put the `darkbloom` CLI on an Apple Silicon Mac with `scripts/install.sh`, what the script verifies before it touches an existing install, how the binary is updated afterwards, and how to remove everything. For anyone installing -Darkbloom; after it, `darkbloom start --opencode` sets up OpenCode on this +Darkbloom; after it, `darkbloom --opencode` sets up OpenCode on this Mac's models ([quickstart](./quickstart.md)). ## Prerequisites @@ -150,7 +150,7 @@ The `PATH` line the installer added is read only by a new shell. Until then, ### 3. Start Darkbloom ```bash -darkbloom start --opencode # or --hermes, or plain darkbloom start for neither +darkbloom --opencode # or --hermes, or plain darkbloom start for neither ``` It asks how this Mac serves (**Only me**, **Darkbloom network** or **Both, me @@ -378,7 +378,7 @@ Neither `darkbloom uninstall` nor `darkbloom stop --uninstall` removes that job. ## Related -- [Quickstart](./quickstart.md) — `darkbloom start --opencode`, the three choices, then earning. +- [Quickstart](./quickstart.md) — `darkbloom --opencode`, the three choices, then earning. - [CLI reference](./cli-reference.md) — every flag, path and runtime constant. - [Troubleshooting](./troubleshooting.md) — installer exit messages and fixes. - [Attestation](./attestation.md) — what the Secure Enclave key and MDM profile buy you. diff --git a/docs/provider/local-first.md b/docs/provider/local-first.md index c5fedac499..d69edb7f45 100644 --- a/docs/provider/local-first.md +++ b/docs/provider/local-first.md @@ -179,13 +179,14 @@ this Mac, for example `http://127.0.0.1:8001/v1`: ## Use it from OpenCode or Hermes -Add `--opencode` or `--hermes` (or both) to `darkbloom start`, as you would run -`ollama launch` or `omlx launch`: +Run `darkbloom --opencode` or `darkbloom --hermes` (or both), as you would run +`ollama launch` or `omlx launch`. Each runs `darkbloom start` with the flag, so +any `start` option goes with it, in any order: ```bash -darkbloom start --opencode # set OpenCode up -darkbloom start --hermes # set Hermes Agent up -darkbloom start --me-first --opencode --hermes +darkbloom --opencode # set OpenCode up +darkbloom --hermes # set Hermes Agent up +darkbloom --opencode --hermes --me-first ``` Then, in OpenCode, `/models` → Darkbloom. Hermes uses Darkbloom as its main @@ -200,7 +201,7 @@ model. in Hermes' `~/.hermes/config.yaml`, where it also becomes the main model, as Ollama and oMLX do. Everything else in those files stays as it was. - **Your key stays out of them.** The tools read it from Darkbloom's own key - file, and `start --opencode` never prints it. + file, and `darkbloom --opencode` never prints it. - **Undo in one line:** every change is backed up first, and the start prints the file it changed, the backup and the command that puts it back: @@ -241,7 +242,7 @@ model. which Darkbloom changes: unset it, or copy the `darkbloom` provider there. A Hermes profile chosen with `hermes profile use ` reads `~/.hermes/profiles//config.yaml`: set that profile up with - `HERMES_HOME=~/.hermes/profiles/ darkbloom start --hermes`. The start + `HERMES_HOME=~/.hermes/profiles/ darkbloom --hermes`. The start always names the file it changed. ## Check how this Mac serves @@ -276,7 +277,7 @@ A pair gets the same three choices. Run `darkbloom cluster` on each Mac: it pairs them, then the leading Mac asks how the pair serves (**Only me**, **Darkbloom network** or **Both, me first**, preselected) and which model; its list's **Change how the pair serves** asks again. Then run -`darkbloom start --opencode` on the leading Mac, which runs the pair's API. +`darkbloom --opencode` on the leading Mac, which runs the pair's API. - **Only me:** no Mac of the pair contacts Darkbloom. `darkbloom cluster local` serves the pair this way too. The other Mac passes its own port on to the diff --git a/docs/provider/quickstart.md b/docs/provider/quickstart.md index 8fe9fc4af5..c646d7201c 100644 --- a/docs/provider/quickstart.md +++ b/docs/provider/quickstart.md @@ -1,6 +1,6 @@ # Provider quickstart -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 From a fresh Apple Silicon Mac to OpenCode or Hermes on this Mac's own models; then, if you want, to earning on the Darkbloom network. For anyone setting up a @@ -9,14 +9,14 @@ Mac. ```text curl -fsSL https://api.darkbloom.dev/install.sh | bash exec $SHELL -l # or open a new Terminal window -darkbloom start --opencode # or --hermes +darkbloom --opencode # or --hermes How should this Mac serve? 1 Only me · 2 Darkbloom network · 3 Both, me first [3] Enter → your models (downloads offered) → memory when idle → serves in the background ✓ OpenCode can use Darkbloom opencode # then /models → Darkbloom ``` -Two Macs: run `darkbloom cluster` on each, then `darkbloom start --opencode` on +Two Macs: run `darkbloom cluster` on each, then `darkbloom --opencode` on the leading Mac. @@ -57,10 +57,11 @@ shell reads. What the script verifies and writes is in ### 2. Start, and set up OpenCode ```bash -darkbloom start --opencode # --hermes for Hermes; both flags for both +darkbloom --opencode # --hermes for Hermes; both flags for both ``` -`start` prints the Terms-of-Service notice (starting is acceptance) and asks +It runs `darkbloom start`, then sets OpenCode up. `start` prints the +Terms-of-Service notice (starting is acceptance) and asks how this Mac serves (`How should this Mac serve?`). Type 1, 2 or 3, or press Enter for 3: @@ -130,7 +131,7 @@ client: `darkbloom local` prints the address, the key and a `curl` to try - **Switch later:** `darkbloom start --choose` asks how this Mac serves again, then goes on as above. - **Two Macs:** run `darkbloom cluster` on each Mac to pair them and choose - how the pair serves, then `darkbloom start --opencode` on the leading Mac + how the pair serves, then `darkbloom --opencode` on the leading Mac ([Two Macs as one provider](./two-mac-cluster.md)). diff --git a/docs/provider/troubleshooting.md b/docs/provider/troubleshooting.md index 18375dbd60..afbbbf318a 100644 --- a/docs/provider/troubleshooting.md +++ b/docs/provider/troubleshooting.md @@ -1,6 +1,6 @@ # Provider troubleshooting -> Last updated: 2026-11-07 +> Last updated: 2026-11-08 Symptom → check → fix for the `darkbloom` provider: installer exits, `doctor` check names, service lifecycle, coordinator connection, updates, models, the @@ -113,7 +113,7 @@ and `provider-swift/Sources/darkbloom/Diagnostics/DoctorRunner.swift`, using | `No models selected.` | Picker cancelled or `--model` ids not local | `darkbloom models list`; `darkbloom models download ` | | ``Without a terminal, `darkbloom start` can't ask which models to serve: …`` (exit 64) | A script, an agent or a start with its input redirected named no models; no start asks a question without a terminal | Add `--model ` (`darkbloom models list`) or `--all`, or run `darkbloom start` in a terminal to pick | | `No engine-v2-capable models available to serve.` (`--local`) | Every local model's family lacks a CBv2 adapter | Download a supported family (gpt-oss, gemma-4) | -| ``This Mac's local API couldn't listen on :: another program may use port . …`` (Only me) | Another program holds this Mac's local API port | Stop the other program, or run the `darkbloom start --port ` it names: the new port is saved, and tools set up for the old one need `darkbloom start --opencode` or `--hermes` again | +| ``This Mac's local API couldn't listen on :: another program may use port . …`` (Only me) | Another program holds this Mac's local API port | Stop the other program, or run the `darkbloom start --port ` it names: the new port is saved, and tools set up for the old one need `darkbloom --opencode` or `--hermes` again | | ``Serving: Darkbloom and you, me first — the local API isn't up: port is in use (…)`` (`status`; `local` says `The local API isn't up: …`) | Both, me first serves Darkbloom, but another program holds the local API's port (`DaemonState.localAPIFailure`) | As above; after freeing the port, `darkbloom restart` | | `Cannot start --local-endpoint: failed to create the local API token …` | `~/.darkbloom` not writable | Fix permissions, or `--no-auth` on a trusted network | | `warning: … RETIRED knob and is IGNORED` | A retired `[backend]` key or env var is set | Remove it; see [beta features](./beta-features.md#retired) | diff --git a/provider-swift/Sources/ProviderCore/Config/LocalAPIPort.swift b/provider-swift/Sources/ProviderCore/Config/LocalAPIPort.swift index 91de0f931f..7e4c7a3255 100644 --- a/provider-swift/Sources/ProviderCore/Config/LocalAPIPort.swift +++ b/provider-swift/Sources/ProviderCore/Config/LocalAPIPort.swift @@ -126,7 +126,7 @@ public enum LocalAPIPort { guard let saved else { return "Local API port: \(named) (saved)." } let cli = BuildEnvironment.current.cliName return "Local API port: \(named) (saved, instead of \(saved): tools set up for \(saved) need " - + "`\(cli) start --opencode` or `--hermes` again)." + + "`\(cli) --opencode` or `--hermes` again)." } /// Says that no port from `start` is free for a new choice, and what to do. diff --git a/provider-swift/Sources/darkbloom/Darkbloom.swift b/provider-swift/Sources/darkbloom/Darkbloom.swift index 0daf6dd623..ef087dabde 100644 --- a/provider-swift/Sources/darkbloom/Darkbloom.swift +++ b/provider-swift/Sources/darkbloom/Darkbloom.swift @@ -24,7 +24,13 @@ struct Darkbloom: AsyncParsableCommand { static let configuration = CommandConfiguration( commandName: BuildEnvironment.current.cliName, abstract: "Swift-native provider CLI for Darkbloom.", - discussion: "Runs on Apple Silicon Macs. Connects to the coordinator, serves inference requests via mlx-swift.", + discussion: """ + Runs on Apple Silicon Macs. Connects to the coordinator, serves inference requests via mlx-swift. + + Shortcuts (any `start` option can be added): + \(BuildEnvironment.current.cliName) --opencode Set up OpenCode (same as `start --opencode`) + \(BuildEnvironment.current.cliName) --hermes Set up Hermes Agent (same as `start --hermes`) + """, version: ProviderCore.version, subcommands: [ Start.self, @@ -74,6 +80,30 @@ struct Darkbloom: AsyncParsableCommand { } } +// MARK: - `darkbloom --opencode` and `darkbloom --hermes` + +extension Darkbloom { + /// `arguments`, as typed after `darkbloom`, with `start` put first when they are a tool shortcut: + /// `darkbloom --opencode --me-first` runs `darkbloom start --opencode --me-first`. + /// + /// The root forwards to `start` when no subcommand is named (the first argument is an option) and `--opencode` or + /// `--hermes` comes before any `--`. Every other argument then goes to `start` too, in any order, so `start`'s + /// errors and help apply. Anything else is parsed as typed: plain `darkbloom`, `--help` or `--version` without a + /// tool flag, a subcommand and its options (`darkbloom models --opencode` is refused), and a mistyped flag + /// (`darkbloom --opencod` gets the root's unknown-option error). ArgumentParser's default subcommand isn't used: + /// it would also run `start` for plain `darkbloom` and for `darkbloom --me-first`. + static func expandingToolShortcuts(_ arguments: [String]) -> [String] { + let toolFlags = Set(IntegrationTool.allCases.map(\.flag)) + guard arguments.first?.hasPrefix("-") == true, + arguments.prefix(while: { $0 != "--" }).contains(where: toolFlags.contains) else { return arguments } + return ["start"] + arguments + } + + /// This process's arguments as `main` hosts and parses them (`expandingToolShortcuts`), for a later check that + /// must agree with `main`, such as whether the AppKit host runs. + static var commandLineArguments: [String] { expandingToolShortcuts(Array(CommandLine.arguments.dropFirst())) } +} + // MARK: - Update banner (best-effort, non-blocking) /// Run the update banner before any subcommand executes. Uses a hard diff --git a/provider-swift/Sources/darkbloom/LocalCommand.swift b/provider-swift/Sources/darkbloom/LocalCommand.swift index 8f27819ca4..14f73a1f45 100644 --- a/provider-swift/Sources/darkbloom/LocalCommand.swift +++ b/provider-swift/Sources/darkbloom/LocalCommand.swift @@ -74,7 +74,7 @@ struct Local: AsyncParsableCommand { print(line) } } - if !info.apiKey.isEmpty { print(" tools: \(BuildEnvironment.current.cliName) start --opencode · --hermes") } + if !info.apiKey.isEmpty { print(Self.toolsLine) } print() print("Use it with any OpenAI client:") print(" export OPENAI_BASE_URL=\(info.baseURL)") @@ -134,6 +134,9 @@ struct Local: AsyncParsableCommand { " or: \(cli) start --local (only you, on this Mac)"] } + /// The line under a keyed server's address: the commands that set the tools up for it. + static var toolsLine: String { " tools: \(BuildEnvironment.current.cliName) --opencode · --hermes" } + /// For a server listening on every interface: this Mac's Bonjour (`.local`) URL, which other computers on the /// same network can dial; nil for a loopback or specific-address server, or when the Mac has no local host name. static func networkURL(host: String, port: UInt16) -> String? { diff --git a/provider-swift/Sources/darkbloom/Start/StartCommand+Modes.swift b/provider-swift/Sources/darkbloom/Start/StartCommand+Modes.swift index c76c9d4dd0..21066db7c6 100644 --- a/provider-swift/Sources/darkbloom/Start/StartCommand+Modes.swift +++ b/provider-swift/Sources/darkbloom/Start/StartCommand+Modes.swift @@ -104,7 +104,7 @@ extension Start { // `start --local` runs under the AppKit host, which turns Ctrl-C into a drain; "Only me" from the question // or the saved choice runs here, so it takes the same signals itself. #if os(macOS) - let signals = ProviderAppKitHost.shouldHost(Array(CommandLine.arguments.dropFirst())) ? nil + let signals = ProviderAppKitHost.shouldHost(Darkbloom.commandLineArguments) ? nil : ProviderSignalHandler { _ = await ProviderTermination.shared.request() } defer { withExtendedLifetime(signals) {} } #endif diff --git a/provider-swift/Sources/darkbloom/Start/StartCommand+Tools.swift b/provider-swift/Sources/darkbloom/Start/StartCommand+Tools.swift index 8e248e7eeb..b0eac41042 100644 --- a/provider-swift/Sources/darkbloom/Start/StartCommand+Tools.swift +++ b/provider-swift/Sources/darkbloom/Start/StartCommand+Tools.swift @@ -2,7 +2,7 @@ import ArgumentParser import Foundation import ProviderCore -// `darkbloom start --opencode` / `--hermes`: start Darkbloom only if no local API runs, then point the tools at it +// `darkbloom --opencode` / `--hermes`: start Darkbloom only if no local API runs, then point the tools at it // (ToolIntegrationStep). They run once, at start: never in the launchd child, never per request. A start without a // tool flag reads nothing here. No line, and no tool file, holds a key. extension Start { @@ -26,7 +26,7 @@ extension Start { } if distributed { return "`\(first.flag)` doesn't start a cluster. Start it first, then run " - + "`\(BuildEnvironment.current.cliName) start \(first.flag)` on its own: it sets " + + "`\(ToolIntegrationStep.command([first]))` on its own: it sets " + "\(first.displayName) up for the cluster's local API." } return nil diff --git a/provider-swift/Sources/darkbloom/ToolIntegration/HermesConfigPlan.swift b/provider-swift/Sources/darkbloom/ToolIntegration/HermesConfigPlan.swift index 61df6849e8..8f9e0ace3f 100644 --- a/provider-swift/Sources/darkbloom/ToolIntegration/HermesConfigPlan.swift +++ b/provider-swift/Sources/darkbloom/ToolIntegration/HermesConfigPlan.swift @@ -153,7 +153,7 @@ private struct HermesEdit { // A new block comes with a line saying where it came from. A replaced block keeps the lines above it, that one // included, so a re-run never adds a second. func newBlock(_ indent: String) -> [String] { - [indent + "# Added by `\(provider.id) start --hermes`. Run it again to refresh \(provider.name)'s models."] + [indent + "# Added by `\(provider.id) --hermes`. Run it again to refresh \(provider.name)'s models."] + block(indent) } guard let section = providers else { diff --git a/provider-swift/Sources/darkbloom/ToolIntegration/HermesVersion.swift b/provider-swift/Sources/darkbloom/ToolIntegration/HermesVersion.swift index 1ef58dc75f..6c9e594a3e 100644 --- a/provider-swift/Sources/darkbloom/ToolIntegration/HermesVersion.swift +++ b/provider-swift/Sources/darkbloom/ToolIntegration/HermesVersion.swift @@ -19,7 +19,7 @@ enum HermesVersion { return nil } - /// The one line `start --hermes` prints when the installed Hermes predates `key_cmd`; nil when it doesn't, or + /// The one line `darkbloom --hermes` prints when the installed Hermes predates `key_cmd`; nil when it doesn't, or /// when its version can't be read. A release date (a first number of 2000 or more) compares with v0.20.2's. static func keyCommandWarning(versionOutput: String) -> String? { guard let version = parse(versionOutput) else { return nil } diff --git a/provider-swift/Sources/darkbloom/ToolIntegration/OpenCodeConfigPlan.swift b/provider-swift/Sources/darkbloom/ToolIntegration/OpenCodeConfigPlan.swift index cb8c10ddaa..ad2804a207 100644 --- a/provider-swift/Sources/darkbloom/ToolIntegration/OpenCodeConfigPlan.swift +++ b/provider-swift/Sources/darkbloom/ToolIntegration/OpenCodeConfigPlan.swift @@ -252,7 +252,7 @@ private struct Block { /// The whole member, the comment line first in a `.jsonc` file, as lines relative to the member's indent. var member: [String] { - let comment = "// Added by `\(provider.id) start --opencode`. Run it again to refresh \(provider.name)'s models." + let comment = "// Added by `\(provider.id) --opencode`. Run it again to refresh \(provider.name)'s models." let lines = valueLines.enumerated().map { index, line in index == 0 ? "\(OpenCodeConfigPlan.jsonString(provider.id)): {" : String(repeating: unit, count: line.level) + line.text diff --git a/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegration.swift b/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegration.swift index a2922ed048..7ff1764e53 100644 --- a/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegration.swift +++ b/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegration.swift @@ -2,7 +2,7 @@ import Darwin import Foundation import ProviderCore -/// The agent tools Darkbloom sets up to use it as a provider (`start --opencode` / `--hermes`). +/// The agent tools Darkbloom sets up to use it as a provider (`darkbloom --opencode` / `--hermes`). enum IntegrationTool: String, CaseIterable, Sendable { case opencode case hermes diff --git a/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift b/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift index 54da9fba36..2276c41148 100644 --- a/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift +++ b/provider-swift/Sources/darkbloom/ToolIntegration/ToolIntegrationStep.swift @@ -18,7 +18,7 @@ extension IntegrationTool { var flag: String { "--\(rawValue)" } } -/// Whether a tool is on this Mac, as `start --opencode` / `--hermes` looks for it. +/// Whether a tool is on this Mac, as `darkbloom --opencode` / `--hermes` looks for it. enum ToolInstall: Equatable, Sendable { case installed(URL) case missing @@ -73,7 +73,7 @@ enum ToolLocator { } } -/// `darkbloom start --opencode` / `--hermes`: once, at start, points each tool at this Mac's live local API, with a +/// `darkbloom --opencode` / `--hermes`: once, at start, points each tool at this Mac's live local API, with a /// backup and a one-line undo. It never prints or writes a key, and a tool it can't set up never stops Darkbloom /// serving. struct ToolIntegrationStep { @@ -123,11 +123,11 @@ struct ToolIntegrationStep { ready.append((tool, executable)) case .missing: say("✗ \(tool.displayName) isn't installed on this Mac. Install it, then run " - + "`\(Self.cli) start \(tool.flag)` again.") + + "`\(Self.command([tool]))` again.") failed = true case .tooOld: say("✗ OpenCode 1 is installed; Darkbloom sets up OpenCode 2. Run `opencode upgrade`, then " - + "`\(Self.cli) start --opencode` again.") + + "`\(Self.command([.opencode]))` again.") failed = true } } @@ -183,7 +183,7 @@ struct ToolIntegrationStep { } if !unloaded.isEmpty { let one = unloaded.count == 1 - say(" Run `\(Self.cli) start \(Self.flags(ready.map(\.tool)))` again once the " + say(" Run `\(Self.command(ready.map(\.tool)))` again once the " + "\(one ? "model is" : "models are") loaded, to pick up \(one ? "its" : "their") limits.") } let keyFile = ToolIntegration.displayPath(endpoint.keyFile, home: environment.home) @@ -235,14 +235,14 @@ struct ToolIntegrationStep { /// The line when this start has no local API for the tools. static func noLocalAPI(_ tools: [IntegrationTool]) -> String { "This Mac serves only the Darkbloom network, so \(names(tools)) \(tools.count == 1 ? "has" : "have") no local " - + "address to use. Choose \"Both, me first\" (`\(cli) start --me-first \(flags(tools))`) or \"Only me\" " - + "(`\(cli) start --local \(flags(tools))`)." + + "address to use. Choose \"Both, me first\" (`\(command(tools)) --me-first`) or \"Only me\" " + + "(`\(command(tools)) --local`)." } /// The line when the local API didn't come up in time after a background start. static func notUp(_ tools: [IntegrationTool], seconds: Int) -> String { "✗ This Mac's local API didn't answer within \(seconds) seconds, so \(notSetUp(tools)). Run " - + "`\(cli) start \(flags(tools))` again once `\(cli) local` shows it." + + "`\(command(tools))` again once `\(cli) local` shows it." } /// The line on a paired Mac whose pair has no local API on this Mac. @@ -267,7 +267,7 @@ struct ToolIntegrationStep { /// The line when the catalog can't be read and a tool now lists a model without its name and image support. static func catalogUnreachable(_ tools: [IntegrationTool]) -> String { - " Darkbloom's catalog wasn't reachable: run `\(cli) start \(flags(tools))` again online for the models' " + " Darkbloom's catalog wasn't reachable: run `\(command(tools))` again online for the models' " + "names and image support." } @@ -278,7 +278,9 @@ struct ToolIntegrationStep { static func names(_ tools: [IntegrationTool]) -> String { tools.map(\.displayName).joined(separator: " and ") } - static func flags(_ tools: [IntegrationTool]) -> String { tools.map(\.flag).joined(separator: " ") } + /// The command that sets `tools` up: `darkbloom --opencode --hermes`, short for `darkbloom start --opencode + /// --hermes` (`Darkbloom.expandingToolShortcuts`). + static func command(_ tools: [IntegrationTool]) -> String { ([cli] + tools.map(\.flag)).joined(separator: " ") } /// "OpenCode wasn't set up", "OpenCode and Hermes weren't set up". static func notSetUp(_ tools: [IntegrationTool]) -> String { diff --git a/provider-swift/Sources/darkbloom/main.swift b/provider-swift/Sources/darkbloom/main.swift index 960b885a2e..f1ca63c6f8 100644 --- a/provider-swift/Sources/darkbloom/main.swift +++ b/provider-swift/Sources/darkbloom/main.swift @@ -34,17 +34,21 @@ if rawArgs.first == AppAttestQualificationCommand.argument { // (`ClusterCandidateRecovery.startCheckFailure`). MacOSUpgradeNotice.emit() +// `darkbloom --opencode` / `--hermes` are short for `start --opencode` / `--hermes`. Expanded before the host check +// and the parse, they are hosted and parsed exactly as `start` is (`Darkbloom.expandingToolShortcuts`). +let commandArgs = Darkbloom.commandLineArguments + #if os(macOS) -if ProviderAppKitHost.shouldHost(rawArgs) { +if ProviderAppKitHost.shouldHost(commandArgs) { // Takes over the main thread with the AppKit run loop and never returns. - ProviderAppKitHost.runHosted(rawArgs) + ProviderAppKitHost.runHosted(commandArgs) } #endif // Non-serve path: parse + dispatch as ArgumentParser's async main() would, done // manually because @main is removed (it would fight AppKit for the main thread). do { - var command = try Darkbloom.parseAsRoot(rawArgs) + var command = try Darkbloom.parseAsRoot(commandArgs) if var asyncCommand = command as? any AsyncParsableCommand { try await runAsyncCommand(&asyncCommand) } else { diff --git a/provider-swift/Tests/DarkbloomCLITests/CLIDispatchTests.swift b/provider-swift/Tests/DarkbloomCLITests/CLIDispatchTests.swift index f443497036..001d11aa3e 100644 --- a/provider-swift/Tests/DarkbloomCLITests/CLIDispatchTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/CLIDispatchTests.swift @@ -25,6 +25,10 @@ private final class BundleAnchor {} /// the subprocess can never read or write a real provider config /// on the host, and the update banner is disabled to keep the run offline. private func run(_ args: [String], home: URL) throws -> String { + try runWithStatus(args, home: home).output + } + + private func runWithStatus(_ args: [String], home: URL) throws -> (output: String, status: Int32) { let proc = Process() proc.executableURL = binary proc.arguments = args @@ -38,7 +42,7 @@ private final class BundleAnchor {} try proc.run() let data = pipe.fileHandleForReading.readDataToEndOfFile() proc.waitUntilExit() - return String(decoding: data, as: UTF8.self) + return (String(decoding: data, as: UTF8.self), proc.terminationStatus) } private func makeTempHome() throws -> URL { @@ -73,4 +77,32 @@ private final class BundleAnchor {} #expect(out.contains("SUBCOMMANDS")) #expect(out.contains("status")) } + + /// `darkbloom --help` is the root help, with a line for each tool shortcut. + @Test func rootHelpNamesTheToolShortcuts() throws { + let home = try makeTempHome() + defer { try? FileManager.default.removeItem(at: home) } + let out = try run(["--help"], home: home) + #expect(out.contains("USAGE: darkbloom "), "Got:\n\(out)") + #expect(out.contains(" darkbloom --opencode ") && out.contains(" darkbloom --hermes "), "Got:\n\(out)") + } + + /// `main` makes `darkbloom --opencode` `start --opencode` before it parses: with `--help`, start's help prints, + /// and nothing starts. + @Test func toolShortcutParsesAsStart() throws { + let home = try makeTempHome() + defer { try? FileManager.default.removeItem(at: home) } + let (out, status) = try runWithStatus(["--opencode", "--help"], home: home) + #expect(status == 0) + #expect(out.contains("USAGE: darkbloom start"), "Got:\n\(out)") + } + + /// A mistyped tool flag is the root command's usual unknown-option error. + @Test func mistypedToolFlagIsTheUsualError() throws { + let home = try makeTempHome() + defer { try? FileManager.default.removeItem(at: home) } + let (out, status) = try runWithStatus(["--opencod"], home: home) + #expect(status == 64) + #expect(out.contains("Error: Unknown option '--opencod'\nUsage: darkbloom "), "Got:\n\(out)") + } } diff --git a/provider-swift/Tests/DarkbloomCLITests/ClusterPairCommandsTests.swift b/provider-swift/Tests/DarkbloomCLITests/ClusterPairCommandsTests.swift index b93e538227..a10c30ddea 100644 --- a/provider-swift/Tests/DarkbloomCLITests/ClusterPairCommandsTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/ClusterPairCommandsTests.swift @@ -1358,7 +1358,7 @@ struct ClusterPairControlTests { + ClusterPairSummary.releaseBusyLines + [""]) } - /// On DevNet pair-2 a `darkbloom start --opencode` that got no answer hung on "Serve on this Mac alone / Start the + /// On DevNet pair-2 a start with `--opencode` that got no answer hung on "Serve on this Mac alone / Start the /// pair". No start asks a question without a terminal: on a paired Mac one starts the pair, with or without the tool /// flags, and never reads standard input (`neverAnswering`). @Test("a start without a terminal on a paired Mac starts the pair and never reads standard input, with or without --opencode or --hermes") diff --git a/provider-swift/Tests/DarkbloomCLITests/LocalAPIOnePortTests.swift b/provider-swift/Tests/DarkbloomCLITests/LocalAPIOnePortTests.swift index d22c6c0208..4bdafcd481 100644 --- a/provider-swift/Tests/DarkbloomCLITests/LocalAPIOnePortTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/LocalAPIOnePortTests.swift @@ -105,7 +105,7 @@ struct LocalAPIOnePortTests { terminal: false)) #expect(moved.port == 8007 && saved.local == LocalSettings(port: 8007)) #expect(moved.portNote == "Local API port: 8007 (saved, instead of 8005: tools set up for 8005 need " - + "`darkbloom start --opencode` or `--hermes` again).") + + "`darkbloom --opencode` or `--hermes` again).") let before = saved.bytes let child = try #require(try ScriptedTerminal().resolve( diff --git a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/HermesConfigPlanTests.swift b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/HermesConfigPlanTests.swift index 29a3310601..16c893aa22 100644 --- a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/HermesConfigPlanTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/HermesConfigPlanTests.swift @@ -29,7 +29,7 @@ private let block = """ """ -private let added = " # Added by `darkbloom start --hermes`. Run it again to refresh Darkbloom's models.\n" +private let added = " # Added by `darkbloom --hermes`. Run it again to refresh Darkbloom's models.\n" private let mainModel = """ model: @@ -210,7 +210,9 @@ struct HermesConfigPlanTests { """ let result = plan(owner) - #expect(F.newText(result) == "providers:\n" + added + block + """ + // The line an earlier version wrote above the block stays as it is: a re-run never adds a second. + let earlierLine = " # Added by `darkbloom start --hermes`. Run it again to refresh Darkbloom's models.\n" + #expect(F.newText(result) == "providers:\n" + earlierLine + block + """ ollama-launch: api: http://127.0.0.1:11434/v1 diff --git a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/OpenCodeConfigPlanTests.swift b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/OpenCodeConfigPlanTests.swift index 2e33a2add1..a2b933f52a 100644 --- a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/OpenCodeConfigPlanTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/OpenCodeConfigPlanTests.swift @@ -45,7 +45,7 @@ private func darkbloomValue(indent: String) -> String { """.replacingOccurrences(of: "\n", with: "\n" + indent) } -private let addedComment = "// Added by `darkbloom start --opencode`. Run it again to refresh Darkbloom's models." +private let addedComment = "// Added by `darkbloom --opencode`. Run it again to refresh Darkbloom's models." @Suite("OpenCode config plan") struct OpenCodeConfigPlanTests { diff --git a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/StartToolIntegrationTests.swift b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/StartToolIntegrationTests.swift index 434dd30e11..d19494ee54 100644 --- a/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/StartToolIntegrationTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/ToolIntegration/StartToolIntegrationTests.swift @@ -91,7 +91,7 @@ struct StartToolIntegrationTests { (["--opencode", "--foreground"], "`--opencode` runs once, at `darkbloom start`; the --foreground service never sets tools up."), (["--opencode", "--local", "--distributed"], - "`--opencode` doesn't start a cluster. Start it first, then run `darkbloom start --opencode` on its own: it " + "`--opencode` doesn't start a cluster. Start it first, then run `darkbloom --opencode` on its own: it " + "sets OpenCode up for the cluster's local API."), ] @@ -112,8 +112,8 @@ struct StartToolIntegrationTests { let config = try directory.write("[provider]\nname = \"d2b\"\n", to: "provider.toml") let before = try Data(contentsOf: config) let refusal = "This Mac serves only the Darkbloom network, so OpenCode and Hermes have no local address to " - + "use. Choose \"Both, me first\" (`darkbloom start --me-first --opencode --hermes`) or \"Only me\" " - + "(`darkbloom start --local --opencode --hermes`). Nothing was started or saved." + + "use. Choose \"Both, me first\" (`darkbloom --opencode --hermes --me-first`) or \"Only me\" " + + "(`darkbloom --opencode --hermes --local`). Nothing was started or saved." for (terminal, answers) in [(false, [String]()), (true, ["2"])] { var remaining = answers let start = try Start.parse(["--opencode", "--hermes", "--config", config.path]) @@ -128,7 +128,7 @@ struct StartToolIntegrationTests { } } #expect(try Data(contentsOf: config) == before) - #expect(ToolIntegrationStep.noLocalAPI([.opencode]).hasSuffix("(`darkbloom start --local --opencode`).")) + #expect(ToolIntegrationStep.noLocalAPI([.opencode]).hasSuffix("(`darkbloom --opencode --local`).")) } // MARK: - Already serving: set the tools up, start nothing @@ -183,7 +183,7 @@ struct StartToolIntegrationTests { keyFile: { _ in nil }, pause: { pauses += 1 }) #expect(keyless == .noKeyFile && pauses == 0) #expect(ToolIntegrationStep.notUp([.opencode], seconds: 30) == "✗ This Mac's local API didn't answer within 30 " - + "seconds, so OpenCode wasn't set up. Run `darkbloom start --opencode` again once `darkbloom local` shows it.") + + "seconds, so OpenCode wasn't set up. Run `darkbloom --opencode` again once `darkbloom local` shows it.") } @Test("beside a running local API without a key (--no-auth), the start names it and starts nothing") @@ -286,7 +286,7 @@ struct StartToolIntegrationTests { @Test("a model this Mac hasn't loaded yet gets one line: run the start again once it is loaded") func unloadedModelsSayRunAgain() async throws { - let line = " Run `darkbloom start --opencode` again once the model is loaded, to pick up its limits." + let line = " Run `darkbloom --opencode` again once the model is loaded, to pick up its limits." let sandbox = try StepSandbox() let unloaded = StepSandbox.listed + [EndpointModel(id: "gpt-oss-120b", ownedBy: "this-mac")] #expect(await sandbox.step([.opencode], listed: unloaded).run(endpoint: sandbox.endpoint, requests: "x")) @@ -345,7 +345,7 @@ struct StartToolIntegrationTests { " Switch back: hermes model · Undo: rm \(ToolIntegration.shellQuoted(sandbox.hermesFile.path)) · " + "Chats already open keep their model.", " Left out: gemma-4-26b-qat-4bit (Hermes needs 64K context)", - " Darkbloom's catalog wasn't reachable: run `darkbloom start --opencode --hermes` again online for the " + " Darkbloom's catalog wasn't reachable: run `darkbloom --opencode --hermes` again online for the " + "models' names and image support.", " Requests: this Mac only", " Other tools: OPENAI_BASE_URL=http://127.0.0.1:8123/v1 OPENAI_API_KEY=\"$(cat ~/.darkbloom/local_token)\"", @@ -415,8 +415,8 @@ struct StartToolIntegrationTests { let more = StepSandbox.listed + [EndpointModel(id: "new-model", ownedBy: "this-mac", contextLength: 65_536)] #expect(await sandbox.step([.opencode, .hermes], listed: more) .run(endpoint: sandbox.endpoint, requests: "this Mac only")) - #expect(sandbox.said.contains(" Darkbloom's catalog wasn't reachable: run `darkbloom start --opencode " - + "--hermes` again online for the models' names and image support.")) + #expect(sandbox.said.contains(" Darkbloom's catalog wasn't reachable: run `darkbloom --opencode --hermes` " + + "again online for the models' names and image support.")) let rewritten = F.utf8(try Data(contentsOf: sandbox.openCodeFile)) #expect(rewritten.contains("\"name\": \"Qwen 3.8 27B (this Mac)\"") && rewritten.contains("\"name\": \"Gemma 4 26B (this Mac)\"") @@ -430,7 +430,7 @@ struct StartToolIntegrationTests { #expect(await !missing.step([.opencode, .hermes], installed: [.opencode]) .run(endpoint: missing.endpoint, requests: "this Mac only")) #expect(missing.said.first == "✗ Hermes isn't installed on this Mac. Install it, then run " - + "`darkbloom start --hermes` again.") + + "`darkbloom --hermes` again.") #expect(missing.said.last == "Darkbloom keeps serving.") #expect(!FileManager.default.fileExists(atPath: missing.hermesFile.path)) #expect(FileManager.default.fileExists(atPath: missing.openCodeFile.path)) @@ -458,7 +458,7 @@ struct StartToolIntegrationTests { fetchModels: { _ in StepSandbox.listed }, fetchCatalog: { nil }, say: { old.said.append($0) }) #expect(await !step.run(endpoint: old.endpoint, requests: "this Mac only")) #expect(old.said == ["✗ OpenCode 1 is installed; Darkbloom sets up OpenCode 2. Run `opencode upgrade`, then " - + "`darkbloom start --opencode` again.", "Darkbloom keeps serving."]) + + "`darkbloom --opencode` again.", "Darkbloom keeps serving."]) #expect(old.filesOtherThanTheKey().isEmpty) } diff --git a/provider-swift/Tests/DarkbloomCLITests/ToolShortcutTests.swift b/provider-swift/Tests/DarkbloomCLITests/ToolShortcutTests.swift new file mode 100644 index 0000000000..8ccb8ea395 --- /dev/null +++ b/provider-swift/Tests/DarkbloomCLITests/ToolShortcutTests.swift @@ -0,0 +1,155 @@ +import ArgumentParser +import Testing + +@testable import ProviderCore +@testable import darkbloom + +/// `darkbloom --opencode` and `darkbloom --hermes`: with no subcommand named, a tool flag forwards the arguments to +/// `start` (`Darkbloom.expandingToolShortcuts`, which `main` applies before it hosts or parses anything). Parsing only: +/// no command runs. +@Suite("darkbloom --opencode and --hermes") +struct ToolShortcutTests { + static let cli = BuildEnvironment.current.cliName + + /// What `main` parses for `arguments`, typed after `darkbloom`. + static func parsed(_ arguments: [String]) throws -> any ParsableCommand { + try Darkbloom.parseAsRoot(Darkbloom.expandingToolShortcuts(arguments)) + } + + /// The error `main` reports for `arguments`; nil when they parse. + static func failure(_ arguments: [String]) -> Error? { + do { + _ = try parsed(arguments) + return nil + } catch { + return error + } + } + + /// The help `main` prints for `arguments` that ask for it: they parse to ArgumentParser's own help command, whose + /// `run` only throws the help request. + static func help(_ arguments: [String]) throws -> String { + var command = try parsed(arguments) + #expect(!(command is Darkbloom) && !(command is Start), "\(arguments) parse to the help command") + do { + try command.run() + } catch { + #expect(Darkbloom.exitCode(for: error) == .success) + return Darkbloom.fullMessage(for: error, columns: 80) + } + Issue.record("\(arguments): the help command didn't throw its request") + return "" + } + + static let shortcuts: [([String], [IntegrationTool])] = [ + (["--opencode"], [.opencode]), + (["--hermes"], [.hermes]), + (["--opencode", "--hermes"], [.opencode, .hermes]), + (["--hermes", "--opencode"], [.opencode, .hermes]), + (["--opencode", "--me-first"], [.opencode]), + (["--me-first", "--opencode"], [.opencode]), + (["--local", "--hermes"], [.hermes]), + (["--port", "8123", "--opencode", "--model", "fixture/a", "--model", "fixture/b"], [.opencode]), + (["-c", "/tmp/fixture/provider.toml", "--hermes", "--route", "my-macs", "--opencode"], [.opencode, .hermes]), + ] + + @Test("each form is `start` with its tool flags and every other option, in any order", + arguments: ToolShortcutTests.shortcuts) + func shortcutsAreStart(arguments: [String], tools: [IntegrationTool]) throws { + #expect(Darkbloom.expandingToolShortcuts(arguments) == ["start"] + arguments) + let short = try #require(try Self.parsed(arguments) as? Start, "\(arguments) must parse to start") + let long = try Start.parse(arguments) + #expect(short.requestedTools == tools) + #expect(short.localFirstOptions == long.localFirstOptions) + #expect(short.singleMacOptions == long.singleMacOptions) + #expect(short.model == long.model && short.configOptions.config == long.configOptions.config) + } + + @Test("start's own refusals and errors still apply, with start's usage") + func startStillRefuses() throws { + let network = try #require(Self.failure(["--opencode", "--network"])) + #expect(Darkbloom.message(for: network) == "`--opencode` needs this Mac's local API, which `--network` " + + "doesn't serve. Use --me-first or --local instead.") + let typo = try #require(Self.failure(["--opencode", "--me-firs"])) + #expect(Darkbloom.message(for: typo) == "Unknown option '--me-firs'. Did you mean '--me-first'?") + #expect(Darkbloom.fullMessage(for: typo, columns: 80).contains("Usage: \(Self.cli) start ")) + // A subcommand after a tool flag is an argument `start` doesn't take: `darkbloom --opencode start`. + let extra = try #require(Self.failure(["--opencode", "start"])) + #expect(Darkbloom.message(for: extra) == "Unexpected argument 'start'") + #expect(Darkbloom.exitCode(for: extra) == .validationFailure) + #expect(Darkbloom.fullMessage(for: extra, columns: 80).contains("Usage: \(Self.cli) start ")) + } + + @Test("`start --opencode` keeps working", arguments: [["start", "--opencode"], ["start", "--hermes", "--me-first"]]) + func longFormKeepsWorking(arguments: [String]) throws { + #expect(Darkbloom.expandingToolShortcuts(arguments) == arguments) + let start = try #require(try Self.parsed(arguments) as? Start) + #expect(start.requestedTools == (arguments.contains("--opencode") ? [.opencode] : [.hermes])) + } + + @Test("help, the version, plain darkbloom, subcommands and other arguments are parsed as typed", + arguments: [[], ["--help"], ["-h"], ["--version"], ["help"], ["help", "start"], ["status"], ["local"], + ["status", "--opencode"], ["models", "--opencode"], ["cluster", "local"], ["--opencod"], + ["--", "--opencode"]]) + func otherArgumentsAreUnchanged(arguments: [String]) { + #expect(Darkbloom.expandingToolShortcuts(arguments) == arguments) + } + + @Test("plain darkbloom, --help and --version answer as before; a subcommand keeps its own options") + func rootAnswersAsBefore() throws { + #expect(try Self.parsed([]) is Darkbloom, "the root command runs, and prints its help") + for flag in ["--help", "-h"] { + #expect(try Self.help([flag]) == Darkbloom.helpMessage(includeHidden: false, columns: 80)) + } + // `--version` prints the version, beside a tool flag too, and nothing starts. + for arguments in [["--version"], ["--version", "--opencode"], ["--hermes", "--version"]] { + let version = try #require(Self.failure(arguments), "\(arguments)") + #expect(Darkbloom.exitCode(for: version) == .success, "\(arguments)") + #expect(Darkbloom.fullMessage(for: version, columns: 80) == Darkbloom.configuration.version, "\(arguments)") + } + // A subcommand refuses a tool flag itself. `models` runs its default subcommand, `models catalog`. + for (arguments, usage) in [(["status", "--opencode"], "status"), (["models", "--opencode"], "models catalog")] { + let refused = try #require(Self.failure(arguments), "\(arguments)") + #expect(Darkbloom.message(for: refused) == "Unknown option '--opencode'") + #expect(Darkbloom.fullMessage(for: refused, columns: 80).contains("Usage: \(Self.cli) \(usage) ")) + } + // `--help` with a shortcut, before or after it, is the help of what it runs: start's. + let startHelp = Darkbloom.helpMessage(for: Start.self, includeHidden: false, columns: 80) + for arguments in [["--opencode", "--help"], ["--help", "--opencode"]] { + #expect(try Self.help(arguments) == startHelp, "\(arguments)") + } + } + + @Test("a mistyped tool flag gets the usual unknown-option error, from the root command", + arguments: ["--opencod", "--hermez", "--open-code"]) + func typoIsTheUsualError(flag: String) throws { + let error = try #require(Self.failure([flag])) + #expect(Darkbloom.message(for: error) == "Unknown option '\(flag)'") + #expect(Darkbloom.exitCode(for: error) == .validationFailure) + #expect(Darkbloom.fullMessage(for: error, columns: 80) == "Error: Unknown option '\(flag)'\n" + + "Usage: \(Self.cli) \n See '\(Self.cli) --help' for more information.") + } + + @Test("`darkbloom --help` lists every subcommand and shows each shortcut in one line") + func helpShowsTheShortcuts() throws { + let help = Darkbloom.helpMessage(includeHidden: false, columns: 80) + let lines = help.split(separator: "\n", omittingEmptySubsequences: false).map(String.init) + // The longest command name of any build (darkbloom-staging) still fits each line in 80 columns. + let longestName = BuildEnvironment.allCases.map(\.cliName.count).max() ?? Self.cli.count + for (flag, tool) in [("--opencode", "OpenCode"), ("--hermes", "Hermes Agent")] { + let shortcut = lines.filter { $0.contains("\(Self.cli) \(flag)") } + #expect(shortcut.count == 1, "one line for \(flag): \(shortcut)") + #expect(shortcut.first?.hasSuffix("Set up \(tool) (same as `start \(flag)`)") == true, "\(shortcut)") + #expect(shortcut.allSatisfy { $0.count - Self.cli.count + longestName < 80 }, "\(shortcut)") + } + #expect(lines.contains("USAGE: \(Self.cli) ")) + for command in Darkbloom.configuration.subcommands where command.configuration.shouldDisplay { + #expect(lines.contains { $0.hasPrefix(" \(command._commandName)") }, "\(command._commandName) is listed") + } + } + + @Test("`darkbloom local` names the shortcuts") + func localNamesTheShortcuts() { + #expect(Local.toolsLine == " tools: \(Self.cli) --opencode · --hermes") + } +} diff --git a/provider-swift/Tests/ProviderCoreTests/Config/LocalAPIPortTests.swift b/provider-swift/Tests/ProviderCoreTests/Config/LocalAPIPortTests.swift index c328b740b1..f357cfd68a 100644 --- a/provider-swift/Tests/ProviderCoreTests/Config/LocalAPIPortTests.swift +++ b/provider-swift/Tests/ProviderCoreTests/Config/LocalAPIPortTests.swift @@ -63,7 +63,7 @@ struct LocalAPIPortTests { #expect(try LocalAPIPort.choose(named: 8007, saved: 8005, ownLivePort: { nil }, installedPort: { nil }, isFree: noProbe) == LocalAPIPort.Choice(port: 8007, saves: true, note: "Local API port: 8007 (saved, instead of 8005: tools " - + "set up for 8005 need `darkbloom start --opencode` or `--hermes` again).")) + + "set up for 8005 need `darkbloom --opencode` or `--hermes` again).")) #expect(try LocalAPIPort.choose(named: 8005, saved: 8005, ownLivePort: { nil }, installedPort: { nil }, isFree: noProbe) == LocalAPIPort.Choice(port: 8005, saves: false, note: nil)) diff --git a/scripts/install.sh b/scripts/install.sh index 7c9810e86f..c755d1c9e0 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -702,12 +702,12 @@ echo "" echo " Installed: $PROVIDER_LABEL v$VERSION in $INSTALL_DIR" echo " Command: $CLI_NAME" echo "" -echo " $CLI_NAME start asks how this Mac serves: Only me, Darkbloom network," -echo " or Both, me first. With --opencode it then sets OpenCode up: in OpenCode," -echo " /models → $PROVIDER_LABEL. For Hermes, use --hermes instead." +echo " $CLI_NAME --opencode asks how this Mac serves: Only me, Darkbloom" +echo " network, or Both, me first. It then sets OpenCode up: in OpenCode," +echo " /models → $PROVIDER_LABEL. For Hermes, use $CLI_NAME --hermes instead." echo " Two Macs: run $CLI_NAME cluster on each Mac to pair them." echo "" # The full path works at once: the user's shell reads the new PATH line only once it restarts, and the # /usr/local/bin link is best effort. -echo " Next: ~/.$CLI_NAME/bin/$CLI_NAME start --opencode" +echo " Next: ~/.$CLI_NAME/bin/$CLI_NAME --opencode" echo "" diff --git a/scripts/test-install-identity.py b/scripts/test-install-identity.py index 5a897f4003..4b293559d1 100755 --- a/scripts/test-install-identity.py +++ b/scripts/test-install-identity.py @@ -190,6 +190,10 @@ def existing_production_install(home): self.assertIn(f"Installed: Darkbloom Dev v0.9.20-dev.152 in {home}/.darkbloom-dev", result.stdout) self.assertIn("Command: darkbloom-dev\n", result.stdout) self.assertIn("darkbloom-dev login", result.stdout) + self.assertIn(" darkbloom-dev --opencode asks how this Mac serves", result.stdout) + self.assertTrue(result.stdout.endswith(" Next: ~/.darkbloom-dev/bin/darkbloom-dev --opencode\n\n"), + result.stdout[-300:]) + self.assertNotIn("start --opencode", result.stdout) self.assertIn(f"ln -sf {home}/.darkbloom-dev/bin/darkbloom-dev /usr/local/bin/darkbloom-dev", trace) self.assertNotIn("profiles", trace) for text in (result.stdout, result.stderr, trace): @@ -218,6 +222,12 @@ def existing_dev_install(home): self.assertIn(f"Provider: Darkbloom (darkbloom, installs in {home}/.darkbloom)", result.stdout) self.assertIn(f"Installed: Darkbloom v0.9.20 in {home}/.darkbloom", result.stdout) self.assertIn("Command: darkbloom\n", result.stdout) + # The last line is the one command to run next, with its full path: the shell reads the new PATH line only + # once it restarts. + self.assertIn(" darkbloom --opencode asks how this Mac serves", result.stdout) + self.assertTrue(result.stdout.endswith(" Next: ~/.darkbloom/bin/darkbloom --opencode\n\n"), + result.stdout[-300:]) + self.assertNotIn("start --opencode", result.stdout) for text in (result.stdout, result.stderr, trace): self.assertNotIn("darkbloom-dev", text) self.assertNotIn("Darkbloom Dev", text)