@mcpbox/mcpbox-claude 0.1.16 → 0.1.18

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.16",
4
+ "version": "0.1.18",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "mcpbox",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
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
@@ -1,6 +1,6 @@
1
1
  # @mcpbox/mcpbox-claude
2
2
 
3
- MCPBox agent harness for **Claude Code**, **Codex**, **Cursor**, and **Kimi Code**.
3
+ MCPBox agent harness for **Claude Code**, **Codex**, **Cursor**, **Kimi Code**, and **OpenCode**.
4
4
  Wires the single canonical MCP server (`https://mcpbox.ru/v1/mcp` — the daruma
5
5
  tracker tools plus the platform pipeline `torii→satori→enma→yatagarasu→fujin→daruma`)
6
6
  and drops a managed policy into each agent's native config file.
@@ -46,12 +46,18 @@ 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
 
52
57
  ```bash
53
58
  npx -y @mcpbox/mcpbox-claude@latest cursor-init
54
59
  npx -y @mcpbox/mcpbox-claude@latest kimi-init
60
+ npx -y @mcpbox/mcpbox-claude@latest opencode-init
55
61
  ```
56
62
 
57
63
  A stale version announces itself at session start on Claude, Codex, and Kimi.
@@ -65,9 +71,14 @@ installs, CI).
65
71
  | Agent | Policy surface | MCP server | Hooks |
66
72
  |--------|----------------------------------------|-------------------------------------|-------|
67
73
  | Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
