@mcpbox/mcpbox-claude 0.1.27 → 0.1.29

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 (54) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/.codex-plugin/plugin.json +4 -4
  3. package/README.md +280 -20
  4. package/bin/mcpbox-claude.mjs +61 -11
  5. package/commands/close.md +2 -0
  6. package/commands/mine.md +4 -4
  7. package/commands/mode.md +4 -12
  8. package/commands/next.md +4 -3
  9. package/commands/pipeline-run.md +4 -4
  10. package/commands/plan.md +4 -4
  11. package/commands/sync.md +1 -1
  12. package/commands/tasks.md +4 -4
  13. package/hooks/acceptance-guard.mjs +5 -62
  14. package/hooks/bootstrap.mjs +167 -0
  15. package/hooks/edit-gate.mjs +7 -0
  16. package/hooks/hooks.json +37 -1
  17. package/hooks/impl/acceptance-guard.mjs +63 -0
  18. package/hooks/impl/edit-gate.mjs +32 -0
  19. package/hooks/impl/prepare-commit-msg.mjs +8 -0
  20. package/hooks/impl/session-gate.mjs +81 -0
  21. package/hooks/impl/session-start.mjs +89 -0
  22. package/hooks/impl/stop.mjs +64 -0
  23. package/hooks/impl/track-claims.mjs +35 -0
  24. package/hooks/impl/user-prompt-submit.mjs +234 -0
  25. package/hooks/prepare-commit-msg.mjs +7 -0
  26. package/hooks/session-gate.mjs +7 -0
  27. package/hooks/session-start.mjs +5 -204
  28. package/hooks/stop.mjs +5 -104
  29. package/hooks/track-claims.mjs +7 -0
  30. package/hooks/user-prompt-submit.mjs +5 -259
  31. package/lib/cloud-knowledge.mjs +19 -3
  32. package/lib/codex.mjs +2 -2
  33. package/lib/cursor.mjs +1 -1
  34. package/lib/edit-gate.mjs +120 -0
  35. package/lib/git-trailer.mjs +104 -0
  36. package/lib/harness-hooks.mjs +186 -0
  37. package/lib/hook-doctor.mjs +517 -0
  38. package/lib/hook-output.mjs +16 -0
  39. package/lib/kimi.mjs +16 -4
  40. package/lib/knowledge-skills.mjs +259 -0
  41. package/lib/mode.mjs +2 -12
  42. package/lib/policy.mjs +54 -127
  43. package/lib/session-gate.mjs +385 -0
  44. package/lib/version.mjs +1 -1
  45. package/package.json +2 -2
  46. package/skills/mcpbox/SKILL.md +17 -94
  47. package/skills/mcpbox-close/SKILL.md +2 -0
  48. package/skills/mcpbox-mine/SKILL.md +4 -4
  49. package/skills/mcpbox-mode/SKILL.md +4 -12
  50. package/skills/mcpbox-next/SKILL.md +4 -3
  51. package/skills/mcpbox-pipeline-run/SKILL.md +4 -4
  52. package/skills/mcpbox-plan/SKILL.md +4 -4
  53. package/skills/mcpbox-sync/SKILL.md +1 -1
  54. package/skills/mcpbox-tasks/SKILL.md +4 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcpbox-claude",
3
- "description": "MCPBox for Claude Code: the mcpbox task tracker and idea pipeline over one MCP server. Ships /mcpbox:* commands, session hooks, and a managed CLAUDE.md policy that makes mcpbox the default tracker.",
4
- "version": "0.1.27",
3
+ "description": "MCPBox for Claude Code: Daruma tasks, project memory, and optional idea exploration over MCP. Ships /mcpbox:* commands, session hooks, and a managed CLAUDE.md policy that makes mcpbox the default tracker.",
4
+ "version": "0.1.29",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcpbox",
3
- "version": "0.1.27",
4
- "description": "MCPBox for Codex: the mcpbox task tracker and idea pipeline behind one MCP server.",
3
+ "version": "0.1.29",
4
+ "description": "MCPBox for Codex: Daruma plans and project memory over MCP.",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
@@ -10,8 +10,8 @@
10
10
  "mcpServers": "./.mcp.json",
