@kontextmind/kxm 0.7.164 → 0.7.166

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 (45) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +2 -0
  4. package/docs/README.md +1 -0
  5. package/docs/architecture/inventory.md +4 -3
  6. package/docs/concepts/trust-model.md +1 -1
  7. package/docs/glossary.md +4 -4
  8. package/docs/operations/troubleshooting.md +4 -1
  9. package/docs/operations.md +208 -0
  10. package/docs/reference/cli-reference.md +12 -11
  11. package/docs/reference/config-reference.md +36 -11
  12. package/docs/reference/configuration.md +11 -1
  13. package/docs/reference/tools.md +1 -1
  14. package/docs/start/quickstart-claude-code.md +2 -2
  15. package/package.json +1 -1
  16. package/plugins/kxm/.claude-plugin/plugin.json +2 -2
  17. package/plugins/kxm/README.md +4 -4
  18. package/plugins/kxm/dist/claude-hook.js +511 -56
  19. package/plugins/kxm/dist/cli.js +15661 -14775
  20. package/plugins/kxm/dist/extension.js +645 -133
  21. package/plugins/kxm/dist/mcp-server.js +8152 -81
  22. package/plugins/kxm/dist/runtime-supervisor.js +804 -155
  23. package/plugins/kxm/dist/runtime.js +851 -202
  24. package/plugins/kxm/dist/server.js +466 -58
  25. package/plugins/kxm/package.json +1 -1
  26. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +17 -5
  27. package/plugins/kxm/src/cli/context-skills.ts +64 -10
  28. package/plugins/kxm/src/cli/hub.ts +192 -22
  29. package/plugins/kxm/src/cli/project.ts +7 -3
  30. package/plugins/kxm/src/cli/types.ts +14 -1
  31. package/plugins/kxm/src/cli/workflows.ts +12 -1
  32. package/plugins/kxm/src/cli.ts +63 -11
  33. package/plugins/kxm/src/config.ts +246 -3
  34. package/plugins/kxm/src/extension.ts +12 -7
  35. package/plugins/kxm/src/hub-autostart.ts +23 -0
  36. package/plugins/kxm/src/hub-binding.ts +182 -2
  37. package/plugins/kxm/src/hub-env.ts +132 -9
  38. package/plugins/kxm/src/hub-identity.ts +337 -0
  39. package/plugins/kxm/src/mcp-server.ts +17 -14
  40. package/plugins/kxm/src/project-name.ts +6 -20
  41. package/plugins/kxm/src/runtime-supervisor.ts +9 -3
  42. package/plugins/kxm/src/server.ts +22 -4
  43. package/plugins/kxm/src/tenant-status.ts +9 -2
  44. package/scripts/build-runtime.mjs +5 -0
  45. package/scripts/kxm-hub.mjs +5 -0
@@ -11,7 +11,7 @@
11
11
  "name": "kxm",
12
12
  "source": "./plugins/kxm",
13
13
  "description": "Durable workflows, peer agents, and kxm tui",
14
- "version": "0.7.164",
14
+ "version": "0.7.166",
15
15
  "category": "development",
16
16
  "tags": ["kxm", "multi-agent", "workflows", "mcp"]
17
17
  }
