@mcpbox/mcpbox-claude 0.1.17 → 0.1.19

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcpbox-claude",
3
3
  "description": "MCPBox × Claude Code glue. Drives the mcpbox MCP server (daruma tracker + full MeiSei pipeline torii→…→fujin→daruma). Ships /mcpbox:{tasks,plan,next,mine,status,close,sync,capture,doctor,mode} and pipeline commands, SessionStart/Stop/UserPromptSubmit hooks, and a managed CLAUDE.md policy that makes mcpbox the default tracker AND pipeline substrate.",
4
- "version": "0.1.17",
4
+ "version": "0.1.19",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "mcpbox",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "MCPBox agent stack for Codex: the daruma tracker plus the MeiSei maturity pipeline behind one MCP server.",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
8
8
  "homepage": "https://mcpbox.ru",
9
+ "skills": "./skills/",
9
10
  "mcpServers": "./.mcp.json",
10
11
  "interface": {
11
12
  "displayName": "MCPBox",
12
13
  "shortDescription": "Task tracker + maturity pipeline for agents.",
13
- "longDescription": "One MCP endpoint (https://mcpbox.ru/v1/mcp) exposing the daruma tracker (tasks, plans, plan-only intake) and the platform pipeline torii→satori→enma→yatagarasu→fujin→daruma. Ships the routing policy as a skill and /mcpbox-* prompts.",
14
+ "longDescription": "One MCP endpoint (https://mcpbox.ru/v1/mcp) exposing the daruma tracker (tasks, plans, plan-only intake) and the platform pipeline torii→satori→enma→yatagarasu→fujin→daruma. Ships the routing policy and command workflows as model-invoked Codex skills generated from the Claude command source.",
14
15
  "developerName": "tupical",
15
16
  "category": "Productivity",
16
17
  "websiteURL": "https://mcpbox.ru"
package/README.md CHANGED
@@ -46,6 +46,11 @@ codex plugin add mcpbox --marketplace mcpbox
46
46
  codex plugin marketplace upgrade mcpbox # later, to update
47
47
  ```
48
48
 
49
+ Codex exposes the plugin's command workflows as skills. `codex-init` installs
50
+ the managed policy, MCP server, and routing skill; it does not write the unused
51
+ `~/.codex/prompts` surface. `codex-uninit` still removes legacy `mcpbox-*.md`
52
+ prompt files left by older installs.
53
+
49
54
  Cursor and Kimi have no plugin manager; they are file installs, so re-run their
50
55
  init to update:
51
56
 
@@ -55,9 +60,36 @@ npx -y @mcpbox/mcpbox-claude@latest kimi-init
55
60
  npx -y @mcpbox/mcpbox-claude@latest opencode-init
56
61
  ```
57
62
 
63
+ On Claude and Codex a plugin update also reaches the policy you already
64
+ installed: at session start the hook rewrites every existing `mcpbox:policy`
65
+ block from the working directory up (`CLAUDE.md` on Claude, `AGENTS.md` plus
66
+ the `mcpbox` skill on Codex) to the running version, and says so in the
67
+ session context. It never adds a block and never touches text outside the
68
+ markers; `doctor --json` reports `policy_stale` until it has run. Set
69
+ `MCPBOX_NO_POLICY_SYNC=1` to keep installed blocks as they are.
70
+
71
+ ### Project knowledge in every session
72
+
73
+ Agents answer repo questions right when they have the project's knowledge
74
+ (`mcpbox_knowledge_read`) in front of them, and rarely fetch it on their own.
75
+ Pair the machine once so the first prompt of every session carries it:
76
+
77
+ ```bash
78
+ npx -y @mcpbox/mcpbox-claude login # confirm the code in the browser
79
+ ```
80
+
81
+ The workspace-bound token is kept in `~/.agents/mcpbox/credentials.json`
82
+ (mode 0600) and only ever sent over https; `logout` deletes the file, and
83
+ revoking the token itself happens in the workspace settings (Tokens). The
84
+ repo path of each new session goes to the server to find its project. Unpaired, rejected, or with the path
85
+ unbound in the paired workspace, the hook adds a ready `mcpbox_knowledge_read`
86
+ call instead of the text. Knowledge rows arrive
87
+ marked as workspace data, not instructions. Mode `off` disables both.
88
+
58
89
  A stale version announces itself at session start on Claude, Codex, and Kimi.
59
- Cursor exposes no hooks at all, so nothing can announce anything there — check
60
- manually, or let `cursor-init` in a routine update pass do it. Set
90
+ The Cursor adapter installs no hooks (Cursor has them since 2026, unwired
91
+ here), so nothing announces anything there — check manually, or let
92
+ `cursor-init` in a routine update pass do it. Set
61
93
  `MCPBOX_NO_UPDATE_CHECK=1` to disable the registry lookup entirely (air-gapped
62
94
  installs, CI).
63
95
 
@@ -66,11 +98,15 @@ installs, CI).
66
98
  | Agent | Policy surface | MCP server | Hooks |
