@mcpbox/mcpbox-claude 0.1.17 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +3 -2
- package/README.md +42 -2
- package/bin/mcpbox-claude.mjs +11 -18
- package/commands/capture.md +3 -3
- package/commands/close.md +7 -3
- package/commands/mode.md +2 -2
- package/commands/next.md +7 -6
- package/commands/status.md +10 -9
- package/commands/trace.md +2 -2
- package/hooks/acceptance-guard.mjs +64 -0
- package/hooks/hooks.json +23 -1
- package/hooks/user-prompt-submit.mjs +5 -5
- package/lib/codex.mjs +5 -42
- package/lib/policy.mjs +96 -273
- package/lib/version.mjs +1 -1
- package/package.json +4 -1
- package/skills/mcpbox-capture/SKILL.md +15 -0
- package/skills/mcpbox-close/SKILL.md +20 -0
- package/skills/mcpbox-doctor/SKILL.md +16 -0
- package/skills/mcpbox-mine/SKILL.md +13 -0
- package/skills/mcpbox-mode/SKILL.md +34 -0
- package/skills/mcpbox-next/SKILL.md +39 -0
- package/skills/mcpbox-pipeline-run/SKILL.md +26 -0
- package/skills/mcpbox-plan/SKILL.md +26 -0
- package/skills/mcpbox-status/SKILL.md +43 -0
- package/skills/mcpbox-sync/SKILL.md +14 -0
- package/skills/mcpbox-tasks/SKILL.md +35 -0
- package/skills/mcpbox-trace/SKILL.md +23 -0
|
@@ -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.
|
|
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.
|
|
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
|
|
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
|
|
|
@@ -66,11 +71,15 @@ installs, CI).
|
|
|
66
71
|
| Agent | Policy surface | MCP server | Hooks |
|
|
67
72
|
|--------|----------------------------------------|-------------------------------------|-------|
|
|
68
73
|
| Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
|
|
69
|
-
| Codex | `AGENTS.md` block
|
|
74
|
+
| Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
|
|
70
75
|
| Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` | `mcpbox` entry in `.cursor/mcp.json` | — |
|
|
71
76
|
| Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
|
|
72
77
|
| OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
|
|
73
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.
|
|
82
|
+
|
|
74
83
|
All four agents accept `mcpbox mode [off|lite|full]` through the managed
|
|
75
84
|
policy. Claude also exposes `/mcpbox:mode`, Cursor exposes `/mcpbox-mode`, and
|
|
76
85
|
the shared value lives in `~/.agents/mcpbox/mode`.
|
|
@@ -90,7 +99,7 @@ Kimi specifics:
|
|
|
90
99
|
```
|
|
91
100
|
mcpbox-claude init [--dir DIR] Managed CLAUDE.md policy block. Idempotent.
|
|
92
101
|
mcpbox-claude uninit [--dir DIR] Remove the CLAUDE.md policy block.
|
|
93
|
-
mcpbox-claude codex-init [--dir DIR] AGENTS.md policy +
|
|
102
|
+
mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + config.toml server + routing skill.
|
|
94
103
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
95
104
|
mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server.
|
|
96
105
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
@@ -110,3 +119,34 @@ Set `MCPBOX_NO_UPDATE_CHECK=1` to disable hook update checks.
|
|
|
110
119
|
## License
|
|
111
120
|
|
|
112
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.
|
package/bin/mcpbox-claude.mjs
CHANGED
|
@@ -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,
|
|
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,
|
|
@@ -41,8 +41,8 @@ Usage:
|
|
|
41
41
|
(daruma tracker + full pipeline). Idempotent.
|
|
42
42
|
mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
|
|
43
43
|
mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
|
|
44
|
-
[mcp_servers.mcpbox]
|
|
45
|
-
|
|
44
|
+
[mcp_servers.mcpbox] and the mcpbox skill.
|
|
45
|
+
Idempotent.
|
|
46
46
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
47
47
|
mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
|
|
48
48
|
.cursor/mcp.json mcpbox entry. Idempotent.
|
|
@@ -81,6 +81,7 @@ function parseDirFlag(rest) {
|
|
|
81
81
|
|
|
82
82
|
const VERB = {
|
|
83
83
|
installed: "Created",
|
|
84
|
+
inherited: "Using ancestor policy:",
|
|
84
85
|
updated: "Refreshed mcpbox block in",
|
|
85
86
|
appended: "Appended mcpbox block to",
|
|
86
87
|
unchanged: "Already current:",
|
|
@@ -108,11 +109,10 @@ function report(r) {
|
|
|
108
109
|
|
|
109
110
|
async function cmdCodexInit(rest) {
|
|
110
111
|
const { projectDir } = parseDirFlag(rest);
|
|
111
|
-
const { policy, mcp, skill
|
|
112
|
+
const { policy, mcp, skill } = await installCodex({ projectDir });
|
|
112
113
|
report(policy);
|
|
113
114
|
report(mcp);
|
|
114
115
|
report(skill);
|
|
115
|
-
report(prompts);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
async function cmdCodexUninit(rest) {
|
|
@@ -183,15 +183,6 @@ async function cmdCursorPolicy(rest) {
|
|
|
183
183
|
report(await installCursorModeCommand({ projectDir }));
|
|
184
184
|
}
|
|
185
185
|
|
|
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
186
|
|
|
196
187
|
function mcpServerPresent() {
|
|
197
188
|
// `claude mcp list` prints one server per line as "name: url ...".
|
|
@@ -215,17 +206,19 @@ async function cmdDoctor(rest) {
|
|
|
215
206
|
const flags = rest.filter((a) => a !== "--json");
|
|
216
207
|
const { projectDir } = parseDirFlag(flags);
|
|
217
208
|
|
|
218
|
-
const
|
|
209
|
+
const hierarchy = await policyHierarchy({ projectDir });
|
|
210
|
+
const policy = hierarchy.present;
|
|
219
211
|
const mcp = mcpServerPresent();
|
|
220
|
-
const ready = policy && mcp === true;
|
|
212
|
+
const ready = policy && !hierarchy.duplicate && mcp === true;
|
|
221
213
|
|
|
222
214
|
if (json) {
|
|
223
|
-
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");
|
|
224
216
|
} else {
|
|
225
217
|
const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
|
|
226
218
|
process.stdout.write(
|
|
227
219
|
`mcpbox MCP server: ${mark(mcp)}${mcp === null ? " (claude CLI not found)" : ""}\n` +
|
|
228
|
-
`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("") +
|
|
229
222
|
`${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
|
|
230
223
|
);
|
|
231
224
|
}
|
package/commands/capture.md
CHANGED
|
@@ -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.
|
|
12
|
-
|
|
13
|
-
|
|
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.
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
19
|
-
|
|
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 =
|
|
12
|
-
If none, stop with "no active plan — `
|
|
13
|
-
3. `
|
|
14
|
-
ready (unblocked) task and
|
|
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
|
|
34
|
-
→ On failure:
|
|
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.
|
package/commands/status.md
CHANGED
|
@@ -6,9 +6,10 @@ The user invoked `/mcpbox:status`.
|
|
|
6
6
|
|
|
7
7
|
## Steps
|
|
8
8
|
|
|
9
|
-
1. `
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
+
3. One scoped `daruma_list status=active` → count open tasks (do not enumerate
|
|
23
24
|
the archive).
|
|
24
|
-
|
|
25
|
+
4. `mcpbox_runs_list` with `limit=5` (and `status=failed` if the user asked about
|
|
25
26
|
failures) → recent pipeline runs.
|
|
26
|
-
|
|
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
|
-
|
|
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
|
|
22
|
-
|
|
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
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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)
|
|
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
|
|
126
|
-
//
|
|
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
|
-
|
|
175
|
-
return { policy, mcp, skill, prompts };
|
|
138
|
+
return { policy, mcp, skill };
|
|
176
139
|
}
|
|
177
140
|
|
|
178
141
|
export async function removeCodex({ projectDir, codexHome } = {}) {
|