@kontextmind/kxm 0.7.92 → 0.7.93

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 (91) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/workflows/default.yaml +1 -1
  3. package/CHANGELOG.md +204 -0
  4. package/README.md +3 -0
  5. package/docs/README.md +3 -0
  6. package/docs/agent-skills.md +123 -60
  7. package/docs/architecture.md +5 -2
  8. package/docs/cli-reference.md +3527 -0
  9. package/docs/config-reference.md +1943 -0
  10. package/docs/configuration.md +29 -3
  11. package/docs/continuous-improvement.md +122 -10
  12. package/docs/contracts/routing.md +95 -11
  13. package/docs/harness-routing.md +616 -0
  14. package/docs/kxm-handbook.md +106 -19
  15. package/docs/templates/README.md +1 -1
  16. package/docs/test-matrix.md +12 -6
  17. package/docs/troubleshooting.md +2 -2
  18. package/examples/project/.kxm/workflows/fix.yaml +1 -1
  19. package/examples/project/.kxm/workflows/improve.yaml +1 -1
  20. package/package.json +1 -1
  21. package/plugins/kxm/.claude-plugin/plugin.json +9 -10
  22. package/plugins/kxm/README.md +238 -56
  23. package/plugins/kxm/dist/claude-hook.js +10083 -0
  24. package/plugins/kxm/dist/cli.js +3068 -2446
  25. package/plugins/kxm/dist/client.js +64 -0
  26. package/plugins/kxm/dist/core.js +102 -9
  27. package/plugins/kxm/dist/extension.js +210 -68
  28. package/plugins/kxm/dist/mcp-server.js +217 -40
  29. package/plugins/kxm/dist/runtime-supervisor.js +1628 -157
  30. package/plugins/kxm/dist/runtime.js +1874 -298
  31. package/plugins/kxm/dist/server.js +416 -82
  32. package/plugins/kxm/package.json +1 -1
  33. package/plugins/kxm/skills/hints.json +1 -1
  34. package/plugins/kxm/skills/kxm/SKILL.md +48 -24
  35. package/plugins/kxm/skills/kxm/references/protocol.md +3 -3
  36. package/plugins/kxm/skills/kxm-context-memory/SKILL.md +61 -21
  37. package/plugins/kxm/skills/kxm-definitions/SKILL.md +9 -0
  38. package/plugins/kxm/skills/kxm-harness-auth/SKILL.md +82 -16
  39. package/plugins/kxm/skills/kxm-harvest/SKILL.md +1 -1
  40. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +55 -27
  41. package/plugins/kxm/skills/kxm-insights/SKILL.md +1 -1
  42. package/plugins/kxm/skills/kxm-mind/SKILL.md +2 -2
  43. package/plugins/kxm/skills/{kxm-setup → kxm-mind-setup}/SKILL.md +4 -4
  44. package/plugins/kxm/skills/kxm-peer/SKILL.md +68 -93
  45. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +156 -23
  46. package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
  47. package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
  48. package/plugins/kxm/skills/kxm-query/SKILL.md +1 -1
  49. package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +74 -15
  50. package/plugins/kxm/skills/kxm-runs/SKILL.md +46 -17
  51. package/plugins/kxm/skills/kxm-session/SKILL.md +64 -36
  52. package/plugins/kxm/skills/kxm-skill-lifecycle/SKILL.md +44 -15
  53. package/plugins/kxm/skills/kxm-tasks/SKILL.md +16 -4
  54. package/plugins/kxm/skills/kxm-triage/SKILL.md +1 -1
  55. package/plugins/kxm/skills/kxm-work/SKILL.md +1 -1
  56. package/plugins/kxm/skills/kxm-workflow/SKILL.md +60 -19
  57. package/plugins/kxm/src/arbiter.ts +67 -22
  58. package/plugins/kxm/src/autocomplete.ts +1 -1
  59. package/plugins/kxm/src/claude-hook.ts +192 -0
  60. package/plugins/kxm/src/cli/project.ts +11 -5
  61. package/plugins/kxm/src/cli/system.ts +85 -13
  62. package/plugins/kxm/src/cli/types.ts +4 -1
  63. package/plugins/kxm/src/cli/workflows.ts +18 -16
  64. package/plugins/kxm/src/cli.ts +23 -13
  65. package/plugins/kxm/src/client.ts +15 -4
  66. package/plugins/kxm/src/commands.ts +19 -9
  67. package/plugins/kxm/src/config.ts +42 -7
  68. package/plugins/kxm/src/context-packet.ts +14 -2
  69. package/plugins/kxm/src/context.ts +16 -5
  70. package/plugins/kxm/src/dispatch-context.ts +286 -0
  71. package/plugins/kxm/src/engine-plan.ts +40 -0
  72. package/plugins/kxm/src/engine.ts +138 -6
  73. package/plugins/kxm/src/hub-env.ts +17 -1
  74. package/plugins/kxm/src/hub.ts +92 -29
  75. package/plugins/kxm/src/improve-sources.ts +228 -0
  76. package/plugins/kxm/src/improve.ts +325 -140
  77. package/plugins/kxm/src/local-snapshot.ts +101 -42
  78. package/plugins/kxm/src/mcp-server.ts +129 -30
  79. package/plugins/kxm/src/project-config.ts +25 -0
  80. package/plugins/kxm/src/protocol.ts +11 -0
  81. package/plugins/kxm/src/relevance.ts +138 -0
  82. package/plugins/kxm/src/retrospective.ts +16 -10
  83. package/plugins/kxm/src/runtime-service.ts +8 -1
  84. package/plugins/kxm/src/runtime-supervisor.ts +16 -2
  85. package/plugins/kxm/src/session-token-hint.ts +17 -0
  86. package/plugins/kxm/src/suggest.ts +7 -7
  87. package/plugins/kxm/src/workflow-manager.ts +80 -78
  88. package/plugins/kxm/src/workflow.ts +202 -12
  89. package/scripts/build-runtime.mjs +7 -1
  90. package/scripts/check-generated.mjs +1 -0
  91. package/scripts/emit-codex-artifacts.mjs +1 -1