67
99
  |--------|----------------------------------------|-------------------------------------|-------|
68
100
  | Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
69
- | Codex | `AGENTS.md` block (`mcpbox:policy`) | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
101
+ | Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
70
102
  | Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` | `mcpbox` entry in `.cursor/mcp.json` | — |
71
103
  | Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
72
104
  | OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
73
105
 
106
+ Codex skills are generated at package time from the same `commands/*.md` files
107
+ that provide Claude's `/mcpbox:*` commands. Codex selects these skills by their
108
+ descriptions; they are not user-entered slash commands.
109
+
74
110
  All four agents accept `mcpbox mode [off|lite|full]` through the managed
75
111
  policy. Claude also exposes `/mcpbox:mode`, Cursor exposes `/mcpbox-mode`, and
76
112
  the shared value lives in `~/.agents/mcpbox/mode`.
@@ -90,7 +126,7 @@ Kimi specifics:
90
126
  ```
91
127
  mcpbox-claude init [--dir DIR] Managed CLAUDE.md policy block. Idempotent.
92
128
  mcpbox-claude uninit [--dir DIR] Remove the CLAUDE.md policy block.
93
- mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + ~/.codex/config.toml server.
129
+ mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + config.toml server + routing skill.
94
130
  mcpbox-claude codex-uninit [--dir DIR]
95
131
  mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server.
96
132
  mcpbox-claude cursor-uninit [--dir DIR]
@@ -110,3 +146,35 @@ Set `MCPBOX_NO_UPDATE_CHECK=1` to disable hook update checks.
110
146
  ## License
111
147
 
112
148
  UNLICENSED — MCPBox is a closed SaaS.
149
+
150
+ ### Inherited Claude policy
151
+
152
+ `init --dir DIR` checks `CLAUDE.md` in DIR and its parent directories, matching
153
+ [Claude Code's cumulative directory hierarchy](https://code.claude.com/docs/en/memory#how-claude-md-files-load).
154
+ If a parent already has a managed MCPBox block, init inherits it and removes only
155
+ the requested directory's redundant managed block. Other local instructions and
156
+ parent files are preserved. A managed-only child file is removed. Re-running init
157
+ is idempotent; symlink/hardlink edits and malformed markers are refused.
158
+
159
+ `doctor --json` reports `policy_paths` and `policy_duplicate`; duplicate blocks
160
+ make readiness false. Parent blocks are not refreshed by a child install: run init
161
+ in the owning parent directory explicitly to update that policy. This check covers
162
+ the installer-owned `CLAUDE.md` hierarchy; it does not interpret imports,
163
+ `CLAUDE.local.md`, `.claude/CLAUDE.md`, or exclusion settings.
164
+
165
+ Measured on 2026-09-11 for task `01a05e61-0067-7163-b74e-acacdd77cf5d`:
166
+ removing the redundant project block reduced the combined parent/project files
167
+ from 38,851 to 22,964 bytes. Two one-turn Haiku probes using the same command,
168
+ with tools disabled and no session persistence, both had zero cache reads.
169
+ `cache_creation_input_tokens` changed from 24,349 to 19,745 (−4,604; −18.9%);
170
+ uncached input stayed at 10 tokens. Reported costs were $0.049013 and $0.039800.
171
+ These are observed cold-start totals, not a controlled attribution of every token
172
+ or evidence about conversational-history cost. The AFTER probe was explicitly
173
+ approved by the owner with a $0.30 cap; no local instruction text is published.
174
+
175
+ The managed policy is a compact index (at most 100 lines) for all clients.
176
+ It retains tracker safety rules, mode handling and tool/skill entry points.
177
+ Routing and the execution-path verification rule before editing are supplied by
178
+ MCP `initialize.instructions` (`PLATFORM_INSTRUCTIONS` in
179
+ `crates/cloud-api/src/v1_gateway.rs`); clients without command skills use the plain tool
180
+ entry points. Reconnect the MCP server if its instructions are unavailable.
@@ -19,7 +19,8 @@ import { homedir } from "node:os";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { dirname, join, resolve } from "node:path";
21
21
  import { spawnSync } from "node:child_process";
22
- import { installPolicy, removePolicy, BEGIN } from "../lib/policy.mjs";
22
+ import { installPolicy, removePolicy, policyHierarchy, stalePolicyPaths, competingPolicyPaths } from "../lib/policy.mjs";
23
+ import { credentialsPath, login, logout, readCredentials } from "../lib/cloud-knowledge.mjs";
23
24
  import { installCodex, removeCodex, installCodexPolicy } from "../lib/codex.mjs";
24
25
  import {
25
26
  installCursor,
@@ -41,8 +42,8 @@ Usage:
41
42
  (daruma tracker + full pipeline). Idempotent.
42
43
  mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
43
44
  mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
44
- [mcp_servers.mcpbox], the mcpbox skill and
45
- /mcpbox-* prompts. Idempotent.
45
+ [mcp_servers.mcpbox] and the mcpbox skill.
46
+ Idempotent.
46
47
  mcpbox-claude codex-uninit [--dir DIR]
47
48
  mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
48
49
  .cursor/mcp.json mcpbox entry. Idempotent.
@@ -56,6 +57,8 @@ Usage:
56
57
  opencode.json. Idempotent.
57
58
  mcpbox-claude opencode-uninit [--dir DIR]
58
59
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
60
+ mcpbox-claude login Pair this machine so hooks load project knowledge.
61
+ mcpbox-claude logout Forget the pairing token.
59
62
  mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (how raw ideas route).
60
63
  mcpbox-claude export-marketplace [--dir DIR]
61
64
  Mirror this package to a stable directory usable as
@@ -81,12 +84,14 @@ function parseDirFlag(rest) {
81
84
 
82
85
  const VERB = {
83
86
  installed: "Created",
87
+ inherited: "Using ancestor policy:",
84
88
  updated: "Refreshed mcpbox block in",
85
89
  appended: "Appended mcpbox block to",
86
90
  unchanged: "Already current:",
87
91
  "removed-block": "Removed mcpbox block from",
88
92
  "removed-file": "Removed",
89
93
  missing: "No mcpbox block found at",
94
+ malformed: "Left alone (broken or repeated mcpbox markers — fix by hand):",
90
95
  };
91
96
 
92
97
  async function cmdInit(rest) {
@@ -108,11 +113,10 @@ function report(r) {
108
113
 
109
114
  async function cmdCodexInit(rest) {
110
115
  const { projectDir } = parseDirFlag(rest);
111
- const { policy, mcp, skill, prompts } = await installCodex({ projectDir });
116
+ const { policy, mcp, skill } = await installCodex({ projectDir });
112
117
  report(policy);
113
118
  report(mcp);
114
119
  report(skill);
115
- report(prompts);
116
120
  }
117
121
 
118
122
  async function cmdCodexUninit(rest) {
@@ -183,15 +187,6 @@ async function cmdCursorPolicy(rest) {
183
187
  report(await installCursorModeCommand({ projectDir }));
184
188
  }
185
189
 
186
- async function policyPresent(projectDir) {
187
- const target = join(projectDir ? resolve(projectDir) : process.cwd(), "CLAUDE.md");
188
- try {
189
- return (await fs.readFile(target, "utf8")).includes(BEGIN);
190
- } catch (err) {
191
- if (err.code === "ENOENT") return false;
192
- throw err;
193
- }
194
- }
195
190
 
196
191
  function mcpServerPresent() {
197
192
  // `claude mcp list` prints one server per line as "name: url ...".
@@ -210,22 +205,59 @@ async function cmdMode(rest) {
210
205
  process.stdout.write(`✓ mcpbox pipeline mode: ${m}\n`);
211
206
  }
212
207
 
208
+ // Pairs this machine with a workspace so hooks can put its project knowledge
209
+ // into new sessions (lib/cloud-knowledge.mjs). The token stays in
210
+ // ~/.agents/mcpbox/credentials.json, readable by this user only.
211
+ async function cmdLogin(rest) {
212
+ const i = rest.indexOf("--base-url");
213
+ const baseUrl = i !== -1 ? rest[i + 1] : undefined;
214
+ if (i !== -1 && (!baseUrl || baseUrl.startsWith("--"))) throw new Error("--base-url needs a value");
215
+ const creds = await login(baseUrl ? { baseUrl } : {});
216
+ process.stdout.write(`✓ Paired with workspace ${creds.workspace_id}; token in ${credentialsPath()}\n`);
217
+ }
218
+
219
+ async function cmdLogout() {
220
+ await logout();
221
+ process.stdout.write(
222
+ `✓ Removed ${credentialsPath()}\n` +
223
+ "The token itself stays valid until revoked in the workspace settings (Tokens).\n",
224
+ );
225
+ }
226
+
213
227
  async function cmdDoctor(rest) {
214
228
  const json = rest.includes("--json");
215
229
  const flags = rest.filter((a) => a !== "--json");
216
230
  const { projectDir } = parseDirFlag(flags);
217
231
 
218
- const policy = await policyPresent(projectDir);
232
+ const hierarchy = await policyHierarchy({ projectDir });
233
+ const policy = hierarchy.present;
219
234
  const mcp = mcpServerPresent();
220
- const ready = policy && mcp === true;
235
+ const ready = policy && !hierarchy.duplicate && mcp === true;
236
+ // Stale is a warning, not NOT READY: the next SessionStart refreshes it.
237
+ const stale = await stalePolicyPaths(hierarchy.paths);
238
+ // Also a warning: two policies in one file, one of them from the daruma CLI.
239
+ const competing = await competingPolicyPaths({ projectDir });
240
+ // Not required: without it hooks hint at the knowledge instead of loading it.
241
+ const paired = (await readCredentials()) !== null;
221
242
 
222
243
  if (json) {
223
- process.stdout.write(JSON.stringify({ ready, policy, mcp }) + "\n");
244
+ process.stdout.write(JSON.stringify({
245
+ ready, policy, mcp,
246
+ policy_paths: hierarchy.paths,
247
+ policy_duplicate: hierarchy.duplicate,
248
+ policy_stale: stale.length > 0,
249
+ policy_stale_paths: stale,
250
+ policy_competing_paths: competing,
251
+ knowledge_paired: paired,
252
+ }) + "\n");
224
253
  } else {
225
254
  const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
226
255
  process.stdout.write(
227
256
  `mcpbox MCP server: ${mark(mcp)}${mcp === null ? " (claude CLI not found)" : ""}\n` +
228
- `CLAUDE.md policy: ${mark(policy)}\n` +
257
+ `CLAUDE.md policy: ${mark(policy)}${hierarchy.duplicate ? " (duplicate managed blocks)" : ""}\n` +
258
+ hierarchy.paths.map((p) => ` ${p}${stale.includes(p) ? " (stale — the next session start of this plugin version refreshes it)" : ""}\n`).join("") +
259
+ competing.map((p) => ` ! ${p} also holds a daruma CLI policy block — keep one\n`).join("") +
260
+ `Project knowledge: ${paired ? "✓ paired" : "hint only — run: npx -y @mcpbox/mcpbox-claude login"}\n` +
229
261
  `${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
230
262
  );
231
263
  }
@@ -290,6 +322,10 @@ async function main(argv) {
290
322
  return cmdCursorPolicy(rest);
291
323
  case "doctor":
292
324
  return cmdDoctor(rest);
325
+ case "login":
326
+ return cmdLogin(rest);
327
+ case "logout":
328
+ return cmdLogout();
293
329
  case "mode":
294
330
  return cmdMode(rest);
295
331
  case "export-marketplace":
@@ -8,7 +8,7 @@ The user invoked `/mcpbox:capture` (optionally with the lesson text in `$ARGUMEN
8
8
 
9
9
  1. Distill ONE concrete reusable lesson from the session: a command, invariant, bug
10
10
  pattern, or file path — not a generic summary. If nothing durable, say so and stop.
11
- 2. Attach it where it belongs:
12
- - If a task is in progress, `daruma_comment task_id=<id> body="lesson: <lesson>"`.
13
- - Else, if the project uses docs, `daruma_doc_append` to the relevant doc.
11
+ 2. Persist it with `mcpbox_knowledge_write` (kind `constraint`, `decision`,
12
+ `project_context` or `research_note`; scope=project with the resolved `project_id`).
13
+ If it only matters to one in-progress task, a `daruma_comment` on that task is enough.
14
14
  3. Keep it to one or two sentences. Confirm what was recorded and where.
package/commands/close.md CHANGED
@@ -10,6 +10,10 @@ The user invoked `/mcpbox:close` (optionally with a task id or title in `$ARGUME
10
10
  - If `$ARGUMENTS` has a task id, use it.
11
11
  - Else resolve the current in-progress task via `daruma_list status=in_progress`
12
12
  (if exactly one, use it; if several, list them and ask which).
13
- 2. If the user gave a summary, first `daruma_comment task_id=<id> body="<summary>"`.
14
- 3. `daruma_complete task_id=<id>` (preferred) or `daruma_set_status status=done`.
15
- 4. Confirm: `✓ closed <id> — <title>`. Do not touch other tasks.
13
+ 2. `daruma_complete id=<id>` (preferred) — if the user gave a summary, pass it
14
+ as `result_summary="<summary>"` (plus `reason` / `related_artifacts` when
15
+ known); the completion note replaces a preliminary
16
+ comment, so no separate `daruma_comment` call. Fallback:
17
+ `daruma_set_status status=done comment={ body: "<summary>", kind: "outcome" }`
18
+ (the comment lands atomically with the transition).
19
+ 3. Confirm: `✓ closed <id> — <title>`. Do not touch other tasks.
@@ -11,5 +11,9 @@ The user invoked `/mcpbox:doctor`.
11
11
  `npx @mcpbox/mcpbox setup` and restart Claude Code.
12
12
  2. Reachability: `daruma_healthz`. Report version + git_sha, or the failure verbatim.
13
13
  3. Policy: confirm this project's `CLAUDE.md` contains the `mcpbox:policy` managed block.
14
- If missing, `npx -y @mcpbox/mcpbox-claude init` (or re-run setup).
14
+ If missing, `npx -y @mcpbox/mcpbox-claude init` (or re-run setup). If
15
+ `npx -y @mcpbox/mcpbox-claude doctor --json` reports `policy_stale`, the block
16
+ predates the installed plugin; the next session start refreshes it. Paths in
17
+ `policy_competing_paths` also carry a daruma CLI policy block
18
+ (`daruma-claude` / `daruma-codex`); tell the user to keep one of the two.
15
19
  4. Render a short checklist with ✓ / ✗ per item and a final READY / NOT READY line.
package/commands/mode.md CHANGED
@@ -15,8 +15,8 @@ The user invoked `/mcpbox:mode` with `$ARGUMENTS` = `off` | `lite` | `full` (emp
15
15
  before it becomes a task.
16
16
 
17
17
  The mode only tunes how actively you *offer* the pipeline. It does not change where work
18
- lands — that is the one routing rule, identical in the MCP server's `initialize` instructions,
19
- the policy block, and the `daruma_plan_materialize` description: decided-and-bounded work and
18
+ lands — that is the one routing rule in the MCP server's `initialize` instructions (tool descriptions
19
+ point to it): decided-and-bounded work and
20
20
  follow-ups extending a run that already handed off go straight to daruma; raw material — and
21
21
  anything belonging to a run still in flight — goes through the pipeline.
22
22
 
package/commands/next.md CHANGED
@@ -8,10 +8,11 @@ to the user/agent to actually execute it.
8
8
  ## Steps
9
9
 
10
10
  1. Resolve project (`daruma_workspace_info` → `default_project`).
11
- 2. Active plan: `daruma_plan_list` filtered to `status = ["active","in_progress"]`, most recent.
12
- If none, stop with "no active plan — `daruma_plan_create` first".
13
- 3. `daruma_plan_next_task` with the plan id. The server atomically picks the next
14
- ready (unblocked) task and transitions `todo → in_progress`.
11
+ 2. Active plan: `daruma_plan_list` filtered to `status = "active"`, most recent.
12
+ If none, stop with "no active plan — create one with `daruma_plan_materialize`".
13
+ 3. `daruma_plan_drain_next` with the plan id. The server atomically picks the next
14
+ ready (unblocked) task and claims it for this session; it returns null when no
15
+ unclaimed ready task remains.
15
16
  4. If "no ready task": print the server reason (e.g. "3 tasks blocked by X") and
16
17
  suggest `/mcpbox:plan` to inspect dependencies. Stop.
17
18
  5. Otherwise render the briefing:
@@ -30,8 +31,8 @@ to the user/agent to actually execute it.
30
31
  6. End with:
31
32
 
32
33
  ```
33
- → When done: daruma_complete task_id=<task_id> [comment="<summary>"]
34
- → On failure: daruma_comment + daruma_set_status status=todo
34
+ → When done: daruma_complete id=<task_id> [result_summary="<summary>"]
35
+ → On failure: daruma_set_status status=todo comment={ body, kind: "blocker" }
35
36
  ```
36
37
 
37
38
  7. Briefing only — do not start executing the task in this command.
@@ -6,9 +6,10 @@ The user invoked `/mcpbox:status`.
6
6
 
7
7
  ## Steps
8
8
 
9
- 1. `daruma_healthz` — if it fails, report "mcpbox unreachable" and how to start the
10
- server; stop (do not fall back to `.omc/plans/` or markdown).
11
- 2. `daruma_workspace_info` — one call carries most of the answer:
9
+ 1. `daruma_workspace_info` — one call carries most of the answer. If it fails
10
+ with a transport error, report "mcpbox unreachable" and how to start the
11
+ server; stop (do not fall back to `.omc/plans/` or markdown). No separate
12
+ health probe: the first real call is the probe.
12
13
  - `workspace.slug` / `workspace.title` — the authorized workspace;
13
14
  - `account.email` — who this MCP session is authenticated as;
14
15
  - `scopes[]` — repo→project bindings; match the current working directory
@@ -16,14 +17,14 @@ The user invoked `/mcpbox:status`.
16
17
  this repo's `project_id`.
17
18
  - Self-hosted installs have no cloud account, so `workspace` and `account`
18
19
  may be absent. Omit the line entirely — never print `null` or a bare UUID.
19
- 3. Resolve the project **title** for that `project_id` via `daruma_project_list`
20
+ 2. Resolve the project **title** for that `project_id` via `daruma_project_list`
20
21
  (the `name` inside `scopes` is only the directory basename, not the project's
21
22
  title). Skip if the cwd matches no scope.
22
- 4. One scoped `daruma_list status=active` → count open tasks (do not enumerate
23
+ 3. One scoped `daruma_list status=active` → count open tasks (do not enumerate
23
24
  the archive).
24
- 5. `mcpbox_runs_list` with `limit=5` (and `status=failed` if the user asked about
25
+ 4. `mcpbox_runs_list` with `limit=5` (and `status=failed` if the user asked about
25
26
  failures) → recent pipeline runs.
26
- 6. Render, dropping any line whose value is unknown:
27
+ 5. Render, dropping any line whose value is unknown:
27
28
 
28
29
  ```
29
30
  ## mcpbox status
@@ -31,11 +32,11 @@ The user invoked `/mcpbox:status`.
31
32
  account: <email>
32
33
  project: <project title> — <repo path>
33
34
  open: <N> tasks
34
- server: ok (v<version>, sha <git_sha>)
35
+ server: ok (v<version>, sha <git_sha>) — only when `/mcpbox:doctor` ran
35
36
  runs: <run_id> <status> · <run_id> <status> …
36
37
  ```
37
38
 
38
39
  Identity first: "which workspace am I in, as whom, on what project" is the
39
40
  question this command exists to answer; server health is the footnote.
40
41
 
41
- 7. Read-only.
42
+ 6. Read-only.
package/commands/trace.md CHANGED
@@ -18,5 +18,5 @@ The user invoked `/mcpbox:trace` with a `run_id` in `$ARGUMENTS` (or asked about
18
18
  handoff: <task_id or —>
19
19
  ```
20
20
 
21
- 4. If `status=failed`, surface the failing layer + reason and suggest re-running
22
- `/mcpbox:pipeline-run` from the previous layer. Read-only.
21
+ 4. If `status=failed`, surface the failing layer + reason and suggest retrying that
22
+ hop with `mcpbox_pipeline_advance { run_id, layer }` once its input is fixed. Read-only.
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ // Integrity check, not an OS sandbox. The controller pins the baseline before execution.
3
+ import { execFileSync } from "node:child_process";
4
+ import { readFileSync, lstatSync, realpathSync, writeSync } from "node:fs";
5
+ import { resolve, relative, isAbsolute } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+
8
+ export function checkAcceptanceLock(lock, event = {}) {
9
+ if (!lock || typeof lock.repo !== "string" || !isAbsolute(lock.repo)
10
+ || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(lock.base)
11
+ || !Array.isArray(lock.paths) || !lock.paths.length) {
12
+ throw new Error("invalid acceptance lock: expected absolute repo, immutable commit SHA and paths");
13
+ }
14
+ const repo = realpathSync(lock.repo);
15
+ const gitEnv = { ...process.env };
16
+ for (const key of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE"]) delete gitEnv[key];
17
+ const git = (args) => execFileSync("git", ["--no-replace-objects", ...args], {
18
+ cwd: repo, timeout: 5000, maxBuffer: 16 * 1024 * 1024,
19
+ env: gitEnv,
20
+ stdio: ["ignore", "pipe", "pipe"],
21
+ });
22
+ // Do not allow Git environment overrides to redirect the baseline lookup.
23
+ if (realpathSync(git(["rev-parse", "--show-toplevel"]).toString().replace(/\r?\n$/, "")) !== repo) {
24
+ throw new Error("acceptance repo must be the Git root");
25
+ }
26
+ for (const path of lock.paths) {
27
+ if (typeof path !== "string" || !path || isAbsolute(path)
28
+ || path.includes("\\") || path.split("/").some((part) => !part || part === "." || part === "..")) {
29
+ throw new Error("acceptance paths must be normalized repository-relative files");
30
+ }
31
+ const file = resolve(repo, path);
32
+ const actual = realpathSync(file);
33
+ const rel = relative(repo, actual);
34
+ if (rel.startsWith("../") || isAbsolute(rel) || actual !== file || !lstatSync(file).isFile()) {
35
+ throw new Error(`protected assertion must be a regular file without symlink traversal: ${path}`);
36
+ }
37
+ if (!readFileSync(file).equals(git(["show", `${lock.base}:${path}`]))) {
38
+ throw new Error(`protected assertion changed: ${path}`);
39
+ }
40
+ if (event.hook_event_name === "PreToolUse" && ["Edit", "Write", "MultiEdit"].includes(event.tool_name)) {
41
+ const target = event.tool_input?.file_path ?? event.tool_input?.path;
42
+ if (typeof target === "string" && resolve(event.cwd ?? repo, target) === file) {
43
+ throw new Error(`executor cannot edit protected assertion: ${path}`);
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
50
+ if (process.env.MCPBOX_ACCEPTANCE_LOCK) {
51
+ try {
52
+ let input = "";
53
+ for await (const chunk of process.stdin) {
54
+ input += chunk;
55
+ // Hook transports may keep stdin open after the JSON message.
56
+ try { JSON.parse(input); break; } catch { /* await the remaining JSON */ }
57
+ }
58
+ checkAcceptanceLock(JSON.parse(process.env.MCPBOX_ACCEPTANCE_LOCK), input.trim() ? JSON.parse(input) : {});
59
+ } catch (error) {
60
+ writeSync(2, `[mcpbox/acceptance-integrity] ${error.message}\nStop execution; record an integrity warning in Daruma. Do not rebaseline the oracle to obtain PASS.\n`);
61
+ process.exitCode = 2;
62
+ }
63
+ }
64
+ }
package/hooks/hooks.json CHANGED
@@ -29,11 +29,33 @@
29
29
  "type": "command",
