@mcpbox/mcpbox-claude 0.1.9 → 0.1.11
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/hooks/session-start.mjs +5 -3
- package/hooks/stop.mjs +3 -2
- package/hooks/user-prompt-submit.mjs +4 -2
- package/lib/codex.mjs +19 -2
- package/lib/hook-output.mjs +32 -0
- 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.11",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tupical"
|
|
7
7
|
},
|
package/hooks/session-start.mjs
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// MCPBOX_MCP_ARGS — space-separated extra args (default: "mcp serve")
|
|
17
17
|
// MCPBOX_SCOPE — optional project_scope path filter
|
|
18
18
|
|
|
19
|
+
import { writeHookOutput } from "../lib/hook-output.mjs";
|
|
19
20
|
import { MCPClient } from "../lib/mcp-client.mjs";
|
|
20
21
|
|
|
21
22
|
const TIMEOUT_MS = 12_000;
|
|
@@ -111,8 +112,9 @@ async function main() {
|
|
|
111
112
|
const { tasks, projectTitle } = data;
|
|
112
113
|
|
|
113
114
|
if (!tasks || tasks.length === 0) {
|
|
114
|
-
|
|
115
|
-
"
|
|
115
|
+
writeHookOutput(
|
|
116
|
+
"SessionStart",
|
|
117
|
+
"[mcpbox] No open tasks — run /mcpbox:tasks to verify, or /mcpbox:pipeline-run \"<idea>\" to open a maturity run."
|
|
116
118
|
);
|
|
117
119
|
process.exit(0);
|
|
118
120
|
}
|
|
@@ -129,7 +131,7 @@ async function main() {
|
|
|
129
131
|
if (extra > 0) lines.push(` …and ${extra} more — /mcpbox:tasks for full list`);
|
|
130
132
|
lines.push("→ /mcpbox:next to claim the next task | /mcpbox:status for server + pipeline health");
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
writeHookOutput("SessionStart", lines.join("\n"));
|
|
133
135
|
process.exit(0);
|
|
134
136
|
}
|
|
135
137
|
|
package/hooks/stop.mjs
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
|
|
13
|
+
import { writeHookOutput } from "../lib/hook-output.mjs";
|
|
14
|
+
|
|
13
15
|
export function stopHookMessage(activeTask = "") {
|
|
14
16
|
if (!activeTask) return "";
|
|
15
17
|
return (
|
|
@@ -22,8 +24,7 @@ export function stopHookMessage(activeTask = "") {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
function main() {
|
|
25
|
-
|
|
26
|
-
if (message) process.stdout.write(message);
|
|
27
|
+
writeHookOutput("Stop", stopHookMessage(process.env.MCPBOX_ACTIVE_TASK ?? ""));
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
@@ -18,6 +18,7 @@ import { homedir } from "node:os";
|
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { pathToFileURL } from "node:url";
|
|
20
20
|
|
|
21
|
+
import { writeHookOutput } from "../lib/hook-output.mjs";
|
|
21
22
|
import { readMode } from "../lib/mode.mjs";
|
|
22
23
|
|
|
23
24
|
// Intent patterns. Order matters — first match wins. ASCII keywords use \b;
|
|
@@ -165,9 +166,10 @@ async function main() {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
const policy = await policyForFirstPrompt(payload);
|
|
168
|
-
if (policy) process.stdout.write(policy + "\n");
|
|
169
169
|
const hint = promptSubmitHint(prompt, readMode());
|
|
170
|
-
|
|
170
|
+
// One write, not two: Codex parses stdout as a single JSON document, so a
|
|
171
|
+
// policy object followed by a hint object is as invalid as plain text.
|
|
172
|
+
writeHookOutput("UserPromptSubmit", [policy, hint].filter(Boolean).join("\n"));
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
package/lib/codex.mjs
CHANGED
|
@@ -66,8 +66,25 @@ export function removeCodexPolicy({ projectDir } = {}) {
|
|
|
66
66
|
|
|
67
67
|
// [mcp_servers.mcpbox] entry in the global ~/.codex/config.toml.
|
|
68
68
|
// `configPath` overrides the target (used by tests).
|
|
69
|
-
export function installCodexMcp({ configPath } = {}) {
|
|
70
|
-
|
|
69
|
+
export async function installCodexMcp({ configPath } = {}) {
|
|
70
|
+
const target = codexConfigPath(configPath);
|
|
71
|
+
// Someone else may already declare the server — oh-my-claudecode keeps its own
|
|
72
|
+
// "OMC MANAGED MCP REGISTRY" block, for one. Appending ours next to it makes
|
|
73
|
+
// `[mcp_servers.mcpbox]` a duplicate key, which is a TOML parse error: codex
|
|
74
|
+
// then fails to read its whole config. An entry that already points at us is
|
|
75
|
+
// the entry we wanted, so leave it alone.
|
|
76
|
+
let existing = "";
|
|
77
|
+
try {
|
|
78
|
+
existing = await fs.readFile(target, "utf8");
|
|
79
|
+
} catch { /* absent → install */ }
|
|
80
|
+
const outsideOurBlock = existing.replace(
|
|
81
|
+
new RegExp(`${TOML_BEGIN}[\\s\\S]*?${TOML_END}\\n?`, "g"),
|
|
82
|
+
"",
|
|
83
|
+
);
|
|
84
|
+
if (/^\s*\[mcp_servers\.mcpbox\]/m.test(outsideOurBlock)) {
|
|
85
|
+
return { action: "unchanged", path: target, reason: "already declared outside the managed block" };
|
|
86
|
+
}
|
|
87
|
+
return installManagedBlock({ target, begin: TOML_BEGIN, end: TOML_END, block: TOML_BLOCK });
|
|
71
88
|
}
|
|
72
89
|
|
|
73
90
|
export function removeCodexMcp({ configPath } = {}) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// One writer for every hook's stdout, because the surfaces disagree on format.
|
|
2
|
+
//
|
|
3
|
+
// Claude Code and Kimi take plain text. Codex parses hook stdout as JSON and
|
|
4
|
+
// rejects anything else with "hook returned invalid <event> JSON output" —
|
|
5
|
+
// which is what every mcpbox hint turned into on Codex 0.147, once per prompt.
|
|
6
|
+
//
|
|
7
|
+
// Codex is the surface that exports PLUGIN_DATA (its per-plugin state dir,
|
|
8
|
+
// ~/.codex/plugins/data/<marketplace>-<plugin>); Claude Code exports only
|
|
9
|
+
// CLAUDE_PLUGIN_ROOT/CLAUDE_PLUGIN_DATA, so a bare PLUGIN_DATA identifies Codex.
|
|
10
|
+
export function isCodexSurface(env = process.env) {
|
|
11
|
+
return Boolean(env.PLUGIN_DATA);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Codex has a *HookSpecificOutputWire for SessionStart / UserPromptSubmit /
|
|
15
|
+
// SubagentStart only; Stop has none and rejects additionalContext there, so a
|
|
16
|
+
// Stop message rides as systemMessage instead.
|
|
17
|
+
export function hookOutputPayload(event, text) {
|
|
18
|
+
return event === "Stop" || event === "SubagentStop"
|
|
19
|
+
? { systemMessage: text }
|
|
20
|
+
: { hookSpecificOutput: { hookEventName: event, additionalContext: text } };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Empty output stays empty: every surface reads "no stdout" as "no hint", and
|
|
24
|
+
// Codex only parses when something was written.
|
|
25
|
+
export function writeHookOutput(event, text, env = process.env) {
|
|
26
|
+
if (!text) return;
|
|
27
|
+
if (!isCodexSurface(env)) {
|
|
28
|
+
process.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
process.stdout.write(`${JSON.stringify(hookOutputPayload(event, text))}\n`);
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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": {
|