@mcpbox/mcpbox-claude 0.1.11 → 0.1.13
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 +1 -0
- package/hooks/session-start.mjs +26 -12
- package/hooks/user-prompt-submit.mjs +34 -9
- package/lib/hook-output.mjs +20 -11
- package/lib/kimi.mjs +6 -2
- package/lib/mcp-client.mjs +40 -14
- package/lib/policy.mjs +14 -2
- package/lib/update-check.mjs +81 -0
- package/lib/version.mjs +1 -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.13",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tupical"
|
|
7
7
|
},
|
package/README.md
CHANGED
package/hooks/session-start.mjs
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
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
|
+
import { isCodexSurface, writeHookOutput } from "../lib/hook-output.mjs";
|
|
20
20
|
import { MCPClient } from "../lib/mcp-client.mjs";
|
|
21
|
+
import { checkForUpdate, updateNotice } from "../lib/update-check.mjs";
|
|
22
|
+
import { VERSION } from "../lib/version.mjs";
|
|
23
|
+
import { pathToFileURL } from "node:url";
|
|
21
24
|
|
|
22
25
|
const TIMEOUT_MS = 12_000;
|
|
23
26
|
const MAX_TASKS = 15;
|
|
@@ -98,14 +101,22 @@ async function fetchSummary() {
|
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
async function main() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
104
|
+
export async function main() {
|
|
105
|
+
const [data, update] = await Promise.all([
|
|
106
|
+
fetchSummary().catch((err) => {
|
|
107
|
+
if (process.env.MCPBOX_DEBUG) {
|
|
108
|
+
process.stderr.write(`[mcpbox-claude/session-start] error: ${err?.message ?? err}\n`);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}),
|
|
112
|
+
checkForUpdate({ current: VERSION }),
|
|
113
|
+
]);
|
|
114
|
+
const systemMessage = update?.outdated
|
|
115
|
+
? updateNotice(update.current, update.latest, isCodexSurface() ? "codex" : "claude")
|
|
116
|
+
: undefined;
|
|
117
|
+
|
|
118
|
+
if (!data) {
|
|
119
|
+
writeHookOutput("SessionStart", "", { systemMessage });
|
|
109
120
|
process.exit(0);
|
|
110
121
|
}
|
|
111
122
|
|
|
@@ -114,7 +125,8 @@ async function main() {
|
|
|
114
125
|
if (!tasks || tasks.length === 0) {
|
|
115
126
|
writeHookOutput(
|
|
116
127
|
"SessionStart",
|
|
117
|
-
"[mcpbox] No open tasks — run /mcpbox:tasks to verify, or /mcpbox:pipeline-run \"<idea>\" to open a maturity run."
|
|
128
|
+
"[mcpbox] No open tasks — run /mcpbox:tasks to verify, or /mcpbox:pipeline-run \"<idea>\" to open a maturity run.",
|
|
129
|
+
{ systemMessage },
|
|
118
130
|
);
|
|
119
131
|
process.exit(0);
|
|
120
132
|
}
|
|
@@ -131,8 +143,10 @@ async function main() {
|
|
|
131
143
|
if (extra > 0) lines.push(` …and ${extra} more — /mcpbox:tasks for full list`);
|
|
132
144
|
lines.push("→ /mcpbox:next to claim the next task | /mcpbox:status for server + pipeline health");
|
|
133
145
|
|
|
134
|
-
writeHookOutput("SessionStart", lines.join("\n"));
|
|
146
|
+
writeHookOutput("SessionStart", lines.join("\n"), { systemMessage });
|
|
135
147
|
process.exit(0);
|
|
136
148
|
}
|
|
137
149
|
|
|
138
|
-
|
|
150
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
151
|
+
main();
|
|
152
|
+
}
|
|
@@ -20,6 +20,8 @@ import { pathToFileURL } from "node:url";
|
|
|
20
20
|
|
|
21
21
|
import { writeHookOutput } from "../lib/hook-output.mjs";
|
|
22
22
|
import { readMode } from "../lib/mode.mjs";
|
|
23
|
+
import { checkForUpdate, updateNotice } from "../lib/update-check.mjs";
|
|
24
|
+
import { VERSION } from "../lib/version.mjs";
|
|
23
25
|
|
|
24
26
|
// Intent patterns. Order matters — first match wins. ASCII keywords use \b;
|
|
25
27
|
// Cyrillic uses whitespace/edge guards since \b is ASCII-only.
|
|
@@ -58,8 +60,20 @@ const PATTERNS = [
|
|
|
58
60
|
|
|
59
61
|
// full mode: remind the agent to judge rawness itself — a regex can't. Only
|
|
60
62
|
// fires on substantive prompts that didn't already match an explicit intent.
|
|
63
|
+
// The exit comes FIRST. When this hint led with "assess for rawness", an agent
|
|
64
|
+
// asked to start a dev server announced a Daruma follow-up and went looking for
|
|
65
|
+
// ceremony: the routing rule offered three doors and every one of them ended in
|
|
66
|
+
// a tracker artifact, so there was no branch that said "just do it".
|
|
67
|
+
// A routing hint fires on the first PATTERNS match, so an operational request
|
|
68
|
+
// that happens to contain a keyword never reached the exit below: "запусти
|
|
69
|
+
// сервер и закрой лишние процессы" matched the close pattern and pointed a pure
|
|
70
|
+
// process restart at daruma_complete — the incident again, wearing another verb.
|
|
71
|
+
// In full mode every hint therefore carries the exit in front of it.
|
|
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: ";
|
|
74
|
+
|
|
61
75
|
const FULL_ASSESS_HINT =
|
|
62
|
-
"[mcpbox:full]
|
|
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.";
|
|
63
77
|
|
|
64
78
|
// ponytail: length heuristic for "substantive" — cheap and good enough to skip
|
|
65
79
|
// "ok"/"yes"/"go". Swap for a token/keyword check only if it nags in practice.
|
|
@@ -72,7 +86,11 @@ export function promptSubmitHint(promptText = "", mode = "lite") {
|
|
|
72
86
|
const prompt = promptText.replace(/```[\s\S]*?```/g, " ").toLowerCase().trim();
|
|
73
87
|
const patterns = mode === "off" ? PATTERNS.slice(1) : PATTERNS;
|
|
74
88
|
for (const { re, hint } of patterns) {
|
|
75
|
-
if (re.test(prompt))
|
|
89
|
+
if (re.test(prompt)) {
|
|
90
|
+
// A keyword match is a guess about intent, not a verdict on it — in full
|
|
91
|
+
// mode the operational exit goes ahead of the guess.
|
|
92
|
+
return mode === "full" ? `[mcpbox:full] ${OPERATIONAL_EXIT}${hint}` : hint;
|
|
93
|
+
}
|
|
76
94
|
}
|
|
77
95
|
if (mode === "full" && prompt.length >= SUBSTANTIVE_MIN) return FULL_ASSESS_HINT;
|
|
78
96
|
return "";
|
|
@@ -127,19 +145,21 @@ export function promptFromHookPayload(payload) {
|
|
|
127
145
|
// fire, so for Kimi the policy rides in on the first prompt of a session.
|
|
128
146
|
// Claude registers this hook without --policy: it reads CLAUDE.md already.
|
|
129
147
|
async function policyForFirstPrompt(payload) {
|
|
130
|
-
if (!process.argv.includes("--policy")) return "";
|
|
148
|
+
if (!process.argv.includes("--policy")) return { policy: "", firstPrompt: false };
|
|
131
149
|
// PLAIN: this path only ever serves non-Claude surfaces, which have no
|
|
132
150
|
// /mcpbox:* commands.
|
|
133
151
|
const { BLOCK_BODY_PLAIN, BEGIN } = await import("../lib/policy.mjs");
|
|
134
152
|
const cwd = typeof payload?.cwd === "string" && payload.cwd ? payload.cwd : process.cwd();
|
|
153
|
+
let policy = BLOCK_BODY_PLAIN;
|
|
135
154
|
try {
|
|
136
155
|
// An AGENTS.md right here already carries the block — the agent is
|
|
137
156
|
// reading it, so a second copy would be pure noise.
|
|
138
|
-
if ((await readFile(join(cwd, "AGENTS.md"), "utf8")).includes(BEGIN))
|
|
157
|
+
if ((await readFile(join(cwd, "AGENTS.md"), "utf8")).includes(BEGIN)) policy = "";
|
|
139
158
|
} catch { /* no AGENTS.md here — the policy has to come from us */ }
|
|
140
159
|
|
|
160
|
+
if (!policy) return { policy: "", firstPrompt: false };
|
|
141
161
|
const sessionId = typeof payload?.session_id === "string" ? payload.session_id : "";
|
|
142
|
-
if (!sessionId) return
|
|
162
|
+
if (!sessionId) return { policy, firstPrompt: false }; // policy repeats; update notices must not
|
|
143
163
|
// ponytail: one empty marker file per session, never swept. They are 0
|
|
144
164
|
// bytes; add a cleanup pass only if a long-lived install ever complains.
|
|
145
165
|
const marker = join(homedir(), ".agents", "mcpbox", "sessions", sessionId.replace(/[^\w.-]/g, "_"));
|
|
@@ -148,9 +168,9 @@ async function policyForFirstPrompt(payload) {
|
|
|
148
168
|
// wx fails if it exists → the policy already went out this session.
|
|
149
169
|
await writeFile(marker, "", { flag: "wx" });
|
|
150
170
|
} catch {
|
|
151
|
-
return "";
|
|
171
|
+
return { policy: "", firstPrompt: false };
|
|
152
172
|
}
|
|
153
|
-
return
|
|
173
|
+
return { policy, firstPrompt: true };
|
|
154
174
|
}
|
|
155
175
|
|
|
156
176
|
async function main() {
|
|
@@ -165,11 +185,16 @@ async function main() {
|
|
|
165
185
|
} catch { /* not JSON — no prompt to route */ }
|
|
166
186
|
}
|
|
167
187
|
}
|
|
168
|
-
const policy = await policyForFirstPrompt(payload);
|
|
188
|
+
const { policy, firstPrompt } = await policyForFirstPrompt(payload);
|
|
189
|
+
const update = firstPrompt ? await checkForUpdate({ current: VERSION }) : null;
|
|
169
190
|
const hint = promptSubmitHint(prompt, readMode());
|
|
191
|
+
const notice = update?.outdated ? updateNotice(update.current, update.latest, "kimi") : "";
|
|
170
192
|
// One write, not two: Codex parses stdout as a single JSON document, so a
|
|
171
193
|
// policy object followed by a hint object is as invalid as plain text.
|
|
172
|
-
writeHookOutput(
|
|
194
|
+
writeHookOutput(
|
|
195
|
+
"UserPromptSubmit",
|
|
196
|
+
[notice, policy, hint].filter(Boolean).join("\n"),
|
|
197
|
+
);
|
|
173
198
|
}
|
|
174
199
|
|
|
175
200
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
package/lib/hook-output.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// One writer for every hook's stdout, because the surfaces disagree on format.
|
|
2
2
|
//
|
|
3
|
-
// Claude Code and Kimi take plain text. Codex parses hook stdout as
|
|
4
|
-
//
|
|
5
|
-
// which is what every mcpbox hint turned into on Codex 0.147, once per prompt.
|
|
3
|
+
// Claude Code and Kimi normally take plain text. Codex parses hook stdout as
|
|
4
|
+
// JSON; Claude also accepts JSON when a user-visible systemMessage is present.
|
|
6
5
|
//
|
|
7
6
|
// Codex is the surface that exports PLUGIN_DATA (its per-plugin state dir,
|
|
8
7
|
// ~/.codex/plugins/data/<marketplace>-<plugin>); Claude Code exports only
|
|
@@ -14,19 +13,29 @@ export function isCodexSurface(env = process.env) {
|
|
|
14
13
|
// Codex has a *HookSpecificOutputWire for SessionStart / UserPromptSubmit /
|
|
15
14
|
// SubagentStart only; Stop has none and rejects additionalContext there, so a
|
|
16
15
|
// Stop message rides as systemMessage instead.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/** @param {{ systemMessage?: string }} [options] */
|
|
17
|
+
export function hookOutputPayload(event, text, options = {}) {
|
|
18
|
+
const systemMessage = options?.systemMessage;
|
|
19
|
+
const hasSystemMessage = systemMessage !== undefined;
|
|
20
|
+
if (event === "Stop" || event === "SubagentStop") {
|
|
21
|
+
return { systemMessage: systemMessage ?? text };
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...(hasSystemMessage ? { systemMessage } : {}),
|
|
25
|
+
...(text ? { hookSpecificOutput: { hookEventName: event, additionalContext: text } } : {}),
|
|
26
|
+
};
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
// Empty output stays empty: every surface reads "no stdout" as "no hint", and
|
|
24
30
|
// Codex only parses when something was written.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
/** @param {{ systemMessage?: string }} [options] */
|
|
32
|
+
export function writeHookOutput(event, text, options = {}, env = process.env) {
|
|
33
|
+
const systemMessage = options?.systemMessage;
|
|
34
|
+
const hasSystemMessage = systemMessage !== undefined;
|
|
35
|
+
if (!text && !hasSystemMessage) return;
|
|
36
|
+
if (!hasSystemMessage && !isCodexSurface(env)) {
|
|
28
37
|
process.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
|
-
process.stdout.write(`${JSON.stringify(hookOutputPayload(event, text))}\n`);
|
|
40
|
+
process.stdout.write(`${JSON.stringify(hookOutputPayload(event, text, { systemMessage }))}\n`);
|
|
32
41
|
}
|
package/lib/kimi.mjs
CHANGED
|
@@ -45,16 +45,20 @@ const END = "<!-- mcpbox:policy:end -->";
|
|
|
45
45
|
const TOML_BEGIN = "# mcpbox:hooks:begin";
|
|
46
46
|
const TOML_END = "# mcpbox:hooks:end";
|
|
47
47
|
|
|
48
|
-
// Hook assets copied into the Kimi home: the three hook scripts
|
|
49
|
-
//
|
|
48
|
+
// Hook assets copied into the Kimi home: the three hook scripts and all their
|
|
49
|
+
// local imports. Tests import static dependencies and execute --policy for the
|
|
50
|
+
// dynamic policy.mjs import.
|
|
50
51
|
const HOOK_ASSETS = [
|
|
51
52
|
["hooks", "session-start.mjs"],
|
|
52
53
|
["hooks", "user-prompt-submit.mjs"],
|
|
53
54
|
["hooks", "stop.mjs"],
|
|
54
55
|
["lib", "mcp-client.mjs"],
|
|
56
|
+
["lib", "hook-output.mjs"],
|
|
55
57
|
["lib", "mode.mjs"],
|
|
56
58
|
// user-prompt-submit.mjs --policy reads the policy body from here.
|
|
57
59
|
["lib", "policy.mjs"],
|
|
60
|
+
["lib", "update-check.mjs"],
|
|
61
|
+
["lib", "version.mjs"],
|
|
58
62
|
];
|
|
59
63
|
|
|
60
64
|
const MCP_ENTRY = { url: MCP_URL };
|
package/lib/mcp-client.mjs
CHANGED
|
@@ -28,23 +28,31 @@ export class MCPClient {
|
|
|
28
28
|
this._initialized = false;
|
|
29
29
|
this._serverInfo = null;
|
|
30
30
|
this._stderrStream = null;
|
|
31
|
+
this._failure = null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
async start(cmd, args = [], { cwd = process.cwd(), stderrLog = null, env = process.env } = {}) {
|
|
34
35
|
if (this._proc) throw new Error("MCPClient already started");
|
|
35
|
-
|
|
36
|
+
const proc = spawn(cmd, args, { cwd, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
37
|
+
this._proc = proc;
|
|
38
|
+
this._failure = null;
|
|
39
|
+
|
|
40
|
+
for (const stream of [proc.stdin, proc.stdout, proc.stderr]) {
|
|
41
|
+
stream.on("error", (err) => this._onError(err));
|
|
42
|
+
}
|
|
36
43
|
|
|
37
44
|
if (stderrLog) {
|
|
38
45
|
this._stderrStream = createWriteStream(stderrLog, { flags: "a" });
|
|
39
|
-
this.
|
|
46
|
+
this._stderrStream.on("error", () => {});
|
|
47
|
+
proc.stderr.pipe(this._stderrStream);
|
|
40
48
|
} else {
|
|
41
|
-
|
|
49
|
+
proc.stderr.on("data", () => {}); // drain to avoid backpressure
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
proc.stdout.setEncoding("utf8");
|
|
53
|
+
proc.stdout.on("data", (chunk) => this._onData(chunk));
|
|
54
|
+
proc.on("exit", (code, signal) => this._onExit(proc, code, signal));
|
|
55
|
+
proc.on("error", (err) => this._onError(err));
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
async initialize() {
|
|
@@ -56,7 +64,7 @@ export class MCPClient {
|
|
|
56
64
|
this._serverInfo = result.serverInfo ?? null;
|
|
57
65
|
this._initialized = true;
|
|
58
66
|
// Per spec, follow up with a one-way "initialized" notification.
|
|
59
|
-
this._send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
67
|
+
await this._send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
60
68
|
return result;
|
|
61
69
|
}
|
|
62
70
|
|
|
@@ -73,6 +81,7 @@ export class MCPClient {
|
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
async stop() {
|
|
84
|
+
if (this._stderrStream) this._stderrStream.end();
|
|
76
85
|
if (!this._proc) return;
|
|
77
86
|
const proc = this._proc;
|
|
78
87
|
this._proc = null;
|
|
@@ -87,7 +96,6 @@ export class MCPClient {
|
|
|
87
96
|
}, 2000);
|
|
88
97
|
proc.once("exit", () => { clearTimeout(timer); resolve(); });
|
|
89
98
|
});
|
|
90
|
-
if (this._stderrStream) this._stderrStream.end();
|
|
91
99
|
this._failAll(new Error("MCPClient stopped"));
|
|
92
100
|
}
|
|
93
101
|
|
|
@@ -104,13 +112,24 @@ export class MCPClient {
|
|
|
104
112
|
resolve: (v) => { clearTimeout(timer); resolve(v); },
|
|
105
113
|
reject: (e) => { clearTimeout(timer); reject(e); },
|
|
106
114
|
});
|
|
107
|
-
this._send({ jsonrpc: "2.0", id, method, params })
|
|
115
|
+
this._send({ jsonrpc: "2.0", id, method, params }).catch((err) => {
|
|
116
|
+
const pending = this._pending.get(id);
|
|
117
|
+
if (!pending) return;
|
|
118
|
+
this._pending.delete(id);
|
|
119
|
+
pending.reject(err);
|
|
120
|
+
});
|
|
108
121
|
});
|
|
109
122
|
}
|
|
110
123
|
|
|
111
124
|
_send(msg) {
|
|
112
|
-
|
|
113
|
-
this.
|
|
125
|
+
const proc = this._proc;
|
|
126
|
+
if (this._failure) return Promise.reject(this._failure);
|
|
127
|
+
if (!proc || proc.stdin.destroyed || proc.stdin.writableEnded) {
|
|
128
|
+
return Promise.reject(new Error("MCPClient: server not running"));
|
|
129
|
+
}
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
proc.stdin.write(JSON.stringify(msg) + "\n", (err) => err ? reject(err) : resolve());
|
|
132
|
+
});
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
_onData(chunk) {
|
|
@@ -148,8 +167,15 @@ export class MCPClient {
|
|
|
148
167
|
// Otherwise: notification or unmatched response — drop it.
|
|
149
168
|
}
|
|
150
169
|
|
|
151
|
-
_onExit(code, signal) {
|
|
152
|
-
this.
|
|
170
|
+
_onExit(proc, code, signal) {
|
|
171
|
+
if (this._proc !== proc) return;
|
|
172
|
+
this._proc = null;
|
|
173
|
+
this._onError(new Error(`MCP server exited (code=${code}, signal=${signal})`));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_onError(err) {
|
|
177
|
+
this._failure ??= err;
|
|
178
|
+
this._failAll(this._failure);
|
|
153
179
|
}
|
|
154
180
|
|
|
155
181
|
_failAll(err) {
|
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\` управляет только тем, насколько активно ты *предлагаешь*
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const REGISTRY_URL = "https://registry.npmjs.org/@mcpbox/mcpbox-claude";
|
|
6
|
+
const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
7
|
+
const FAILED_TTL_MS = 60 * 60 * 1000;
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 1000;
|
|
9
|
+
|
|
10
|
+
export function compareVersions(left, right) {
|
|
11
|
+
const clean = (value) => String(value).split("-")[0];
|
|
12
|
+
const a = clean(left);
|
|
13
|
+
const b = clean(right);
|
|
14
|
+
if (!/^\d+(?:\.\d+)*$/.test(a) || !/^\d+(?:\.\d+)*$/.test(b)) return null;
|
|
15
|
+
const leftSegments = a.split(".").map(Number);
|
|
16
|
+
const rightSegments = b.split(".").map(Number);
|
|
17
|
+
for (let i = 0; i < Math.max(leftSegments.length, rightSegments.length); i += 1) {
|
|
18
|
+
const difference = (leftSegments[i] ?? 0) - (rightSegments[i] ?? 0);
|
|
19
|
+
if (difference) return difference;
|
|
20
|
+
}
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function checkForUpdate({
|
|
25
|
+
current,
|
|
26
|
+
home = homedir(),
|
|
27
|
+
ttlMs = DEFAULT_TTL_MS,
|
|
28
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
29
|
+
} = {}) {
|
|
30
|
+
if (process.env.MCPBOX_NO_UPDATE_CHECK) return null;
|
|
31
|
+
const cacheFile = join(home, ".agents", "mcpbox", "update-check.json");
|
|
32
|
+
/** @type {{ checkedAt?: number, failedAt?: number, latest?: string } | null} */
|
|
33
|
+
let cached = null;
|
|
34
|
+
try {
|
|
35
|
+
try {
|
|
36
|
+
cached = JSON.parse(await readFile(cacheFile, "utf8"));
|
|
37
|
+
} catch { /* missing or invalid cache — check the registry */ }
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
typeof cached?.latest === "string"
|
|
41
|
+
&& Number.isFinite(cached?.checkedAt)
|
|
42
|
+
&& Date.now() - cached.checkedAt < ttlMs
|
|
43
|
+
) {
|
|
44
|
+
const comparison = compareVersions(current, cached.latest);
|
|
45
|
+
return comparison === null
|
|
46
|
+
? null
|
|
47
|
+
: { current, latest: cached.latest, outdated: comparison < 0 };
|
|
48
|
+
}
|
|
49
|
+
if (Number.isFinite(cached?.failedAt) && Date.now() - cached.failedAt < FAILED_TTL_MS) return null;
|
|
50
|
+
|
|
51
|
+
const response = await fetch(REGISTRY_URL, {
|
|
52
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
53
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok) throw new Error(`registry returned ${response.status}`);
|
|
56
|
+
const latest = (await response.json())?.["dist-tags"]?.latest;
|
|
57
|
+
const comparison = compareVersions(current, latest);
|
|
58
|
+
if (typeof latest !== "string" || comparison === null) throw new Error("invalid registry version");
|
|
59
|
+
await writeCache(cacheFile, { checkedAt: Date.now(), latest }).catch(() => {});
|
|
60
|
+
return { current, latest, outdated: comparison < 0 };
|
|
61
|
+
} catch {
|
|
62
|
+
await writeCache(cacheFile, { ...(cached ?? {}), failedAt: Date.now() }).catch(() => {});
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function writeCache(cacheFile, value) {
|
|
68
|
+
await mkdir(dirname(cacheFile), { recursive: true });
|
|
69
|
+
await writeFile(cacheFile, `${JSON.stringify(value)}\n`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const UPDATE_COMMANDS = Object.assign(Object.create(null), {
|
|
73
|
+
claude: "npx -y @mcpbox/mcpbox-claude@latest export-marketplace && claude plugin marketplace update mcpbox",
|
|
74
|
+
codex: "npx -y @mcpbox/mcpbox-claude@latest export-marketplace && codex plugin add mcpbox --marketplace mcpbox",
|
|
75
|
+
kimi: "npx -y @mcpbox/mcpbox-claude@latest kimi-init",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export function updateNotice(current, latest, surface) {
|
|
79
|
+
const command = UPDATE_COMMANDS[surface] ?? "npx -y @mcpbox/mcpbox-claude@latest";
|
|
80
|
+
return `mcpbox ${current} → ${latest}.\nОбновить: ${command}`;
|
|
81
|
+
}
|
package/lib/version.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "0.1.13";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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": {
|