@kontextmind/kxm 0.7.94 → 0.7.96

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 (140) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/README.md +39 -9
  3. package/CHANGELOG.md +1 -1
  4. package/README.md +147 -257
  5. package/SECURITY.md +21 -12
  6. package/docs/README.md +133 -54
  7. package/docs/adr/ADR-0002-browser-automation-steel-doks.md +24 -18
  8. package/docs/adr/ADR-0003-sqlite-only-store.md +100 -0
  9. package/docs/adr/ADR-0004-edge-identity-authentik.md +99 -0
  10. package/docs/adr/README.md +33 -0
  11. package/docs/concepts/architecture.md +262 -0
  12. package/docs/concepts/data-and-storage.md +194 -0
  13. package/docs/concepts/trust-model.md +152 -0
  14. package/docs/contracts/README.md +22 -14
  15. package/docs/contracts/effects-and-recovery.md +3 -0
  16. package/docs/contracts/migration.md +2 -2
  17. package/docs/contracts/routing.md +6 -5
  18. package/docs/contributing/assignment-runner.md +388 -0
  19. package/docs/contributing/ci-and-release.md +231 -0
  20. package/docs/contributing/development.md +362 -0
  21. package/docs/contributing/harness-routing-internals.md +192 -0
  22. package/docs/{packages.md → contributing/packages.md} +13 -15
  23. package/docs/{skills → contributing}/repo-work-delivery.md +20 -21
  24. package/docs/contributing/test-matrix.md +208 -0
  25. package/docs/{tui-components.md → contributing/tui-components.md} +30 -22
  26. package/docs/contributing/writing-docs.md +340 -0
  27. package/docs/glossary.md +471 -0
  28. package/docs/guides/agent-skills.md +137 -0
  29. package/docs/guides/browser-automation.md +160 -0
  30. package/docs/guides/context-and-memory.md +352 -0
  31. package/docs/guides/continuous-improvement.md +228 -0
  32. package/docs/guides/governed-skills.md +173 -0
  33. package/docs/guides/nous-providers.md +186 -0
  34. package/docs/guides/peer-messaging.md +304 -0
  35. package/docs/guides/pi-workers.md +219 -0
  36. package/docs/guides/provenance-gates.md +313 -0
  37. package/docs/guides/webhook-workflows.md +364 -0
  38. package/docs/kb/how-credentials-retrieved-safely.md +38 -12
  39. package/docs/kb/how-to-capture-and-annotate-section.md +15 -13
  40. package/docs/kb/how-to-connect-playwright-to-steel.md +16 -11
  41. package/docs/kb/how-to-recover-expired-session-or-orphan.md +26 -16
  42. package/docs/kb/how-to-resume-after-mfa.md +19 -11
  43. package/docs/kb/how-to-take-over-session.md +17 -13
  44. package/docs/kb/why-authentication-disappeared.md +22 -14
  45. package/docs/kb/why-automation-opened-different-browser.md +23 -14
  46. package/docs/kb/why-session-viewer-cannot-control.md +13 -12
  47. package/docs/operations/backup-and-restore.md +248 -0
  48. package/docs/operations/deploy.md +307 -0
  49. package/docs/operations/monitoring.md +209 -0
  50. package/docs/operations/runtime-sync.md +192 -0
  51. package/docs/operations/troubleshooting.md +265 -0
  52. package/docs/operations/upgrade.md +124 -0
  53. package/docs/prompts/browser-annotate-feedback.md +7 -7
  54. package/docs/prompts/browser-diagnose-recover.md +11 -10
  55. package/docs/prompts/browser-explore.md +7 -7
  56. package/docs/prompts/browser-repro-fix.md +7 -7
  57. package/docs/prompts/browser-start.md +12 -11
  58. package/docs/prompts/browser-takeover.md +8 -8
  59. package/docs/{cli-reference.md → reference/cli-reference.md} +83 -41
  60. package/docs/{config-reference.md → reference/config-reference.md} +159 -148
  61. package/docs/reference/configuration.md +299 -0
  62. package/docs/reference/harness-routing.md +508 -0
  63. package/docs/reference/http-api.md +203 -0
  64. package/docs/reference/tools.md +370 -0
  65. package/docs/{workflow-guide.md → reference/workflow-catalog.md} +92 -153
  66. package/docs/reference/workflow-definitions.md +286 -0
  67. package/docs/start/first-workflow.md +287 -0
  68. package/docs/start/install.md +146 -0
  69. package/docs/start/quickstart-claude-code.md +405 -0
  70. package/docs/start/quickstart-pi.md +213 -0
  71. package/docs/templates/README.md +78 -73
  72. package/docs/templates/adr.md +13 -13
  73. package/docs/templates/architecture.md +55 -71
  74. package/docs/templates/bug-fix.md +13 -16
  75. package/docs/templates/feature.md +14 -19
  76. package/docs/templates/handoff.md +44 -46
  77. package/docs/templates/postmortem.md +30 -43
  78. package/docs/templates/research.md +15 -20
  79. package/docs/templates/review.md +49 -50
  80. package/docs/templates/runbook.md +38 -30
  81. package/docs/templates/test-plan.md +16 -23
  82. package/docs/templates/test-report.md +14 -17
  83. package/examples/README.md +9 -5
  84. package/examples/provenance-workflow.json +1 -1
  85. package/examples/webhook-workflows/jira-development.json +59 -0
  86. package/examples/webhook-workflows/jira-issue-updated.json +12 -0
  87. package/package.json +2 -2
  88. package/packages/core/tui/README.md +1 -1
  89. package/plugins/kxm/.claude-plugin/plugin.json +1 -1
  90. package/plugins/kxm/README.md +31 -32
  91. package/plugins/kxm/dist/cli.js +5 -5
  92. package/plugins/kxm/dist/mcp-server.js +1 -1
  93. package/plugins/kxm/dist/runtime.js +1 -1
  94. package/plugins/kxm/package.json +1 -1
  95. package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
  96. package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
  97. package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
  98. package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
  99. package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
  100. package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
  101. package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
  102. package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
  103. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
  104. package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
  105. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
  106. package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
  107. package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
  108. package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
  109. package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
  110. package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
  111. package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
  112. package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
  113. package/plugins/kxm/src/cli/system.ts +1 -1
  114. package/plugins/kxm/src/cli.ts +3 -3
  115. package/plugins/kxm/src/init-guide-setup.ts +1 -1
  116. package/plugins/kxm/src/mcp-server.ts +1 -1
  117. package/plugins/kxm/src/modes.ts +1 -1
  118. package/schemas/README.md +1 -1
  119. package/docs/agent-communication-envelopes-and-gates.md +0 -553
  120. package/docs/agent-skills.md +0 -198
  121. package/docs/architecture.md +0 -245
  122. package/docs/assignment-runner.md +0 -264
  123. package/docs/browser-automation.md +0 -139
  124. package/docs/configuration.md +0 -437
  125. package/docs/continuous-improvement.md +0 -226
  126. package/docs/getting-started.md +0 -277
  127. package/docs/harness-routing.md +0 -616
  128. package/docs/kb/qa-authentik-authentication.md +0 -97
  129. package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
  130. package/docs/kb/qa-hub-on-a-public-host.md +0 -48
  131. package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
  132. package/docs/kb/qa-what-the-hub-stores.md +0 -64
  133. package/docs/kxm-handbook.md +0 -1181
  134. package/docs/operations.md +0 -510
  135. package/docs/operator-pi-packages.md +0 -67
  136. package/docs/provenance-gates.md +0 -295
  137. package/docs/skills.md +0 -47
  138. package/docs/test-matrix.md +0 -132
  139. package/docs/troubleshooting.md +0 -293
  140. package/docs/webhook-workflows.md +0 -240
