@mcpbox/mcpbox-claude 0.1.10 → 0.1.12
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 +22 -4
- package/lib/hook-output.mjs +32 -0
- package/lib/policy.mjs +14 -2
- 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.12",
|
|
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;
|
|
@@ -57,8 +58,20 @@ const PATTERNS = [
|
|
|
57
58
|
|
|
58
59
|
// full mode: remind the agent to judge rawness itself — a regex can't. Only
|
|
59
60
|
// fires on substantive prompts that didn't already match an explicit intent.
|
|
61
|
+
// The exit comes FIRST. When this hint led with "assess for rawness", an agent
|
|
62
|
+
// asked to start a dev server announced a Daruma follow-up and went looking for
|
|
63
|
+
// ceremony: the routing rule offered three doors and every one of them ended in
|
|
64
|
+
// a tracker artifact, so there was no branch that said "just do it".
|
|
65
|
+
// A routing hint fires on the first PATTERNS match, so an operational request
|
|
66
|
+
// that happens to contain a keyword never reached the exit below: "запусти
|
|
67
|
+
// сервер и закрой лишние процессы" matched the close pattern and pointed a pure
|
|
68
|
+
// process restart at daruma_complete — the incident again, wearing another verb.
|
|
69
|
+
// In full mode every hint therefore carries the exit in front of it.
|
|
70
|
+
const OPERATIONAL_EXIT =
|
|
71
|
+
"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: ";
|
|
72
|
+
|
|
60
73
|
const FULL_ASSESS_HINT =
|
|
61
|
-
"[mcpbox:full]
|
|
74
|
+
"[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.";
|
|
62
75
|
|
|
63
76
|
// ponytail: length heuristic for "substantive" — cheap and good enough to skip
|
|
64
77
|
// "ok"/"yes"/"go". Swap for a token/keyword check only if it nags in practice.
|
|
@@ -71,7 +84,11 @@ export function promptSubmitHint(promptText = "", mode = "lite") {
|
|
|
71
84
|
const prompt = promptText.replace(/```[\s\S]*?```/g, " ").toLowerCase().trim();
|
|
72
85
|
const patterns = mode === "off" ? PATTERNS.slice(1) : PATTERNS;
|
|
73
86
|
for (const { re, hint } of patterns) {
|
|
74
|
-
if (re.test(prompt))
|
|
87
|
+
if (re.test(prompt)) {
|
|
88
|
+
// A keyword match is a guess about intent, not a verdict on it — in full
|
|
89
|
+
// mode the operational exit goes ahead of the guess.
|
|
90
|
+
return mode === "full" ? `[mcpbox:full] ${OPERATIONAL_EXIT}${hint}` : hint;
|
|
91
|
+
}
|
|
75
92
|
}
|
|
76
93
|
if (mode === "full" && prompt.length >= SUBSTANTIVE_MIN) return FULL_ASSESS_HINT;
|
|
77
94
|
return "";
|
|
@@ -165,9 +182,10 @@ async function main() {
|
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
184
|
const policy = await policyForFirstPrompt(payload);
|
|
168
|
-
if (policy) process.stdout.write(policy + "\n");
|
|
169
185
|
const hint = promptSubmitHint(prompt, readMode());
|
|
170
|
-
|
|
186
|
+
// One write, not two: Codex parses stdout as a single JSON document, so a
|
|
187
|
+
// policy object followed by a hint object is as invalid as plain text.
|
|
188
|
+
writeHookOutput("UserPromptSubmit", [policy, hint].filter(Boolean).join("\n"));
|
|
171
189
|
}
|
|
172
190
|
|
|
173
191
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
@@ -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/lib/policy.mjs
CHANGED
|
@@ -237,7 +237,18 @@ daruma execution задача/план (терминальный слой
|
|
|
237
237
|
и в описании \`daruma_plan_materialize\`. Три носителя, один текст — если они
|
|
238
238
|
когда-нибудь разойдутся, прав сервер.
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
Сначала отсей то, что вообще не работа.
|
|
241
|
+
|
|
242
|
+
0. **Действие, а не работа** — операционная просьба, выполнимая здесь и сейчас
|
|
243
|
+
и **не оставляющая после себя ничего, что можно отслеживать**: запустить или
|
|
244
|
+
перезапустить процесс, посмотреть лог, проверить статус, прочитать файл,
|
|
245
|
+
ответить на вопрос. Такое **не заводится никуда** — ни в daruma, ни в
|
|
246
|
+
pipeline. Просто сделай и всё. Трекер существует для работы, которая
|
|
247
|
+
переживает сессию; у действия после выполнения не остаётся ничего, что можно
|
|
248
|
+
было бы отслеживать, поэтому запись о нём — чистый шум. Развёрнутая
|
|
249
|
+
формулировка просьбы не превращает её в работу.
|
|
250
|
+
|
|
251
|
+
Если осталась именно работа — задай один вопрос: **она уже решена?**
|
|
241
252
|
|
|
242
253
|
1. **Решена и ограничена** — цель, границы и критерий завершения известны
|
|
243
254
|
(включая внешний issue с готовой постановкой) → сразу в daruma через
|
|
@@ -257,7 +268,8 @@ daruma execution задача/план (терминальный слой
|
|
|
257
268
|
*что* делать → \`mcpbox_pipeline_run\`, довести до \`fujin\`, материализовать
|
|
258
269
|
через \`mcpbox_pipeline_handoff\`. Напрямую в daruma такое не заводить.
|
|
259
270
|
|
|
260
|
-
Pipeline обязателен **только в случае 3**; случаи 1 и 2 — обычный вход в daruma
|
|
271
|
+
Pipeline обязателен **только в случае 3**; случаи 1 и 2 — обычный вход в daruma;
|
|
272
|
+
по случаю 0 не заводится ничего.
|
|
261
273
|
Не можешь отличить случай 1 от случая 3 — спроси пользователя, не угадывай.
|
|
262
274
|
|
|
263
275
|
\`~/.agents/mcpbox/mode\` управляет только тем, насколько активно ты *предлагаешь*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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": {
|