@mcpbox/mcpbox-claude 0.1.19 → 0.1.20
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 +1 -1
- package/README.md +6 -4
- package/bin/mcpbox-claude.mjs +34 -0
- package/lib/cursor.mjs +80 -1
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -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.20",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tupical"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -87,8 +87,9 @@ call instead of the text. Knowledge rows arrive
|
|
|
87
87
|
marked as workspace data, not instructions. Mode `off` disables both.
|
|
88
88
|
|
|
89
89
|
A stale version announces itself at session start on Claude, Codex, and Kimi.
|
|
90
|
-
The Cursor adapter
|
|
91
|
-
|
|
90
|
+
The Cursor adapter's only hook is the user-level `sessionStart` that carries
|
|
91
|
+
the policy (global installs); it does no update check, so nothing announces
|
|
92
|
+
anything there — check manually, or let
|
|
92
93
|
`cursor-init` in a routine update pass do it. Set
|
|
93
94
|
`MCPBOX_NO_UPDATE_CHECK=1` to disable the registry lookup entirely (air-gapped
|
|
94
95
|
installs, CI).
|
|
@@ -99,7 +100,7 @@ installs, CI).
|
|
|
99
100
|
|--------|----------------------------------------|-------------------------------------|-------|
|
|
100
101
|
| Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
|
|
101
102
|
| Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
|
|
102
|
-
| Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` | `mcpbox` entry in `.cursor/mcp.json` |
|
|
103
|
+
| Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` (repo); in `$HOME` a `sessionStart` hook in `~/.cursor/hooks.json` instead — Cursor reads no `~/.cursor/rules` | `mcpbox` entry in `.cursor/mcp.json` | `~/.cursor/hooks.json` `sessionStart` (global only) |
|
|
103
104
|
| Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
|
|
104
105
|
| OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
|
|
105
106
|
|
|
@@ -128,7 +129,8 @@ mcpbox-claude init [--dir DIR] Managed CLAUDE.md policy block. Idempote
|
|
|
128
129
|
mcpbox-claude uninit [--dir DIR] Remove the CLAUDE.md policy block.
|
|
129
130
|
mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + config.toml server + routing skill.
|
|
130
131
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
131
|
-
mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server
|
|
132
|
+
mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server
|
|
133
|
+
(in $HOME: ~/.cursor/hooks.json sessionStart hook).
|
|
132
134
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
133
135
|
mcpbox-claude kimi-init [--dir DIR] AGENTS.md policy + ~/.kimi-code/mcp.json server
|
|
134
136
|
+ ~/.kimi-code/config.toml [[hooks]].
|
package/bin/mcpbox-claude.mjs
CHANGED
|
@@ -26,7 +26,13 @@ import {
|
|
|
26
26
|
installCursor,
|
|
27
27
|
removeCursor,
|
|
28
28
|
installCursorRule,
|
|
29
|
+
removeCursorRule,
|
|
30
|
+
installCursorMcp,
|
|
31
|
+
removeCursorMcp,
|
|
29
32
|
installCursorModeCommand,
|
|
33
|
+
removeCursorModeCommand,
|
|
34
|
+
installCursorSessionHook,
|
|
35
|
+
removeCursorSessionHook,
|
|
30
36
|
} from "../lib/cursor.mjs";
|
|
31
37
|
import { installKimi, removeKimi } from "../lib/kimi.mjs";
|
|
32
38
|
import { installOpencode, removeOpencode } from "../lib/opencode.mjs";
|
|
@@ -47,6 +53,8 @@ Usage:
|
|
|
47
53
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
48
54
|
mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
|
|
49
55
|
.cursor/mcp.json mcpbox entry. Idempotent.
|
|
56
|
+
In $HOME the policy goes to a sessionStart
|
|
57
|
+
hook in ~/.cursor/hooks.json instead.
|
|
50
58
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
51
59
|
mcpbox-claude kimi-init [--dir DIR] Write AGENTS.md policy + ~/.kimi-code/mcp.json
|
|
52
60
|
mcpbox entry + [[hooks]] in ~/.kimi-code/config.toml.
|
|
@@ -128,8 +136,26 @@ async function cmdCodexUninit(rest) {
|
|
|
128
136
|
report(prompts);
|
|
129
137
|
}
|
|
130
138
|
|
|
139
|
+
// Cursor ignores ~/.cursor/rules: in the home dir the policy goes through the
|
|
140
|
+
// user-level sessionStart hook, and a rule left by older installs is dropped.
|
|
141
|
+
function isHomeDir(projectDir) {
|
|
142
|
+
return resolve(projectDir ?? process.cwd()) === resolve(homedir());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function installCursorHome(homeDir) {
|
|
146
|
+
report(await installCursorSessionHook({ homeDir }));
|
|
147
|
+
const stale = await removeCursorRule({ projectDir: homeDir });
|
|
148
|
+
if (stale.action !== "missing") report(stale);
|
|
149
|
+
report(await installCursorModeCommand({ projectDir: homeDir }));
|
|
150
|
+
}
|
|
151
|
+
|
|
131
152
|
async function cmdCursorInit(rest) {
|
|
132
153
|
const { projectDir } = parseDirFlag(rest);
|
|
154
|
+
if (isHomeDir(projectDir)) {
|
|
155
|
+
await installCursorHome(homedir());
|
|
156
|
+
report(await installCursorMcp({ projectDir: homedir() }));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
133
159
|
const { rule, mcp, mode } = await installCursor({ projectDir });
|
|
134
160
|
report(rule);
|
|
135
161
|
report(mcp);
|
|
@@ -138,6 +164,13 @@ async function cmdCursorInit(rest) {
|
|
|
138
164
|
|
|
139
165
|
async function cmdCursorUninit(rest) {
|
|
140
166
|
const { projectDir } = parseDirFlag(rest);
|
|
167
|
+
if (isHomeDir(projectDir)) {
|
|
168
|
+
report(await removeCursorSessionHook({ homeDir: homedir() }));
|
|
169
|
+
report(await removeCursorRule({ projectDir: homedir() }));
|
|
170
|
+
report(await removeCursorMcp({ projectDir: homedir() }));
|
|
171
|
+
report(await removeCursorModeCommand({ projectDir: homedir() }));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
141
174
|
const { rule, mcp, mode } = await removeCursor({ projectDir });
|
|
142
175
|
report(rule);
|
|
143
176
|
report(mcp);
|
|
@@ -183,6 +216,7 @@ async function cmdCodexPolicy(rest) {
|
|
|
183
216
|
|
|
184
217
|
async function cmdCursorPolicy(rest) {
|
|
185
218
|
const { projectDir } = parseDirFlag(rest);
|
|
219
|
+
if (isHomeDir(projectDir)) return installCursorHome(homedir());
|
|
186
220
|
report(await installCursorRule({ projectDir }));
|
|
187
221
|
report(await installCursorModeCommand({ projectDir }));
|
|
188
222
|
}
|
package/lib/cursor.mjs
CHANGED
|
@@ -139,6 +139,85 @@ export async function removeCursorMcp({ projectDir } = {}) {
|
|
|
139
139
|
return { action: "removed-block", path: target };
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// User-level policy. Cursor reads no rule files from ~/.cursor/rules (User
|
|
143
|
+
// Rules live only in its settings UI), so a global install injects the policy
|
|
144
|
+
// through a sessionStart hook in ~/.cursor/hooks.json instead. The script is
|
|
145
|
+
// self-contained: the npx cache that ran us is ephemeral.
|
|
146
|
+
const SESSION_HOOK_NAME = "mcpbox-session-start.mjs";
|
|
147
|
+
|
|
148
|
+
function sessionHookPaths(homeDir) {
|
|
149
|
+
const root = join(resolve(homeDir), ".cursor");
|
|
150
|
+
return { script: join(root, "hooks", SESSION_HOOK_NAME), config: join(root, "hooks.json") };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function sessionHookScript() {
|
|
154
|
+
return `// Managed by mcpbox-claude. Injects the MCPBox policy into Cursor sessions.
|
|
155
|
+
const BODY = ${JSON.stringify(BLOCK_BODY_PLAIN)};
|
|
156
|
+
process.stdout.write(JSON.stringify({ additional_context: BODY }) + "\\n");
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function readHooks(target) {
|
|
161
|
+
let doc;
|
|
162
|
+
try {
|
|
163
|
+
doc = JSON.parse(await fs.readFile(target, "utf8"));
|
|
164
|
+
} catch (err) {
|
|
165
|
+
if (err.code === "ENOENT") return null;
|
|
166
|
+
throw err;
|
|
167
|
+
}
|
|
168
|
+
if (!doc || typeof doc !== "object" || Array.isArray(doc)) {
|
|
169
|
+
throw new Error(`${target} is not a JSON object`);
|
|
170
|
+
}
|
|
171
|
+
if (!doc.hooks || typeof doc.hooks !== "object" || Array.isArray(doc.hooks)) doc.hooks = {};
|
|
172
|
+
return doc;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const isOurHook = (h) => typeof h?.command === "string" && h.command.includes(SESSION_HOOK_NAME);
|
|
176
|
+
|
|
177
|
+
export async function installCursorSessionHook({ homeDir } = {}) {
|
|
178
|
+
const { script, config } = sessionHookPaths(homeDir);
|
|
179
|
+
const content = sessionHookScript();
|
|
180
|
+
let existingScript = null;
|
|
181
|
+
try {
|
|
182
|
+
existingScript = await fs.readFile(script, "utf8");
|
|
183
|
+
} catch (err) {
|
|
184
|
+
if (err.code !== "ENOENT") throw err;
|
|
185
|
+
}
|
|
186
|
+
const doc = (await readHooks(config)) ?? { version: 1, hooks: {} };
|
|
187
|
+
if (doc.version === undefined) doc.version = 1;
|
|
188
|
+
const entry = { command: `node "${script}"` };
|
|
189
|
+
const before = Array.isArray(doc.hooks.sessionStart) ? doc.hooks.sessionStart : [];
|
|
190
|
+
const ours = before.filter(isOurHook);
|
|
191
|
+
const configSame = ours.length === 1 && JSON.stringify(ours[0]) === JSON.stringify(entry);
|
|
192
|
+
if (existingScript === content && configSame) return { action: "unchanged", path: config };
|
|
193
|
+
|
|
194
|
+
await fs.mkdir(dirname(script), { recursive: true });
|
|
195
|
+
await fs.writeFile(script, content);
|
|
196
|
+
doc.hooks.sessionStart = [...before.filter((h) => !isOurHook(h)), entry];
|
|
197
|
+
await fs.writeFile(config, JSON.stringify(doc, null, 2) + "\n");
|
|
198
|
+
return { action: existingScript === null && ours.length === 0 ? "installed" : "updated", path: config };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function removeCursorSessionHook({ homeDir } = {}) {
|
|
202
|
+
const { script, config } = sessionHookPaths(homeDir);
|
|
203
|
+
let removed = false;
|
|
204
|
+
const doc = await readHooks(config);
|
|
205
|
+
if (doc && Array.isArray(doc.hooks.sessionStart) && doc.hooks.sessionStart.some(isOurHook)) {
|
|
206
|
+
const rest = doc.hooks.sessionStart.filter((h) => !isOurHook(h));
|
|
207
|
+
if (rest.length) doc.hooks.sessionStart = rest;
|
|
208
|
+
else delete doc.hooks.sessionStart;
|
|
209
|
+
await fs.writeFile(config, JSON.stringify(doc, null, 2) + "\n");
|
|
210
|
+
removed = true;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
await fs.unlink(script);
|
|
214
|
+
removed = true;
|
|
215
|
+
} catch (err) {
|
|
216
|
+
if (err.code !== "ENOENT") throw err;
|
|
217
|
+
}
|
|
218
|
+
return { action: removed ? "removed-block" : "missing", path: config };
|
|
219
|
+
}
|
|
220
|
+
|
|
142
221
|
// Both surfaces at once (what `mcpbox-claude cursor-init` calls).
|
|
143
222
|
export async function installCursor({ projectDir } = {}) {
|
|
144
223
|
const rule = await installCursorRule({ projectDir });
|
|
@@ -154,4 +233,4 @@ export async function removeCursor({ projectDir } = {}) {
|
|
|
154
233
|
return { rule, mcp, mode };
|
|
155
234
|
}
|
|
156
235
|
|
|
157
|
-
export { rulePath, mcpPath, modeCommandPath };
|
|
236
|
+
export { rulePath, mcpPath, modeCommandPath, sessionHookPaths };
|
package/lib/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.20";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "MCPBox agent harness for Claude Code: managed policy (daruma tracker + full pipeline), hooks, and slash commands over the single mcpbox MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|