11
11
  "interface": {
12
12
  "displayName": "MCPBox",
13
- "shortDescription": "Task tracker + maturity pipeline for agents.",
14
- "longDescription": "One MCP endpoint (https://mcpbox.ru/v1/mcp) with the mcpbox task tracker (tasks and plans) and the idea pipeline. Ships the policy and command workflows as Codex skills.",
13
+ "shortDescription": "Daruma plans and project memory for agents.",
14
+ "longDescription": "One MCP endpoint (https://mcpbox.ru/v1/mcp) with Daruma tasks, project memory, and an optional workflow for exploring ideas. Ships the policy and command workflows as Codex skills.",
15
15
  "developerName": "tupical",
16
16
  "category": "Productivity",
17
17
  "websiteURL": "https://mcpbox.ru"
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @mcpbox/mcpbox-claude
2
2
 
3
3
  MCPBox agent harness for **Claude Code**, **Codex**, **Cursor**, **Kimi Code**, and **OpenCode**.
4
- Wires the single canonical MCP server (`https://mcpbox.ru/v1/mcp` — the daruma
5
- tracker tools plus the platform pipeline `torii→satori→enma→yatagarasu→fujin→daruma`)
4
+ Wires the single canonical MCP server (`https://mcpbox.ru/v1/mcp` — the Daruma
5
+ tracker and project memory)
6
6
  and drops a managed policy into each agent's native config file.
7
7
 
8
8
  Normally installed for you by `npx @mcpbox/mcpbox setup` (or
@@ -10,6 +10,37 @@ Normally installed for you by `npx @mcpbox/mcpbox setup` (or
10
10
  server and picks Repository, Repository (user scope), or Global. Use this CLI directly to manage
11
11
  just the policy.
12
12
 
13
+ ## Start with a plan
14
+
15
+ Once connected, ask your agent to create a Daruma plan with tasks and acceptance
16
+ criteria. For example, “Plan a CSV import. Skip duplicate email addresses and
17
+ report how many rows were skipped.” On servers with MeiSei Critique, creating
18
+ a plan can also return advisory findings, such as two tasks with the same
19
+ title. Review the finding and decide whether to amend the plan.
20
+
21
+ Critique uses the recorded plan by default. Local Git observations require a
22
+ separate Daruma CLI invocation with an explicit checkout. They are self-reported
23
+ and do not attest that tests passed. For an undecided idea, the existing
24
+ `mcpbox_pipeline_run` workflow and its handoff remain available.
25
+
26
+ ## Add the Claude Code policy to a project
27
+
28
+ First install the CLI globally with `npm install -g @mcpbox/mcpbox-claude`
29
+ and ensure npm's global bin directory is on your PATH. Then, from the project
30
+ directory, run:
31
+
32
+ ```bash
33
+ mcpbox-claude init
34
+ ```
35
+
36
+ The command creates a managed policy in `CLAUDE.md` and prints:
37
+
38
+ ```text
39
+ Open Claude Code in this directory to pick it up.
40
+ ```
41
+
42
+ Running it again leaves the policy unchanged.
43
+
13
44
  ## Install and update
14
45
 
15
46
  Claude Code and Codex install from the public git marketplace, which is the only
@@ -104,6 +135,102 @@ until the next release: the skill shipped inside the Codex plugin package
104
135
  (a session of that plugin keeps `AGENTS.md` on the server text) and the
105
136
  Kimi hooks frozen at `kimi-init`.
106
137
 
138
+ ### Windows / Codex: "hook exited with code 1"
139
+
140
+ Codex shows only `hook exited with code N` and drops the hook's stderr, so the
141
+ reason is not visible in the session. `npx -y @mcpbox/mcpbox-claude doctor`
142
+ reproduces it: for every mcpbox entry in `~/.codex/hooks.json` (or
143
+ `$CODEX_HOME/hooks.json`), `~/.cursor/hooks.json` and `~/.claude/settings.json`
144
+ it runs the command the way the host does — Windows `%COMSPEC% /C "<command>"`,
145
+ Unix `$SHELL -lc <command>`, Claude Code `bash -c` (Git Bash on Windows), the
146
+ event JSON on stdin — and prints the exit
147
+ code, the first 20 lines of stderr and, for a failing hook, of stdout
148
+ (`hooks` in `--json`). It does not change READY or the exit code and fixes
149
+ nothing itself.
150
+
151
+ It also runs the hooks Codex takes from the mcpbox plugin: the
152
+ `hooks/hooks.json` of an `[plugins."<name>@<marketplace>"]` with
153
+ `enabled = true` in `config.toml`, from the cache copy
154
+ `$CODEX_HOME/plugins/cache/<marketplace>/<name>/<version>` (the newest), when
155
+ its `.codex-plugin/plugin.json` says `"name": "mcpbox"` — other plugins' hooks
156
+ are never run, whatever their scripts are called. Its commands run with
157
+ `${PLUGIN_ROOT}` / `${CLAUDE_PLUGIN_ROOT}` replaced by that root and
158
+ `PLUGIN_ROOT`, `CLAUDE_PLUGIN_ROOT`, `PLUGIN_DATA` set the way Codex sets them.
159
+ Codex runs this file without a `hooks` key in `.codex-plugin/plugin.json`
160
+ (`hooks/list` of `codex app-server` 0.165.0 lists all nine with
161
+ `source: plugin`). Codex 0.141.0 (seen in the Windows desktop app) parses that
162
+ file strictly, rejects it for the top-level `description` key
163
+ (`unknown field`) and runs none of the plugin hooks; `doctor` says so next to
164
+ the file — update Codex.
165
+
166
+ The hooks run in a sandbox: a throwaway home, `CODEX_HOME`,
167
+ `CLAUDE_CONFIG_DIR`, plugin data dir and working directory, with
168
+ `MCPBOX_NO_POLICY_SYNC`, `MCPBOX_NO_KNOWLEDGE_SKILLS`, `MCPBOX_NO_UPDATE_CHECK`
169
+ and `MCPBOX_NO_POLICY_FETCH` set. A SessionStart under `doctor` therefore does
170
+ not refresh `AGENTS.md`, `CLAUDE.md` or skills and reaches no tracker (the
171
+ credentials live in the real home). The shell itself keeps the real
172
+ environment and working directory: `${HOME}`, `%USERPROFILE%` or a relative
173
+ path in a command resolve to the script Codex would run, and the login
174
+ profile gives the same PATH and `node`. The sandbox starts inside the hook's
175
+ node — a `--require` preload added to `NODE_OPTIONS` swaps `HOME`,
176
+ `USERPROFILE`, `CODEX_HOME`, `CLAUDE_CONFIG_DIR` and the working directory
177
+ before the script loads. The policy files around the project and the user skill
178
+ dirs are hashed before and after; a difference is reported as an error
179
+ (`hooks.touched`). A hook that hits its timeout is killed with everything it
180
+ started (its process group on Unix, `taskkill /T` on Windows), so `doctor`
181
+ does not wait for a leftover child.
182
+
183
+ - **`${CLAUDE_PLUGIN_ROOT}` in a user hooks file.** Codex expands
184
+ `${PLUGIN_ROOT}` / `${CLAUDE_PLUGIN_ROOT}` only for hooks a plugin ships.
185
+ Copied into `~/.codex/hooks.json` (for example from this package's
186
+ `hooks/hooks.json`) it stays literal: node looks for
187
+ `…\${CLAUDE_PLUGIN_ROOT}\hooks\session-start.mjs` and exits 1 on every event.
188
+ `doctor` marks such entries; delete them and run `codex-init`, which writes
189
+ absolute paths into the harness copy (`~/.agents/mcpbox/harness`). Under
190
+ `cmd.exe` no `${VAR}` is expanded at all.
191
+ - **Which node.** The hooks run `node` from the PATH Codex was started with
192
+ (the desktop app or the shell that launched it), not from the terminal where
193
+ you type. `doctor` asks the hooks' own shell and prints the version and
194
+ `execPath`. Node 20 or newer is required (`engines`); OpenServer, OSPanel and
195
+ similar panels, as well as version managers, can put another `node` first on
196
+ that PATH.
197
+ - **Harness copy.** `doctor` reports harness files that are missing or differ
198
+ from the installed package (`codex-init` / `cursor-init` rewrite them) and any
199
+ relative import of a harness script that the copy does not include.
200
+
201
+ ### When a hook itself fails
202
+
203
+ Every `hooks/<name>.mjs` is a thin entry over `hooks/bootstrap.mjs`; the hook
204
+ lives in `hooks/impl/<name>.mjs` and is loaded by a dynamic import. A failure
205
+ to load it (a missing harness file, a SyntaxError), a throw in it or a node
206
+ older than 20 does not exit 1: the bootstrap writes one line
207
+
208
+ ```
209
+ [mcpbox] hook <name> failed: <error> (<code>) — node <version> <execPath>; run: mcpbox-claude doctor
210
+ ```
211
+
212
+ as the hook's stdout JSON, the same line plus the stack to stderr, and exits 0.
213
+ The line is capped at 1 KB of UTF-8 (the error message is cut, at a code
214
+ point, before the runtime part). A hook that already wrote its own output gets
215
+ no second document (Codex parses exactly one): then the line goes to stderr
216
+ only; output the hook still writes after the failure (a timer, a deferred
217
+ write) goes to stderr as well. Tracker and network errors
218
+ stay silent inside the hooks, as before — only unexpected failures surface.
219
+
220
+ | Surface | SessionStart / UserPromptSubmit | Stop, SessionEnd, Pre/PostToolUse |
221
+ |---|---|---|
222
+ | Claude Code, Kimi | `systemMessage` (user) + `hookSpecificOutput.additionalContext` (model) | `systemMessage` |
223
+ | Codex (`PLUGIN_DATA` or `--surface=codex`) | `systemMessage` (user) + `hookSpecificOutput.additionalContext` (model) | `systemMessage` |
224
+ | Cursor (`--surface=cursor`) | `additional_context` | stderr only |
225
+ | git `prepare-commit-msg` | — | stderr only; the commit proceeds |
226
+
227
+ `acceptance-guard` keeps its exit 2 with the reason on stderr for a broken
228
+ acceptance lock; only its load failures go through the bootstrap. `doctor`
229
+ counts a hook that printed the `[mcpbox] hook … failed:` line as failing even
230
+ with exit 0. Not covered: a command whose entry script itself is not found
231
+ (the literal `${CLAUDE_PLUGIN_ROOT}` case above) or a node too old to parse
232
+ the bootstrap (before 12.17) — node exits 1 before any of our code runs.
233
+
107
234
  ### Project knowledge in every session
108
235
 
109
236
  Agents answer repo questions right when they have the project's knowledge
@@ -117,18 +244,39 @@ npx -y @mcpbox/mcpbox-claude login # confirm the code in the browser
117
244
  The workspace-bound token is kept in `~/.agents/mcpbox/credentials.json`
118
245
  (mode 0600) and only ever sent over https; `logout` deletes the file, and
119
246
  revoking the token itself happens in the workspace settings (Tokens). The
120
- repo path of each new session goes to the server to find its project. Unpaired, rejected, or with the path
121
- unbound in the paired workspace, the hook adds a ready `mcpbox_knowledge_read`
247
+ repo path of each new session goes to the server to find its project. The hook inlines complete, framed knowledge up to 800 UTF-8 bytes. For larger or truncated results, an unpaired or rejected token, or an unbound path, it adds a ready `mcpbox_knowledge_read`
122
248
  call instead of the text. Knowledge rows arrive
123
- marked as workspace data, not instructions. Mode `off` disables both.
124
-
125
- Paired, the `Stop` hook blocks a stop once per task left `in_progress` that was taken in this session, asking the agent to complete, send to review, or release it.
249
+ marked as workspace data, not instructions, with their source `id`, `maturity` and
250
+ `plan_id`: a `raw` row is one agent's working note for a plan, not verified
251
+ knowledge. Mode `off` disables both.
252
+
253
+ Paired, `SessionStart` also turns the project's published skills
254
+ (`kind=skill`, `maturity=consolidated`) into skill files of the running client:
255
+ `~/.claude/skills` for Claude Code (`$CLAUDE_CONFIG_DIR/skills` when set),
256
+ `$CODEX_HOME/skills` for Codex. One flat directory per row,
257
+ `mcpbox-<workspace-slug>-<title>/SKILL.md` (the slug is a hash of the paired
258
+ workspace id; Claude Code finds user skills one level deep only). The row's
259
+ text travels inside the same untrusted frame as above. Each file carries a
260
+ marker with the project id, the knowledge id and `updated_at`: an unchanged
261
+ row is not rewritten, and a row of the project just read that is gone from
262
+ the answer (retired or superseded) loses its directory. The skill root is
263
+ shared by every project of the workspace and one read answers for one
264
+ project, so skills of the other projects stay; a title another project already
265
+ holds gets an id suffix. A failed, unbound or truncated read changes nothing,
266
+ and neither does an answer that names no project (a server older than this
267
+ contract, when it has no rows). Directories without the marker, with extra
268
+ files, or of another workspace are never touched. A file written before the
269
+ marker carried a project is adopted by the read that returns its row; until
270
+ then it stays, and removal after a retire needs that adoption first.
271
+ `MCPBOX_NO_KNOWLEDGE_SKILLS=1` or mode `off` turns this off.
272
+
273
+ The session gate tracks work taken by the current session. Its Stop and SessionEnd rules are listed below.
126
274
  If the lookup times out, it exits silently; lingering network connections do not delay process exit. Any blocking response is flushed before exit.
127
275
 
128
- A stale version announces itself at session start on Claude, Codex, and Kimi.
129
- The Cursor adapter's only hook is the user-level `sessionStart` that carries
130
- the policy (global installs); it does no update check, so nothing announces
131
- anything there — check manually, or let
276
+ Claude and Codex check for updates at session start. Kimi can deliver the notice on the first prompt.
277
+ Cursor's hooks are the session gate (every `cursor-init`) plus, for global
278
+ installs, the user-level `sessionStart` that carries the policy; none of them
279
+ checks for updates, so nothing announces anything there — check manually, or let
132
280
  `cursor-init` in a routine update pass do it. Set
133
281
  `MCPBOX_NO_UPDATE_CHECK=1` to disable the registry lookup entirely (air-gapped
134
282
  installs, CI).
@@ -138,8 +286,8 @@ installs, CI).
138
286
  | Agent | Policy surface | MCP server | Hooks |
139
287
  |--------|----------------------------------------|-------------------------------------|-------|
140
288
  | Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
141
- | Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
142
- | Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` (repo); in `$HOME` a `sessionStart` hook in `~/.cursor/hooks.json` instead — Cursor reads no `~/.cursor/rules` | `mcpbox` entry in `.cursor/mcp.json` | `~/.cursor/hooks.json` `sessionStart` (global only) |
289
+ | Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | session gate in `~/.codex/hooks.json` |
290
+ | Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` (repo); in `$HOME` a `sessionStart` hook in `~/.cursor/hooks.json` instead — Cursor reads no `~/.cursor/rules` | `mcpbox` entry in `.cursor/mcp.json` | `~/.cursor/hooks.json`: `sessionStart` policy (global only) + session gate (`failClosed`) |
143
291
  | Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
144
292
  | OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
145
293
 
@@ -148,7 +296,7 @@ that provide Claude's `/mcpbox:*` commands, plus `skills/mcpbox` from the shared
148
296
  plain policy (`BLOCK_BODY_PLAIN`). Codex selects these skills by their
149
297
  descriptions; they are not user-entered slash commands.
150
298
 
151
- All four agents accept `mcpbox mode [off|lite|full]` through the managed
299
+ All five agents accept `mcpbox mode [off|lite|full]` through the managed
152
300
  policy. Claude also exposes `/mcpbox:mode`, Cursor exposes `/mcpbox-mode`, and
153
301
  the shared value lives in `~/.agents/mcpbox/mode`.
154
302
 
@@ -157,11 +305,73 @@ Kimi specifics:
157
305
  - MCP and hooks are **user-level** (Kimi reads hooks only from
158
306
  `~/.kimi-code/config.toml`; `$KIMI_CODE_HOME` is honored). One
159
307
  `/mcp-config login mcpbox` OAuth then covers every project.
160
- - The hook scripts (`SessionStart` task summary, `UserPromptSubmit` routing
161
- hints, `Stop` guard) are the same ones the Claude plugin ships;
308
+ - The hook scripts (`SessionStart` notices, `UserPromptSubmit` routing
309
+ hints, `PostToolUse` claim/write tracking, `Stop` guard) are the same ones the Claude plugin ships;
162
310
  `kimi-init` copies them into `~/.kimi-code/mcpbox/` so the config never
163
311
  references an ephemeral npx cache path. `kimi-uninit` removes that directory.
164
312
 
313
+ Session gate (Claude, Codex, Cursor, Kimi) — one set of scripts, different
314
+ configs; `--surface=codex|cursor` selects the host's stdin/stdout wire. Kimi
315
+ uses `track-claims.mjs` and `stop.mjs` for claim tracking and the Stop gate:
316
+
317
+ - `hooks/session-gate.mjs start` — SessionStart (also after compaction): the
318
+ claim this session holds (from local hook state, so also unpaired/offline),
319
+ then this agent's `in_progress` claims and the repo's `in_review` tasks
320
+ (`scope_path` = the session cwd): a header, up to 10 tasks, and one
321
+ `… and N more` line when truncated; silent when there are none.
322
+ - `hooks/track-claims.mjs` — PostToolUse (Cursor: `afterMCPExecution`):
323
+ successful claims plus `daruma_plan_materialize` / `daruma_set_status` /
324
+ `daruma_comment` writes; a `kind=outcome` comment marks its task reported.
325
+ A claim is stored as a projection of the server claim, not a session entity
326
+ of its own: plan/task/run/claim ids, the claiming agent, expiry, MCP server,
327
+ paired workspace, git toplevel (worktree) and cwd. Only a parsed successful
328
+ `daruma_plan_drain_next` / `daruma_ready_drain` / `daruma_claim` result
329
+ makes one — an MCP error (`rule_blocked` included), a null drain, a busy
330
+ claim or an unknown shape do not. `daruma_release`, `daruma_complete` and
331
+ `daruma_set_status` off `in_progress` end it (`<session>.cleared`).
332
+ - `hooks/user-prompt-submit.mjs` — besides routing hints, one line with the
333
+ held claim's ids (`run_id` for the run step calls), or why the recorded
334
+ claim no longer counts: expired, unknown expiry (older records), another
335
+ paired workspace or another repo/worktree. No tracker call.
336
+ - `hooks/stop.mjs` — blocks while a task this session took (a claim, or
337
+ `daruma_set_status` to `in_progress`) is `todo`/`in_progress` and the
338
+ session has not settled it since: `daruma_complete`, `daruma_release`,
339
+ `daruma_set_status` to `todo`/`in_review`/`blocked`/`done`, or a
340
+ `kind=outcome` comment. Creating tasks (`daruma_plan_materialize`) or
341
+ commenting on them takes nothing, so a session that only planned ends
342
+ freely; a task the server shows closed or held by another claim is not
343
+ pending. `<session>.tracked` records the kind of each write
344
+ (`via`: `materialize`, `set_status:<status>`, `comment:<kind>`); older
345
+ records without it keep the former rule. Two reminders per pending
346
+ set, then a warning (Cursor: `followup_message`, and the release after two
347
+ reminders is silent — Cursor has no warning field). A claim the server no
348
+ longer shows (task out of `in_progress`, another claim holder) is cleared
349
+ from the projection; an unread task (offline, no access) clears nothing.
350
+ - `hooks/session-gate.mjs end` — SessionEnd: releases the exact claim generation recorded by this session.
351
+ On a server without generation-aware release, the claim expires normally.
352
+ - `hooks/edit-gate.mjs` — PreToolUse, **Claude Code only**: claim-before-edit
353
+ gate over the same claim projection (no tracker call, no model call). A held
354
+ claim that still counts here lets every call through. Without one, coverage
355
+ is **partial** and stated as such:
356
+ - `Edit` / `Write` / `MultiEdit` / `NotebookEdit` — the first-line surface;
357
+ - `Bash` / `PowerShell` — commands are **not** classified (no regex over
358
+ arbitrary shell); every command but a narrow read-only exception
359
+ (`git status|diff|log|show|rev-parse`, `ls`, `pwd` — one plain command, no
360
+ character the shell interprets, no `--output`/`--ext-diff`/`--textconv`)
361
+ gets a consultative note. Advisory for shell, not a security boundary;
362
+ - Serena MCP tools outside its read-only set (`find_symbol`, `read_file`,
363
+ `search_for_pattern`, …) — same as shell.
364
+
365
+ Other MCP tools, subagents, Codex/Cursor/Kimi and claims made outside the
366
+ session's MCP tools (`mcporter`, another session) are not seen by the gate.
367
+ `MCPBOX_EDIT_GATE` selects the mode: `advisory` (default) adds a context
368
+ note once per session and surface; `strict` (opt-in pilot on one host, not a
369
+ default) denies the edit tools and asks the human for shell/Serena; `off`
370
+ disables the gate.
371
+
372
+ Codex and Cursor run copies in `~/.agents/mcpbox/harness/` (written by
373
+ `codex-init` / `cursor-init`), never the ephemeral npx cache.
374
+
165
375
  ## CLI
166
376
 
167
377
  ```
@@ -172,7 +382,8 @@ mcpbox-claude codex-uninit [--dir DIR]
172
382
  mcpbox-claude codex-skill User-level routing skill only (Codex without the plugin).
173
383
  mcpbox-claude codex-skill-retire Remove that user-level copy once the plugin ships it.
174
384
  mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server
175
- (in $HOME: ~/.cursor/hooks.json sessionStart hook).
385
+ + session gate in ~/.cursor/hooks.json
386
+ (in $HOME: a sessionStart policy hook, not a rule).
176
387
  mcpbox-claude cursor-uninit [--dir DIR]
177
388
  mcpbox-claude kimi-init [--dir DIR] AGENTS.md policy + ~/.kimi-code/mcp.json server
178
389
  + ~/.kimi-code/config.toml [[hooks]].
@@ -180,10 +391,20 @@ mcpbox-claude kimi-uninit [--dir DIR]
180
391
  mcpbox-claude opencode-init [--dir DIR] AGENTS.md policy + `mcpbox` entry under
181
392
  "mcp" in ~/.config/opencode/opencode.json.
182
393
  mcpbox-claude opencode-uninit [--dir DIR]
183
- mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
184
- mcpbox-claude mode [off|lite|full] Show or set the shared pipeline mode.
394
+ mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired;
395
+ run the mcpbox hooks as their host does
396
+ (exit code + stderr, see Windows / Codex).
397
+ mcpbox-claude mode [off|lite|full] Show or set the shared prompt-hint mode.
398
+ mcpbox-claude git-hook [install|uninstall] [--dir DIR]
399
+ git prepare-commit-msg hook: adds
400
+ "Daruma-Task: <id>" for the work/<id> branch,
401
+ else for tasks this session claimed.
185
402
  ```
186
403
 
404
+ CI on `main` posts an outcome for each `Daruma-Task` (task → `in_review`) and a
405
+ gated deploy completes it; see `docs/CI.md` in mcpbox.ru. The hook never
406
+ overwrites a foreign `prepare-commit-msg` and never blocks a commit.
407
+
187
408
  All writes are idempotent and preserve surrounding hand-written content.
188
409
  Set `MCPBOX_NO_UPDATE_CHECK=1` to disable hook update checks.
189
410
 
@@ -198,7 +419,17 @@ UNLICENSED — MCPBox is a closed SaaS.
198
419
  If a parent already has a managed MCPBox block, init inherits it and removes only
199
420
  the requested directory's redundant managed block. Other local instructions and
200
421
  parent files are preserved. A managed-only child file is removed. Re-running init
201
- is idempotent; symlink/hardlink edits and malformed markers are refused.
422
+ is idempotent; malformed markers are refused.
423
+
424
+ No policy file is written through a symlink or hard link: it is shared with
425
+ another path (`AGENTS.md -> CLAUDE.md`, a parent's `CLAUDE.md` linked into a
426
+ child), so an edit there would change that path too. `init`, `codex-init`,
427
+ `kimi-init` and `opencode-init` check `CLAUDE.md` / `AGENTS.md` before every
428
+ write and fail with `Refusing to write policy through symlink/hardlink`; the
429
+ `*-uninit` commands leave such a file as is and report it. Session-start sync
430
+ skips linked files the same way. User configs (`~/.codex/config.toml`,
431
+ `~/.kimi-code/config.toml`) are written through a symlink on purpose — dotfile
432
+ managers keep them as links.
202
433
 
203
434
  `doctor --json` reports `policy_paths` and `policy_duplicate`; duplicate blocks
204
435
  make readiness false. Parent blocks are not refreshed by a child install: run init
@@ -222,3 +453,32 @@ Routing and the execution-path verification rule before editing are supplied by
222
453
  MCP `initialize.instructions` (`PLATFORM_INSTRUCTIONS` in
223
454
  `crates/cloud-api/src/v1_gateway.rs`); clients without command skills use the plain tool
224
455
  entry points. Reconnect the MCP server if its instructions are unavailable.
456
+
457
+ Pipeline and advisor calls are optional in every mode. Each fresh hosted `tools/list` reflects the current workspace provider capabilities. Provider-only discovery requires workspace-wide project access, an owner/admin role and agent dispatch capability. The complexity tool also requires the full profile. The advisor still accepts direct calls from existing sessions under its usual authorization and can return null advice. Clients caching a catalogue can refresh it by listing tools again or reconnecting.
458
+
459
+ ## Audit findings
460
+
461
+ Use `daruma_audit_findings` with the project ID to list open findings. Pass a finding ID to read its detail and history. Use `daruma_audit_finding_ack` to change its status. Both tools are in the default profile. For REST clients:
462
+
463
+ - project ids: `daruma_project_list` (one repo path can map to two ids —
464
+ list findings for each).
465
+ - token: `access_token` in `~/.agents/mcpbox/credentials.json` (created by
466
+ `npx -y @mcpbox/mcpbox-claude@latest login`).
467
+ - list: `curl -H "Authorization: Bearer $TOKEN" -H "X-Daruma-Plugin-Contract: 1"
468
+ "https://mcpbox.ru/v1/audit/findings?project_id=<id>&status=open"`
469
+ (optional `severity`, `category`); one: `GET /v1/audit/findings/<id>`.
470
+ - set status for a finding without a plan revision: `curl -X POST -H "Authorization: Bearer $TOKEN" -H "X-Daruma-Plugin-Contract: 1"
471
+ -H "Content-Type: application/json" -d '{"status":"resolved"}'
472
+ https://mcpbox.ru/v1/audit/findings/<id>/status`; body values: open,
473
+ acknowledged, muted or resolved.
474
+
475
+ For a revision-bound `critique.*` finding, read its detail and `history` first.
476
+ Post `acknowledged` with the finding's current `plan_revision`, a non-empty
477
+ `reason`, and `evidence_ids` from the plan or the task named in the finding.
478
+ An independent reviewer sends `muted` or `resolved` with the same required
479
+ fields. The reviewer must be independent of both the finding author and the respondent.
480
+
481
+ Triage one finding at a time, never one task per finding.
482
+ `task.duplicate_candidate`: read both tasks — a done/cancelled side resolves
483
+ it at once; two active tasks need the human's call or a `relates_to` link.
484
+ `task.no_acceptance_criteria`: add the criterion to the task, then resolve.
@@ -3,10 +3,11 @@
3
3
  //
4
4
  // Subcommands:
5
5
  // mcpbox-claude init [--dir DIR] Write the managed CLAUDE.md policy block
6
- // (daruma tracker + full pipeline). Idempotent.
6
+ // (Daruma plans and optional idea pipeline). Idempotent.
7
7
  // mcpbox-claude uninit [--dir DIR] Remove the managed policy block.
8
- // mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
9
- // mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (raw-idea routing).
8
+ // mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired,
9
+ // and run the mcpbox hooks the way their host does.
10
+ // mcpbox-claude mode [off|lite|full] Get/set prompt hints.
10
11
  // mcpbox-claude --version | --help
11
12
  //
12
13
  // ponytail: no orchestrator (start/team-from-plan) or self-update here — the
@@ -45,8 +46,11 @@ import {
45
46
  syncCursorRules,
46
47
  } from "../lib/cursor.mjs";
47
48
  import { installKimi, removeKimi } from "../lib/kimi.mjs";
49
+ import { installCodexHooks, installCursorHooks, removeCodexHooks, removeCursorHooks } from "../lib/harness-hooks.mjs";
50
+ import { formatHookReport, hookReport } from "../lib/hook-doctor.mjs";
48
51
  import { installOpencode, removeOpencode } from "../lib/opencode.mjs";
49
52
  import { readMode, writeMode, MODES } from "../lib/mode.mjs";
53
+ import { installGitHook, prepareCommitMsg, removeGitHook } from "../lib/git-trailer.mjs";
50
54
 
51
55
  const __dirname = dirname(fileURLToPath(import.meta.url));
52
56
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
@@ -55,15 +59,18 @@ const HELP = `mcpbox-claude v${pkg.version} — MCPBox agent harness (Claude / C
55
59
 
56
60
  Usage:
57
61
  mcpbox-claude init [--dir DIR] Write the managed CLAUDE.md policy block
58
- (daruma tracker + full pipeline). Idempotent.
62
+ (Daruma plans and optional idea pipeline). Idempotent.
59
63
  mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
60
64
  mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
61
- [mcp_servers.mcpbox] and the mcpbox skill
65
+ [mcp_servers.mcpbox], the mcpbox skill
62
66
  (for Codex without the plugin, which ships
63
- that skill itself). Idempotent.
67
+ that skill itself) and the session-gate
68
+ hooks in ~/.codex/hooks.json. Idempotent.
64
69
  mcpbox-claude codex-uninit [--dir DIR]
65
70
  mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
66
- .cursor/mcp.json mcpbox entry. Idempotent.
71
+ .cursor/mcp.json mcpbox entry, plus the
72
+ session-gate hooks in ~/.cursor/hooks.json.
73
+ Idempotent.
67
74
  In $HOME the policy goes to a sessionStart
68
75
  hook in ~/.cursor/hooks.json instead.
69
76
  mcpbox-claude cursor-uninit [--dir DIR]
@@ -76,9 +83,17 @@ Usage:
76
83
  opencode.json. Idempotent.
77
84
  mcpbox-claude opencode-uninit [--dir DIR]
78
85
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
86
+ Runs the mcpbox entries of ~/.codex/hooks.json,
87
+ ~/.cursor/hooks.json and ~/.claude/settings.json
88
+ as the host would and prints exit code + stderr.
79
89
  mcpbox-claude login Pair this machine so hooks load project knowledge.
80
90
  mcpbox-claude logout Forget the pairing token.
81
- mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (how raw ideas route).
91
+ mcpbox-claude mode [off|lite|full] Get/set prompt hints.
92
+ mcpbox-claude git-hook [install|uninstall] [--dir DIR]
93
+ Manage the git prepare-commit-msg hook that adds
94
+ "Daruma-Task: <id>" trailers (work/<id> branch or
95
+ tasks claimed in this session). Never overwrites a
96
+ foreign hook.
82
97
  mcpbox-claude export-marketplace [--dir DIR]
83
98
  Mirror this package to a stable directory usable as
84
99
  a Claude Code marketplace; prints the path.
@@ -111,6 +126,7 @@ const VERB = {
111
126
  "removed-file": "Removed",
112
127
  missing: "No mcpbox block found at",
113
128
  malformed: "Left alone (broken or repeated mcpbox markers — fix by hand):",
129
+ linked: "Left alone (symlink/hardlink — edit the real file by hand):",
114
130
  };
115
131
 
116
132
  async function cmdInit(rest) {
@@ -140,6 +156,7 @@ async function cmdCodexInit(rest) {
140
156
  report(policy);
141
157
  report(mcp);
142
158
  report(skill);
159
+ report(await installCodexHooks());
143
160
  }
144
161
 
145
162
  async function cmdCodexUninit(rest) {
@@ -149,6 +166,7 @@ async function cmdCodexUninit(rest) {
149
166
  report(mcp);
150
167
  report(skill);
151
168
  report(prompts);
169
+ report(await removeCodexHooks());
152
170
  }
153
171
 
154
172
  // Cursor ignores ~/.cursor/rules: in the home dir the policy goes through the
@@ -169,12 +187,15 @@ async function cmdCursorInit(rest) {
169
187
  if (isHomeDir(projectDir)) {
170
188
  await installCursorHome(homedir());
171
189
  report(await installCursorMcp({ projectDir: homedir() }));
190
+ report(await installCursorHooks());
172
191
  return;
173
192
  }
174
193
  const { rule, mcp, mode } = await installCursor({ projectDir, block: (await installBlocks()).plain });
175
194
  report(rule);
176
195
  report(mcp);
177
196
  report(mode);
197
+ // The session gate is user-level: Cursor runs ~/.cursor/hooks.json in every project.
198
+ report(await installCursorHooks());
178
199
  }
179
200
 
180
201
  async function cmdCursorUninit(rest) {
@@ -184,6 +205,7 @@ async function cmdCursorUninit(rest) {
184
205
  report(await removeCursorRule({ projectDir: homedir() }));
185
206
  report(await removeCursorMcp({ projectDir: homedir() }));
186
207
  report(await removeCursorModeCommand({ projectDir: homedir() }));
208
+ report(await removeCursorHooks());
187
209
  return;
188
210
  }
189
211
  const { rule, mcp, mode } = await removeCursor({ projectDir });
@@ -261,11 +283,11 @@ function mcpServerPresent() {
261
283
  async function cmdMode(rest) {
262
284
  const [arg] = rest;
263
285
  if (!arg || arg === "--show") {
264
- process.stdout.write(`mcpbox pipeline mode: ${readMode()} (${MODES.join(" | ")})\n`);
286
+ process.stdout.write(`mcpbox prompt-hint mode: ${readMode()} (${MODES.join(" | ")})\n`);
265
287
  return;
266
288
  }
267
289
  const m = await writeMode(arg); // throws on invalid → caught by main().catch
268
- process.stdout.write(`✓ mcpbox pipeline mode: ${m}\n`);
290
+ process.stdout.write(`✓ mcpbox prompt-hint mode: ${m}\n`);
269
291
  }
270
292
 
271
293
  // Pairs this machine with a workspace so hooks can put its project knowledge
@@ -326,6 +348,9 @@ async function cmdDoctor(rest) {
326
348
  const competing = await competingPolicyPaths({ projectDir });
327
349
  // Not required: without it hooks hint at the knowledge instead of loading it.
328
350
  const paired = (await readCredentials()) !== null;
351
+ // Diagnosis only, not part of READY: a broken hook does not unwire the
352
+ // server or the policy, and the section names its own fix.
353
+ const hooks = await hookReport({ cwd: resolve(projectDir ?? process.cwd()) });
329
354
 
330
355
  if (json) {
331
356
  process.stdout.write(JSON.stringify({
@@ -341,6 +366,7 @@ async function cmdDoctor(rest) {
341
366
  cursor_rule_stale_paths: cursorStale,
342
367
  knowledge_paired: paired,
343
368
  policy_server: policyServer,
369
+ hooks,
344
370
  }) + "\n");
345
371
  } else {
346
372
  const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
@@ -357,10 +383,13 @@ async function cmdDoctor(rest) {
357
383
  cursorStale.map((p) => ` ${p} (stale — run: mcpbox-claude cursor-init)\n`).join("") +
358
384
  competing.map((p) => ` ! ${p} also holds a daruma CLI policy block — keep one\n`).join("") +
359
385
  `Project knowledge: ${paired ? "✓ paired" : "hint only — run: npx -y @mcpbox/mcpbox-claude login"}\n` +
386
+ formatHookReport(hooks) +
360
387
  `${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
361
388
  );
362
389
  }
363
- process.exit(ready ? 0 : 1);
390
+ // A pipe is asynchronous on macOS: exiting right after the write cuts the
391
+ // report at the first 8 KiB. Same flush as hooks/bootstrap.mjs.
392
+ process.stdout.write("", () => process.exit(ready ? 0 : 1));
364
393
  }