30
30
  "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/stop.mjs\"",
31
31
  "asyncRewake": true,
32
- "rewakeMessage": "mcpbox-claude auto-record: a reusable lesson was captured from this session. Acknowledge or skip.",
32
+ "rewakeMessage": "mcpbox-claude auto-record: consider capturing a reusable lesson from this session, or skip.",
33
33
  "rewakeSummary": "mcpbox-claude captured a session lesson"
34
34
  }
35
35
  ]
36
36
  }
37
+ ],
38
+ "PreToolUse": [
39
+ {
40
+ "hooks": [
41
+ {
42
+ "type": "command",
43
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/acceptance-guard.mjs\"",
44
+ "timeout": 15
45
+ }
46
+ ]
47
+ }
48
+ ],
49
+ "PostToolUse": [
50
+ {
51
+ "hooks": [
52
+ {
53
+ "type": "command",
54
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/acceptance-guard.mjs\"",
55
+ "timeout": 15
56
+ }
57
+ ]
58
+ }
37
59
  ]
38
60
  }
39
61
  }
@@ -18,6 +18,7 @@
18
18
 
19
19
  import { isCodexSurface, writeHookOutput } from "../lib/hook-output.mjs";
20
20
  import { MCPClient } from "../lib/mcp-client.mjs";