@@ -1,70 +1,250 @@
1
- # KXM
1
+ # KXM Claude Code plugin
2
2
 
3
- Connect a Claude Code session to running Pi or Claude peers through the KXM hub.
3
+ This plugin connects a Claude Code session to a KXM hub. Claude can then exchange requests with Pi and Claude peers, work on durable workflow runs, and read the project's KXM context. The same directory is also the source of the repository's Pi extension and of the KXM Agent Skills.
4
4
 
5
- This directory is both a Claude Code plugin and the source of the repository's Pi extension and shared Agent Skill.
5
+ This page is the plugin reference. For the whole path from an empty repository to a first workflow (initialize, start the hub, install this plugin, run a workflow), follow the root README: [Set up a new project with Claude Code](../../README.md#set-up-a-new-project-with-claude-code).
6
6
 
7
7
  ## Requirements
8
8
 
9
- - Node.js 22.19 or newer on the 22.x line, or Node.js 24 or newer;
10
- - a running KXM hub;
11
- - the same authentication token and project name used by the other agents.
9
+ - Node.js 22.19 or newer on the 22.x line, or Node.js 24 or newer, on the `PATH` that Claude Code uses. The plugin's MCP server and its hook both run `node`.
10
+ - A running KXM hub that Claude Code can reach. The operator starts it with [`kxm hub start`](../../docs/cli-reference.md#kxm-hub-start).
11
+ - A project token for this project on that hub. See [Which token to use](#which-token-to-use).
12
+ - The `kxm` CLI, to create projects and run the hub. The plugin does not install it:
12
13
 
13
- ## Install in Claude Code
14
+ ```bash
15
+ npm install --global --omit=peer @kontextmind/kxm
16
+ ```
17
+
18
+ The plugin's hook and MCP server run from the plugin's own bundled files, so they do not need `kxm` on `PATH`.
19
+
20
+ `kxm init` writes no Git ignore rules. Add `.kxm/state/` and `.kxm/logs/` to `.gitignore` yourself, and commit the rest of `.kxm/`. [Workspace layout](../../docs/config-reference.md#workspace-layout-tracked-ignored-and-state) lists what to track.
21
+
22
+ ## Install
23
+
24
+ In Claude Code:
14
25
 
15
26
  ```text
16
27
  /plugin marketplace add kontextmind/kxm
17
- /plugin install kxm
28
+ /plugin install kxm@kxm
18
29
  /reload-plugins
19
30
  ```
20
31
 
21
- Configure the hub URL, token, unique agent name, purpose, and project when prompted. Then ask Claude to call `kxm_list` to confirm that it can see the expected peers.
32
+ Choose project scope to share the plugin with everyone who works in the repository.
33
+
34
+ From a shell, the same install at project scope:
35
+
36
+ ```bash
37
+ claude plugin marketplace add kontextmind/kxm
38
+ claude plugin install kxm@kxm --scope project \
39
+ --config server_url=http://127.0.0.1:7331 \
40
+ --config agent_name=<unique agent name> \
41
+ --config agent_purpose="<what this agent does>" \
42
+ --config project=<hub project key>
43
+ ```
44
+
45
+ A project-scope install writes `{"enabledPlugins": {"kxm@kxm": true}}` to `.claude/settings.json`. Claude Code then prints `1 userConfig option not yet set` for the empty `auth_token`, which is expected on the machine that runs the hub.
46
+
47
+ Enter `auth_token` only at `/plugin configure kxm@kxm` inside Claude Code. Do not pass it with `--config`, which leaves the token in your shell history.
48
+
49
+ To check the connection, start Claude Code in the project (or run `/reload-plugins`), confirm in `/mcp` that the `kxm` server is connected, and ask Claude to call `kxm_list`. It lists this session in your hub project.
50
+
51
+ ## Configure
52
+
53
+ Claude Code asks for these options when you install the plugin. Change them later with `/plugin configure kxm@kxm`, then restart Claude Code: the MCP server reads them when it starts. The plugin's `.mcp.json` passes each option to the MCP server as an environment variable.
54
+
55
+ | Option | Variable | Default | What to enter |
56
+ |---|---|---|---|
57
+ | `server_url` | `KXM_SERVER_URL` | `http://127.0.0.1:7331` | URL of the KXM hub. The SessionStart hook probes the same URL. |
58
+ | `auth_token` | `KXM_AUTH_TOKEN` | Blank | The project token for this project, 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
+ | `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
+ | `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. It must match a key in the hub's `KXM_PROJECT_TOKENS`. Blank uses the `name` in `package.json` in the project directory, then the directory name. |
62
+
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
+
65
+ ### Which token to use
66
+
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
+
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/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.
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.
73
+
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. The root README section [Add Claude Code to an existing KXM project](../../README.md#add-claude-code-to-an-existing-kxm-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
+
76
+ ## What the plugin adds
77
+
78
+ ### MCP server
79
+
80
+ `.mcp.json` starts `node ${CLAUDE_PLUGIN_ROOT}/dist/mcp-server.js` over stdio. The server registers with the hub as `agent_name` in the hub project:
22
81
 
23
- ## Tools
82
+ - at startup, when the project directory has `.kxm/`, a project token is available, and the KXM session policy (if any) allows `kxm_inbox` and `kxm_reply`. Peers see the session, and requests can reach it, before Claude calls any tool.
83
+ - otherwise, at the first `kxm_*` tool call.
24
84
 
25
- | Tool | Use |
85
+ The server's instructions tell Claude to call `kxm_context` with its role and task before planning in a KXM project, and to answer peer requests with `kxm_reply`. When a tool reports a hub or token problem, the error names the fix, and Claude is told to continue without KXM and pass that step on to you.
86
+
87
+ ### SessionStart hook
88
+
89
+ The plugin registers one SessionStart hook: `node ${CLAUDE_PLUGIN_ROOT}/dist/claude-hook.js session-start`, with a 5-second timeout. Claude Code shows `KXM brief` while it runs.
90
+
91
+ **Only in KXM projects.** The hook looks for `.kxm/` in the directory Claude Code was started in, not in its parents. Without it, the hook prints nothing and adds no context. The MCP tools and skills still load in every project.
92
+
93
+ **What it adds.** In a KXM project the hook adds, in this order:
94
+
95
+ 1. `KXM project <project> · hub <on|off|unknown> at <server_url>`, from a 300 ms health probe of `server_url`.
96
+ 2. Up to three active runs of this project (created, preparing, running or waiting), each with its workflow, status and current stage, marked `(assigned to you)` when the run is assigned to `agent_name`.
97
+ 3. How many open peer requests are addressed to `agent_name`. It is a count only, with no request text.
98
+ 4. Where to start: `kxm_context` with your role and task before planning, `kxm_workflow_get <runId>` for an assigned run, and `kxm_inbox` then `kxm_reply` for peer requests.
99
+ 5. When the hub is off or unknown: that `kxm_*` tools will fail until you start it with `kxm hub start`.
100
+ 6. When the KXM session token is invalid: the fix, which is `kxm session token --clear` for a token file, or unsetting or replacing `KXM_SESSION_TOKEN` in the environment Claude Code was launched from. See [Troubleshooting](#troubleshooting).
101
+ 7. The project memory brief, verbatim: the active facts in `.kxm/memory/`, the same text [`kxm memory brief`](../../docs/cli-reference.md#kxm-memory-brief) prints.
102
+
103
+ Items 1 to 6 are capped at 1,500 characters. The memory brief follows them in full. If the whole context exceeds Claude Code's 10,000-character hook limit, Claude Code saves it to a file and shows a preview; the status lines come first, so they stay in the preview.
104
+
105
+ **Read-only.** The hook writes no files, mints no session token, starts no hub, runs no `git`, and needs no `kxm` on `PATH`. It reads `.kxm/project.yaml`, `.kxm/memory/`, the hub database under `.kxm/state/`, the Runtime registry and this project's run store under the user state root, and whether a KXM session token is valid.
106
+
107
+ **Scoped to this project.** Runs and request counts come only from this hub project and this project's Runtime runs, never from other projects on the machine. The hook never shows plan or journal text, message bodies, tokens, or any plugin option other than `server_url`, `agent_name` and `project`.
108
+
109
+ **Time-bounded, and it never fails a session.** Claude Code stops the hook after 5 seconds. Within that, reading the hook input waits at most 300 ms, the health probe at most 300 ms, and each SQLite read gives up on a locked database after 250 ms. The hook always exits 0. If anything goes wrong it prints nothing, and the session starts without the brief.
110
+
111
+ ### Skills
112
+
113
+ The plugin ships the KXM Agent Skills. The `kxm` skill teaches Claude when and how to use the tools below safely and points to the rest of the suite. See [Agent Skills](../../docs/agent-skills.md) for the full list.
114
+
115
+ ## MCP tools
116
+
117
+ Every tool acts as this session's agent (`agent_name`) in the hub project.
118
+
119
+ ### Peers
120
+
121
+ | Tool | What it does |
26
122
  |---|---|
27
- | `kxm_list` | Discover online peers and their purposes |
28
- | `kxm_send` | Send one focused request and receive a message ID; attach authorized workflow context when the reply must count as peer evidence |
29
- | `kxm_fanout` | Ask one to three peers independently; local wait expiry returns recoverable pending handles and workflow context supports per-requirement provenance |
30
- | `kxm_get` | Check a request without blocking |
31
- | `kxm_await` | Wait when the reply blocks progress |
32
- | `kxm_cancel` | Cancel pending work owned by this sender |
33
- | `kxm_inbox` | List and reconcile durable inbound requests when pushed channel delivery is unavailable |
34
- | `kxm_reply` | Return a final response to an inbound request |
35
- | `kxm_workflow_list` | List webhook workflows assigned to this coordinator |
36
- | `kxm_workflow_get` | Read stages and the structured workflow journal |
37
- | `kxm_workflow_checkpoint` | Pass a gate with exact keyed evidence and hub-verified peer message references, or record a warning/failure that must be retried |
38
- | `kxm_workflow_wait` | Preserve keyed local evidence and verified peer references, then release the turn until a signed CI, review, merge, or Jira callback arrives |
39
- | `kxm_workflow_record` | Capture a plan, decision, contradiction, error, or lesson |
40
- | `kxm_improvement_report` | Group learning evidence by improvement area |
41
-
42
- The bundled `kxm` skill teaches Claude when and how to use these tools safely. For the complete KXM Agent Skills suite covering all KXM commands, see the [Agent Skills documentation](../../docs/agent-skills.md).
43
-
44
- Signed webhooks can create durable workflows for long-lived Pi coordinators. See the repository's [Webhook workflows](../../docs/webhook-workflows.md) guide and Jira development example.
45
-
46
- Workflow authors can require replied messages from a snapshotted set of
47
- eligible peer identities. The coordinator supplies exact `workflowContext` on
48
- the send or fanout and later cites returned message IDs in `evidenceRefs`; the
49
- hub derives provenance and counts unique producers. Ordinary evidence strings,
50
- correlation IDs, and idempotency prefixes do not satisfy a peer policy. See
51
- [Peer provenance and quorum gates](../../docs/provenance-gates.md) for the
52
- schema, command-first runbook, explicit admin degradation, retention model, and
53
- trust boundary.
54
-
55
- Repository-local configuration, logs, workflow assets, and SQLite state use the `.kxm` workspace layout. Configuration and intentional assets can be tracked; runtime logs, generated assets, and state are ignored. See [Configuration](../../docs/configuration.md) for defaults and overrides.
56
-
57
- ## Pushed inbound requests
58
-
59
- Claude Code channels can inject peer requests into a running session. During the research preview, launch this community channel explicitly:
123
+ | `kxm_list` | Lists peers in this project with their names, purposes, host labels and presence (online, stale, offline). `includeOffline` adds registered peers whose lease expired. |
124
+ | `kxm_send` | Sends one focused request to a peer and returns a message ID for `kxm_get` or `kxm_await`. Pass `workflowContext` when the reply must count as peer evidence for a workflow gate. |
125
+ | `kxm_get` | Checks a sent request's status and reply without waiting. |
126
+ | `kxm_fanout` | Asks one to three peers the same question independently, for comparison. A local timeout returns pending entries with durable message IDs to check later. |
127
+ | `kxm_await` | Waits for the reply to a sent request, for at most 60 seconds. For longer external work, use `kxm_workflow_wait`. |
128
+ | `kxm_cancel` | Cancels a queued or delivered request that this agent sent. |
129
+ | `kxm_inbox` | Lists inbound peer requests that still need a reply (pull mode). |
130
+ | `kxm_reply` | Sends the final reply to an inbound request by its message ID. |
131
+
132
+ ### Workflows
133
+
134
+ These tools work on durable hub workflows, the ones started by signed webhooks or `kxm workflow start` (see [Webhook workflows](../../docs/webhook-workflows.md)). Runs created with `kxm run` are Runtime runs; inspect those with `kxm runs status` in a terminal.
135
+
136
+ | Tool | What it does |
137
+ |---|---|
138
+ | `kxm_workflow_list` | Lists durable workflows assigned to this agent. |
139
+ | `kxm_workflow_get` | Reads a run's stages and its journal. |
140
+ | `kxm_workflow_checkpoint` | Records a stage result (passed, warning or failed) with evidence keyed by the stage's required evidence. Cite peer replies through `evidenceRefs` so the hub can verify provenance and quorum. Warnings and failures need another attempt. |
141
+ | `kxm_workflow_record` | Adds a journal entry: plan, decision, contradiction, error, lesson, observation, hypothesis, experiment, state-change or skill-candidate. Lessons and skill candidates need evidence. |
142
+ | `kxm_workflow_wait` | Parks the active stage until a signed external callback (CI, review, merge, Jira) checkpoints it and resumes the coordinator. |
143
+ | `kxm_improvement_report` | Summarizes errors, contradictions, lessons and skill candidates by improvement area, with ranked cross-run signals. |
144
+
145
+ Workflow authors can require replies from a snapshotted set of eligible peers. The coordinator passes exact `workflowContext` to `kxm_send` or `kxm_fanout` and later cites the returned message IDs in `evidenceRefs`; the hub derives provenance and counts unique producers. Evidence strings, correlation IDs and idempotency keys do not satisfy a peer policy. See [Peer provenance and quorum gates](../../docs/provenance-gates.md).
146
+
147
+ ### Context
148
+
149
+ | Tool | What it does |
150
+ |---|---|
151
+ | `kxm_context` | The starting point for KXM context. Builds a token-budgeted, role-aware packet of evidence, temporal state, episodes, knowledge and skills for a role and task, optionally scoped to a workflow run and stage. Superseded and rejected records are left out. |
152
+ | `kxm_recall` | Searches durable context records by query and returns bounded metadata with a relevance score, never summaries. |
153
+ | `kxm_state` | Reads the current value of one temporal state key, or its value as of an ISO-8601 timestamp. |
154
+ | `kxm_episode` | Reads episodic learning (errors, lessons, observations, experiments) from workflow journals, optionally for one run. |
155
+ | `kxm_promote` | Proposes a change to one authoritative state key, backed by evidence references. It only proposes: the hub returns a proposal ID, and an operator applies it with [`kxm context promote`](../../docs/cli-reference.md#kxm-context-promote). |
156
+
157
+ ## Pushed channel mode and pull mode
158
+
159
+ Peer requests reach Claude in one of two ways. Everything else, including `kxm_send`, `kxm_fanout`, the workflow tools and the context tools, works the same in both.
160
+
161
+ **Pull mode** is the default. Claude checks for work with `kxm_inbox`, handles one request, and answers it with `kxm_reply` and the request's message ID. Nothing arrives on its own: ask Claude to check the inbox, or to poll it with a backoff while it waits. The MCP server keeps the inbox, filling it from the hub's event stream while it is registered; in a KXM project with a project token that starts with the session.
162
+
163
+ **Pushed channel mode** uses Claude Code channels to inject each peer request into the running session as a `<channel source="kxm" message_id="...">` event, which Claude handles and answers with `kxm_reply`. During the channels research preview, start Claude Code with the community channel explicitly and review the trust prompt:
60
164
 
61
165
  ```text
62
- claude --dangerously-load-development-channels plugin:kxm
166
+ claude --dangerously-load-development-channels plugin:kxm@kxm
167
+ ```
168
+
169
+ If your organization has approved the plugin through `allowedChannelPlugins`, use `claude --channels plugin:kxm@kxm` instead. Organization policy can still block channels; `kxm_inbox` and `kxm_reply` keep working either way.
170
+
171
+ ## Update
172
+
173
+ The root README section [Update an existing install](../../README.md#update-an-existing-install) covers the CLI and the plugin together. For the plugin alone:
174
+
175
+ - User scope: `claude plugin marketplace update kxm`, then `claude plugin update kxm@kxm`.
176
+ - Project scope: `claude plugin marketplace update kxm`, then `claude plugin update kxm@kxm --scope project`. Without `--scope project` the update fails with `Plugin "kxm" is not installed at scope user`.
177
+ - Then restart Claude Code.
178
+
179
+ **The version pin.** Claude Code installs new plugin code only when the plugin version changes. This plugin is pinned at `0.7.1` in `plugin.json` and `marketplace.json`, so `claude plugin update` prints `kxm is already at the latest version (0.7.1).` and keeps the cached copy. Existing installs therefore do not receive plugin changes, including the SessionStart hook and MCP server behaviour described on this page, until the next version bump. To refresh the cached copy now, reinstall:
180
+
181
+ ```bash
182
+ claude plugin marketplace update kxm
183
+ claude plugin uninstall kxm@kxm --scope project
184
+ claude plugin install kxm@kxm --scope project \
185
+ --config server_url=http://127.0.0.1:7331 \
186
+ --config agent_name=<unique agent name> \
187
+ --config agent_purpose="<what this agent does>" \
188
+ --config project=<hub project key>
63
189
  ```
64
190
 
65
- Review the trust prompt. If your organization has approved the plugin through `allowedChannelPlugins`, use the normal `--channels` selector instead.
191
+ Drop `--scope project` for a user-scope install. Reinstalling discards the plugin options: without `--config`, Claude Code prints `5 userConfig options not yet set (3 required)`. Pass them again as above, re-enter `auth_token` at `/plugin configure kxm@kxm` if you use one, and restart Claude Code.
192
+
193
+ Once an install has the new plugin code, after a version bump or the reinstall above:
194
+
195
+ - A blank `auth_token` no longer falls back to the hub admin token. Each project needs its own project token; see [Which token to use](#which-token-to-use).
196
+ - The previous SessionStart hooks ran `kxm session brief --status` and `kxm memory brief`. They needed `kxm` on `PATH`, and the first one saved a 24-hour session token. The new hook does neither, and nothing in the plugin refreshes that token, so once it expires it blocks every `kxm_*` tool until you clear it; see [Troubleshooting](#troubleshooting).
197
+
198
+ ## Troubleshooting
199
+
200
+ Tool errors and the SessionStart brief name the fix, addressed to you. Run the commands below in your own terminal rather than through Claude, and never paste tokens into Claude. [Troubleshooting](../../docs/troubleshooting.md) covers the hub and workers.
201
+
202
+ ### The `kxm_*` tools do not appear
203
+
204
+ 1. Check `/mcp` for the `kxm` server and its connection error.
205
+ 2. Check that `node --version` in the environment Claude Code starts from is 22.19 or newer on 22.x, or 24 or newer.
206
+ 3. Run `/reload-plugins`, or restart Claude Code.
207
+ 4. Check that `claude plugin list` shows `kxm@kxm` with `Status: ✔ enabled`.
66
208
 
67
- Channel mode is optional. `kxm_inbox` and `kxm_reply` remain available through ordinary MCP.
209
+ ### `KXM hub unreachable at <url>`
210
+
211
+ No hub answers at `server_url`. Start it with `kxm hub start`, or correct `server_url` with `/plugin configure kxm@kxm` and restart Claude Code.
212
+
213
+ ### `no project token for project <p>`
214
+
215
+ 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.
216
+
217
+ ### `KXM hub rejected the project token for project <p>`
218
+
219
+ `auth_token` is not the token the hub holds for `<p>`. Enter the right one at `/plugin configure kxm@kxm`.
220
+
221
+ ### `tool_policy_denied: Session token on disk is malformed or expired`
222
+
223
+ The same fix applies to `Session token file on disk could not be read`. A KXM session token file in your KXM user configuration directory blocks every `kxm_*` tool. Run [`kxm session token --clear`](../../docs/cli-reference.md#kxm-session-token); it prints `Session token cleared from disk.` `kxm session token --status` prints `No active session token found in env or disk` for such a file even though the file still blocks the tools, so it cannot confirm this problem. Do not use `--issue`: it prints the token and only re-arms it for 24 hours. With no token file and no `KXM_SESSION_TOKEN`, the MCP server applies no session policy.
224
+
225
+ ### `tool_policy_denied: KXM_SESSION_TOKEN is malformed or expired`
226
+
227
+ `KXM_SESSION_TOKEN` in the environment Claude Code was launched from is bad. Unset or replace it there, then restart Claude Code. `kxm session token --clear` does not help here; `kxm session token --status` prints `Session token in env is invalid or expired`.
228
+
229
+ ### The session appears as `<name>-<pid>`
230
+
231
+ Another active session in the same project already uses `agent_name`, so this one registered with its process ID appended. This is expected.
232
+
233
+ ### No KXM brief at session start
234
+
235
+ The hook runs only when the directory Claude Code was started in contains `.kxm/`. Start Claude Code from the project root, or run `kxm init` there. A SessionStart hook error that mentions `node` means `node` is not on the `PATH` Claude Code uses.
236
+
237
+ ### `kxm is already at the latest version (0.7.1)` but the plugin is out of date
238
+
239
+ That is the version pin. Use the reinstall in [Update](#update).
240
+
241
+ ### `kxm_await` reports `timed out waiting for <messageId>`
242
+
243
+ `kxm_await` waits at most 60 seconds. The request is still pending: check it later with `kxm_get`, or use `kxm_workflow_wait` for long external work.
244
+
245
+ ### Pushed requests do not arrive
246
+
247
+ Start Claude Code with the channel flag from [Pushed channel mode and pull mode](#pushed-channel-mode-and-pull-mode) and accept the trust prompt, or use `kxm_inbox`.
68
248
 
69
249
  ## Safety and limits
70
250
 
@@ -72,22 +252,24 @@ Channel mode is optional. `kxm_inbox` and `kxm_reply` remain available through o
72
252
  - Peer quorum proves durable provenance within the shared project-token boundary, not truth, model independence, non-collusion, or approval authority.
73
253
  - Do not send secrets, credentials, or unnecessary private data.
74
254
  - The hub persists state in SQLite by default; protect its database as sensitive data.
75
- - Cancellation stops mesh processing but cannot roll back filesystem or external side effects.
255
+ - Cancellation stops KXM processing but cannot roll back filesystem or external side effects.
76
256
  - Use separate worktrees or a single-writer rule when peers can edit files.
77
257
  - Keep the hub on localhost unless it is protected with authentication, TLS, and network controls.
78
258
 
79
259
  ## Development
80
260
 
81
- Edit `src/mcp-server.ts`, not the generated bundle. From the repository root, run:
261
+ Edit the TypeScript under `src/`, never the generated bundles: `src/mcp-server.ts` builds to `dist/mcp-server.js`, and `src/claude-hook.ts` builds to `dist/claude-hook.js`. From the repository root:
82
262
 
83
- ```powershell
84
- npm run build:mcp
263
+ ```bash
264
+ npm run build
85
265
  npm run verify
86
266
  ```
87
267
 
88
- Plugin manifests are validated in CI (`Plugin validation` with pinned
89
- `claude plugin validate`). Commit `dist/mcp-server.js` with the corresponding
90
- source change. The bundle includes the official MCP SDK so marketplace users
91
- do not need a post-install dependency step.
268
+ The bundles include their dependencies, so marketplace installs need no post-install step. Commit the rebuilt `dist/` files with the source change; `npm run check:generated` fails when they are stale. CI validates both plugin manifests with `claude plugin validate` (`npm run validate:claude`). `test/core/claude-plugin-docs.test.ts` fails when the [MCP tools](#mcp-tools) tables and the tools `dist/mcp-server.js` publishes disagree, so add or remove a row in the same change as the tool.
269
+
270
+ ## More documentation
92
271
 
93
- For installation, configuration, every CLI command, Pi session isolation, Claude channel/pull modes, workflows, gates, and recovery, read the wiki-ready [KXM Handbook](../../docs/kxm-handbook.md). The shorter [Getting started](../../docs/getting-started.md) and [Operations](../../docs/operations.md) guides remain task-focused references.
272
+ - [KXM Handbook](../../docs/kxm-handbook.md): installation, configuration, Claude channel and pull modes, workflows, gates and recovery.
273
+ - [Getting started](../../docs/getting-started.md) and [Operations](../../docs/operations.md): task-focused guides.
274
+ - [CLI reference](../../docs/cli-reference.md): every `kxm` command, with options and output.
275
+ - [Configuration reference](../../docs/config-reference.md): every `.kxm` file, the workspace layout, and state outside the project.