365
394
 
366
395
  // The marketplace repo is private, so `claude plugin marketplace add
@@ -382,6 +411,21 @@ async function cmdExportMarketplace(rest) {
382
411
  process.stdout.write(`${target}\n`);
383
412
  }
384
413
 
414
+ async function cmdGitHook(rest) {
415
+ const [action = "install", ...flags] = rest;
416
+ const dir = parseDirFlag(flags).projectDir ?? process.cwd();
417
+ if (action === "install") {
418
+ const r = await installGitHook(dir);
419
+ process.stdout.write(r.installed ? `installed ${r.path}\n` : `skipped ${r.path}: ${r.reason}\n`);
420
+ if (!r.installed) process.exitCode = 1;
421
+ } else if (action === "uninstall") {
422
+ const r = await removeGitHook(dir);
423
+ process.stdout.write(r.removed ? `removed ${r.path}\n` : `nothing to remove at ${r.path}\n`);
424
+ } else {
425
+ throw new Error(`git-hook: unknown action ${action} (install|uninstall)`);
426
+ }
427
+ }
428
+
385
429
  async function main(argv) {
386
430
  const [, , cmd, ...rest] = argv;
387
431
  switch (cmd) {
@@ -431,6 +475,12 @@ async function main(argv) {
431
475
  return cmdLogout();
432
476
  case "mode":
433
477
  return cmdMode(rest);
478
+ case "git-hook":
479
+ return cmdGitHook(rest);
480
+ case "prepare-commit-msg":
481
+ // The git hook shim's fallback when the plugin path moved; never fails a commit.
482
+ await prepareCommitMsg({ messageFile: rest[0] }).catch(() => {});
483
+ return;
434
484
  case "export-marketplace":
435
485
  return cmdExportMarketplace(rest);
436
486
  default:
package/commands/close.md CHANGED
@@ -16,4 +16,6 @@ The user invoked `/mcpbox:close` (optionally with a task id or title in `$ARGUME
16
16
  comment, so no separate `daruma_comment` call. Fallback:
17
17
  `daruma_set_status status=done comment={ body: "<summary>", kind: "outcome" }`
18
18
  (the comment lands atomically with the transition).
19
+ When the completion schema includes `side_findings`, review them first and pass
20
+ `{reviewed:true, occurrence_ids:[…]}` on either transition. Use an empty list only after review.
19
21
  3. Confirm: `✓ closed <id> — <title>`. Do not touch other tasks.
package/commands/mine.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ---
2
- description: Show mcpbox tasks currently claimed / in progress for this session.
2
+ description: Show project tasks in progress or in review.
3
3
  ---
4
4
 
5
5
  The user invoked `/mcpbox:mine`.
6
6
 
7
7
  ## Steps
8
8
 
9
- 1. Resolve project (`daruma_workspace_info` → `default_project`).
9
+ 1. Resolve project as in `/mcpbox:tasks`.
10
10
  2. `daruma_list project_id=<resolved> status="in_progress,in_review" limit=30`.
11
- 3. Render the same compact table as `/mcpbox:tasks`, titled `## In progress — <N>`.
12
- 4. If empty: "nothing claimed — `/mcpbox:next` to claim the next ready task." Read-only.
11
+ 3. Render the same compact table as `/mcpbox:tasks`, titled `## Project tasks in progress or in review — <N>`. These are project-wide tasks, not necessarily claimed by this session. If the response has more pages, say so.
12
+ 4. If empty: "No project tasks in progress or in review." On error, print it verbatim. Read-only.