@bike4mind/cli 3.4.0 → 4.6.0

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.
Files changed (56) hide show
  1. package/README.md +223 -39
  2. package/bin/bike4mind-cli.mjs +301 -38
  3. package/bin/envFlags.d.mts +17 -0
  4. package/bin/envFlags.mjs +89 -0
  5. package/bin/hearth-hook.mjs +53 -7
  6. package/dist/{AgentHistoryStore-ClO2zOn6.mjs → AgentHistoryStore--J3sgO_-.mjs} +9011 -6699
  7. package/dist/ApiClient-CdO4Gamg.mjs +152 -0
  8. package/dist/BubblewrapRuntime-3jAbC60G.mjs +157 -0
  9. package/dist/ConfigStore-CausUCzY.mjs +2 -0
  10. package/dist/ConfigStore-Dusy6glb.mjs +3364 -0
  11. package/dist/{ConfigStore-CbVFLXMH.mjs → Logger-C1Wj6xla.mjs} +32880 -20779
  12. package/dist/{ProxyManager-B0-RuR2w.mjs → ProxyManager-TxEKlgdO.mjs} +88 -3
  13. package/dist/RemoteSkillSource-qTvRkaNA.mjs +455 -0
  14. package/dist/{SandboxOrchestrator-BcUv9fQ3.mjs → SandboxOrchestrator-CQwYq_uy.mjs} +26 -7
  15. package/dist/SandboxRuntimeAdapter-BsT2iLky.mjs +190 -0
  16. package/dist/SandboxRuntimeAdapter-Zg_0th7V.mjs +2 -0
  17. package/dist/SeatbeltRuntime-C2DEkrjy.mjs +194 -0
  18. package/dist/{WorkItemsClient-SeNbzvEw.mjs → WorkItemsClient-CxNZaOmc.mjs} +1 -1
  19. package/dist/agents/defaults/review.md +8 -1
  20. package/dist/agents/defaults/test.md +8 -1
  21. package/dist/buildToolSearch-DOb7mx6F.mjs +417 -0
  22. package/dist/commands/acpCommand.mjs +33 -27
  23. package/dist/commands/apiCommand.mjs +3 -5
  24. package/dist/commands/doctorCommand.mjs +2 -2
  25. package/dist/commands/envCommand.mjs +1 -1
  26. package/dist/commands/headlessCommand.mjs +118 -36
  27. package/dist/commands/hostCommand.mjs +2344 -0
  28. package/dist/commands/mcpCommand.mjs +46 -30
  29. package/dist/commands/mirrorCommand.mjs +279 -0
  30. package/dist/commands/modelsCommand.mjs +1117 -0
  31. package/dist/commands/pluginCommand.mjs +9 -9
  32. package/dist/commands/skillsCommand.mjs +404 -0
  33. package/dist/commands/updateCommand.mjs +2 -2
  34. package/dist/curated-build.json +1 -0
  35. package/dist/dist-CbViwiS9.mjs +4739 -0
  36. package/dist/dist-Citbv0y0.mjs +7864 -0
  37. package/dist/fit-CVWDiavv.mjs +200 -0
  38. package/dist/index.mjs +1001 -442
  39. package/dist/modelHub-BSB6qRFP.mjs +1963 -0
  40. package/dist/modelServers-BaegigV-.mjs +2465 -0
  41. package/dist/{package-MoDZ9cGj.mjs → package-C9pfAdGF.mjs} +1 -1
  42. package/dist/{serve-zi-B2iUT.mjs → serve-8wyGb8of.mjs} +1243 -44
  43. package/dist/store-BYeE0shc.mjs +2 -0
  44. package/dist/{store-BxmPEI3v.mjs → store-BbvSi3KK.mjs} +26 -2
  45. package/dist/types-BFIvwByC.mjs +2 -0
  46. package/dist/{types-F61_hxmG.mjs → types-CxrzVXel.mjs} +9 -5
  47. package/dist/{updateChecker-CCLVVdH0.mjs → updateChecker-BAKb8KWP.mjs} +7 -29
  48. package/package.json +17 -13
  49. package/dist/BubblewrapRuntime-5bLPTwEC.mjs +0 -72
  50. package/dist/SandboxRuntimeAdapter-BgLUVTJL.mjs +0 -57
  51. package/dist/SandboxRuntimeAdapter-Bt1wPpld.mjs +0 -2
  52. package/dist/SeatbeltRuntime-C_Y8q8Mr.mjs +0 -124
  53. package/dist/buildAgent-BeaVbpzH.mjs +0 -1992
  54. package/dist/dist-DlBq3wHu.mjs +0 -739
  55. package/dist/store-BkMur6uk.mjs +0 -2
  56. package/dist/types-I45lMh7Q.mjs +0 -2
package/README.md CHANGED
@@ -43,10 +43,12 @@ pnpm install
43
43
  The CLI uses native dependencies (`better-sqlite3` for image caching, `sharp` for image processing) that require compilation. These should build automatically during installation, but if you encounter errors:
44
44
 
45
45
  **Prerequisites:**
46
+
46
47
  - Python 3 (required by node-gyp)
47
48
  - C++ compiler (Xcode Command Line Tools on macOS, build-essential on Linux, Visual Studio on Windows)
48
49
 
49
50
  **Manual rebuild if needed:**
51
+
50
52
  ```bash
51
53
  # If you see "Could not locate the bindings file" errors
52
54
  pnpm rebuild better-sqlite3
@@ -65,7 +67,31 @@ pnpm rebuild
65
67
  b4m
66
68
  ```
67
69
 