21
+ import { BLOCK_BODY_PLAIN, syncPolicyBlocks } from "../lib/policy.mjs";
21
22
  import { checkForUpdate, updateNotice } from "../lib/update-check.mjs";
22
23
  import { VERSION } from "../lib/version.mjs";
23
24
  import { pathToFileURL } from "node:url";
@@ -101,8 +102,29 @@ async function fetchSummary() {
101
102
  }
102
103
  }
103
104
 
105
+ // Bring the policy blocks already installed around cwd up to this plugin
106
+ // version (see syncPolicyBlocks). Failures stay silent: a read-only tree must
107
+ // never block the session. MCPBOX_NO_POLICY_SYNC=1 opts out. Only the plugin
108
+ // surfaces sync: Kimi runs a copy frozen at kimi-init (no CLAUDE_PLUGIN_ROOT,
109
+ // no PLUGIN_DATA), whose policy would be stale by construction.
110
+ export async function syncPolicy(cwd = process.cwd(), env = process.env) {
111
+ if (env.MCPBOX_NO_POLICY_SYNC) return [];
112
+ const paths = [];
113
+ if (isCodexSurface(env)) {
114
+ paths.push(...await syncPolicyBlocks({ cwd, file: "AGENTS.md", block: BLOCK_BODY_PLAIN }).catch(() => []));
115
+ try {
116
+ const { syncCodexSkill } = await import("../lib/codex.mjs");
117
+ const skill = await syncCodexSkill();
118
+ if (skill.action === "updated") paths.push(skill.path);
119
+ } catch { /* skill dir unwritable — AGENTS.md sync still counts */ }
120
+ } else if (env.CLAUDE_PLUGIN_ROOT) {
121
+ paths.push(...await syncPolicyBlocks({ cwd }).catch(() => []));
122
+ }
123
+ return paths;
124
+ }
125
+
104
126
  export async function main() {
105
- const [data, update] = await Promise.all([
127
+ const [data, update, synced] = await Promise.all([
106
128
  fetchSummary().catch((err) => {
107
129
  if (process.env.MCPBOX_DEBUG) {
108
130
  process.stderr.write(`[mcpbox-claude/session-start] error: ${err?.message ?? err}\n`);
@@ -110,13 +132,22 @@ export async function main() {
110
132
  return null;
111
133
  }),
112
134
  checkForUpdate({ current: VERSION }),
135
+ syncPolicy(),
113
136
  ]);
114
- const systemMessage = update?.outdated
115
- ? updateNotice(update.current, update.latest, isCodexSurface() ? "codex" : "claude")
116
- : undefined;
137
+ const syncNote = synced.length
138
+ ? `[mcpbox] Policy block refreshed to plugin ${VERSION}: ${synced.join(", ")}\n`
139
+ : "";
140
+ // The user sees what we wrote into their files, not just the model.
141
+ const notices = [
142
+ update?.outdated
143
+ ? updateNotice(update.current, update.latest, isCodexSurface() ? "codex" : "claude")
144
+ : null,
145
+ synced.length ? `mcpbox: policy block refreshed to ${VERSION} in ${synced.join(", ")}` : null,
146
+ ].filter(Boolean);
147
+ const systemMessage = notices.length ? notices.join("\n") : undefined;
117
148
 
118
149
  if (!data) {
119
- writeHookOutput("SessionStart", "", { systemMessage });
150
+ writeHookOutput("SessionStart", syncNote, { systemMessage });
120
151
  process.exit(0);
121
152
  }
122
153
 
@@ -125,7 +156,7 @@ export async function main() {
125
156
  if (!tasks || tasks.length === 0) {
126
157
  writeHookOutput(
127
158
  "SessionStart",
128
- "[mcpbox] No open tasks — run /mcpbox:tasks to verify, or /mcpbox:pipeline-run \"<idea>\" to open a maturity run.",
159
+ syncNote + "[mcpbox] No open tasks — run /mcpbox:tasks to verify, or /mcpbox:pipeline-run \"<idea>\" to open a maturity run.",
129
160
  { systemMessage },
130
161
  );
131
162
  process.exit(0);
@@ -143,7 +174,7 @@ export async function main() {
143
174
  if (extra > 0) lines.push(` …and ${extra} more — /mcpbox:tasks for full list`);
144
175
  lines.push("→ /mcpbox:next to claim the next task | /mcpbox:status for server + pipeline health");
145
176
 
146
- writeHookOutput("SessionStart", lines.join("\n"), { systemMessage });
177
+ writeHookOutput("SessionStart", syncNote + lines.join("\n"), { systemMessage });
147
178
  process.exit(0);
148
179
  }
149
180