@mcpbox/mcpbox-claude 0.1.0 → 0.1.3
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/README.md +22 -8
- package/bin/mcpbox-claude.mjs +26 -1
- package/commands/pipeline-run.md +2 -2
- package/hooks/user-prompt-submit.mjs +64 -9
- package/lib/kimi.mjs +191 -0
- package/lib/policy.mjs +21 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @mcpbox/mcpbox-claude
|
|
2
2
|
|
|
3
|
-
MCPBox agent harness for **Claude Code**, **Codex**, and **
|
|
4
|
-
single canonical MCP server (`https://mcpbox.ru/v1/mcp` — the daruma
|
|
5
|
-
tools plus the platform pipeline `torii→satori→enma→yatagarasu→fujin→daruma`)
|
|
3
|
+
MCPBox agent harness for **Claude Code**, **Codex**, **Cursor**, and **Kimi Code**.
|
|
4
|
+
Wires the single canonical MCP server (`https://mcpbox.ru/v1/mcp` — the daruma
|
|
5
|
+
tracker tools plus the platform pipeline `torii→satori→enma→yatagarasu→fujin→daruma`)
|
|
6
6
|
and drops a managed policy into each agent's native config file.
|
|
7
7
|
|
|
8
8
|
Normally installed for you by `npx @mcpbox/mcpbox setup` (or
|
|
@@ -12,11 +12,22 @@ just the policy.
|
|
|
12
12
|
|
|
13
13
|
## What it manages
|
|
14
14
|
|
|
15
|
-
| Agent | Policy surface | MCP server |
|
|
16
|
-
|
|
17
|
-
| Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) |
|
|
18
|
-
| Codex | `AGENTS.md` block (`mcpbox:policy`) | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` |
|
|
19
|
-
| Cursor | `.cursor/rules/mcpbox-policy.mdc` (`alwaysApply`) | `mcpbox` entry in `.cursor/mcp.json` |
|
|
15
|
+
| Agent | Policy surface | MCP server | Hooks |
|
|
16
|
+
|--------|----------------------------------------|-------------------------------------|-------|
|
|
17
|
+
| Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
|
|
18
|
+
| Codex | `AGENTS.md` block (`mcpbox:policy`) | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | — |
|
|
19
|
+
| Cursor | `.cursor/rules/mcpbox-policy.mdc` (`alwaysApply`) | `mcpbox` entry in `.cursor/mcp.json` | — |
|
|
20
|
+
| Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
|
|
21
|
+
|
|
22
|
+
Kimi specifics:
|
|
23
|
+
|
|
24
|
+
- MCP and hooks are **user-level** (Kimi reads hooks only from
|
|
25
|
+
`~/.kimi-code/config.toml`; `$KIMI_CODE_HOME` is honored). One
|
|
26
|
+
`/mcp-config login mcpbox` OAuth then covers every project.
|
|
27
|
+
- The hook scripts (`SessionStart` task summary, `UserPromptSubmit` routing
|
|
28
|
+
hints, `Stop` auto-record nudge) are the same ones the Claude plugin ships;
|
|
29
|
+
`kimi-init` copies them into `~/.kimi-code/mcpbox/` so the config never
|
|
30
|
+
references an ephemeral npx cache path. `kimi-uninit` removes that directory.
|
|
20
31
|
|
|
21
32
|
## CLI
|
|
22
33
|
|
|
@@ -27,6 +38,9 @@ mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + ~/.codex/config.toml
|
|
|
27
38
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
28
39
|
mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server.
|
|
29
40
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
41
|
+
mcpbox-claude kimi-init [--dir DIR] AGENTS.md policy + ~/.kimi-code/mcp.json server
|
|
42
|
+
+ ~/.kimi-code/config.toml [[hooks]].
|
|
43
|
+
mcpbox-claude kimi-uninit [--dir DIR]
|
|
30
44
|
mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
|
|
31
45
|
```
|
|
32
46
|
|
package/bin/mcpbox-claude.mjs
CHANGED
|
@@ -20,11 +20,12 @@ import { spawnSync } from "node:child_process";
|
|
|
20
20
|
import { installPolicy, removePolicy, BEGIN } from "../lib/policy.mjs";
|
|
21
21
|
import { installCodex, removeCodex, installCodexPolicy } from "../lib/codex.mjs";
|
|
22
22
|
import { installCursor, removeCursor, installCursorRule } from "../lib/cursor.mjs";
|
|
23
|
+
import { installKimi, removeKimi } from "../lib/kimi.mjs";
|
|
23
24
|
|
|
24
25
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
25
26
|
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
|
|
26
27
|
|
|
27
|
-
const HELP = `mcpbox-claude v${pkg.version} — MCPBox agent harness (Claude / Codex / Cursor)
|
|
28
|
+
const HELP = `mcpbox-claude v${pkg.version} — MCPBox agent harness (Claude / Codex / Cursor / Kimi)
|
|
28
29
|
|
|
29
30
|
Usage:
|
|
30
31
|
mcpbox-claude init [--dir DIR] Write the managed CLAUDE.md policy block
|
|
@@ -36,6 +37,10 @@ Usage:
|
|
|
36
37
|
mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
|
|
37
38
|
.cursor/mcp.json mcpbox entry. Idempotent.
|
|
38
39
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
40
|
+
mcpbox-claude kimi-init [--dir DIR] Write AGENTS.md policy + ~/.kimi-code/mcp.json
|
|
41
|
+
mcpbox entry + [[hooks]] in ~/.kimi-code/config.toml.
|
|
42
|
+
Idempotent.
|
|
43
|
+
mcpbox-claude kimi-uninit [--dir DIR]
|
|
39
44
|
mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
|
|
40
45
|
mcpbox-claude --version | -v
|
|
41
46
|
mcpbox-claude --help | -h
|
|
@@ -110,6 +115,22 @@ async function cmdCursorUninit(rest) {
|
|
|
110
115
|
report(mcp);
|
|
111
116
|
}
|
|
112
117
|
|
|
118
|
+
async function cmdKimiInit(rest) {
|
|
119
|
+
const { projectDir } = parseDirFlag(rest);
|
|
120
|
+
const { policy, mcp, hooks } = await installKimi({ projectDir });
|
|
121
|
+
report(policy);
|
|
122
|
+
report(mcp);
|
|
123
|
+
report(hooks);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function cmdKimiUninit(rest) {
|
|
127
|
+
const { projectDir } = parseDirFlag(rest);
|
|
128
|
+
const { policy, mcp, hooks } = await removeKimi({ projectDir });
|
|
129
|
+
report(policy);
|
|
130
|
+
report(mcp);
|
|
131
|
+
report(hooks);
|
|
132
|
+
}
|
|
133
|
+
|
|
113
134
|
// Policy-only variants — for callers (mcpbox-cli setup) that already own the
|
|
114
135
|
// MCP-server wiring and just need the managed policy file dropped.
|
|
115
136
|
async function cmdCodexPolicy(rest) {
|
|
@@ -186,6 +207,10 @@ async function main(argv) {
|
|
|
186
207
|
return cmdCursorInit(rest);
|
|
187
208
|
case "cursor-uninit":
|
|
188
209
|
return cmdCursorUninit(rest);
|
|
210
|
+
case "kimi-init":
|
|
211
|
+
return cmdKimiInit(rest);
|
|
212
|
+
case "kimi-uninit":
|
|
213
|
+
return cmdKimiUninit(rest);
|
|
189
214
|
case "codex-policy":
|
|
190
215
|
return cmdCodexPolicy(rest);
|
|
191
216
|
case "cursor-policy":
|
package/commands/pipeline-run.md
CHANGED
|
@@ -5,8 +5,8 @@ description: Open an mcpbox maturity run from raw input (torii→…→fujin→h
|
|
|
5
5
|
The user invoked `/mcpbox:pipeline-run` with a raw idea/request in `$ARGUMENTS`.
|
|
6
6
|
|
|
7
7
|
Raw input matures through the layers; a daruma task is created **only** via handoff,
|
|
8
|
-
never by
|
|
9
|
-
as target → `422`).
|
|
8
|
+
never by materializing a daruma task directly. The server enforces the layer order
|
|
9
|
+
(skip / `torii` as target → `422`).
|
|
10
10
|
|
|
11
11
|
## Steps
|
|
12
12
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// UserPromptSubmit hook: detect capture / sync / status / close / pipeline
|
|
3
|
-
// intent in the user's prompt and prepend a short routing hint so
|
|
4
|
-
// to the right slash command rather than improvising.
|
|
3
|
+
// intent in the user's prompt and prepend a short routing hint so the agent
|
|
4
|
+
// routes to the right slash command rather than improvising.
|
|
5
5
|
//
|
|
6
|
-
// Output goes to stdout — Claude Code injects it as a <system-reminder
|
|
7
|
-
// Exit 0 always; this hook must
|
|
6
|
+
// Output goes to stdout — Claude Code injects it as a <system-reminder>; Kimi
|
|
7
|
+
// Code appends it to the context on exit 0. Exit 0 always; this hook must
|
|
8
|
+
// never block a prompt from being submitted.
|
|
8
9
|
//
|
|
9
|
-
//
|
|
10
|
+
// Prompt source: CLAUDE_USER_PROMPT env var (Claude Code); otherwise the hook
|
|
11
|
+
// event JSON on stdin (Kimi Code passes the payload via stdin, and so does
|
|
12
|
+
// Claude Code — this also covers Claude setups without the env var).
|
|
10
13
|
|
|
11
14
|
import { pathToFileURL } from "node:url";
|
|
12
15
|
|
|
@@ -15,7 +18,16 @@ import { pathToFileURL } from "node:url";
|
|
|
15
18
|
const PATTERNS = [
|
|
16
19
|
{
|
|
17
20
|
re: /\b(pipeline|maturity|handoff|action\s*packet)\b|(?<![а-яёА-ЯЁ])(пайплайн|конвейер|зрелость|хендофф)(?![а-яёА-ЯЁ])/,
|
|
18
|
-
hint: "[mcpbox] Detected pipeline intent → /mcpbox:pipeline-run or mcpbox_pipeline_run (raw input matures torii→…→fujin→handoff, never
|
|
21
|
+
hint: "[mcpbox] Detected pipeline intent → /mcpbox:pipeline-run or mcpbox_pipeline_run (raw input matures torii→…→fujin→handoff, never a direct daruma task).",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// create / import — ACTION + task/issue OBJECT (avoids bare-verb false positives).
|
|
25
|
+
re: /\b(add|create|new|log|move|import)\s+(a\s+|an\s+)?(task|issue|ticket|subtask)\b|(?<![а-яёА-ЯЁ])(добавь|добавить|заведи|завести|создай|создать)\s+(задачу|таск|подзадачу|тикет)(?![а-яёА-ЯЁ])|(?<![а-яёА-ЯЁ])(перенеси|перенести|импортируй|заведи)\s+(ишью|задачу|таск|тикет|issue)(?![а-яёА-ЯЁ])/,
|
|
26
|
+
hint: "[mcpbox] Detected task-intake/import intent → daruma_plan_materialize (plan-only intake, ADR-0007; external issue: also daruma_link the source). Adding to an EXISTING plan: still materialize (no bare-task intake), then attach via daruma_plan_add_task (recompose) or pass parent_plan_id. Not a lookup — don't treat the id as an existing task.",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
re: /\b(list|show|view)\s+(all\s+|active\s+|open\s+)?(tasks|issues|backlog)\b|(?<![а-яёА-ЯЁ])(выпиши|покажи|перечисли|список)\s+(активные\s+)?(задачи|задач|таски|бэклог)(?![а-яёА-ЯЁ])/,
|
|
30
|
+
hint: "[mcpbox] Detected task-list intent → /mcpbox:tasks (daruma_list status=active, scoped).",
|
|
19
31
|
},
|
|
20
32
|
{
|
|
21
33
|
re: /\b(capture|record|lesson)\b|(?<![а-яёА-ЯЁ])(сохрани|запомни|урок)(?![а-яёА-ЯЁ])/,
|
|
@@ -36,15 +48,58 @@ const PATTERNS = [
|
|
|
36
48
|
];
|
|
37
49
|
|
|
38
50
|
export function promptSubmitHint(promptText = "") {
|
|
39
|
-
|
|
51
|
+
// Strip fenced code blocks so a keyword pasted inside ``` … ``` doesn't
|
|
52
|
+
// trigger a routing hint (OMC-style false-positive guard, kept minimal —
|
|
53
|
+
// these hints are low-stakes suggestions, not mode activation).
|
|
54
|
+
const prompt = promptText.replace(/```[\s\S]*?```/g, " ").toLowerCase().trim();
|
|
40
55
|
for (const { re, hint } of PATTERNS) {
|
|
41
56
|
if (re.test(prompt)) return hint;
|
|
42
57
|
}
|
|
43
58
|
return "";
|
|
44
59
|
}
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
// Reads stdin to EOF with a timeout so a hook caller that keeps stdin open
|
|
62
|
+
// can never hang the prompt submit path.
|
|
63
|
+
function readStdin(timeoutMs = 3000) {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
if (process.stdin.isTTY) return resolve("");
|
|
66
|
+
let raw = "";
|
|
67
|
+
const done = () => {
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
resolve(raw);
|
|
70
|
+
};
|
|
71
|
+
const timer = setTimeout(() => {
|
|
72
|
+
process.stdin.destroy();
|
|
73
|
+
resolve(raw);
|
|
74
|
+
}, timeoutMs);
|
|
75
|
+
process.stdin.setEncoding("utf8");
|
|
76
|
+
process.stdin.on("data", (chunk) => { raw += chunk; });
|
|
77
|
+
process.stdin.on("end", done);
|
|
78
|
+
process.stdin.on("error", done);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Kimi's UserPromptSubmit payload carries the prompt text; the exact field
|
|
83
|
+
// name is not documented, so accept the common shapes.
|
|
84
|
+
export function promptFromHookPayload(payload) {
|
|
85
|
+
if (!payload || typeof payload !== "object") return "";
|
|
86
|
+
for (const key of ["prompt", "user_prompt", "userPrompt", "message", "text"]) {
|
|
87
|
+
if (typeof payload[key] === "string" && payload[key].trim()) return payload[key];
|
|
88
|
+
}
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function main() {
|
|
93
|
+
let prompt = process.env.CLAUDE_USER_PROMPT ?? "";
|
|
94
|
+
if (!prompt) {
|
|
95
|
+
const raw = await readStdin();
|
|
96
|
+
if (raw.trim()) {
|
|
97
|
+
try {
|
|
98
|
+
prompt = promptFromHookPayload(JSON.parse(raw));
|
|
99
|
+
} catch { /* not JSON — no prompt to route */ }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const hint = promptSubmitHint(prompt);
|
|
48
103
|
if (hint) process.stdout.write(hint + "\n");
|
|
49
104
|
}
|
|
50
105
|
|
package/lib/kimi.mjs
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Kimi Code CLI surface for the mcpbox harness — parity with the Claude
|
|
2
|
+
// CLAUDE.md plugin and the Codex AGENTS.md surface. Three idempotent writes:
|
|
3
|
+
// 1. AGENTS.md policy block (Kimi reads AGENTS.md every session in the
|
|
4
|
+
// workspace) — same managed block as the Codex surface.
|
|
5
|
+
// 2. `$KIMI_CODE_HOME/mcp.json` (default `~/.kimi-code/mcp.json`) — upsert
|
|
6
|
+
// the `mcpbox` HTTP server entry, preserving other servers. A bare `url`
|
|
7
|
+
// entry means HTTP transport in Kimi. User-level on purpose: one server
|
|
8
|
+
// entry (and one `/mcp-config login mcpbox` OAuth) covers every project.
|
|
9
|
+
// 3. `$KIMI_CODE_HOME/config.toml` — managed `[[hooks]]` block pointing at
|
|
10
|
+
// the hook scripts copied into `$KIMI_CODE_HOME/mcpbox/`. Kimi reads
|
|
11
|
+
// hooks only from the user-level config.toml (no project-level hooks),
|
|
12
|
+
// so — like the Codex MCP entry — the block is fenced with comment
|
|
13
|
+
// markers and replaced in place; surrounding hand-written TOML is
|
|
14
|
+
// preserved.
|
|
15
|
+
//
|
|
16
|
+
// The policy body is BLOCK_BODY from lib/policy.mjs — one source of truth
|
|
17
|
+
// shared across CLAUDE.md / AGENTS.md / .cursor/rules.
|
|
18
|
+
//
|
|
19
|
+
// Hook semantics in Kimi (https://www.kimi.com/code/docs/en/kimi-code-cli/customization/hooks.html):
|
|
20
|
+
// stdin carries the event JSON; exit 0 + stdout appends text to the context;
|
|
21
|
+
// SessionStart/UserPromptSubmit/Stop all exist. The hook scripts are the same
|
|
22
|
+
// ones the Claude plugin ships (hooks/), copied into the Kimi home so the
|
|
23
|
+
// config never references an ephemeral npx cache path.
|
|
24
|
+
|
|
25
|
+
import { promises as fs } from "node:fs";
|
|
26
|
+
import { homedir } from "node:os";
|
|
27
|
+
import { dirname, join, resolve } from "node:path";
|
|
28
|
+
import { fileURLToPath } from "node:url";
|
|
29
|
+
import {
|
|
30
|
+
BLOCK_BODY,
|
|
31
|
+
MCP_URL,
|
|
32
|
+
installManagedBlock,
|
|
33
|
+
removeManagedBlock,
|
|
34
|
+
} from "./policy.mjs";
|
|
35
|
+
|
|
36
|
+
const BEGIN = "<!-- mcpbox:policy:begin -->";
|
|
37
|
+
const END = "<!-- mcpbox:policy:end -->";
|
|
38
|
+
|
|
39
|
+
const TOML_BEGIN = "# mcpbox:hooks:begin";
|
|
40
|
+
const TOML_END = "# mcpbox:hooks:end";
|
|
41
|
+
|
|
42
|
+
// Hook assets copied into the Kimi home: the three hook scripts plus the
|
|
43
|
+
// stdio MCP client session-start.mjs imports (../lib/mcp-client.mjs).
|
|
44
|
+
const HOOK_ASSETS = [
|
|
45
|
+
["hooks", "session-start.mjs"],
|
|
46
|
+
["hooks", "user-prompt-submit.mjs"],
|
|
47
|
+
["hooks", "stop.mjs"],
|
|
48
|
+
["lib", "mcp-client.mjs"],
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const MCP_ENTRY = { url: MCP_URL };
|
|
52
|
+
|
|
53
|
+
function packageRoot() {
|
|
54
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Kimi data dir: explicit override (tests) > $KIMI_CODE_HOME > ~/.kimi-code.
|
|
58
|
+
export function kimiHomeDir(home) {
|
|
59
|
+
if (home) return resolve(home);
|
|
60
|
+
const env = process.env.KIMI_CODE_HOME?.trim();
|
|
61
|
+
if (env) return env;
|
|
62
|
+
return join(homedir(), ".kimi-code");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// --- 1. AGENTS.md policy block in the project directory ---
|
|
66
|
+
|
|
67
|
+
export function installKimiPolicy({ projectDir } = {}) {
|
|
68
|
+
const dir = projectDir ? resolve(projectDir) : process.cwd();
|
|
69
|
+
return installManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END, block: BLOCK_BODY });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function removeKimiPolicy({ projectDir } = {}) {
|
|
73
|
+
const dir = projectDir ? resolve(projectDir) : process.cwd();
|
|
74
|
+
return removeManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// --- 2. `mcpbox` entry in the user-level mcp.json ---
|
|
78
|
+
|
|
79
|
+
async function readMcp(target) {
|
|
80
|
+
try {
|
|
81
|
+
const doc = JSON.parse(await fs.readFile(target, "utf8"));
|
|
82
|
+
if (!doc || typeof doc !== "object" || Array.isArray(doc)) {
|
|
83
|
+
throw new Error(`${target} is not a JSON object`);
|
|
84
|
+
}
|
|
85
|
+
if (!doc.mcpServers || typeof doc.mcpServers !== "object") doc.mcpServers = {};
|
|
86
|
+
return doc;
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (err.code === "ENOENT") return { mcpServers: {} };
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function installKimiMcp({ mcpPath, kimiHome } = {}) {
|
|
94
|
+
const target = mcpPath ? resolve(mcpPath) : join(kimiHomeDir(kimiHome), "mcp.json");
|
|
95
|
+
const doc = await readMcp(target);
|
|
96
|
+
const before = doc.mcpServers.mcpbox;
|
|
97
|
+
if (before && JSON.stringify(before) === JSON.stringify(MCP_ENTRY)) {
|
|
98
|
+
return { action: "unchanged", path: target };
|
|
99
|
+
}
|
|
100
|
+
doc.mcpServers.mcpbox = MCP_ENTRY;
|
|
101
|
+
await fs.mkdir(dirname(target), { recursive: true });
|
|
102
|
+
await fs.writeFile(target, JSON.stringify(doc, null, 2) + "\n");
|
|
103
|
+
return { action: before ? "updated" : "installed", path: target };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function removeKimiMcp({ mcpPath, kimiHome } = {}) {
|
|
107
|
+
const target = mcpPath ? resolve(mcpPath) : join(kimiHomeDir(kimiHome), "mcp.json");
|
|
108
|
+
let doc;
|
|
109
|
+
try {
|
|
110
|
+
doc = await readMcp(target);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
if (err.code === "ENOENT") return { action: "missing", path: target };
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
if (!doc.mcpServers.mcpbox) return { action: "missing", path: target };
|
|
116
|
+
delete doc.mcpServers.mcpbox;
|
|
117
|
+
await fs.writeFile(target, JSON.stringify(doc, null, 2) + "\n");
|
|
118
|
+
return { action: "removed-block", path: target };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// --- 3. Hooks: copied scripts + managed [[hooks]] block in config.toml ---
|
|
122
|
+
|
|
123
|
+
// TOML literal strings (single quotes) keep absolute paths with spaces or
|
|
124
|
+
// backslashes intact without escaping.
|
|
125
|
+
function hooksTomlBlock(assetsRoot) {
|
|
126
|
+
const command = (file) => `command = 'node "${join(assetsRoot, "hooks", file)}"'`;
|
|
127
|
+
return [
|
|
128
|
+
"[[hooks]]",
|
|
129
|
+
'event = "SessionStart"',
|
|
130
|
+
command("session-start.mjs"),
|
|
131
|
+
"timeout = 15",
|
|
132
|
+
"",
|
|
133
|
+
"[[hooks]]",
|
|
134
|
+
'event = "UserPromptSubmit"',
|
|
135
|
+
command("user-prompt-submit.mjs"),
|
|
136
|
+
"",
|
|
137
|
+
"[[hooks]]",
|
|
138
|
+
'event = "Stop"',
|
|
139
|
+
command("stop.mjs"),
|
|
140
|
+
"",
|
|
141
|
+
].join("\n");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function copyHookAssets(assetsRoot) {
|
|
145
|
+
for (const [subdir, file] of HOOK_ASSETS) {
|
|
146
|
+
const target = join(assetsRoot, subdir, file);
|
|
147
|
+
await fs.mkdir(dirname(target), { recursive: true });
|
|
148
|
+
await fs.copyFile(join(packageRoot(), subdir, file), target);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function installKimiHooks({ configPath, kimiHome } = {}) {
|
|
153
|
+
const home = kimiHomeDir(kimiHome);
|
|
154
|
+
const assetsRoot = join(home, "mcpbox");
|
|
155
|
+
await copyHookAssets(assetsRoot);
|
|
156
|
+
const target = configPath ? resolve(configPath) : join(home, "config.toml");
|
|
157
|
+
return installManagedBlock({
|
|
158
|
+
target,
|
|
159
|
+
begin: TOML_BEGIN,
|
|
160
|
+
end: TOML_END,
|
|
161
|
+
block: hooksTomlBlock(assetsRoot),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function removeKimiHooks({ configPath, kimiHome } = {}) {
|
|
166
|
+
const home = kimiHomeDir(kimiHome);
|
|
167
|
+
const target = configPath ? resolve(configPath) : join(home, "config.toml");
|
|
168
|
+
const block = await removeManagedBlock({ target, begin: TOML_BEGIN, end: TOML_END });
|
|
169
|
+
// The assets dir is ours (namespaced `mcpbox` under the Kimi home) — drop it.
|
|
170
|
+
const assetsRoot = join(home, "mcpbox");
|
|
171
|
+
await fs.rm(assetsRoot, { recursive: true, force: true });
|
|
172
|
+
return block;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// --- All three surfaces at once (what `mcpbox-claude kimi-init` calls) ---
|
|
176
|
+
|
|
177
|
+
export async function installKimi({ projectDir, kimiHome } = {}) {
|
|
178
|
+
const policy = await installKimiPolicy({ projectDir });
|
|
179
|
+
const mcp = await installKimiMcp({ kimiHome });
|
|
180
|
+
const hooks = await installKimiHooks({ kimiHome });
|
|
181
|
+
return { policy, mcp, hooks };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function removeKimi({ projectDir, kimiHome } = {}) {
|
|
185
|
+
const policy = await removeKimiPolicy({ projectDir });
|
|
186
|
+
const mcp = await removeKimiMcp({ kimiHome });
|
|
187
|
+
const hooks = await removeKimiHooks({ kimiHome });
|
|
188
|
+
return { policy, mcp, hooks };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { BEGIN, END, TOML_BEGIN, TOML_END };
|
package/lib/policy.mjs
CHANGED
|
@@ -46,17 +46,16 @@ platform **pipeline** tools (\`mcpbox_pipeline_*\`, \`mcpbox_trace_get\`,
|
|
|
46
46
|
1. **All durable task/plan state lives in mcpbox (daruma tools).** Never persist
|
|
47
47
|
tasks, plans, subtasks, or backlogs in markdown scratchpads,
|
|
48
48
|
\`TODO.md\` files, or in-chat notes as the source of truth. Use
|
|
49
|
-
\`
|
|
50
|
-
\`
|
|
51
|
-
\`daruma_comment\`.
|
|
49
|
+
\`daruma_plan_materialize\` (plan-only intake, ADR-0007),
|
|
50
|
+
\`daruma_set_status\`, \`daruma_comment\`.
|
|
52
51
|
|
|
53
52
|
2. **Do not create or modify \`.omc/plans/\`, \`.omc/ultragoal/\`, or
|
|
54
53
|
\`.omc/state/plans*\`.** OMC skills (\`/plan\`, \`/ultragoal\`,
|
|
55
54
|
\`/autopilot\`, \`/ralph\`, \`/ultrawork\`, \`/ralplan\`, \`/team\`)
|
|
56
55
|
must not author new files under those paths. If a request triggers
|
|
57
56
|
one of those skills, route the plan into mcpbox first:
|
|
58
|
-
\`daruma_workspace_info\` →
|
|
59
|
-
\`
|
|
57
|
+
\`daruma_workspace_info\` →
|
|
58
|
+
\`daruma_plan_materialize\` (the plan with its tasks, one atomic call). OMC may
|
|
60
59
|
still execute, but the plan it follows must come from
|
|
61
60
|
\`daruma_plan_get\` / \`daruma_plan_next_task\`.
|
|
62
61
|
|
|
@@ -131,18 +130,24 @@ When the user mentions any of the following, the conversation is about
|
|
|
131
130
|
**this workspace's mcpbox tracker**. Do not invent another tracker
|
|
132
131
|
and do not reach for \`.omc/plans/\` or markdown TODO files.
|
|
133
132
|
|
|
134
|
-
- **Russian:** «трекер», «таск-трекер»,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
«закрыть задачу».
|
|
138
|
-
- **English:** "tracker", "issue tracker", "task tracker", "
|
|
139
|
-
"todo system", "plan", "task", "subtask", "decompose",
|
|
140
|
-
subtasks", "what's next", "mark this done", "track progress".
|
|
133
|
+
- **Russian:** «трекер», «таск-трекер», «таск-менеджер», «таск менеджер»,
|
|
134
|
+
«менеджер задач», «трекер задач», «бэклог», «список задач», «план»,
|
|
135
|
+
«задача», «таск», «подзадача», «ишью», «декомпозиция», «декомпозировать»,
|
|
136
|
+
«спланируй», «что дальше», «прогресс», «закрыть задачу».
|
|
137
|
+
- **English:** "tracker", "issue tracker", "task tracker", "task manager",
|
|
138
|
+
"backlog", "todo system", "plan", "task", "issue", "subtask", "decompose",
|
|
139
|
+
"break into subtasks", "what's next", "mark this done", "track progress".
|
|
141
140
|
|
|
142
|
-
If the user says "the tracker" / «наш трекер» without naming
|
|
143
|
-
**assume mcpbox**. Only ask for clarification when they explicitly
|
|
141
|
+
If the user says "the tracker" / «наш трекер» / «таск-менеджер» without naming
|
|
142
|
+
a tool, **assume mcpbox**. Only ask for clarification when they explicitly
|
|
144
143
|
mention a different system (Linear, Jira, GitHub Issues, etc.).
|
|
145
144
|
|
|
145
|
+
**Importing an external issue** — «перенеси/заведи ишью N в трекер / таск-менеджер»,
|
|
146
|
+
"move/import issue N into the tracker" — is **intake**, not a lookup: land it by
|
|
147
|
+
materializing a plan (\`daruma_plan_materialize\`) that carries the imported task,
|
|
148
|
+
and when the source is a real system (GitHub/Jira/Linear) \`daruma_link\` the new
|
|
149
|
+
task back to it. Do not treat the issue id as an existing daruma task to fetch.
|
|
150
|
+
|
|
146
151
|
---
|
|
147
152
|
|
|
148
153
|
## Part B — MCPBox pipeline (full maturity stack)
|
|
@@ -189,8 +194,8 @@ daruma execution задача/план (терминальный слой
|
|
|
189
194
|
артефактов — полный контекст персистирован на сервере, читается через
|
|
190
195
|
\`mcpbox_trace_get\`.
|
|
191
196
|
- **daruma-задача заводится ТОЛЬКО через \`mcpbox_pipeline_handoff\`** зрелого
|
|
192
|
-
Action Packet.
|
|
193
|
-
апстрима) в pipeline-контексте запрещено — на стороне daruma инвариант
|
|
197
|
+
Action Packet. Материализовать задачу «из воздуха» (\`daruma_plan_materialize\`
|
|
198
|
+
без апстрима) в pipeline-контексте запрещено — на стороне daruma инвариант
|
|
194
199
|
«планы — единственный вход».
|
|
195
200
|
- **Отказ слоя → возврат на предыдущий слой, не обход.** Ошибка хопа помечает
|
|
196
201
|
прогон \`failed\` (причина в \`mcpbox_trace_get\`); почини вход предыдущего
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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": {
|