68
- The CLI will prompt you to authenticate with your Bike4Mind account on first run.
70
+ When you are signed out, the CLI starts on a local model from Ollama or a model server saved in Desktop. With no local model available, it offers Bike4Mind sign-in.
71
+
72
+ ### Chat without signing in
73
+
74
+ Start Ollama and pull a model, then open the CLI:
75
+
76
+ ```bash
77
+ ollama serve
78
+ # In another terminal:
79
+ ollama pull qwen3.5
80
+ b4m
81
+ ```
82
+
83
+ The signed-out session lists only local models. Run `/login` to use Bike4Mind cloud models; finish or stop the current reply with Esc before signing in. From a local session, cancelling sign-in returns you to that session.
84
+
85
+ For headless prompts, save a local default first:
86
+
87
+ ```bash
88
+ b4m models use qwen3.5
89
+ b4m -p "say hello" </dev/null
90
+ ```
91
+
92
+ A signed-out headless run uses the selected local model or your saved local default. With a cloud default and no saved local default, it exits with an error instead of choosing an arbitrary model. ACP sessions also support local models while signed out.
93
+
94
+ If no local model is found, start Ollama, pull a model, or check the saved model server's address and credentials. A server login hint uses `b4m models servers login <name>`. An expired Bike4Mind sign-in is refreshed at startup; a temporary refresh failure keeps the saved sign-in and uses local models for that run, so restart the CLI to retry.
69
95
 
70
96
  ### CLI Flags
71
97
 
@@ -77,42 +103,43 @@ A bare positional argument seeds **and** submits the first turn while keeping th
77
103
 