package/CHANGELOG.md CHANGED
@@ -6,6 +6,31 @@ All notable user-facing changes are documented here. The project follows [Semant
6
6
 
7
7
  ### Added
8
8
 
9
+ - **Hub project identity and its access key live in `.kxm/config.yaml`.**
10
+ `hub.local` and `hub.cloud` hold the URL, the project id to present, and a
11
+ key reference (`key.op` is an `op://` reference, `key.env` is an environment
12
+ variable name). A literal token is refused. `op read` runs at use time and
13
+ the resolved value is not saved. The same order is used everywhere: flag,
14
+ `KXM_PROJECT`, the active mode's config project, `.kxm/project.yaml`, the
15
+ package name, then the directory name. `kxm hub bind` and
16
+ `kxm hub bind --cloud` write the non-secret fields, and `kxm hub view`
17
+ prints the mode, URL, project id, and key source. The hub's
18
+ `hub.projects` map uses the same references. `KXM_PROJECT_TOKENS` still
19
+ replaces that map. Setups whose hub map is keyed by the package name should
20
+ set `hub.local.project` or `hub.cloud.project` to that name, or keep passing
21
+ `KXM_PROJECT`: a checkout with `.kxm/project.yaml` otherwise sends that id
22
+ and gets `project_token_missing`. See
23
+ [Operate a KXM hub](docs/operations.md#hub-identity-in-config).
24
+
25
+ - **`kxm hub bind --cloud` attaches a client to a remote hub reached through a loopback forward.**
26
+ The binding records `--token-env` and/or `--token-command` and never the token.
27
+ Later commands, including the environment for a Pi worker, use that source and
28
+ do not fall back to this machine's hub-env token. Peer commands and
29
+ `kxm tenant status` resolve one project id: flag or `KXM_PROJECT`, then
30
+ `.kxm/project.yaml`, then `package.json`, then the directory name. The
31
+ SSH-forward recipe is in
32
+ [Operate a KXM hub](docs/operations.md#cross-box-peer-attach).
33
+
9
34
  - **A live agent step uses a configurable one-shot timeout, and a cancelling run recovers when its child has already exited.**
10
35
  The bound is the step `timeoutMs`, or the project `limits.agentStepTimeoutMs`
11
36
  when the step omits it (minimum 60 seconds, default one hour). A wider step
package/README.md CHANGED
@@ -105,6 +105,8 @@ You need Node.js 22.19 or newer on the 22.x line, or Node.js 24 or newer, plus G
105
105
  kxm hub view
106
106
  ```
107
107
 
108
+ A hub on another machine, reached through an SSH forward to loopback, uses `kxm hub bind --cloud` so this machine's hub-env token is not sent. The recipe is in [Operate a KXM hub](docs/operations.md#cross-box-peer-attach).
109
+
108
110
  Expected output:
109
111
 
110
112
  ```text
package/docs/README.md CHANGED
@@ -96,6 +96,7 @@ KXM connects coding agents through a durable, authenticated [hub](glossary.md#hu
96
96
 
97
97
  | Page | For | What you get |
98
98
  |---|---|---|
99
+ | [Operate a KXM hub](operations.md) | Hub operators | Index of the operations guides, and cross-box attach over an SSH forward |
99
100
  | [Deploy KXM](operations/deploy.md) | Hub operators | Deployment classes, supervision, and hosted per-tenant hubs behind a proxy |
100
101
  | [Monitor KXM](operations/monitoring.md) | Hub operators | `kxm dash`, health and readiness, metrics, logs and alerts |
101
102
  | [Back up and restore KXM](operations/backup-and-restore.md) | Hub operators | `kxm backup` and `kxm restore`, the state roots, and a stopped-hub recipe |
@@ -32,9 +32,10 @@ On macOS the user state root is `Library/Application Support/KXM` under the
32
32
  home directory (`kxmUserStateRoot` in `plugins/kxm/src/bindings.ts`). Windows
33
33
  uses `AppData/Local/KXM`. Other platforms use `$XDG_STATE_HOME/kxm` or
34
34
  `.local/state/kxm`. `KXM_STATE_HOME` overrides that root when it is absolute.
35
- The tracker mentions `docs/operations.md` for the six backup roots. That file
36
- is not in this checkout. The six roots are described in
37
- [Backup and restore](../operations/backup-and-restore.md).
35
+ The tracker mentions `docs/operations.md` for the six backup roots. That page
36
+ indexes the operations guides and links the six roots to
37
+ [Backup and restore](../operations/backup-and-restore.md). It also holds
38
+ [Cross-box peer attach](../operations.md#cross-box-peer-attach).
38
39
 
39
40
  ## Related
40
41
 
@@ -56,7 +56,7 @@ flowchart LR
56
56
  - **Claude Code plugin.** The MCP server uses the plugin's `auth_token` setting, else the project token the hub saved for this project. It never falls back to the saved admin token; without a project token, its tools report that and do nothing.
57
57
  - **SessionStart hook.** It reads local state read-only. It mints no token, writes no file, and never prints a token.
58
58
  - **Pi extension.** It uses `KXM_AUTH_TOKEN`, else the project token the hub saved for this project. It never uses the saved admin token, nor the one a hub it auto-started generated; without a project token it reports the fix and stays offline.
59
- - **`kxm peer` and `kxm workflow` agent commands.** They act as a peer agent, so they choose a token as the Pi extension does, and exit 2 with `project_token_missing` when none resolves.
59
+ - **`kxm peer` and `kxm workflow` agent commands.** They act as a peer agent, so they choose a token as the Pi extension does, and exit 2 with `project_token_missing` when none resolves. The message names the project id that was sent and where it came from.
60
60
  - **Dashboard and Runtime supervisor.** Operator tools use `KXM_AUTH_TOKEN`, else the saved project token, else the saved admin token.
61
61
 
62
62
  ## Project isolation
package/docs/glossary.md CHANGED
@@ -38,7 +38,7 @@ The service that authenticates [agents](#agent), stores [messages](#message) and
38
38
 
39
39
  ### Hub binding
40
40
 
41
- The record that `kxm hub bind <url>` writes to `hub-binding.json` in the [user state root](#user-state-root), naming the hub this machine uses. `kxm hub view` checks it, and the Runtime syncs to it. Binding a remote hub requires a credential.
41
+ The record that `kxm hub bind <url>` writes to `hub-binding.json` in the [user state root](#user-state-root), naming the hub this machine uses. `kxm hub view` checks it, and the Runtime syncs to it. Binding a remote hub requires a credential. `kxm hub bind --cloud` marks a loopback forward as remote and records a token variable or command, never the token.
42
42
 
43
43
  ### KontextMind
44
44
 
@@ -104,15 +104,15 @@ Another [agent](#agent) in the same [project](#project). `kxm_list` and `kxm pee
104
104
 
105
105
  ### Project
106
106
 
107
- The authentication and discovery namespace on the hub. An agent names it with `KXM_PROJECT` (otherwise the `package.json` name, then the directory name), and its key in the hub's `KXM_PROJECT_TOKENS` holds its token. Agents see only peers in the same project. Compare [project ID](#project-id).
107
+ The authentication and discovery namespace on the hub. Every command resolves it the same way: `--project` or `KXM_PROJECT`, then the active mode's `project` in `.kxm/config.yaml`, then the [project ID](#project-id) in `.kxm/project.yaml`, then the `package.json` name, then the directory name. Its token is a key reference in that config, or the matching key in the hub's `KXM_PROJECT_TOKENS`. Agents see only peers in the same project.
108
108
 
109
109
  ### Project ID
110
110
 
111
- The stable `prj_` identifier in `.kxm/project.yaml`. The [Runtime](#runtime) and hub sync use it. It is not the hub [project](#project) name, even though both describe the same body of work.
111
+ The stable `prj_` identifier in `.kxm/project.yaml`. It is the hub [project](#project) name unless `--project` or `KXM_PROJECT` overrides it. The [Runtime](#runtime) store keeps this id as the local key.
112
112
 
113
113
  ### Project token
114
114
 
115
- The credential that the agents of one [project](#project) use. The operator sets it in the hub's `KXM_PROJECT_TOKENS` JSON map, and agents receive it as `KXM_AUTH_TOKEN` or the plugin's `auth_token`. Setting `KXM_PROJECT_TOKENS` replaces the hub's saved map, so list every project each time.
115
+ The credential that the agents of one [project](#project) use. The operator points config at it with `key.op` (`op://vault/item/field`) or `key.env` (an environment variable name), or sets the hub's `KXM_PROJECT_TOKENS` JSON map. The config file never holds the token. Agents receive the resolved value as `KXM_AUTH_TOKEN` or the plugin's `auth_token`. Setting `KXM_PROJECT_TOKENS` replaces the hub's saved map, so list every project each time. A config `hub.projects` map is resolved in memory and is not saved.
116
116
 
117
117
  ### Session token
118
118
 
@@ -87,6 +87,9 @@ If a malformed claim remains, read the exact `.pid` JSON in the state directory
87
87
  | `hub_url_invalid` | Use an `http` or `https` URL without user info, query or fragment |
88
88
  | `hub_bind_unauthenticated` | The URL is remote and this machine has no token for the project; export it and bind again |
89
89
  | `hub_credential_unreadable` | Repair or remove `hub-env.json` under the user state root |
90
+ | `cloud_token_missing` | A `--cloud` binding's variable is empty and it has no working command. Export the variable or fix `--token-command`. This machine's hub-env token is not sent |
91
+ | `cloud_flag_required` | `--token-command` was passed without `--cloud`. `--token-env` and `--key-op` are key references and are valid on a local bind |
92
+ | 401 after binding a loopback forward | The bind was not `--cloud`, so the client sent the local hub-env token. See [Cross-box peer attach](../operations.md#cross-box-peer-attach) |
90
93
 
91
94
  ## Claude Code plugin and MCP
92
95
 
@@ -96,7 +99,7 @@ The [plugin troubleshooting guide](../../plugins/kxm/README.md#troubleshooting)
96
99
  |---|---|
97
100
  | `kxm_*` tools do not appear | Check `/mcp` for the `kxm` server, check `node --version`, run `/reload-plugins`, and confirm `claude plugin list` shows `kxm@kxm` enabled |
98
101
  | `KXM hub unreachable at <url>` | Start the hub, or correct `server_url` with `/plugin configure kxm@kxm` |
99
- | `no project token for project <p>` | Enter the project token at `/plugin configure kxm@kxm`, or add `<p>` to the hub's full `KXM_PROJECT_TOKENS` map and restart the hub |
102
+ | `kxm has no project token for project <p>` | The message names where `<p>` came from. Set `hub.local.project` or `hub.cloud.project` and a key reference in `.kxm/config.yaml`, or add `<p>` to the hub's full `KXM_PROJECT_TOKENS` map and restart the hub. Never paste the token into the file |
100
103
  | `KXM hub rejected the project token for project <p>` | Enter the token the hub holds for `<p>` |
101
104
  | `tool_policy_denied: Session token on disk is malformed or expired` | Run `kxm session token --clear` |
102
105
  | Pushed requests never arrive | Start Claude Code with `claude --dangerously-load-development-channels plugin:kxm@kxm` and accept the trust prompt, or use `kxm_inbox` and `kxm_reply` |
@@ -0,0 +1,208 @@
1
+ # Operate a KXM hub
2
+
3
+ This page is the operator index for a [hub](glossary.md#hub): where the other
4
+ operations guides live, and how to attach a client on another machine to a hub
5
+ that is not reachable from the internet. The client in that setup is a local
6
+ `kxm` CLI, plus the Pi and Claude Code agents that CLI starts.
7
+
8
+ ## Where each procedure lives
9
+
10
+ | Procedure | Page |
11
+ |---|---|
12
+ | Install the services on a tenant box, including loopback listeners | [Deploy KXM](operations/deploy.md) |
13
+ | Health, readiness, metrics, logs, and alerts | [Monitor KXM](operations/monitoring.md) |
14
+ | Stopped-state backup of all six state roots, and restore | [Back up and restore KXM](operations/backup-and-restore.md) |
15
+ | Package update, plugin reinstall, and schema ceilings | [Upgrade KXM](operations/upgrade.md) |
16
+ | Runtime outbox, sync refusals, and hub leases | [Operate Runtime sync and leases](operations/runtime-sync.md) |
17
+ | Symptoms, causes, and fixes | [Troubleshoot KXM](operations/troubleshooting.md) |
18
+
19
+ The six roots are the checkout, the workspace, workspace state, the user state
20
+ root, user config, and federated telemetry. The stopped-state copy of each one
21
+ is in [Back up and restore KXM](operations/backup-and-restore.md).
22
+
23
+ ## Before you begin
24
+
25
+ - The `kxm` CLI is installed on the client machine.
26
+ - You can open SSH to the hub host, and you already have that host's key.
27
+ - The hub's admin token is in a password manager. 1Password CLI (`op`) is the
28
+ usual source. The token is never written into `hub-binding.json`.
29
+
30
+ ## Cross-box peer attach
31
+
32
+ Use this when the hub listens on loopback on a private machine and your client
33
+ reaches it through an SSH local forward. A plain `kxm hub bind` of
34
+ `http://127.0.0.1:17331` is a loopback bind: it stores no credential, and later
35
+ commands send this machine's hub-env admin token. The remote hub rejects that
36
+ token with 401. `--cloud` marks the binding remote even though the URL is
37
+ loopback, and names where the token comes from without storing the token.
38
+
39
+ ### Open the forward with a pinned host key
40
+
41
+ Pin the host key before the first connection. Do not accept a key on first use.
42
+
43
+ ```bash
44
+ ssh-keyscan -H 10.31.0.21 >> ~/.ssh/known_hosts
45
+ ssh -N \
46
+ -o ExitOnForwardFailure=yes \
47
+ -o StrictHostKeyChecking=yes \
48
+ -o UserKnownHostsFile="$HOME/.ssh/known_hosts" \
49
+ -L 127.0.0.1:17331:127.0.0.1:7331 \
50
+ user@10.31.0.21
51
+ ```
52
+
53
+ Leave that SSH session open. Hub traffic then goes to `127.0.0.1:17331` on the
54
+ client and comes out on the hub host's loopback port 7331.
55
+
56
+ <details><summary>PowerShell</summary>
57
+
58
+ ```powershell
59
+ ssh-keyscan -H 10.31.0.21 >> $env:USERPROFILE\.ssh\known_hosts
60
+ ssh -N `
61
+ -o ExitOnForwardFailure=yes `
62
+ -o StrictHostKeyChecking=yes `
63
+ -o UserKnownHostsFile="$env:USERPROFILE\.ssh\known_hosts" `
64
+ -L 127.0.0.1:17331:127.0.0.1:7331 `
65
+ user@10.31.0.21
66
+ ```
67
+
68
+ </details>
69
+
70
+ ### Bind the forward as a cloud hub
71
+
72
+ Pick one token source. The environment variable is enough when the shell
73
+ already holds the token. The command form asks 1Password each time a command
74
+ needs the token. Do not put the token text in `--token-command`: that string
75
+ is stored in the binding.
76
+
77
+ ```bash
78
+ export KXMD_HUB_TOKEN="$(op read 'op://Private/kxmd/admin-token')"
79
+ kxm hub bind --cloud --token-env KXMD_HUB_TOKEN http://127.0.0.1:17331
80
+ kxm hub view
81
+ ```
82
+
83
+ Or name the 1Password command and skip the variable:
84
+
85
+ ```bash
86
+ kxm hub bind --cloud \
87
+ --token-command "op read op://Private/kxmd/admin-token" \
88
+ http://127.0.0.1:17331
89
+ ```
90
+
91
+ Expected output:
92
+
93
+ ```text
94
+ bound hub http://127.0.0.1:17331 · remote · health=on · token is not stored
95
+ hub health=true ready=true · remote hub · mode=cloud project=prj_example (.kxm/config.yaml hub.cloud.project) key=env:KXMD_HUB_TOKEN
96
+ ```
97
+
98
+ `--token-env` and `--token-command` can be combined. A non-empty variable wins.
99
+ Otherwise the command runs. The command is a program and arguments, not a shell
100
+ pipeline (`|`, `&`, `;`, and redirection are refused).
101
+
102
+ <details><summary>PowerShell</summary>
103
+
104
+ ```powershell
105
+ $env:KXMD_HUB_TOKEN = op read "op://Private/kxmd/admin-token"
106
+ kxm hub bind --cloud --token-env KXMD_HUB_TOKEN http://127.0.0.1:17331
107
+ kxm hub view
108
+ ```
109
+
110
+ </details>
111
+
112
+ ### What --cloud changes
113
+
114
+ | | Local bind | `--cloud` bind |
115
+ |---|---|---|
116
+ | Loopback URL | Scope `loopback`. No credential required | Scope `remote`, including an SSH forward |
117
+ | Token stored in `hub-binding.json` | No | No. The file names `tokenEnv` and/or `tokenCommand` |
118
+ | Credential later commands send | `KXM_AUTH_TOKEN`, then the active mode's key reference in `.kxm/config.yaml`, then this machine's hub-env | The active mode's key reference, then the binding's named source. Hub-env is not a fallback |
119
+ | Missing source | Agent commands report `project_token_missing` and name the project id that was sent | `cloud_token_missing` or `cloud_token_command_failed`. The local admin token is not sent |
120
+ | `kxm hub start` from an extension | May start a local hub | Does not start a local hub when the forward is down (`cloud_hub_unreachable`) |
121
+
122
+ `kxm hub view`, `kxm tenant status`, `kxm peer`, `kxm workflow` agent commands,
123
+ `kxm context`, Runtime presence, and the environment exported for a Pi worker
124
+ all use that source. `kxm agent worker` puts `KXM_AUTH_TOKEN` in the child
125
+ process environment only. It does not write the token to disk.
126
+
127
+ The hub project id is the same value everywhere: `--project` or `KXM_PROJECT`,
128
+ then the active mode's `project` in `.kxm/config.yaml`, then the `id` in
129
+ `.kxm/project.yaml`, then `package.json` `name`, then the directory name.
130
+
131
+ ### Hub identity in config
132
+
133
+ Hub URL, mode, project id, and key reference live in `.kxm/config.yaml`
134
+ (`kxm.config.v1`), the same file as `hub.autoStart`. `.kxm/project.yaml` stays
135
+ the stable project id. The project file wins over
136
+ `~/.config/kxm/config.yaml`. `KXM_PROJECT` and `KXM_SERVER_URL` select the
137
+ live connection for one process. They do not rewrite the file.
138
+
139
+ ```yaml
140
+ hub:
141
+ autoStart: background
142
+ mode: local # local | cloud
143
+ local:
144
+ url: http://127.0.0.1:7331
145
+ project: prj_example # optional; defaults to the project.yaml id
146
+ key:
147
+ op: op://Private/kxm/local-project-token
148
+ env: KXM_LOCAL_PROJECT_TOKEN
149
+ cloud:
150
+ url: https://hub.kxmd.dev
151
+ project: prj_example
152
+ key:
153
+ op: op://Private/kxmd/project-token
154
+ env: KXMD_HUB_TOKEN
155
+ projects: # hub process map; references only
156
+ prj_example:
157
+ op: op://Private/kxm/local-project-token
158
+ env: KXM_LOCAL_PROJECT_TOKEN
159
+ ```
160
+
161
+ `key.op` is an `op://vault/item/field` reference. `key.env` is an environment
162
+ variable name. A non-empty variable wins; otherwise `op read` runs when the
163
+ client or the hub needs the token. The resolved value is not written to
164
+ config, `hub-binding.json`, or `hub-env.json`. A literal token is refused
165
+ with `hub_config_invalid`.
166
+
167
+ `kxm hub bind` and `kxm hub bind --cloud` write the mode, URL, project id, and
168
+ key reference. `--key-op` is the `op://` reference for either mode.
169
+ `--token-env` names the variable for either mode. `--token-command` stays
170
+ cloud-only. `kxm hub view` prints the mode, URL, project id, and key source.
171
+ It does not print the token. `kxm hub unbind` removes the binding and
172
+ `hub.mode`, and leaves the `local` and `cloud` blocks in place.
173
+
174
+ On the hub, `hub.projects` is that same kind of map. `KXM_PROJECT_TOKENS`
175
+ still replaces the map and is saved. A config map is resolved in memory and
176
+ does not replace the saved file.
177
+
178
+ A setup whose hub map is still keyed by the package name should set
179
+ `hub.local.project` or `hub.cloud.project` to that name. Otherwise clients
180
+ send the `.kxm/project.yaml` id and the hub has no token for it.
181
+
182
+ ### Remove the binding
183
+
184
+ ```bash
185
+ kxm hub unbind
186
+ ```
187
+
188
+ Unbind deletes `hub-binding.json` and clears `hub.mode` in `.kxm/config.yaml`.
189
+ The `local` and `cloud` blocks stay, so the next bind can switch mode again.
190
+ It does not delete hub-env, and it does not close the SSH forward. Stop the
191
+ forward by ending the `ssh -N` session.
192
+
193
+ ## Troubleshooting
194
+
195
+ | Symptom | Cause | Fix |
196
+ |---|---|---|
197
+ | 401 `invalid_auth` after binding `127.0.0.1:17331` | The bind was not `--cloud`, so the client sent this machine's hub-env admin token | Bind again with `--cloud` and a token source that holds the remote hub's token. Unset a stale `KXM_AUTH_TOKEN` that points at the local hub |
198
+ | `cloud_token_missing` | `KXMD_HUB_TOKEN` (or the variable you named) is unset or empty, and no command is configured | Export the variable or pass `--token-command`. The local hub-env token is intentionally unused |
199
+ | `project_token_missing` | The project id sent to the hub has no agent token. The message names that id and where it came from | Set `hub.local.project` or `hub.cloud.project` in `.kxm/config.yaml` to the id the hub already knows, and point `key.op` or `key.env` at the token. `KXM_PROJECT` or `--project` overrides the id for one command. Do not paste the token into the file |
200
+ | `cloud_token_command_failed` | `op` exited non-zero, timed out, or printed more than one line | Run the same command in a terminal and sign in to 1Password. Do not paste the token into the binding |
201
+ | Clients through one SSH host get locked out together | The hub rate-limits by agent id, otherwise by source address. Every forward from one SSH session shares `127.0.0.1` on the hub. `sshd` `MaxStartups` and `MaxSessions` can refuse new forwards first | Give each long-lived agent its own name. Raise the SSH limits on that host if many people share one jump host. Do not point two tenants at one hub |
202
+ | `kxm hub view` says `loopback` for the forward | `--cloud` was omitted | Bind again with `--cloud`. `KXM_SERVER_URL` overrides the binding URL and is labeled on its own |
203
+
204
+ ## Next steps
205
+
206
+ - Deploy the hub itself: [Deploy KXM](operations/deploy.md)
207
+ - Read health and metrics: [Monitor KXM](operations/monitoring.md)
208
+ - Command flags: [kxm hub bind](reference/cli-reference.md#kxm-hub-bind)
@@ -477,20 +477,20 @@ Starts, inspects, and stops the local KXM hub, and binds this machine to a hub.
477
477
  kxm hub view
478
478
  ```
479
479
 
480
- Calls `GET /health` and `GET /ready` on the target hub and reports whether the URL is loopback or remote.
480
+ Calls `GET /health` and `GET /ready` on the target hub and reports whether the URL is loopback or remote, plus the mode, project id, and key source in effect. The key source is an environment variable name or an `op://` reference. The token is not printed.
481
481
 
482
482
  No command-specific options.
483
483
 
484
484
  - Needs a hub to succeed. Reads only.
485
- - JSON keys: `target` (`url`, `scope`, and `source: "env"` when `KXM_SERVER_URL` overrides a binding), `health`, `ready`. An unreachable hub reports `{"error":"hub_unreachable"}` for both probes.
486
- - Exit 0 when both probes succeed, 1 otherwise.
485
+ - JSON keys: `target` (`url`, `scope`, and `source: "env"` when `KXM_SERVER_URL` overrides a binding), `identity` (`mode`, `modeSource`, `url`, `urlSource`, `project`, `projectSource`, `keySource`), `health`, `ready`. An unreachable hub reports `{"error":"hub_unreachable"}` for both probes.
486
+ - Exit 0 when both probes succeed, 1 otherwise. A cloud mode with no resolvable key exits 2 with `cloud_token_missing`.
487
487
 
488
488
  ```bash
489
489
  kxm hub view
490
490
  ```
491
491
 
492
492
  ```text
493
- hub health=true ready=true · loopback hub
493
+ hub health=true ready=true · loopback hub · mode=local project=prj_example (.kxm/project.yaml id) key=hub-env
494
494
  ```
495
495
 
496
496
  ```bash
@@ -569,16 +569,17 @@ kxm hub stop --wait-ms 8000 --json
569
569
  ### `kxm hub bind`
570
570
 
571
571
  ```text
572
- kxm hub bind <url>
572
+ kxm hub bind <url> [--cloud] [--token-env <name>] [--token-command <command>] [--key-op <op://vault/item/field>]
573
573
  ```
574
574
 
575
- Binds this machine to a running hub by writing `hub-binding.json` under the user state root, then probes the hub's health for up to 300 ms. Every hub client uses the binding when `KXM_SERVER_URL` is unset.
575
+ Binds this machine to a running hub by writing `hub-binding.json` under the user state root and the non-secret endpoint (mode, URL, project id, key reference) into `.kxm/config.yaml`, then probes the hub's health for up to 300 ms. Every hub client uses that endpoint when `KXM_SERVER_URL` is unset. The token is never written.
576
576
 
577
577
  - Arguments: `<url>`, Hub base URL (http or https).
578
578
  - A URL with credentials, a query, a fragment, or a scheme other than http or https fails with `hub_url_invalid` (exit 2).
579
- - A remote (non-loopback) URL is refused with `hub_bind_unauthenticated` (exit 2, `nextAction: "export_kxm_auth_token"`) unless a credential for the current project resolves from `KXM_AUTH_TOKEN` or the persisted `hub-env.json`. A malformed record fails with `hub_credential_unreadable` (exit 2).
580
- - Mutates the binding file. `--dry-run` validates and prints the plan without writing.
581
- - JSON keys: `url`, `scope`, `file`, `health` (`on`, `off`, or `unknown`), `probeMs`.
579
+ - A remote (non-loopback) URL is refused with `hub_bind_unauthenticated` (exit 2, `nextAction: "export_kxm_auth_token"`) unless a credential for the current project resolves from `KXM_AUTH_TOKEN` or the persisted `hub-env.json`. A malformed record fails with `hub_credential_unreadable` (exit 2). A loopback URL without `--cloud` still binds with no credential.
580
+ - `--cloud` marks the binding remote even when the URL is a loopback forward. It requires `--token-env`, `--token-command`, `--key-op`, or a combination. The token is not written. A non-empty variable wins; otherwise an `op://` reference is read with `op read`, or the command runs. `--token-command` without `--cloud` fails with `cloud_flag_required`. `--token-env` and `--key-op` are also valid on a local bind and are stored only as references in config. A missing cloud source later fails with `cloud_token_missing` and does not fall back to hub-env. See [Cross-box peer attach](../operations.md#cross-box-peer-attach).
581
+ - Mutates the binding file and `.kxm/config.yaml`. `--dry-run` validates and prints the plan without writing.
582
+ - JSON keys: `url`, `scope`, `file`, `configFile`, `project`, `health` (`on`, `off`, or `unknown`), `probeMs`. A cloud bind also returns `cloud`, and `tokenEnv` or `tokenCommand` when set.
582
583
 
583
584
  ```bash
584
585
  kxm hub bind http://127.0.0.1:7331 --dry-run
@@ -602,7 +603,7 @@ kxm hub bind https://hub.example.com --dry-run --json
602
603
  kxm hub unbind
603
604
  ```
604
605
 
605
- Removes this machine's hub binding, including a malformed binding record.
606
+ Removes this machine's hub binding, including a malformed binding record, and clears `hub.mode` in `.kxm/config.yaml`. The `hub.local` and `hub.cloud` blocks stay.
606
607
 
607
608
  No command-specific options.
608
609
 
@@ -2468,7 +2469,7 @@ Captured without a GitHub token. With `GITHUB_TOKEN` set, the same command polls
2468
2469
 
2469
2470
  ## `kxm peer`
2470
2471
 
2471
- Peer agent messaging through the hub. Each invocation connects to the hub as a short-lived agent named `KXM_AGENT_NAME` (default `cli-<pid>`) in project `KXM_PROJECT` (default: the `package.json` name, else the directory name), using `KXM_AUTH_TOKEN`, else this project's saved project token from `hub-env.json`. It never uses the persisted admin token: with neither, the command exits 2 with `project_token_missing` (`nextAction: "export_kxm_auth_token"`) before contacting the hub. The `kxm workflow` agent verbs (`checkpoint`, `record`, `wait`, `get`, `list`) connect the same way. That agent appears in `peer list` and the dashboard. Every subcommand accepts `--payload <json>` with the tool's fields as one object; explicit flags override it. Tool policy from `KXM_ATTEMPT_TOKEN`, `KXM_SESSION_TOKEN`, or the on-disk session token is enforced first (`tool_policy_denied`, `session_token_invalid`, `attempt_token_invalid`).
2472
+ Peer agent messaging through the hub. Each invocation connects to the hub as a short-lived agent named `KXM_AGENT_NAME` (default `cli-<pid>`). The project id is `--project`, then `KXM_PROJECT`, then the active mode's `project` in `.kxm/config.yaml`, then the `id` in `.kxm/project.yaml`, then the `package.json` name, then the directory name. The token is `KXM_AUTH_TOKEN`, else the active mode's key reference, else this project's saved project token from `hub-env.json`. It never uses the persisted admin token: with none of those, the command exits 2 with `project_token_missing` (`nextAction: "configure_hub_project"`) and names the project id and where it came from, before contacting the hub. The `kxm workflow` agent verbs (`checkpoint`, `record`, `wait`, `get`, `list`) connect the same way. That agent appears in `peer list` and the dashboard. Every subcommand accepts `--payload <json>` with the tool's fields as one object; explicit flags override it. Tool policy from `KXM_ATTEMPT_TOKEN`, `KXM_SESSION_TOKEN`, or the on-disk session token is enforced first (`tool_policy_denied`, `session_token_invalid`, `attempt_token_invalid`).
2472
2473
 
2473
2474
  All subcommands need a hub, honor `--dry-run` (printing the parsed `args` without connecting), print the hub's result object on success, and print `{"ok":false,"error":"command_failed","detail":"..."}` with exit 1 on failure. Malformed `--payload` exits 2 with `invalid_payload`.
2474
2475
 
@@ -1255,20 +1255,28 @@ in `plugins/kxm/src/config.ts`, then the user file
1255
1255
  `$KXM_USER_CONFIG_DIR/config.yaml` (default `~/.config/kxm/config.yaml`), then
1256
1256
  the project file `.kxm/config.yaml` in the current directory. Later layers win
1257
1257
  key by key; arrays are replaced, not merged. The files need no `schema` key.
1258
- Nothing validates keys or values except `hub.autoStart` and the `improvement.*`
1259
- keys, which fall back to their defaults field by field (see the table), but a file
1260
- that is not valid YAML makes every `kxm config` command fail. `kxm improve` loads
1261
- the project file from its project root (the current directory's Git root when it
1262
- holds `.kxm/project.yaml`) rather than from the current directory.
1263
-
1264
- Two groups of keys change behavior today: `hub.autoStart`, and the `improvement.*`
1265
- keys that shape the report `kxm improve` prints. The **Read by** column lists every
1266
- reader found in `plugins/kxm/src`, `scripts/`, and `packages/`; the `kxm config`
1267
- commands themselves are not counted.
1258
+ `hub.autoStart` and the `improvement.*` keys fall back to their defaults field
1259
+ by field (see the table). `hub.mode`, `hub.local`, `hub.cloud`, and
1260
+ `hub.projects` are validated: a literal token is refused with
1261
+ `hub_config_invalid`, and a mode other than `local` or `cloud` is refused. A
1262
+ file that is not valid YAML makes every `kxm config` command fail. `kxm improve`
1263
+ loads the project file from its project root (the current directory's Git root
1264
+ when it holds `.kxm/project.yaml`) rather than from the current directory.
1265
+
1266
+ The keys that change behavior are the `hub` section below and the
1267
+ `improvement.*` keys that shape the report `kxm improve` prints. Hub URL, mode,
1268
+ project id, and key reference live here rather than in `.kxm/project.yaml`
1269
+ because `hub.autoStart` was already this file's hub setting, and
1270
+ `project.yaml` stays the stable hashed project id. The **Read by** column lists
1271
+ every reader found in `plugins/kxm/src`, `scripts/`, and `packages/`; the
1272
+ `kxm config` commands themselves are not counted.
1268
1273
 
1269
1274
  | Key | Type and allowed values | Default | Read by |
1270
1275
  |---|---|---|---|
1271
1276
  | `hub.autoStart` | `background` or `off`; any other value falls back to `background` | `background` | The Pi extension on load (`plugins/kxm/src/extension.ts`, `hub-autostart.ts`) |
1277
+ | `hub.mode` | `local` or `cloud`. Any other value is `hub_config_invalid`. Unset means local unless a cloud binding exists | unset | Every hub client (`hub-identity.ts`): CLI, Pi extension, MCP server, dash, and `kxm agent worker` |
1278
+ | `hub.local`, `hub.cloud` | `url` (http or https, no userinfo, query, or fragment), `project` (one line, no spaces), and `key` | unset | The same clients, for the active mode. `project` defaults to the `.kxm/project.yaml` id when omitted |
1279
+ | `hub.local.key`, `hub.cloud.key`, `hub.projects.<id>` | `op` is `op://vault/item/field`. `env` is an environment variable name. A string, or a field named like a token, is refused | unset | Clients resolve the active mode's key at use time. The hub process resolves `hub.projects` in memory (`server.ts`). Neither writes the resolved token |
1272
1280
  | `user.name`, `user.email` | String | none | Not read by any code path yet |
1273
1281
  | `user.preferredHarness`, `user.preferredModel` | String | none | Not read by any code path yet |
1274
1282
  | `user.preferredCritics` | Array of strings | `[reviewer-arch, reviewer-cli]` | Not read by any code path yet |
@@ -1302,9 +1310,26 @@ no recorded cost is never ready.
1302
1310
 
1303
1311
  ```yaml
1304
1312
  # .kxm/config.yaml (project scope) or ~/.config/kxm/config.yaml (user scope).
1305
- # Only hub.autoStart and improvement.* change behavior today.
1313
+ # The project file wins. Key fields are references, never tokens.
1306
1314
  hub:
1307
1315
  autoStart: background # background | off
1316
+ mode: local # local | cloud
1317
+ local:
1318
+ url: http://127.0.0.1:7331
1319
+ project: prj_example
1320
+ key:
1321
+ op: op://Private/kxm/local-project-token
1322
+ env: KXM_LOCAL_PROJECT_TOKEN
1323
+ cloud:
1324
+ url: https://hub.kxmd.dev
1325
+ project: prj_example
1326
+ key:
1327
+ op: op://Private/kxmd/project-token
1328
+ env: KXMD_HUB_TOKEN
1329
+ projects:
1330
+ prj_example:
1331
+ op: op://Private/kxm/local-project-token
1332
+ env: KXM_LOCAL_PROJECT_TOKEN
1308
1333
  improvement:
1309
1334
  promotionPolicy: manual_pr # manual_pr | critic_quorum | auto_threshold (readiness only)
1310
1335
  telemetryHalfLifeDays: 14
@@ -108,7 +108,7 @@ Every agent client (the Pi extension, the Claude Code MCP server, and the `kxm p
108
108
  |---|---|---|
109
109
  | `KXM_SERVER_URL` | `http://127.0.0.1:7331` | Hub base URL. For the CLI, the machine's `kxm hub bind` URL is used when this is unset |
110
110
  | `KXM_AUTH_TOKEN` | See below | The project token for this agent's project |
111
- | `KXM_PROJECT` | `name` in `package.json` in the working directory, else the directory name | Project for discovery and authentication |
111
+ | `KXM_PROJECT` | Active mode's `project` in `.kxm/config.yaml`, else `id` in the nearest `.kxm/project.yaml`, else `name` in `package.json` in the working directory, else the directory name | Project for discovery and authentication. An explicit `--project` flag wins over this variable, and this variable wins over the config file. The same resolver is used by peer commands, tenant status, workers, the Pi extension, dash, and the Claude Code MCP server |
112
112
  | `KXM_AGENT_NAME` | Harness-specific (see below) | Name peers see; unique among online agents in the project, compared case-insensitively |
113
113
  | `KXM_AGENT_PURPOSE` | Harness-specific (see below) | One line peers use to decide what to send this agent |
114
114
 
@@ -120,6 +120,16 @@ Every agent client (the Pi extension, the Claude Code MCP server, and the `kxm p
120
120
 
121
121
  A clean shutdown marks an identity offline. Reconnecting with the same project and name resumes its durable agent ID and rotates its agent key. If the Claude Code name is already online in the project, the MCP server registers once more as `<name>-<pid>`.
122
122
 
123
+ A cloud hub mode replaces this table's token lookup for every client, including agents. The token comes from that mode's key reference in `.kxm/config.yaml` (`key.env`, then `key.op` via `op read`), then from the binding's `--token-env` or `--token-command`. It never comes from this machine's hub-env file, and it is not written to disk. `kxm agent worker` copies it into the child process environment as `KXM_AUTH_TOKEN`. Local mode uses `KXM_AUTH_TOKEN`, then the local key reference, then the saved project token, and still never the admin token.
124
+
125
+ Also check plugin.json is valid JSON.
126
+
127
+ And configuration table cell might be very long. That's ok.
128
+
129
+ Look at harness table "never the admin token" - the new paragraph clarifies cloud. Good.
130
+
131
+ Plugin README add one sentence under which token.
132
+
123
133
  ## Claude Code plugin settings
124
134
 
125
135
  The plugin asks for `server_url`, `auth_token`, `agent_name`, `agent_purpose` and `project` when you install it, and passes them to its MCP server as `KXM_SERVER_URL`, `KXM_AUTH_TOKEN`, `KXM_AGENT_NAME`, `KXM_AGENT_PURPOSE` and `KXM_PROJECT`. It also sets `KXM_PROJECT_DIR` to the directory Claude Code started in. Change them with `/plugin configure kxm@kxm`. Every field, default and token rule is in [Claude Code plugin settings](config-reference.md#claude-code-plugin-settings) and the [plugin README](../../plugins/kxm/README.md).
@@ -64,7 +64,7 @@ Every tool returns its result as JSON text; Pi also attaches the same value as s
64
64
 
65
65
  | Error text | Harness | Fix |
66
66
  |---|---|---|
67
- | `KXM has no project token for project <p> on this machine` | Claude Code | Set `auth_token` with `/plugin configure kxm@kxm`, or [give the project a token](../start/quickstart-claude-code.md#give-the-project-a-token-on-the-running-hub) on the hub |
67
+ | `kxm has no project token for project <p>` | Claude Code and the Pi extension | The message names where `<p>` came from. Set `hub.local.project` or `hub.cloud.project` and a key reference in `.kxm/config.yaml`, set `auth_token` with `/plugin configure kxm@kxm`, or [give the project a token](../start/quickstart-claude-code.md#give-the-project-a-token-on-the-running-hub) on the hub |
68
68
  | `KXM hub unreachable at <url> (<cause>)` | Claude Code | Start the hub with `kxm hub start`, or correct `server_url` |
69
69
  | `KXM hub rejected the project token for project <p>` | Claude Code | Enter that project's token from the hub's `KXM_PROJECT_TOKENS` |
70
70
  | `kxm hub is not connected; check KXM_SERVER_URL and /kxm hub` | Pi | Start the hub or fix `KXM_SERVER_URL`, then restart the session |
@@ -181,7 +181,7 @@ Claude Code asks for these options at install. Change them later with `/plugin c
181
181
  | `auth_token` | Blank | Blank on the machine that runs the hub. Elsewhere, this project's token. Never the admin token. |
182
182
  | `agent_name` | `claude` | The name peers see. A second concurrent session in the project registers as `<name>-<pid>`. |
183
183
  | `agent_purpose` | `Claude Code implementation and review agent` | One line that peers use to decide what to send this agent |
184
- | `project` | Blank | `<hub-project>`. Blank uses the `name` in `package.json`, then the directory name. |
184
+ | `project` | Blank | `<hub-project>`. Blank uses `hub.local.project` or `hub.cloud.project` in `.kxm/config.yaml` for the active mode, then the `id` in `.kxm/project.yaml`, then the `name` in `package.json`, then the directory name. |
185
185
 
186
186
  With a blank `auth_token`, the plugin uses the project token the hub saved for `project` in `hub-env.json`, and only that token. It never uses the admin token. On another machine, get the project token from whoever runs the hub, through a password manager, and enter it at `/plugin configure kxm@kxm`. [Plugin settings](../reference/config-reference.md#claude-code-plugin-settings) has the full rules.
187
187
 
@@ -394,7 +394,7 @@ The `kxm_*` tools and the session brief name the fix for setup problems. Run the
394
394
  | Message or symptom | Cause | Fix |
395
395
  |---|---|---|
396
396
  | `KXM hub unreachable at <url>` | No hub answers at `server_url` | Start the hub with `kxm hub start`, or correct `server_url` and restart Claude Code |
397
- | `KXM has no project token for project <p> on this machine` | No `auth_token`, and the hub saved no token for `<p>` | Add `<p>` with [step 3](#3-start-the-hub), enter its token, or fix the `project` option |
397
+ | `kxm has no project token for project <p>` | No `auth_token`, and the hub saved no token for `<p>`. The message names where `<p>` came from | Set `hub.<mode>.project` in `.kxm/config.yaml` to the key the hub knows, add a key reference, or add `<p>` with [step 3](#3-start-the-hub). Never paste the token into the file |
398
398
  | `KXM hub rejected the project token for project <p>` | `auth_token` is not the hub's token for `<p>` | Enter the right token at `/plugin configure kxm@kxm` |
399
399
  | `tool_policy_denied: Session token on disk is malformed or expired` | A stale session token file blocks every tool | Run `kxm session token --clear`; it prints `Session token cleared from disk.` |
400
400
  | `tool_policy_denied: KXM_SESSION_TOKEN is malformed or expired` | A bad `KXM_SESSION_TOKEN` in Claude Code's environment | Unset or replace it where you launch Claude Code, then restart it |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontextmind/kxm",
3
- "version": "0.7.164",
3
+ "version": "0.7.166",
4
4
  "description": "KXM local-first multi-agent orchestration and operator dashboard",
5
5
  "type": "module",
6
6
  "author": "KontextMind",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
3
3
  "name": "kxm",
4
4
  "displayName": "KXM",
5
- "version": "0.7.164",
5
+ "version": "0.7.166",
6
6
  "description": "Headless multi-agent orchestration, durable workflows, and a live operator dashboard for Pi and Claude Code",
7
7
  "author": {
8
8
  "name": "KontextMind",
@@ -65,7 +65,7 @@
65
65
  "project": {
66
66
  "type": "string",
67
67
  "title": "Project",
68
- "description": "Hub project key; must match a key in the hub KXM_PROJECT_TOKENS. Blank uses the package.json name, then the directory name",
68
+ "description": "Hub project key; must match a key in the hub KXM_PROJECT_TOKENS. Blank uses the .kxm/project.yaml id, then the package.json name, then the directory name",
69
69
  "required": false
70
70
  }
71
71
  }
@@ -58,7 +58,7 @@ Claude Code asks for these options when you install the plugin. Change them late
58
58
  | `auth_token` | `KXM_AUTH_TOKEN` | Blank | This project's token from the hub's `KXM_PROJECT_TOKENS`. Leave it blank on the machine that runs the hub. Never the hub admin token. Marked sensitive. |
59
59
  | `agent_name` | `KXM_AGENT_NAME` | `claude` | Name other agents see. The first active session in a project keeps it; a later concurrent session registers as `<name>-<pid>`. |
60
60
  | `agent_purpose` | `KXM_AGENT_PURPOSE` | `Claude Code implementation and review agent` | One line that peers use to decide what to send this agent. |
61
- | `project` | `KXM_PROJECT` | Blank | Hub project key; must match a key in the hub's `KXM_PROJECT_TOKENS`. Blank uses `name` from the project's `package.json`, then the directory name. |
61
+ | `project` | `KXM_PROJECT` | Blank | Hub project key. Blank uses the active mode's `project` in `.kxm/config.yaml`, then the `id` in `.kxm/project.yaml`, then `name` from `package.json`, then the directory name. |
62
62
 
63
63
  The MCP server also receives `KXM_PROJECT_DIR`, set to the directory Claude Code was started in (`CLAUDE_PROJECT_DIR`). It decides the default project key and whether this is a KXM project (one with a `.kxm/` directory).
64
64
 
@@ -67,9 +67,9 @@ The MCP server also receives `KXM_PROJECT_DIR`, set to the directory Claude Code
67
67
  The plugin acts as an agent of one hub project and authenticates with that project's token. It never uses the hub admin token.
68
68
 
69
69
  - On the machine that runs the hub, leave `auth_token` blank. The MCP server then uses the project token the hub saved for this project in `hub-env.json` under the user state root (`KXM_STATE_HOME`, or the platform default listed in [State outside the project](../../docs/reference/config-reference.md#state-outside-the-project)). It uses only that entry, never the admin token saved beside it.
70
- - On any other machine, enter this project's token at `/plugin configure kxm@kxm`. Get it from whoever runs the hub, through your password manager.
70
+ - On any other machine, enter this project's token at `/plugin configure kxm@kxm`. Get it from whoever runs the hub, through your password manager. When the machine is bound with `kxm hub bind --cloud`, leave `auth_token` blank: the MCP server reads the binding's token source and does not store the token. The recipe is [Cross-box peer attach](../../docs/operations.md#cross-box-peer-attach).
71
71
  - Never enter the hub admin token. It is the operator's credential. The hub accepts it for any project that has no token of its own, so an agent holding it could act in projects it was never given.
72
- - Without a project token, every `kxm_*` tool fails with `KXM has no project token for project <p> on this machine`, and the MCP server does not contact the hub.
72
+ - Without a project token, every `kxm_*` tool fails with `kxm has no project token for project <p>`, naming where that id came from, and the MCP server does not contact the hub.
73
73
 
74
74
  To give a project a token, the operator adds it to `KXM_PROJECT_TOKENS` and restarts the hub. That variable replaces the hub's saved token map rather than merging with it, so it must list every project, existing and new. [Add Claude Code to an existing project](../../docs/start/quickstart-claude-code.md#add-claude-code-to-an-existing-project) has a command that builds the full map. Run it in your own terminal, and never paste tokens or `hub-env.json` into Claude.
75
75
 
@@ -210,7 +210,7 @@ No hub answers at `server_url`. Start it with `kxm hub start`, or correct `serve
210
210
 
211
211
  ### `no project token for project <p>`
212
212
 
213
- The MCP server found neither an `auth_token` nor a token the hub saved for `<p>`, so it did not contact the hub. Enter the project's token at `/plugin configure kxm@kxm`, or add `<p>` to the hub's `KXM_PROJECT_TOKENS`, listing every existing project too because the variable replaces the saved map, and restart the hub. If `<p>` is not the key you expected, set the `project` option.
213
+ The MCP server found neither an `auth_token` nor a token the hub saved for `<p>`, so it did not contact the hub. The message names where `<p>` came from. Enter the project's token at `/plugin configure kxm@kxm`, set `hub.local.project` or `hub.cloud.project` in `.kxm/config.yaml` to the key the hub already knows, or add `<p>` to the hub's `KXM_PROJECT_TOKENS` or `hub.projects` map. `KXM_PROJECT_TOKENS` replaces the saved map, so list every existing project, then restart the hub. Never paste the token into the config file.
214
214
 
215
215
  ### `KXM hub rejected the project token for project <p>`
216
216