68
- | Codex | `AGENTS.md` block (`mcpbox:policy`) | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
74
+ | Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
69
75
  | Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` | `mcpbox` entry in `.cursor/mcp.json` | — |
70
76
  | Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
77
+ | OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
78
+
79
+ Codex skills are generated at package time from the same `commands/*.md` files
80
+ that provide Claude's `/mcpbox:*` commands. Codex selects these skills by their
81
+ descriptions; they are not user-entered slash commands.
71
82
 
72
83
  All four agents accept `mcpbox mode [off|lite|full]` through the managed
73
84
  policy. Claude also exposes `/mcpbox:mode`, Cursor exposes `/mcpbox-mode`, and
@@ -88,13 +99,16 @@ Kimi specifics:
88
99
  ```
89
100
  mcpbox-claude init [--dir DIR] Managed CLAUDE.md policy block. Idempotent.
90
101
  mcpbox-claude uninit [--dir DIR] Remove the CLAUDE.md policy block.
91
- mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + ~/.codex/config.toml server.
102
+ mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + config.toml server + routing skill.
92
103
  mcpbox-claude codex-uninit [--dir DIR]
93
104
  mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server.
94
105
  mcpbox-claude cursor-uninit [--dir DIR]
95
106
  mcpbox-claude kimi-init [--dir DIR] AGENTS.md policy + ~/.kimi-code/mcp.json server
96
107
  + ~/.kimi-code/config.toml [[hooks]].
97
108
  mcpbox-claude kimi-uninit [--dir DIR]
109
+ mcpbox-claude opencode-init [--dir DIR] AGENTS.md policy + `mcpbox` entry under
110
+ "mcp" in ~/.config/opencode/opencode.json.
111
+ mcpbox-claude opencode-uninit [--dir DIR]
98
112
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
99
113
  mcpbox-claude mode [off|lite|full] Show or set the shared pipeline mode.
100
114
  ```
@@ -105,3 +119,34 @@ Set `MCPBOX_NO_UPDATE_CHECK=1` to disable hook update checks.
105
119
  ## License
106
120
 
107
121
  UNLICENSED — MCPBox is a closed SaaS.
122
+
123
+ ### Inherited Claude policy
124
+
125
+ `init --dir DIR` checks `CLAUDE.md` in DIR and its parent directories, matching
126
+ [Claude Code's cumulative directory hierarchy](https://code.claude.com/docs/en/memory#how-claude-md-files-load).
127
+ If a parent already has a managed MCPBox block, init inherits it and removes only
128
+ the requested directory's redundant managed block. Other local instructions and
129
+ parent files are preserved. A managed-only child file is removed. Re-running init
130
+ is idempotent; symlink/hardlink edits and malformed markers are refused.
131
+
132
+ `doctor --json` reports `policy_paths` and `policy_duplicate`; duplicate blocks
133
+ make readiness false. Parent blocks are not refreshed by a child install: run init
134
+ in the owning parent directory explicitly to update that policy. This check covers
135
+ the installer-owned `CLAUDE.md` hierarchy; it does not interpret imports,
136
+ `CLAUDE.local.md`, `.claude/CLAUDE.md`, or exclusion settings.
137
+
138
+ Measured on 2026-09-11 for task `01a05e61-0067-7163-b74e-acacdd77cf5d`:
139
+ removing the redundant project block reduced the combined parent/project files
140
+ from 38,851 to 22,964 bytes. Two one-turn Haiku probes using the same command,
141
+ with tools disabled and no session persistence, both had zero cache reads.
142
+ `cache_creation_input_tokens` changed from 24,349 to 19,745 (−4,604; −18.9%);
143
+ uncached input stayed at 10 tokens. Reported costs were $0.049013 and $0.039800.
144
+ These are observed cold-start totals, not a controlled attribution of every token
145
+ or evidence about conversational-history cost. The AFTER probe was explicitly
146
+ approved by the owner with a $0.30 cap; no local instruction text is published.
147
+
148
+ The managed policy is a compact index (at most 100 lines) for all clients.
149
+ It retains tracker safety rules, mode handling and tool/skill entry points.
150
+ The routing decision tree is supplied by MCP `initialize.instructions`
151
+ (`PLATFORM_INSTRUCTIONS`); clients without command skills use the plain tool
152
+ entry points. Reconnect the MCP server if its instructions are unavailable.
@@ -19,7 +19,7 @@ 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 } from "../lib/policy.mjs";
23
23
  import { installCodex, removeCodex, installCodexPolicy } from "../lib/codex.mjs";
24
24
  import {
25
25
  installCursor,
@@ -28,20 +28,21 @@ import {
28
28
  installCursorModeCommand,
29
29
  } from "../lib/cursor.mjs";
30
30
  import { installKimi, removeKimi } from "../lib/kimi.mjs";
31
+ import { installOpencode, removeOpencode } from "../lib/opencode.mjs";
31
32
  import { readMode, writeMode, MODES } from "../lib/mode.mjs";
32
33
 
33
34
  const __dirname = dirname(fileURLToPath(import.meta.url));
34
35
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
35
36
 
36
- const HELP = `mcpbox-claude v${pkg.version} — MCPBox agent harness (Claude / Codex / Cursor / Kimi)
37
+ const HELP = `mcpbox-claude v${pkg.version} — MCPBox agent harness (Claude / Codex / Cursor / Kimi / OpenCode)
37
38
 
38
39
  Usage:
39
40
  mcpbox-claude init [--dir DIR] Write the managed CLAUDE.md policy block
40
41
  (daruma tracker + full pipeline). Idempotent.
41
42
  mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
42
43
  mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
43
- [mcp_servers.mcpbox], the mcpbox skill and
44
- /mcpbox-* prompts. Idempotent.
44
+ [mcp_servers.mcpbox] and the mcpbox skill.
45
+ Idempotent.
45
46
  mcpbox-claude codex-uninit [--dir DIR]
46
47
  mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
47
48
  .cursor/mcp.json mcpbox entry. Idempotent.
@@ -50,6 +51,10 @@ Usage:
50
51
  mcpbox entry + [[hooks]] in ~/.kimi-code/config.toml.
51
52
  Idempotent.
52
53
  mcpbox-claude kimi-uninit [--dir DIR]
54
+ mcpbox-claude opencode-init [--dir DIR] Write AGENTS.md policy + mcpbox entry
55
+ under "mcp" in ~/.config/opencode/
56
+ opencode.json. Idempotent.
57
+ mcpbox-claude opencode-uninit [--dir DIR]
53
58
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
54
59
  mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (how raw ideas route).
55
60
  mcpbox-claude export-marketplace [--dir DIR]
@@ -76,6 +81,7 @@ function parseDirFlag(rest) {
76
81
 
77
82
  const VERB = {
78
83
  installed: "Created",
84
+ inherited: "Using ancestor policy:",
79
85
  updated: "Refreshed mcpbox block in",
80
86
  appended: "Appended mcpbox block to",
81
87
  unchanged: "Already current:",
@@ -103,11 +109,10 @@ function report(r) {
103
109
 
104
110
  async function cmdCodexInit(rest) {
105
111
  const { projectDir } = parseDirFlag(rest);
106
- const { policy, mcp, skill, prompts } = await installCodex({ projectDir });
112
+ const { policy, mcp, skill } = await installCodex({ projectDir });
107
113
  report(policy);
108
114
  report(mcp);
109
115
  report(skill);
110
- report(prompts);
111
116
  }
112
117
 
113
118
  async function cmdCodexUninit(rest) {
@@ -151,6 +156,20 @@ async function cmdKimiUninit(rest) {
151
156
  report(hooks);
152
157
  }
153
158
 
159
+ async function cmdOpencodeInit(rest) {
160
+ const { projectDir } = parseDirFlag(rest);
161
+ const { policy, mcp } = await installOpencode({ projectDir });
162
+ report(policy);
163
+ report(mcp);
164
+ }
165
+
166
+ async function cmdOpencodeUninit(rest) {
167
+ const { projectDir } = parseDirFlag(rest);
168
+ const { policy, mcp } = await removeOpencode({ projectDir });
169
+ report(policy);
170
+ report(mcp);
171
+ }
172
+
154
173
  // Policy-only variants — for callers (mcpbox-cli setup) that already own the
155
174
  // MCP-server wiring and just need the managed policy file dropped.
156
175
  async function cmdCodexPolicy(rest) {
@@ -164,15 +183,6 @@ async function cmdCursorPolicy(rest) {
164
183
  report(await installCursorModeCommand({ projectDir }));
165
184
  }
166
185
 
167
- async function policyPresent(projectDir) {
168
- const target = join(projectDir ? resolve(projectDir) : process.cwd(), "CLAUDE.md");
169
- try {
170
- return (await fs.readFile(target, "utf8")).includes(BEGIN);
171
- } catch (err) {
172
- if (err.code === "ENOENT") return false;
173
- throw err;
174
- }
175
- }
176
186
 
177
187
  function mcpServerPresent() {
178
188
  // `claude mcp list` prints one server per line as "name: url ...".
@@ -196,17 +206,19 @@ async function cmdDoctor(rest) {
196
206
  const flags = rest.filter((a) => a !== "--json");
197
207
  const { projectDir } = parseDirFlag(flags);
198
208
 
199
- const policy = await policyPresent(projectDir);
209
+ const hierarchy = await policyHierarchy({ projectDir });
210
+ const policy = hierarchy.present;
200
211
  const mcp = mcpServerPresent();
201
- const ready = policy && mcp === true;
212
+ const ready = policy && !hierarchy.duplicate && mcp === true;
202
213
 
203
214
  if (json) {
204
- process.stdout.write(JSON.stringify({ ready, policy, mcp }) + "\n");
215
+ process.stdout.write(JSON.stringify({ ready, policy, mcp, policy_paths: hierarchy.paths, policy_duplicate: hierarchy.duplicate }) + "\n");
205
216
  } else {
206
217
  const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
207
218
  process.stdout.write(
208
219
  `mcpbox MCP server: ${mark(mcp)}${mcp === null ? " (claude CLI not found)" : ""}\n` +
209
- `CLAUDE.md policy: ${mark(policy)}\n` +
220
+ `CLAUDE.md policy: ${mark(policy)}${hierarchy.duplicate ? " (duplicate managed blocks)" : ""}\n` +
221
+ hierarchy.paths.map((p) => ` ${p}\n`).join("") +
210
222
  `${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
211
223
  );
212
224
  }
@@ -261,6 +273,10 @@ async function main(argv) {
261
273
  return cmdKimiInit(rest);
262
274
  case "kimi-uninit":
263
275
  return cmdKimiUninit(rest);
276
+ case "opencode-init":
277
+ return cmdOpencodeInit(rest);
278
+ case "opencode-uninit":
279
+ return cmdOpencodeUninit(rest);
264
280
  case "codex-policy":
265
281
  return cmdCodexPolicy(rest);
266
282
  case "cursor-policy":
@@ -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.
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
  }
@@ -29,7 +29,7 @@ import { VERSION } from "../lib/version.mjs";
29
29
  const PATTERNS = [
30
30
  {
31
31
  re: /\b(pipeline|maturity|handoff|action\s*packet)\b|(?<![а-яёА-ЯЁ])(пайплайн|конвейер|зрелость|хендофф)(?![а-яёА-ЯЁ])/,
32
- hint: "[mcpbox] Detected pipeline intent → /mcpbox:pipeline-run or mcpbox_pipeline_run (raw input matures torii→…→fujin→handoff, never a direct daruma task).",
32
+ hint: "[mcpbox] Detected pipeline intent → if this is raw input to mature: /mcpbox:pipeline-run or mcpbox_pipeline_run (torii→…→fujin→handoff). Decided work that only mentions the pipeline follows the normal routing rule.",
33
33
  },
34
34
  {
35
35
  // create / import — ACTION + task/issue OBJECT (avoids bare-verb false positives).
@@ -42,7 +42,7 @@ const PATTERNS = [
42
42
  },
43
43
  {
44
44
  re: /\b(capture|record|lesson)\b|(?<![а-яёА-ЯЁ])(сохрани|запомни|урок)(?![а-яёА-ЯЁ])/,
45
- hint: "[mcpbox] Detected lesson-capture intent → /mcpbox:capture in Claude, otherwise write the lesson as a daruma comment/document.",
45
+ hint: "[mcpbox] Detected lesson-capture intent → /mcpbox:capture in Claude, otherwise persist it with mcpbox_knowledge_write.",
46
46
  },
47
47
  {
48
48
  re: /\b(sync|refresh\s+tasks)\b|(?<![а-яёА-ЯЁ])(синх|обнови\s+задачи)(?![а-яёА-ЯЁ])/,
@@ -50,11 +50,11 @@ const PATTERNS = [
50
50
  },
51
51
  {
52
52
  re: /\b(status|progress|what.?s\s+(open|next|left))\b|(?<![а-яёА-ЯЁ])(статус|прогресс|что\s+(открыто|осталось|дальше))(?![а-яёА-ЯЁ])/,
53
- hint: "[mcpbox] Detected status query → /mcpbox:status in Claude, otherwise daruma_healthz + mcpbox_runs_list.",
53
+ hint: "[mcpbox] Detected status query → if this is about mcpbox/daruma: /mcpbox:status in Claude, otherwise daruma_workspace_info + daruma_list status=active + mcpbox_runs_list.",
54
54
  },
55
55
  {
56
56
  re: /\b(close|complete|mark\s+.*done)\b|(?<![а-яёА-ЯЁ])(закрой|закрыть|завершить|пометь\s+.*выполненной)(?![а-яёА-ЯЁ])/,
57
- hint: "[mcpbox] Detected close intent → /mcpbox:close in Claude, otherwise daruma_complete (or daruma_set_status).",
57
+ hint: "[mcpbox] Detected close intent → if this refers to a daruma task: /mcpbox:close in Claude, otherwise daruma_complete (or daruma_set_status).",
58
58
  },
59
59
  ];
60
60
 
@@ -70,7 +70,7 @@ const PATTERNS = [
70
70
  // process restart at daruma_complete — the incident again, wearing another verb.
71
71
  // In full mode every hint therefore carries the exit in front of it.
72
72
  const OPERATIONAL_EXIT =
73
- "If this is an operational action you can just carry out — start/restart something, read a log, check status, open a file, answer a question — do it and record NOTHING, in neither daruma nor the pipeline. Otherwise: ";
73
+ "If this is an operational action you can just carry out — start/restart something, read a log, check status, open a file, answer a question — do it and record nothing, in neither daruma nor the pipeline. Otherwise: ";
74
74
 
75
75
  const FULL_ASSESS_HINT =
76
76
  "[mcpbox:full] " + OPERATIONAL_EXIT + "assess rawness: only raw material — an idea, hypothesis, or undecided direction — matures through the pipeline (mcpbox_pipeline_run → …fujin → handoff). Work that is already decided and bounded, and follow-up work extending a run that has already handed off (it has a task_id), both go straight to daruma via daruma_plan_materialize. A run still in flight is not a shortcut — finish it first.";
package/lib/codex.mjs CHANGED
@@ -1,17 +1,14 @@
1
1
  // Codex surface for the mcpbox harness — parity with the Claude CLAUDE.md
2
- // plugin. Four idempotent writes:
2
+ // plugin. Three idempotent writes:
3
3
  // 1. AGENTS.md policy block. Measured against Codex 0.146: AGENTS.md is
4
4
  // read from the working directory, NOT from a parent — a global install
5
- // lands it in ~/AGENTS.md where no project sees it, hence (3) and (4).
5
+ // lands it in ~/AGENTS.md where no project sees it, hence (3).
6
6
  // 2. `~/.codex/config.toml` [mcp_servers.mcpbox] pointing at the single
7
7
  // canonical HTTP endpoint. Codex's config is global-only, so the entry
8
8
  // is fenced with comment markers and replaced in place — surrounding
9
9
  // hand-written TOML is preserved.
10
10
  // 3. `$CODEX_HOME/skills/mcpbox/SKILL.md` — the same policy, reachable from
11
11
  // every working directory instead of just the install one.
12
- // 4. `$CODEX_HOME/prompts/mcpbox-*.md` — Codex's slash commands. Generated
13
- // from the plugin's commands/, which already use exactly this shape
14
- // (frontmatter `description` + "the user invoked" body).
15
12
  //
16
13
  // The policy body is BLOCK_BODY_PLAIN from lib/policy.mjs — one source of
17
14
  // truth shared across CLAUDE.md / AGENTS.md / .cursor/rules, minus the
@@ -20,7 +17,6 @@
20
17
  import { promises as fs } from "node:fs";
21
18
  import { homedir } from "node:os";
22
19
  import { dirname, join, resolve } from "node:path";
23
- import { fileURLToPath } from "node:url";
24
20
  import {
25
21
  BLOCK_BODY_PLAIN,
26
22
  MCP_URL,
@@ -49,10 +45,6 @@ function codexConfigPath(configPath) {
49
45
  return configPath ? resolve(configPath) : join(codexHomeDir(), "config.toml");
50
46
  }
51
47
 
52
- function packageRoot() {
53
- return resolve(dirname(fileURLToPath(import.meta.url)), "..");
54
- }
55
-
56
48
  // AGENTS.md policy block in the project directory.
57
49
  export function installCodexPolicy({ projectDir } = {}) {
58
50
  const dir = projectDir ? resolve(projectDir) : process.cwd();
@@ -122,36 +114,8 @@ export async function removeCodexSkill({ codexHome } = {}) {
122
114
  return { action: "removed-block", path: join(dir, "SKILL.md") };
123
115
  }
124
116
 
125
- // Codex slash commands live in `$CODEX_HOME/prompts/<name>.md` and are invoked
126
- // as `/<name>`; the plugin's `commands/tasks.md` becomes `/mcpbox-tasks`.
127
- // There is no `:` namespace here, so the body's `/mcpbox:tasks` is rewritten
128
- // to the name the user can actually type.
129
- export function codexPromptName(commandFile) {
130
- return `mcpbox-${commandFile.replace(/\.md$/, "")}`;
131
- }
132
-
133
- export async function installCodexPrompts({ codexHome } = {}) {
134
- const source = join(packageRoot(), "commands");
135
- const targetDir = join(codexHomeDir(codexHome), "prompts");
136
- const files = (await fs.readdir(source)).filter((f) => f.endsWith(".md")).sort();
137
- await fs.mkdir(targetDir, { recursive: true });
138
- let written = 0;
139
- for (const file of files) {
140
- const name = codexPromptName(file);
141
- const body = (await fs.readFile(join(source, file), "utf8"))
142
- .replace(/\/mcpbox:([a-z-]+)/g, "/mcpbox-$1");
143
- const target = join(targetDir, `${name}.md`);
144
- let before = null;
145
- try {
146
- before = await fs.readFile(target, "utf8");
147
- } catch { /* absent */ }
148
- if (before === body) continue;
149
- await fs.writeFile(target, body);
150
- written += 1;
151
- }
152
- return { action: written ? "installed" : "unchanged", path: targetDir, count: files.length };
153
- }
154
-
117
+ // Legacy cleanup only: Codex 0.147 does not load `$CODEX_HOME/prompts`, so
118
+ // codex-init no longer writes these files, but codex-uninit removes old ones.
155
119
  export async function removeCodexPrompts({ codexHome } = {}) {
156
120
  const targetDir = join(codexHomeDir(codexHome), "prompts");
157
121
  let files = [];
@@ -171,8 +135,7 @@ export async function installCodex({ projectDir, codexHome } = {}) {
171
135
  const policy = await installCodexPolicy({ projectDir });
172
136
  const mcp = await installCodexMcp();
173
137
  const skill = await installCodexSkill({ codexHome });
174
- const prompts = await installCodexPrompts({ codexHome });
175
- return { policy, mcp, skill, prompts };
138
+ return { policy, mcp, skill };
176
139
  }
177
140
 
178
141
  export async function removeCodex({ projectDir, codexHome } = {}) {