@@ -0,0 +1,146 @@
1
+ # Install KXM
2
+
3
+ KXM has three parts you can install: the `kxm` command-line tool, the Claude Code plugin, and the Pi package. This page installs each one and shows how to check it. Install the CLI first, because it is the only part that creates projects and starts a [hub](../glossary.md#hub); the plugin and the Pi package connect agents to one.
4
+
5
+ ## Before you begin
6
+
7
+ - Node.js 22.19 or newer on the 22.x line, or Node.js 24 or newer, with npm. Check with `node --version`.
8
+ - Git.
9
+ - Claude Code, if you want the plugin.
10
+ - Pi, if you want Pi agents. Install it with `npm install --global @earendil-works/pi-coding-agent` and sign in to a model provider as the [Pi documentation](https://pi.dev/docs/latest) describes.
11
+ - The GitHub CLI (`gh`), only if you plan to update with `kxm update --kxm`, which downloads the release tarball from GitHub.
12
+
13
+ ## Choose what to install
14
+
15
+ | Part | What it gives you | How to install |
16
+ |---|---|---|
17
+ | `kxm` CLI | `kxm init`, the hub, runs, backups and updates. Every setup needs it. | [npm](#install-the-cli) |
18
+ | Claude Code plugin | MCP tools, KXM skills, a session-start brief, and optional pushed requests | [Claude Code marketplace](#install-the-claude-code-plugin) |
19
+ | Pi package | The Pi extension (tools, the `/kxm` command, hub auto-start) and KXM skills | [`pi install`](#install-the-pi-package) |
20
+ | Source checkout | The same CLI from a clone, for contributors | [`git clone` and `npm ci`](#run-from-a-source-checkout) |
21
+
22
+ ## Install the CLI
23
+
24
+ 1. Confirm that npm can see the package:
25
+
26
+ ```bash
27
+ npm view @kontextmind/kxm version
28
+ ```
29
+
30
+ Expected output: the latest published version number.
31
+
32
+ 2. Install it globally:
33
+
34
+ ```bash
35
+ npm install --global --omit=peer @kontextmind/kxm
36
+ ```
37
+
38
+ `--omit=peer` skips the package's peer dependencies. They are Pi libraries that only the Pi extension loads, and Pi supplies them itself.
39
+
40
+ 3. Check that `kxm` is on your `PATH`:
41
+
42
+ ```bash
43
+ kxm --version
44
+ ```
45
+
46
+ Expected output: the same version number that `npm view` printed.
47
+
48
+ Optionally, install tab completion for bash, zsh or fish. It also adds the npm global `bin` directory to `PATH` in your shell startup file when it is missing:
49
+
50
+ ```bash
51
+ kxm completion install
52
+ ```
53
+
54
+ > [!NOTE]
55
+ > Only the npm install puts `kxm` on your `PATH`. The Claude Code plugin and the Pi package do not install the CLI.
56
+
57
+ ## Install the Claude Code plugin
58
+
59
+ In Claude Code:
60
+
61
+ ```text
62
+ /plugin marketplace add kontextmind/kxm
63
+ /plugin install kxm@kxm
64
+ /reload-plugins
65
+ ```
66
+
67
+ Choose project scope to share the plugin with everyone who works in the repository. Claude Code then asks for the plugin options; [Quick start: Claude Code](quickstart-claude-code.md#6-configure-the-plugin) explains each one.
68
+
69
+ The same install from a shell, at project scope:
70
+
71
+ ```bash
72
+ claude plugin marketplace add kontextmind/kxm
73
+ claude plugin install kxm@kxm --scope project
74
+ ```
75
+
76
+ Expected output:
77
+
78
+ ```text
79
+ ✔ Successfully installed plugin: kxm@kxm (scope: project)
80
+ 5 userConfig options not yet set (3 required) — run /plugin configure kxm@kxm in Claude Code, or pass --config KEY=VALUE.
81
+ ```
82
+
83
+ A project-scope install writes `{"enabledPlugins": {"kxm@kxm": true}}` to `.claude/settings.json`. Commit that file so teammates get the plugin too.
84
+
85
+ The plugin's MCP server and its session-start hook run `node` from the `PATH` that Claude Code uses. They are bundled with the plugin, so they do not need `kxm` on `PATH`.
86
+
87
+ ## Install the Pi package
88
+
89
+ In a terminal:
90
+
91
+ ```bash
92
+ pi install git:github.com/kontextmind/kxm@main
93
+ ```
94
+
95
+ Restart Pi after you install or update the package. `pi list` shows it.
96
+
97
+ The package adds the KXM extension and the KXM Agent Skills to Pi. The extension registers the `kxm_*` tools and the `/kxm` command, and by default it starts a local hub in the background when none is running. [Quick start: Pi](quickstart-pi.md) connects two Pi agents.
98
+
99
+ ## Run from a source checkout
100
+
101
+ Contributors can run the CLI from a clone instead of installing it:
102
+
103
+ ```bash
104
+ git clone https://github.com/kontextmind/kxm.git
105
+ cd kxm
106
+ npm ci
107
+ node scripts/kxm.mjs --version
108
+ ```
109
+
110
+ Use `node scripts/kxm.mjs` wherever the docs show `kxm`. It runs the CLI bundle committed in `plugins/kxm/dist/`. Update a checkout with `git pull` and `npm ci`; `kxm update --kxm` refuses to run there. [Develop KXM](../contributing/development.md) covers building and testing.
111
+
112
+ ## Update
113
+
114
+ | Part | Command |
115
+ |---|---|
116
+ | `kxm` CLI | `npm install --global --omit=peer @kontextmind/kxm@latest` (check first with `kxm update --check`) |
117
+ | Claude Code plugin | `claude plugin marketplace update kxm`, then uninstall and reinstall the plugin; `claude plugin update` never refreshes it |
118
+ | Pi package | `pi update --extensions` |
119
+
120
+ Back up and stop the hub before you update the CLI. [Update the plugin](quickstart-claude-code.md#update-the-plugin) gives the reinstall commands and explains why an update is not enough, and [Upgrade KXM](../operations/upgrade.md) covers the full procedure and rollback.
121
+
122
+ ## Uninstall
123
+
124
+ ```bash
125
+ npm uninstall --global @kontextmind/kxm
126
+ claude plugin uninstall kxm@kxm
127
+ pi remove git:github.com/kontextmind/kxm
128
+ ```
129
+
130
+ Add `--scope project` to the `claude plugin uninstall` command for a project-scope install. Uninstalling leaves project files (`.kxm/`) and the hub database in place.
131
+
132
+ ## Troubleshooting
133
+
134
+ | Symptom | Cause | Fix |
135
+ |---|---|---|
136
+ | `kxm: command not found` after the npm install | The npm global `bin` directory is not on `PATH` | Run `"$(npm prefix --global)/bin/kxm" completion install`, then restart the shell |
137
+ | npm warns `EBADENGINE` | Node.js is older than 22.19, or is 23 | Install Node.js 22.19 or newer on 22.x, or 24 or newer |
138
+ | The `kxm_*` tools do not appear in Claude Code | `node` is not on the `PATH` Claude Code uses, or the plugin is disabled | Check `/mcp`, `node --version` and `claude plugin list`, then run `/reload-plugins` |
139
+ | Pi update fails with `couldn't find remote ref refs/heads/master` | An old Pi checkout tracks `master` | Run `pi remove git:github.com/kontextmind/kxm`, then install again with `@main` |
140
+
141
+ ## Next steps
142
+
143
+ - Connect Claude Code to a hub: [Quick start: Claude Code](quickstart-claude-code.md)
144
+ - Connect two Pi agents: [Quick start: Pi](quickstart-pi.md)
145
+ - Run a workflow: [Run your first workflow](first-workflow.md)
146
+ - Every `kxm` command: [CLI reference](../reference/cli-reference.md)
@@ -0,0 +1,405 @@
1
+ # Quick start: Claude Code
2
+
3
+ This page connects Claude Code to a KXM [hub](../glossary.md#hub) so that Claude can find peers, exchange requests with Pi agents and other Claude sessions, and read project context. It covers three paths: [set up a new project](#set-up-a-new-project), [add Claude Code to an existing project](#add-claude-code-to-an-existing-project), and [update KXM and the plugin](#update-kxm-and-the-plugin). A new project takes about ten minutes.
4
+
5
+ ## Before you begin
6
+
7
+ - The `kxm` CLI on your `PATH`. See [Install KXM](install.md#install-the-cli).
8
+ - Node.js 22.19 or newer on 22.x, or 24 or newer, on the `PATH` that Claude Code uses. The plugin runs `node`.
9
+ - Claude Code.
10
+ - A Git repository for the project.
11
+ - Two terminals. One of them keeps the hub running.
12
+
13
+ > [!IMPORTANT]
14
+ > You run the commands on this page in your own terminal. The hub's tokens stay with you: never paste a token or `hub-env.json` into Claude. Claude uses the `kxm_*` tools once the plugin is connected.
15
+
16
+ ## Set up a new project
17
+
18
+ ### 1. Initialize the project
19
+
20
+ Initialize before any hub or Pi session runs in this repository. A hub creates `.kxm/state/kxm.db`, and `kxm init` refuses a directory that already has hub state and no project.
21
+
22
+ ```bash
23
+ cd <your-repo>
24
+ kxm init --dry-run
25
+ kxm init --name "<display-name>"
26
+ ```
27
+
28
+ Expected output:
29
+
30
+ ```text
31
+ init plan: create
32
+ initialized KXM project at <repo-root>
33
+ ```
34
+
35
+ `kxm init` writes seven files under `.kxm/`: the project (`project.yaml`), a `coordinator` and an `implementer` agent, a `test` gate that runs `npm test` (`gates.yaml`), the repository binding (`repo/repo.yaml`), a `default` workflow, and `template-provenance.yaml`. It must run inside a Git repository; elsewhere it fails with `git_root_required`.
36
+
37
+ In an interactive terminal, `kxm init` then offers shell completion and workflow-guide agents. Set `KXM_SKIP_COMPLETION_PROMPT=1` and `KXM_SKIP_GUIDE_SETUP_PROMPT=1` to skip the offers.
38
+
39
+ > [!TIP]
40
+ > If your tests do not run with `npm test`, change `gates.test.argv` in `.kxm/gates.yaml` now, before you commit.
41
+
42
+ ### 2. Ignore runtime state and commit `.kxm/`
43
+
44
+ `kxm init` writes no ignore rules. Ignore the hub's state, its logs and local backups, then commit the configuration:
45
+
46
+ ```bash
47
+ printf '%s\n' '.kxm/state/' '.kxm/logs/' '.kxm/backups/' >> .gitignore
48
+ git add .gitignore .kxm
49
+ git commit -m "Add KXM project configuration"
50
+ kxm trust diff
51
+ ```
52
+
53
+ Expected output:
54
+
55
+ ```text
56
+ permission diff: sha256:<revision>… -> sha256:<revision>…
57
+ no authority-bearing or prose changes
58
+ ```
59
+
60
+ The committed `.kxm/` is the project's reviewed authority: which agents exist, which repositories they may write, and which commands gates run. `kxm trust diff` compares your working tree with `HEAD`, so before this commit it fails with `resource_missing`. [Workspace layout](../reference/config-reference.md#workspace-layout-tracked-ignored-and-state) lists what else to track.
61
+
62
+ ### 3. Start the hub
63
+
64
+ In the second terminal, go to the repository root. The hub keeps its database in the `.kxm/state/` of the directory it starts from, so always start it from the same place. If a hub for another project already runs on this machine, do not start a second one: [add this project to it](#give-the-project-a-token-on-the-running-hub), then continue with step 4.
65
+
66
+ Choose a hub [project](../glossary.md#project) key, for example the repository name, and create a [project token](../glossary.md#project-token) for it. The commands below add that token to any projects the hub already saved, then start the hub:
67
+
68
+ ```bash
69
+ # The user state root is KXM_STATE_HOME when set; the default below is for macOS.
70
+ # On Linux, use "${XDG_STATE_HOME:-$HOME/.local/state}/kxm/hub-env.json" instead.
71
+ HUB_ENV="${KXM_STATE_HOME:-$HOME/Library/Application Support/KXM}/hub-env.json"
72
+ export KXM_NEW_PROJECT_TOKEN="$(openssl rand -hex 32)"
73
+ export KXM_PROJECT_TOKENS="$(node -e '
74
+ const fs = require("node:fs");
75
+ const [file, project] = process.argv.slice(1);
76
+ const saved = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")).projectTokens ?? {} : {};
77
+ saved[project] = process.env.KXM_NEW_PROJECT_TOKEN;
78
+ process.stdout.write(JSON.stringify(saved));
79
+ ' "$HUB_ENV" "<hub-project>")"
80
+ kxm hub start
81
+ ```
82
+
83
+ <details><summary>PowerShell</summary>
84
+
85
+ ```powershell
86
+ $bytes = New-Object byte[] 32
87
+ [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
88
+ $env:KXM_NEW_PROJECT_TOKEN = ($bytes | ForEach-Object { $_.ToString('x2') }) -join ''
89
+ $stateRoot = if ($env:KXM_STATE_HOME) { $env:KXM_STATE_HOME } else { Join-Path $env:LOCALAPPDATA 'KXM' }
90
+ $hubEnv = Join-Path $stateRoot 'hub-env.json'
91
+ $env:KXM_PROJECT_TOKENS = node -e "const fs=require('node:fs');const [f,p]=process.argv.slice(1);const s=fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')).projectTokens??{}:{};s[p]=process.env.KXM_NEW_PROJECT_TOKEN;process.stdout.write(JSON.stringify(s))" $hubEnv '<hub-project>'
92
+ kxm hub start
93
+ ```
94
+
95
+ </details>
96
+
97
+ Expected output on the first start:
98
+
99
+ ```text
100
+ kxm hub: using newly generated KXM_AUTH_TOKEN from <state-root>/hub-env.json
101
+ kxm hub listening at http://127.0.0.1:7331; storage=<repo-root>/.kxm/state/kxm.db; auth=token
102
+ ```
103
+
104
+ The hub also prints a JSON `hub_started` log line. Keep this terminal open: `kxm hub start` runs in the foreground.
105
+
106
+ On its first start the hub generates an [admin token](../glossary.md#admin-token) and saves it with the project tokens in `hub-env.json`, readable only by you. The admin token is the operator's credential; never give it to an agent. A later start without `KXM_PROJECT_TOKENS` reuses the saved tokens and prints `using persisted KXM_AUTH_TOKEN`.
107
+
108
+ > [!WARNING]
109
+ > `KXM_PROJECT_TOKENS` replaces the hub's saved project map rather than adding to it, and the hub saves the replacement. A one-project value such as `{"demo":"…"}` removes every other project from the hub. The command above avoids this by starting from the saved map.
110
+
111
+ ### 4. Bind this machine and check the hub
112
+
113
+ Back in the first terminal:
114
+
115
+ ```bash
116
+ kxm hub bind http://127.0.0.1:7331
117
+ kxm hub view
118
+ kxm session status
119
+ ```
120
+
121
+ Expected output:
122
+
123
+ ```text
124
+ bound hub http://127.0.0.1:7331 · loopback · health=on
125
+ hub health=true ready=true · loopback hub
126
+ 1 session claim(s), 0 recovery envelope(s)
127
+ ```
128
+
129
+ The binding tells every `kxm` command and the local [Runtime](../glossary.md#runtime) on this machine where the hub is. The one session claim is the hub's own process record. Neither command writes a token.
130
+
131
+ > [!NOTE]
132
+ > Do not ask Claude to run `kxm session brief`. It saves a 24-hour operator session token, and once that token expires every `kxm_*` tool is denied until you clear it. `kxm hub view` and `kxm session status` are safe for Claude to run.
133
+
134
+ ### 5. Install the plugin
135
+
136
+ In Claude Code:
137
+
138
+ ```text
139
+ /plugin marketplace add kontextmind/kxm
140
+ /plugin install kxm@kxm
141
+ /reload-plugins
142
+ ```
143
+
144
+ Choose project scope to share the plugin with your team; commit the `.claude/settings.json` it writes. From a shell, the same install with the options set:
145
+
146
+ ```bash
147
+ claude plugin marketplace add kontextmind/kxm
148
+ claude plugin install kxm@kxm --scope project \
149
+ --config server_url=http://127.0.0.1:7331 \
150
+ --config agent_name=<agent-name> \
151
+ --config agent_purpose="<what-this-agent-does>" \
152
+ --config project=<hub-project>
153
+ ```
154
+
155
+ Expected output:
156
+
157
+ ```text
158
+ ✔ Successfully installed plugin: kxm@kxm (scope: project)
159
+ 1 userConfig option not yet set — run /plugin configure kxm@kxm in Claude Code, or pass --config KEY=VALUE.
160
+ ```
161
+
162
+ The option not yet set is `auth_token`, which stays blank on the machine that runs the hub. Never pass a token with `--config`: it would stay in your shell history.
163
+
164
+ ### 6. Configure the plugin
165
+
166
+ Claude Code asks for these options at install. Change them later with `/plugin configure kxm@kxm`, then restart Claude Code.
167
+
168
+ | Option | Default | What to enter |
169
+ |---|---|---|
170
+ | `server_url` | `http://127.0.0.1:7331` | The hub URL you bound in step 4 |
171
+ | `auth_token` | Blank | Blank on the machine that runs the hub. Elsewhere, this project's token. Never the admin token. |
172
+ | `agent_name` | `claude` | The name peers see. A second concurrent session in the project registers as `<name>-<pid>`. |
173
+ | `agent_purpose` | `Claude Code implementation and review agent` | One line that peers use to decide what to send this agent |
174
+ | `project` | Blank | `<hub-project>`. Blank uses the `name` in `package.json`, then the directory name. |
175
+
176
+ 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.
177
+
178
+ ### 7. Verify the connection
179
+
180
+ Start Claude Code in the repository root, or run `/reload-plugins`:
181
+
182
+ 1. `/mcp` shows the `kxm` server as connected, and `claude plugin list` shows `kxm@kxm` with `Status: ✔ enabled`.
183
+ 2. The session starts with a short KXM brief. Its status line reads `KXM brief` while it runs. For a hub project named `demo` and an `agent_name` of `claude-demo`, it adds this context:
184
+
185
+ ```text
186
+ KXM project demo · hub on at http://127.0.0.1:7331
187
+ Open peer requests to claude-demo: 0
188
+ Call kxm_context with your role and task before planning; kxm_workflow_get <runId> for an assigned run; kxm_inbox then kxm_reply for peer requests.
189
+
190
+ No active project memory facts.
191
+ ```
192
+
193
+ 3. Ask Claude to call `kxm_list`. It lists this session (output trimmed):
194
+
195
+ ```json
196
+ {
197
+ "agents": [
198
+ { "name": "claude-demo", "project": "demo", "model": "claude-code", "presence": "online" }
199
+ ]
200
+ }
201
+ ```
202
+
203
+ 4. Ask Claude to call `kxm_context` with the role `planner` and a task. On a new project the packet is empty, and `unresolvedGaps` says `no context records exist for this project yet`.
204
+
205
+ The brief appears only when Claude Code starts in a directory that contains `.kxm/`. It is read-only, capped in size, and never shows message text or tokens. The [plugin reference](../../plugins/kxm/README.md#sessionstart-hook) lists everything it can add.
206
+
207
+ > [!TIP]
208
+ > Claude can do the agent side of this setup. Ask it to set up KXM in the repository; the plugin's `kxm-project-setup` skill runs `kxm init` and the trust checks, and stops for you at every step that needs a token, the hub, or a commit.
209
+
210
+ ## How requests flow
211
+
212
+ Claude and a Pi agent exchange requests through the hub, which stores each one durably until it is answered. The diagram shows Claude asking a Pi reviewer, then a Pi agent asking Claude.
213
+
214
+ ```mermaid
215
+ sequenceDiagram
216
+ participant C as Claude Code (kxm plugin)
217
+ participant H as KXM hub
218
+ participant P as Pi agent
219
+ C->>H: kxm_send to reviewer
220
+ H-->>C: message ID (queued)
221
+ H->>P: request delivered over SSE
222
+ P->>P: agent turn
223
+ P->>H: reply with the turn's final response
224
+ C->>H: kxm_await or kxm_get with the message ID
225
+ H-->>C: replied, with the response
226
+ P->>H: kxm_send to Claude
227
+ alt pushed channel mode
228
+ H->>C: channel event in the running session
229
+ else pull mode (default)
230
+ C->>H: kxm_inbox
231
+ end
232
+ C->>H: kxm_reply with the message ID
233
+ ```
234
+
235
+ `kxm_await` waits at most 60 seconds. A request that is still open stays pending: check it later with `kxm_get`.
236
+
237
+ Requests addressed to Claude arrive in one of two ways:
238
+
239
+ - **[Pull mode](../glossary.md#pull-mode)**, the default. Claude checks for work with `kxm_inbox`, handles one request, and answers it with `kxm_reply`. Nothing arrives on its own: ask Claude to check the inbox.
240
+ - **Pushed [channel mode](../glossary.md#channel-mode).** Claude Code channels inject each request into the running session. During the channels research preview, start Claude Code with the community channel and review the trust prompt:
241
+
242
+ ```bash
243
+ claude --dangerously-load-development-channels plugin:kxm@kxm
244
+ ```
245
+
246
+ If your organization approved the plugin through `allowedChannelPlugins`, use `claude --channels plugin:kxm@kxm` instead.
247
+
248
+ Peer requests are untrusted input: Claude's normal permissions and approvals still apply. Supervised Pi workers can keep a separate model session per workflow run; a Claude session cannot, so use a separate Claude session per run when you need that isolation. See [Message peer agents](../guides/peer-messaging.md) for fanout, cancellation and delivery guarantees.
249
+
250
+ ## Add Claude Code to an existing project
251
+
252
+ Use this path when the repository already has a committed `.kxm/`, for example one set up for Pi agents.
253
+
254
+ ### Check the project
255
+
256
+ ```bash
257
+ kxm init --dry-run --json
258
+ ```
259
+
260
+ The JSON `mode` says what `kxm init` would do:
261
+
262
+ | `mode` | Meaning | Next step |
263
+ |---|---|---|
264
+ | `ready` | The project is valid | Continue |
265
+ | `repair` | A file fails validation, or `.kxm/` has no `project.yaml` | Fix each entry in `issues`, then run `kxm init` |
266
+ | `legacy` | Hub state or old configuration sits beside a project that does not load | Fix each entry in `issues` whose code is not `legacy_state_unsupported` |
267
+ | `create` | There is no project yet | Follow [Set up a new project](#set-up-a-new-project) |
268
+
269
+ Then validate the project and review uncommitted permission changes:
270
+
271
+ ```bash
272
+ kxm init
273
+ kxm trust diff
274
+ ```
275
+
276
+ Expected output for a committed, valid project:
277
+
278
+ ```text
279
+ validated KXM project at <repo-root>
280
+ permission diff: sha256:<revision>… -> sha256:<revision>…
281
+ no authority-bearing or prose changes
282
+ ```
283
+
284
+ `kxm init` keeps your local edits and never overwrites them; it has no `--force`. Any `EXPANSION` line from `kxm trust diff` is a permission change that you must review and commit yourself.
285
+
286
+ > [!CAUTION]
287
+ > If `legacy_state_unsupported` is the only issue and `.kxm/project.yaml` does not exist yet, a hub or Pi session ran before `kxm init`. Run `kxm hub stop`, rename `.kxm` to `.kxm-before-init`, and run `kxm init`. Then move the `state` and `logs` folders from `.kxm-before-init` into `.kxm`, and delete `.kxm-before-init`. Never do this in a project whose `.kxm/` is committed.
288
+
289
+ ### Give the project a token on the running hub
290
+
291
+ List the project keys the hub has saved. It prints keys only, never tokens:
292
+
293
+ ```bash
294
+ HUB_ENV="${KXM_STATE_HOME:-$HOME/Library/Application Support/KXM}/hub-env.json"
295
+ node -e 'console.log(Object.keys(JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8")).projectTokens ?? {}))' "$HUB_ENV"
296
+ ```
297
+
298
+ Expected output, for a hub that serves `demo` and `api`:
299
+
300
+ ```text
301
+ [ 'demo', 'api' ]
302
+ ```
303
+
304
+ If your project's key is listed, skip to the next section. Otherwise, stop the hub with Ctrl-C in its terminal (or `kxm hub stop` from the directory it runs in). Then, in that terminal and that directory, run the commands from [step 3](#3-start-the-hub) with this project's key. They keep every saved project and add the new one.
305
+
306
+ Expected output:
307
+
308
+ ```text
309
+ kxm hub: using persisted KXM_AUTH_TOKEN from <state-root>/hub-env.json
310
+ kxm hub listening at http://127.0.0.1:7331; storage=<hub-directory>/.kxm/state/kxm.db; auth=token
311
+ ```
312
+
313
+ One hub can serve every project on the machine; each project is a separate namespace with its own token. Do not start a second hub from another repository on the same port: bind to the running one instead.
314
+
315
+ ### Connect Claude Code
316
+
317
+ Continue with [step 4](#4-bind-this-machine-and-check-the-hub) through [step 7](#7-verify-the-connection) of the new-project path, using this project's key.
318
+
319
+ ## Update KXM and the plugin
320
+
321
+ ### Before you update
322
+
323
+ From the directory the hub runs in, back up its database, then stop the hub and the Runtime:
324
+
325
+ ```bash
326
+ kxm backup
327
+ kxm hub stop
328
+ kxm runtime stop
329
+ ```
330
+
331
+ `kxm backup` writes a verified copy and a hashed manifest to `.kxm/backups/backup-<timestamp>/`.
332
+
333
+ > [!WARNING]
334
+ > `kxm backup` copies the hub store only. It does not find the Runtime's registry and run event stores under the user state root. Copy those while the Runtime is stopped, as [Back up everything else](../operations/backup-and-restore.md#back-up-everything-else) describes.
335
+
336
+ [Back up and restore KXM](../operations/backup-and-restore.md) and [Upgrade KXM](../operations/upgrade.md) cover restores and rollback.
337
+
338
+ ### Update the CLI
339
+
340
+ ```bash
341
+ kxm update --check
342
+ npm install --global --omit=peer @kontextmind/kxm@latest
343
+ kxm --version
344
+ ```
345
+
346
+ In a source checkout, `kxm update --check` prints `kxm <version> (running from source at <root>)`; update it with `git pull` and `npm ci` instead. Start the hub again with `kxm hub start`; it reuses the saved tokens.
347
+
348
+ ### Update the plugin
349
+
350
+ Reinstall the plugin to update it. Claude Code installs new plugin code only when the plugin's version number changes, and the KXM release job sets that version only inside its build and never commits it. So `claude plugin update kxm@kxm` prints `kxm is already at the latest version (<version>).` and keeps the cached copy, and so does `kxm update claude --extensions`, which runs it.
351
+
352
+ Refresh the marketplace, then reinstall:
353
+
354
+ ```bash
355
+ claude plugin marketplace update kxm
356
+ claude plugin uninstall kxm@kxm --scope project
357
+ claude plugin install kxm@kxm --scope project \
358
+ --config server_url=http://127.0.0.1:7331 \
359
+ --config agent_name=<agent-name> \
360
+ --config agent_purpose="<what-this-agent-does>" \
361
+ --config project=<hub-project>
362
+ ```
363
+
364
+ Drop `--scope project` for a user-scope install. Reinstalling discards the plugin options, so pass them again as above, enter `auth_token` again at `/plugin configure kxm@kxm` if you use one, and restart Claude Code.
365
+
366
+ If `claude plugin list` shows `kxm@kontextmind-pi-extensions`, your install comes from the marketplace's former name. Move it to the current one, then set the options again as in [step 6](#6-configure-the-plugin):
367
+
368
+ ```bash
369
+ claude plugin uninstall kxm@kontextmind-pi-extensions
370
+ claude plugin marketplace remove kontextmind-pi-extensions
371
+ claude plugin marketplace add kontextmind/kxm
372
+ claude plugin install kxm@kxm
373
+ ```
374
+
375
+ ### After you update
376
+
377
+ - The plugin never uses the hub admin token. A blank `auth_token` works only when the hub saved a token for the project; otherwise add the project with [step 3](#3-start-the-hub) or enter its token.
378
+ - Earlier plugin versions ran `kxm session brief` at session start, which saved a 24-hour session token that nothing refreshes now. If the tools report `tool_policy_denied: Session token on disk is malformed or expired`, run `kxm session token --clear`.
379
+
380
+ ## Troubleshooting
381
+
382
+ The `kxm_*` tools and the session brief name the fix for setup problems. Run the fix in your own terminal.
383
+
384
+ | Message or symptom | Cause | Fix |
385
+ |---|---|---|
386
+ | `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 |
387
+ | `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 |
388
+ | `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` |
389
+ | `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.` |
390
+ | `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 |
391
+ | `legacy state is not migrated by this build` | Hub state predates `kxm init`, or a file is invalid | See [Check the project](#check-the-project) |
392
+ | `permission diff failed: … resource_missing` | `.kxm/` is not committed yet | Commit `.kxm/`, then run `kxm trust diff` again |
393
+ | `KXM hub is already managed by PID <n>` | A hub already runs from this directory | Use it, or run `kxm hub stop` first |
394
+ | `kxm hub start` crashes with `EADDRINUSE` | A hub from another directory holds the port | Bind to that hub and add this project to it |
395
+ | No KXM brief when the session starts | Claude Code did not start in a directory with `.kxm/` | Start Claude Code from the repository root |
396
+ | The session appears as `<name>-<pid>` | Another session in the project uses `agent_name` | Expected; set a different `agent_name` to avoid it |
397
+
398
+ `kxm session token --status` cannot confirm a stale token file: it prints `No active session token found in env or disk` even while the file blocks the tools. The [plugin reference](../../plugins/kxm/README.md#troubleshooting) and [Troubleshooting](../operations/troubleshooting.md) cover more cases.
399
+
400
+ ## Next steps
401
+
402
+ - Run a workflow end to end: [Run your first workflow](first-workflow.md)
403
+ - Send, fan out and cancel requests: [Message peer agents](../guides/peer-messaging.md)
404
+ - Every tool, option and hook: [Claude Code plugin](../../plugins/kxm/README.md) and [Agent tools reference](../reference/tools.md)
405
+ - Who holds which credential: [Trust model](../concepts/trust-model.md)