78
104
  **Environment / API** (see [API Configuration](#api-configuration)):
79
105
 
80
- | Flag | Effect |
81
- | --- | --- |
82
- | `--dev` | Point the CLI at the local dev server (`http://localhost:3001`) and remember it. Aliases: `--local`, single-dash forms. |
83
- | `--prod` | Point the CLI at Bike4Mind production and remember it. Alias: `--production`. |
106
+ | Flag | Effect |
107
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | `--dev` | Point the CLI at the local dev server (`http://localhost:3001`) and remember it. Aliases: `--local` (except after `b4m mcp serve`), single-dash forms. |
109
+ | `--prod` | Point the CLI at Bike4Mind production and remember it. Alias: `--production`. |
84
110
  | `--api-url <url>` | Point the CLI at **any** instance — a self-hosted stack, an AWS deployment, `http://localhost:3000`, etc. Clears cached auth (bound to the old origin) and exits; run `b4m` again to sign in. |
85
- | `--reset-api` | Reset the API URL to the built-in default and clear auth, then exit. |
111
+ | `--reset-api` | Reset the API URL to the built-in default and clear auth, then exit. |
86
112
 
87
113
  **Session / behavior:**
88
114
 
89
- | Flag | Effect |
90
- | --- | --- |
91
- | `--verbose`, `-v` | Show debug logs in the console (also always written to file — see [Debug Logs](#debug-logs)). |
92
- | `--debug-stream` | Ultra-verbose: log every SSE event (stream-parser debugging). Implies `--verbose`. |
93
- | `--no-project-config` | Skip loading project-specific config (`.bike4mind/`). |
94
- | `--add-dir <dir>` | Grant file access to an additional directory. Repeatable. |
95
- | `--ollama-host <url>` | Add a local Ollama endpoint's models to the picker (e.g. `http://localhost:11434`). |
96
- | `--no-remote-skills` | Skip fetching remote B4M-web skills for this run (local files only). |
115
+ | Flag | Effect |
116
+ | --------------------- | --------------------------------------------------------------------------------------------- |
117
+ | `--verbose`, `-v` | Show debug logs in the console (also always written to file — see [Debug Logs](#debug-logs)). |
118
+ | `--debug-stream` | Ultra-verbose: log every SSE event (stream-parser debugging). Implies `--verbose`. |
119
+ | `--no-project-config` | Skip loading project-specific config (`.bike4mind/`). |
120
+ | `--add-dir <dir>` | Grant file access to an additional directory. Repeatable. |
121
+ | `--ollama-host <url>` | Add a local Ollama endpoint's models to the picker (e.g. `http://localhost:11434`). |
122
+ | `--no-remote-skills` | Skip fetching remote B4M-web skills for this run (local files only). |
97
123
 
98
124
  **Headless / non-interactive** (for scripts and CI):
99
125
 
100
- | Flag | Effect |
101
- | --- | --- |
102
- | `-p`, `--prompt <query>` | Run a single query non-interactively and exit. |
103
- | `--output-format <fmt>` | Output when using `-p`: `text` (default), `json`, or `stream-json` (NDJSON of thoughts/actions/observations). |
104
- | `--dangerously-skip-permissions` | With `-p`, auto-allow all tool permission prompts. Use with caution in CI/CD. |
126
+ | Flag | Effect |
127
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------- |
128
+ | `-p`, `--prompt <query>` | Run a single query non-interactively and exit. |
129
+ | `--output-format <fmt>` | Output when using `-p`: `text` (default), `json`, or `stream-json` (NDJSON of thoughts/actions/observations). |
130
+ | `--dangerously-skip-permissions` | With `-p`, auto-allow all tool permission prompts. Use with caution in CI/CD. |
105
131
 
106
132
  **Info:**
107
133
 
108
- | Flag | Effect |
109
- | --- | --- |
110
- | `--help`, `-h` | Show help. |
134
+ | Flag | Effect |
135
+ | ----------------- | ----------------- |
136
+ | `--help`, `-h` | Show help. |
111
137
  | `--version`, `-V` | Show CLI version. |
112
138
 
113
139
  > **Host / `claude`-drop-in flags** (`--mcp-config`, `--strict-mcp-config`, `--append-system-prompt`, `--allowedTools`, `--settings`, `--session-id`, `--resume`) are documented under [Running as a `claude` engine inside a host app](#running-as-a-claude-engine-inside-a-host-app).
114
140
 
115
141
  **Examples:**
142
+
116
143
  ```bash
117
144
  # Point at a self-hosted stack, then sign in
118
145
  b4m --api-url http://localhost:3000
@@ -138,8 +165,66 @@ b4m mcp enable <name> | disable <name> # Toggle a server on/off
138
165
  b4m mcp serve [--http] [--port <n>] # Expose Bike4Mind itself as an MCP server
139
166
  b4m update # Check for and install CLI updates
140
167
  b4m doctor # Diagnose the CLI installation (Node, registry, ripgrep, native modules)
168
+ b4m skills push <path> # Create a skill from a folder, SKILL.md, or commands/*.md
169
+ b4m skills push <path> --update # Update your skill with the same name without a prompt
170
+ b4m models ls | search | show | curated | pull | rm | use # Find, download and use local models (see below)
171
+ ```
172
+
173
+ ### Local models
174
+
175
+ `b4m models` manages models on a local Ollama and finds GGUF builds on Hugging Face.
176
+
177
+ ```bash
178
+ b4m models ls --ollama-host http://127.0.0.1:11434 # list installed models; a host that answers is saved
179
+ b4m models search qwen2.5 0.5b # Hugging Face GGUF repos: downloads, likes, license, gated
180
+ b4m models show Qwen/Qwen2.5-0.5B-Instruct-GGUF # builds with size, fit, quant and Ollama ref, license, gating
181
+ b4m models curated # Bike4Mind's picks for this computer, then every curated build
182
+ b4m models pull Qwen/Qwen2.5-0.5B-Instruct-GGUF:Q4_K_M
183
+ b4m models pull qwen2.5:0.5b # Ollama registry names (model[:tag], ollama.com/owner/model)
184
+ b4m models pull <ref> --force # pull even when the fit check rates it too large
185
+ b4m models use hf.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF:Q4_K_M # default model for chat
186
+ b4m models rm qwen2.5:0.5b
141
187
  ```
142
188
 
189
+ `search` hides abliterated and uncensored builds and prints how many it hid; `--include-abliterated` lists them last, labelled as not recommended.
190
+
191
+ `show` rates each build `fits`, `tight` or `too large` for this machine, and `pull` prints the verdict with its reasoning before asking anything. It is a rough estimate using the shared memory-budget and compute-buffer calculations: the file size (plus any vision projector) and compute buffers against the memory a model can use here, at the context the CLI asks Ollama for (the model's trained length capped at 32K, or at `OLLAMA_MAX_NUM_CTX`). `pull` refuses a too-large build unless `--force`. The fit is `unknown`, and never blocks, when download sizes are unavailable, the hardware cannot be read, or the Ollama host is another machine. An Ollama reached through an SSH tunnel on localhost is rated as this machine, so use `--force` when the far host has the memory.
192
+
193
+ `curated` prints the curated list Desktop uses: the list bundled with the CLI, or a newer signed one when this build has a list URL and a trusted key (the published CLI bakes both in once they are configured; otherwise it only has the bundled list). A newer list is checked for at most every 6 hours, for up to 3 seconds, verified against the shipped keys and cached under `~/.bike4mind/model-hub/curated/`; a list that fails verification is ignored and the last good one stays. `--refresh` checks now. `--offline` or `B4M_CURATED=off` uses the last verified cached list (else the bundled one) and makes no request; `pull` accepts `--offline` too. The output names where the list came from. It lists the picks for this computer's memory first, then every build with the ref to pull, its size, license and tags (including the Ollama version a build needs). It contacts no runtime and downloads nothing; pull a row with `b4m models pull <ref>`, which asks for the license as below but does not check the build against the reviewed one. Abliterated builds are never on it, and a license that is not permissive, the model's own or its base model's, is shown as `restricted: <license>` (with `(base: <license>)`) and must be accepted before `pull`. With a saved Ollama host on another machine, the picks still describe this computer.
194
+
195
+ Nothing downloads without confirmation: `pull` prints the size and license first and asks (`--yes` skips the question). A license that is not a permissive open-source one (Apache-2.0, MIT, BSD and similar), or no declared license, is named with a link and must be accepted at a prompt or with `--accept-license`. For Ollama registry models the license is read from the model's own license texts, and only unmodified Apache-2.0 or MIT texts count as permissive. Refs naming any other registry are refused. A gated repo needs access granted on Hugging Face first, `HF_TOKEN` set to that account's token, and your Ollama public key added at https://huggingface.co/settings/keys. Ctrl-C cancels a pull without installing anything; pulling again resumes, and says how much was already downloaded. Without a saved host, `b4m models` uses the first local runtime it detects; a scheme-less host without a port uses 11434, and `--ollama-host ''` clears the saved host. `--output-format json` prints `ls`, `search`, `show` and `curated` as JSON. With a saved host, `b4m -p` fails instead of switching to another model when the model picked with `b4m models use` is not available, or Ollama does not answer.
196
+
197
+ `b4m models servers` also lists saved SSH servers with an invalid port or destination as
198
+ refused and explains what to fix. Remove the server in Desktop and add it again; the CLI
199
+ never edits Desktop's list. You can still clear its CLI credential by name with
200
+ `b4m models servers logout <name>`. During `b4m models servers login`, Ctrl-C ends the
201
+ credential check, prints "Cancelled." and exits with code 130 without saving the credential.
202
+
203
+ `b4m mcp serve` (stdio only) offers the same operations to MCP clients as `models_list`, `models_search`, `models_pull` and `models_remove`, with the same checks. Pull and remove act only on the user's own approval. A client that supports elicitation asks the user directly, showing the size and every license, with a separate tick for a license that is not all permissive. With any other client nothing changes: the tool returns the preview and the `b4m models pull` or `b4m models rm` command for the user to run in a terminal, where the CLI asks them. `models_pull` reports the same fit verdict in its preview and prompt, and refuses a too-large model before asking unless the caller passes `force: true`, which still leaves the download to the user's approval. `models_search` leaves abliterated and uncensored builds out unless `includeAbliterated` is true, and then lists them last, labelled `notRecommended`, as `b4m models search --include-abliterated` does. The host comes from `B4M_OLLAMA_HOST`, the saved host, or detection, as for `b4m models`. `b4m mcp serve --local` serves these four tools alone and needs no Bike4Mind backend.
204
+
205
+ A chat with a model on this computer's Ollama (`http://127.0.0.1:11434`) or on an Ollama model server saved in Desktop uses that model's settings from Desktop's Models screen: a fixed context size, keep-alive, draft tokens, sampling (in place of the CLI's `temperature` preference), max output and, on a model with effort levels such as gpt-oss, its effort. Under Auto the CLI keeps its own context size (the trained length capped at 32K or `OLLAMA_MAX_NUM_CTX`) and only applies the model's cap. The CLI reads `model-settings.json` on every turn and never writes it, but the context size is the one it listed at startup, so a context change takes effect after a CLI restart. The file comes from the same Desktop userData folder as the saved model servers: `B4M_DESKTOP_USER_DATA` when set, else the first of `@bike4mind/desktop` and `Bike4Mind` under the app-data folder that holds `model-servers.json` or `model-settings.json`, or failing that the first that exists (a source run of Desktop uses `Bike4Mind Dev`, so point `B4M_DESKTOP_USER_DATA` at it). From WSL with mirrored networking, set `B4M_DESKTOP_USER_DATA=/mnt/c/Users/<you>/AppData/Roaming/@bike4mind/desktop` to use the Windows Desktop's settings. No file means no settings and values this CLI does not know are ignored; a broken file, or a broken entry for the model in use, fails that model's turns with a message naming the file, the model and the field. `B4M_DESKTOP_MODEL_SETTINGS=<path>` reads another file, which must exist, and `off`, `0`, `false`, `no` or `none` ignores Desktop's settings.
206
+
207
+ ### Pushing a local skill
208
+
209
+ Log in with `b4m /login`, then run `b4m skills push ~/.claude/skills/my-skill`.
210
+ Only the Markdown instructions are uploaded; supporting files and unsupported
211
+ frontmatter (including `allowed-tools`) are reported and skipped. If no description
212
+ is present, the first non-empty body line supplies it.
213
+
214
+ An existing skill prompts before updating. For scripts without a terminal, pass
215
+ `--update` explicitly. Removing `argument-hint` from the file clears the stored hint
216
+ on update. A Skill Market import cannot be overwritten; rename the local skill or
217
+ delete the import first.
218
+
219
+ An export from another Skill Market author requires separate consent because the
220
+ copy becomes your own trusted skill. Prefer importing it from the market to retain
221
+ attribution and updates; `--yes` acknowledges this warning when pushing a copy.
222
+
223
+ If push reports missing or expired authentication, run `b4m /login` again. If a
224
+ non-interactive push stops at a name conflict, use `--update` only when you intend
225
+ to replace that skill. Server validation errors are printed without creating or
226
+ updating the skill.
227
+
143
228
  ### Switching environments (`--dev` / `--prod`)
144
229
 
145
230
  Flip which backend the CLI talks to without editing config by hand:
@@ -162,16 +247,28 @@ shown in the startup banner (`🌍 API Environment: …`).
162
247
  > For a one-off custom/self-hosted URL, use the in-session `/set-api <url>` command
163
248
  > (see [API Configuration](#api-configuration) below).
164
249
 
250
+ ### Typing while the agent works
251
+
252
+ You can keep typing while a turn is running. Nothing you send is dropped, and a second turn never starts in parallel with the first.
253
+
254
+ - **Enter** steers the running turn. The message is added to the agent's next model request, which is sent after the current batch of tool calls finishes. If the agent has just answered and has iterations left, it reopens to take the message into account. A message the turn never reaches runs as the next turn.
255
+ - **Tab** queues the message as a follow-up. It runs as a new turn once the current one ends. Everything still queued at that point runs together as a single turn, in the order you sent it.
256
+ - **Esc** cancels the turn and moves any queued messages back into the input, where you can edit and resend them or clear them with Ctrl+C. Any message you send while the cancelled turn is still shutting down runs once the turn has stopped.
257
+
258
+ Queued messages appear above the input. Follow-ups are labelled `[next turn]`.
259
+
165
260
  ## Commands
166
261
 
167
262
  While in interactive mode. This mirrors the registry in `src/config/commands.ts` — run `/help` in a session for the live list (which also includes any custom and project commands).
168
263
 
169
264
  **Authentication:**
265
+
170
266
  - `/login` - Authenticate with your B4M account
171
267
  - `/logout` - Clear authentication and sign out
172
268
  - `/whoami` - Show current authenticated user
173
269
 
174
270
  **Session management:**
271
+
175
272
  - `/save <name>` - Save current session
176
273
  - `/resume` (alias `/sessions`) - List and resume saved sessions
177
274
  - `/clear` (alias `/new`) - Start a new session
@@ -180,11 +277,13 @@ While in interactive mode. This mirrors the registry in `src/config/commands.ts`
180
277
  - `/usage` - Show credit usage and balance
181
278
 
182
279
  **API configuration:**
280
+
183
281
  - `/set-api <url>` - Connect to a self-hosted / custom Bike4Mind instance
184
282
  - `/reset-api` - Reset to the Bike4Mind main service
185
283
  - `/api-info` - Show current API configuration
186
284
 
187
285
  **Files & checkpoints:**
286
+
188
287
  - `/add-dir <path>` / `/remove-dir <path>` / `/dirs` - Manage accessible directories
189
288
  - `/undo` - Undo the last file change
190
289
  - `/checkpoints` - List file restore points
@@ -193,9 +292,11 @@ While in interactive mode. This mirrors the registry in `src/config/commands.ts`
193
292
  - `/rewind` - Rewind the conversation to a previous point
194
293
 
195
294
  **Tool permissions:**
295
+
196
296
  - `/trust <tool-name>` / `/untrust <tool-name>` / `/trusted` - Manage auto-approved tools
197
297
 
198
298
  **Sandbox** (OS-level isolation for `bash`):
299
+
199
300
  - `/sandbox` - Show sandbox status and configuration
200
301
  - `/sandbox:enable` / `/sandbox:disable` - Toggle the sandbox
201
302
  - `/sandbox:mode <auto-allow|permissions>` - Set enforcement mode
@@ -204,20 +305,24 @@ While in interactive mode. This mirrors the registry in `src/config/commands.ts`
204
305
  - `/sandbox:violations [count]` / `/sandbox:violations:clear` - Inspect / clear violations
205
306
 
206
307
  **MCP & agents:**
308
+
207
309
  - `/mcp` (alias `/mcp:list`) - Show MCP server status and connected tools
208
310
  - `/agents` (alias `/agents:list`) - List available agents
209
311
  - `/agents:new <name>` / `/agents:reload` - Create / reload agent definitions
210
312
 
211
313
  **Custom commands:**
314
+
212
315
  - `/commands` - List all custom commands
213
316
  - `/commands:new <name>` / `/commands:reload` - Create / reload custom commands
214
317
 
215
318
  **Durable workflow** (cross-session continuity):
319
+
216
320
  - `/workflow [decisions|blockers|handoff|review-gates]` - Workflow overview or a section
217
321
  - `/decisions` / `/blockers` / `/review-gates` - Shortcuts for the sections above
218
322
  - `/handoff [generate|--local]` - Show or generate a session handoff (`--local` = LLM-free snapshot)
219
323
 
220
324
  **General:**
325
+
221
326
  - `/help` - Show help
222
327
  - `/config` - Open the interactive configuration editor
223
328
  - `/project-config` - Show merged project configuration
@@ -230,7 +335,7 @@ Configuration is stored in `~/.bike4mind/config.json`
230
335
 
231
336
  ### Authentication
232
337
 
233
- The CLI uses OAuth to authenticate with your Bike4Mind account. On first run, you'll be prompted to log in through the device authorization flow:
338
+ Bike4Mind cloud models use OAuth authentication. You can chat with local models while signed out; run `/login` when you want to use your Bike4Mind account:
234
339
 
235
340
  1. Run `b4m` or use the `/login` command
236
341
  2. Visit the verification URL shown in the terminal
@@ -256,6 +361,11 @@ Because that default is injected only at build time, the endpoint is resolved li
256
361
  4. Otherwise (a published, unbranded fork with no baked default), the first `b4m` **prompts you
257
362
  to choose a backend**.
258
363
 
364
+ A build with a baked default also shows this picker on a fresh install, listing the default
365
+ first and preselected, then the local dev server and a custom URL. Any choice (the picker,
366
+ `--prod`, `--dev`, `--api-url`, `--reset-api`, `/set-api`, `/reset-api`) is remembered, so
367
+ later launches go straight to sign-in.
368
+
259
369
  **Quick switch between local dev and production:** use the `b4m --dev` / `b4m --prod`
260
370
  launch flags (see [Switching environments](#switching-environments---dev----prod)).
261
371
  They persist your choice and cache auth per-environment. The `/set-api`, `/reset-api`,
@@ -304,6 +414,7 @@ export SERPER_API_KEY="your-key-here"
304
414
  ```
305
415
 
306
416
  **Available Tools:**
417
+
307
418
  - ✅ `dice_roll` - No API key needed
308
419
  - ✅ `math_evaluate` - No API key needed
309
420
  - ✅ `current_datetime` - No API key needed
@@ -315,6 +426,7 @@ export SERPER_API_KEY="your-key-here"
315
426
  - 🔑 `deep_research` - Requires `toolApiKeys.serper`
316
427
 
317
428
  **Get API Keys:**
429
+
318
430
  - OpenWeather API: https://openweathermap.org/api
319
431
  - Serper API: https://serper.dev/
320
432
 
@@ -361,6 +473,7 @@ You can run MCP servers in Docker containers for isolation and portability:
361
473
  ```
362
474
 
363
475
  **Docker Configuration Notes:**
476
+
364
477
  - The `-i` flag is required for stdin communication with the MCP server
365
478
  - Use `-e VAR_NAME` (without value) to pass a variable through to the container. It must be listed in this server's `env` block: the MCP child is started with those variables plus the MCP SDK's own defaults (`PATH`, `HOME`, `SHELL`, `TERM`, `USER`), never with your whole shell environment
366
479
  - Keys that would have the runtime load code before the server starts - `NODE_*`, `LD_*`, `DYLD_*`, `ELECTRON_RUN_AS_NODE` - are refused and logged. Everything else in `env` is passed through, so `HTTPS_PROXY`, `NO_PROXY` and a `PATH` your wrapper needs all work here
@@ -387,6 +500,7 @@ You can also run any MCP server via npx or custom executables:
387
500
  ```
388
501
 
389
502
  **Available Built-in MCP Servers:**
503
+
390
504
  - 🔧 **GitHub** - Repository management, issues, PRs (requires `GITHUB_ACCESS_TOKEN`)
391
505
  - 🔧 **LinkedIn** - Post management, analytics (requires `LINKEDIN_ACCESS_TOKEN`, `COMPANY_NAME`)
392
506
  - 🔧 **Atlassian** - Jira/Confluence integration (requires `ATLASSIAN_ACCESS_TOKEN`, `ATLASSIAN_CLOUD_ID`, `ATLASSIAN_SITE_URL`)
@@ -395,16 +509,37 @@ You can also run any MCP server via npx or custom executables:
395
509
 
396
510
  #### Serve Bike4Mind itself as an MCP server (`b4m mcp serve`)
397
511
 
398
- The reverse of adding a server: `b4m mcp serve` exposes your Bike4Mind backend to any MCP client (Claude Desktop, editors, other agents). It advertises nineteen tools (`list_notebooks`, `get_notebook`, `create_notebook`, `rename_notebook`, `clone_notebook`, `delete_notebook`, `list_projects`, `get_project`, `create_project`, `send_message`, `search_knowledge_base`, `list_lakes`, `list_files`, `get_file`, `generate_sound_effect`, `text_to_speech`, `generate_image`, `create_artifact`, `publish_artifact`) plus four resource templates (`b4m://notebook/{id}`, `b4m://file/{id}`, `b4m://project/{id}`, `b4m://artifact/{id}`), each listable and readable as JSON, and `b4m://agent-quest` - the credential-free manifest for The Open Door, the onboarding quest for agents.
512
+ The reverse of adding a server: `b4m mcp serve` exposes your Bike4Mind backend to any MCP client (Claude Desktop, editors, other agents). It advertises twenty-seven tools (`list_notebooks`, `get_notebook`, `create_notebook`, `rename_notebook`, `clone_notebook`, `delete_notebook`, `list_projects`, `get_project`, `create_project`, `send_message`, `search_knowledge_base`, `list_lakes`, `list_files`, `get_file`, `upload_file`, `generate_sound_effect`, `text_to_speech`, `generate_image`, `create_artifact`, `publish_artifact`, `bob_read_site`, `bob_compare_sites`, `bob_recheck`, `get_bob_report`, `get_bob_comparison`, `list_bob_reports`, `bob_runs_left`) plus four resource templates (`b4m://notebook/{id}`, `b4m://file/{id}`, `b4m://project/{id}`, `b4m://artifact/{id}`), each listable and readable as JSON, and `b4m://agent-quest` - the credential-free manifest for The Open Door, the onboarding quest for agents.
513
+
514
+ Use `upload_file { path: "/path/to/report.pdf", projectId: "project-id" }` to upload a local regular file, or `upload_file { base64: "YWJj", name: "note.txt" }` to send bytes. Choose exactly one source; base64 requires a name. Local files and decoded base64 have a 100 MiB limit, and local dotfiles, hidden directories and links into them are refused. The tool requires `files:write`; an optional `projectId` also requires `projects:write`. Success returns a `fileId` with pending ingestion. If project association fails, the error includes the retained file ID so you can retry association without uploading again.
399
515
 
400
516
  To get answers grounded in a data lake, call `list_lakes`, then `create_notebook { dataLakeId }` with a lake's id, then `send_message { notebookId }` on that notebook: the result carries the `reply` plus the `citables` it was grounded in. `list_lakes` needs a key with `datalake:read` (and data lakes enabled on the instance).
401
517
 
518
+ The seven Bob tools read websites with Bob on an instance that serves it. `bob_read_site` and `bob_compare_sites` spend the key owner's credits and publish each report, as a run started in the app does; they wait up to `waitSeconds` (default 600, at most 900) with progress, then return the report as Markdown with its in-app and published links, or the id to read back with `get_bob_report` / `get_bob_comparison` when Bob is still reading. `bob_recheck` re-scans one finding against the live site; it costs no credits and adds the reading to the existing report. Bob's routes enforce their scopes: starting work needs `bob:run`, which can also read back, and reading needs `bob:read`.
519
+
402
520
  ```bash
403
521
  b4m mcp serve # stdio (default) - for local clients that spawn the process
404
522
  b4m mcp serve --http --port 7000 # stateless streamable HTTP at http://127.0.0.1:7000/mcp
523
+ b4m mcp serve --local # stdio, local model tools only; no backend needed
405
524
  ```
406
525
 
407
- Auth precedence is `--api-key` > `B4M_API_KEY` > the stored login; the endpoint is `B4M_API_URL` > `--api-url` > the configured backend. Tool *listing* needs no credentials; tool *calls* authenticate. Prefer `B4M_API_KEY` over `--api-key` (a flag value shows up in process listings). HTTP mode binds loopback only (`127.0.0.1`, `/mcp` path) and has no per-request auth, so do not expose it off-host. The advertised scopes are the recommended key configuration, not per-route hard gates. See [Serve Bike4Mind as an MCP server](../../BIKE4MIND_CLI.md#serve-bike4mind-as-an-mcp-server-b4m-mcp-serve) for the Claude Desktop config and details.
526
+ `--local` serves only `models_list`, `models_search`, `models_pull` and `models_remove`, ignores any configured endpoint, and notes this in one stderr line. It is stdio only (`--http` with it is an error, as are `--dev` and `--prod`). Only after `b4m mcp serve` is `--local` serve's own flag and leaves the saved backend alone; before it, as in `b4m --local mcp serve`, it is the `--dev` alias. Without it, `mcp serve` exits with `No API endpoint configured` when no backend is set.
527
+
528
+ Over stdio only, when the caller is entitled to OptiHashi and the key carries `optihashi:read` and `optihashi:compute`, the server also offers `optihashi_solvers` and `optihashi_solve` (a free, bounded classical solver race). With an API key, the CLI first checks the key's own scopes and offers them only when it holds both. The solve input schema comes from the server at startup, with a 5 second discovery budget; restart the session to pick up changed family ids, solver ids or limits. `optihashi_solvers` fetches the current roster on every call. With no entitlement, scopes or feature, they are simply not listed. No paid compute is exposed, and HTTP mode never offers them.
529
+
530
+ Auth precedence is `--api-key` > `B4M_API_KEY` > the stored login; the endpoint is `B4M_API_URL` > `--api-url` > the configured backend. Tool _listing_ needs no credentials, apart from the optional stdio-only tools above, which are fetched once at startup; tool _calls_ authenticate. Prefer `B4M_API_KEY` over `--api-key` (a flag value shows up in process listings). HTTP mode binds loopback only (`127.0.0.1`, `/mcp` path) and requires an `Authorization: Bearer <token>` header on every request. The token is `--token`, else `B4M_MCP_TOKEN`, else a random one generated at startup and printed to stderr (a token you set yourself is printed masked). Prefer `B4M_MCP_TOKEN` over `--token`, which shows up in process listings. The advertised scopes are the recommended key configuration, not per-route hard gates, apart from Bob's, which its routes enforce. See [Serve Bike4Mind as an MCP server](../../BIKE4MIND_CLI.md#serve-bike4mind-as-an-mcp-server-b4m-mcp-serve) for the Claude Desktop config and details. Point an HTTP client at it like this:
531
+
532
+ ```json
533
+ {
534
+ "mcpServers": {
535
+ "bike4mind": {
536
+ "type": "http",
537
+ "url": "http://127.0.0.1:7000/mcp",
538
+ "headers": { "Authorization": "Bearer <token>" }
539
+ }
540
+ }
541
+ }
542
+ ```
408
543
 
409
544
  ## Plugins
410
545
 
@@ -438,22 +573,22 @@ The entry default-exports a factory. It receives a context (currently `{ logger
438
573
 
439
574
  ```js
440
575
  export default ctx => ({
441
- name: 'foo', // unique module name
576
+ name: 'foo', // unique module name
442
577
  description: 'What this plugin does',
443
578
  getTools: () => [
444
579
  {
445
- toolFn: async args => 'result', // invoked when the agent calls the tool
580
+ toolFn: async args => 'result', // invoked when the agent calls the tool
446
581
  toolSchema: {
447
582
  name: 'foo_tool',
448
583
  description: 'What the tool does',
449
- parameters: { type: 'object', properties: {} }, // JSON Schema
584
+ parameters: { type: 'object', properties: {} }, // JSON Schema
450
585
  },
451
586
  },
452
587
  ],
453
588
  getSystemPromptSection: () => 'Extra system-prompt text (or an empty string)',
454
- getCommands: () => [{ name: 'foo', description: '...', execute: args => {} }], // optional
455
- registerWsHandlers: wsManager => {}, // optional
456
- dispose: () => {}, // optional, runs on exit/disable
589
+ getCommands: () => [{ name: 'foo', description: '...', execute: args => {} }], // optional
590
+ registerWsHandlers: wsManager => {}, // optional
591
+ dispose: () => {}, // optional, runs on exit/disable
457
592
  });
458
593
  ```
459
594
 
@@ -489,6 +624,7 @@ The CLI includes a `recent_changes` tool that uses git history to find recently
489
624
  ### How It Works
490
625
 
491
626
  The tool uses `git log` to track file modifications and returns:
627
+
492
628
  - Files sorted by activity (most commits first)
493
629
  - Commit messages for context
494
630
  - Optional statistics showing lines changed
@@ -503,6 +639,7 @@ The CLI supports loading project-specific instructions from context files, simil
503
639
  ### Supported Files
504
640
 
505
641
  **Project-level** (in your project directory, checked in priority order):
642
+
506
643
  1. `CLAUDE.local.md` - Personal/gitignored instructions (highest priority)
507
644
  2. `CLAUDE.md` - Project instructions
508
645
  3. `AGENTS.md` - Cross-tool standard
@@ -511,6 +648,7 @@ The CLI supports loading project-specific instructions from context files, simil
511
648
  6. `INSTRUCTIONS.md` - Project instructions (lowest priority)
512
649
 
513
650
  **Global** (in `~/.bike4mind/`):
651
+
514
652
  1. `AI.local.md` - Personal global instructions
515
653
  2. `AI.md` - Global instructions
516
654
 
@@ -535,6 +673,7 @@ Create a `CLAUDE.md` in your project:
535
673
  ```
536
674
 
537
675
  On startup, you'll see:
676
+
538
677
  ```
539
678
  📄 Project context: CLAUDE.md
540
679
  ```
@@ -546,6 +685,7 @@ The agent will follow these instructions for all interactions in that project.
546
685
  Sessions are saved to `~/.bike4mind/sessions/`
547
686
 
548
687
  Each session includes:
688
+
549
689
  - Full conversation history
550
690
  - Token usage tracking
551
691
  - Agent reasoning steps
@@ -556,6 +696,7 @@ Each session includes:
556
696
  Debug logs are automatically written to `~/.bike4mind/debug/[session-id].txt` for every session, regardless of the `--verbose` flag.
557
697
 
558
698
  **What's logged:**
699
+
559
700
  - Session configuration (API endpoint, environment, model)
560
701
  - HTTP requests and responses (with size and preview)
561
702
  - SSE streaming events from LLM
@@ -564,6 +705,7 @@ Debug logs are automatically written to `~/.bike4mind/debug/[session-id].txt` fo
564
705
  - Authentication flow events
565
706
 
566
707
  **Accessing logs:**
708
+
567
709
  ```bash
568
710
  # List all debug logs
569
711
  ls -lh ~/.bike4mind/debug/
@@ -576,13 +718,41 @@ tail -f ~/.bike4mind/debug/[session-id].txt
576
718
  ```
577
719
 
578
720
  **Log retention:**
721
+
579
722
  - Debug logs older than 30 days are automatically cleaned up on CLI startup
580
723
  - Each log file is named by session ID for easy correlation
581
724
 
582
725
  **Verbose mode:**
726
+
583
727
  - Without `--verbose`: Debug logs only written to file (clean console output)
584
728
  - With `--verbose`: Debug logs shown in console AND written to file
585
729
 
730
+ ### Hearth hook troubleshooting
731
+
732
+ If the standalone `bin/hearth-hook.mjs` reporter is not reaching Hearth, enable its diagnostic:
733
+
734
+ ```bash
735
+ export B4M_HEARTH_DEBUG=1
736
+ echo '{}' | node packages/cli/bin/hearth-hook.mjs
737
+ ```
738
+
739
+ Set `B4M_API_URL` and `B4M_API_KEY` first. With missing credentials the hook makes no request.
740
+ Diagnostics are off by default; an empty `B4M_HEARTH_DEBUG` or exactly `0` also disables them.
741
+ Other nonempty values enable one stderr line on failure:
742
+
743
+ - `POST /api/hearth/events failed: HTTP 401`: check whether the API key is valid.
744
+ - `POST /api/hearth/events error: ECONNREFUSED`: check the endpoint and server availability.
745
+ - `POST /api/hearth/events error: TimeoutError`: check connectivity and server responsiveness.
746
+ - `stdin payload error: SyntaxError`: the hook received malformed JSON.
747
+ - `configuration error: ERR_INVALID_URL`: check that `B4M_API_URL` is a valid absolute URL.
748
+ - `configuration error: missing B4M_API_URL or B4M_API_KEY`: set both variables before running the hook.
749
+
750
+ Each line starts with `hearth-hook:`. Errors expose a native error code or name, never the error
751
+ message, API key, URL, or hook payload. The hook still exits `0` on reporting failures. With debugging
752
+ enabled, the request gets 2.75 seconds and the diagnostic flush gets up to 250 ms within the 3-second
753
+ request/diagnostic budget. A closed or stalled stderr can lose the diagnostic; reporting remains
754
+ best-effort. Unset `B4M_HEARTH_DEBUG` after troubleshooting to keep routine hook events quiet.
755
+
586
756
  ## Development
587
757
 
588
758
  This section covers the contributor workflow for hacking on the CLI from a checkout of the monorepo. For end-user installation see [Installation](#installation) above.
@@ -679,6 +849,7 @@ pnpm --filter @bike4mind/agents dev
679
849
  `dist/` rebuilds on save, so the next `b4m` invocation sees changes without a manual `build`.
680
850
 
681
851
  Caveats:
852
+
682
853
  - This does **not** hot-reload an already-running interactive `b4m` session — you still exit and re-run.
683
854
  - Running multiple watchers in parallel (one per package you're touching) hasn't been load-tested in this repo. If watch seems to miss changes or feels unreliable, fall back to manual `pnpm --filter <pkg> build`.
684
855
 
@@ -786,15 +957,15 @@ runtime. Unknown flags are tolerated (never hard-error) and the interactive TUI
786
957
  preserved (a positional prompt seeds **and** submits turn 1 without switching to
787
958
  headless `-p`):
788
959
 
789
- | Flag | Effect |
790
- | --- | --- |
791
- | `--mcp-config <file>` | Inject MCP servers from a claude-shape JSON (`{ "mcpServers": {...} }`). Supports HTTP transport (`type: "http"`, `url`, `headers`) with per-launch Bearer auth. |
792
- | `--strict-mcp-config` | Use ONLY `--mcp-config` servers; ignore file-config and `.mcp.json` (board YAML pane). |
793
- | `--append-system-prompt <text>` | Append text verbatim to the end of the system prompt (the 3-layer brief). |
794
- | `--allowedTools <patterns>` | Auto-approve matching tools without a permission prompt (glob `mcp__manifold__*` or a space-separated explicit list). |
795
- | `--settings <json>` | Inline JSON; the `hooks` subset drives lifecycle hooks (see below). Malformed JSON is ignored, never fatal. |
960
+ | Flag | Effect |
961
+ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
962
+ | `--mcp-config <file>` | Inject MCP servers from a claude-shape JSON (`{ "mcpServers": {...} }`). Supports HTTP transport (`type: "http"`, `url`, `headers`) with per-launch Bearer auth. |
963
+ | `--strict-mcp-config` | Use ONLY `--mcp-config` servers; ignore file-config and `.mcp.json` (board YAML pane). |
964
+ | `--append-system-prompt <text>` | Append text verbatim to the end of the system prompt (the 3-layer brief). |
965
+ | `--allowedTools <patterns>` | Auto-approve matching tools without a permission prompt (glob `mcp__manifold__*` or a space-separated explicit list). |
966
+ | `--settings <json>` | Inline JSON; the `hooks` subset drives lifecycle hooks (see below). Malformed JSON is ignored, never fatal. |
796
967
  | `--session-id <uuid>` / `--resume <uuid>` | Pin / resume a session (board pane). `/clear` and `/compact` keep the pinned uuid; a bad `--resume` prints `No conversation found with session ID <uuid>` and exits non-zero so the host can self-heal the pane. |
797
- | `<positional prompt>` | Seeds and auto-fires turn 1 while staying interactive. |
968
+ | `<positional prompt>` | Seeds and auto-fires turn 1 while staying interactive. |
798
969
 
799
970
  ### Lifecycle hooks (`--settings.hooks`)
800
971
 
@@ -804,6 +975,19 @@ interactive permission prompt blocks; `PostToolUse` / `Stop` / `UserPromptSubmit
804
975
  commands remove it. Each hook command runs via a real shell with its stdin piped
805
976
  then closed (EOF), so a blocking `cat > <file>` hook returns immediately.
806
977
 
978
+ ### Folder trust on a host launch
979
+
980
+ A launch with a positional prompt **and** at least one host flag (`--mcp-config`,
981
+ `--append-system-prompt`, `--allowedTools`, `--settings`, `--session-id` or
982
+ `--resume`) does not show the folder-trust prompt or the repo MCP-approval prompt,
983
+ since no hook fires for either and the auto-fired turn would wait behind it. An
984
+ untrusted folder's repo config (`CLAUDE.md`, `AGENTS.md`, `.mcp.json`, `.claude/`,
985
+ `.bike4mind/`) stays inert for that session, exactly as if "Not now" had been
986
+ chosen, and nothing is persisted. A one-line notice says so; run `/trust folder`
987
+ to trust it. Pending repo MCP servers stay off with the usual warning. Context the
988
+ host needs should reach the session through `--append-system-prompt` and
989
+ `--mcp-config`.
990
+
807
991
  ## License
808
992
 
809
993
  Private - Bike4Mind