@mcpbox/mcpbox-claude 0.1.5 → 0.1.7
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/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +18 -0
- package/.mcp.json +9 -0
- package/bin/mcpbox-claude.mjs +9 -4
- package/commands/pipeline-run.md +10 -10
- package/hooks/user-prompt-submit.mjs +63 -9
- package/lib/codex.mjs +114 -15
- package/lib/cursor.mjs +4 -3
- package/lib/kimi.mjs +24 -12
- package/lib/policy.mjs +36 -5
- package/package.json +4 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcpbox",
|
|
3
|
+
"interface": {
|
|
4
|
+
"displayName": "MCPBox"
|
|
5
|
+
},
|
|
6
|
+
"plugins": [
|
|
7
|
+
{
|
|
8
|
+
"name": "mcpbox",
|
|
9
|
+
"source": {
|
|
10
|
+
"source": "local",
|
|
11
|
+
"path": "."
|
|
12
|
+
},
|
|
13
|
+
"policy": {
|
|
14
|
+
"installation": "AVAILABLE",
|
|
15
|
+
"authentication": "ON_INSTALL"
|
|
16
|
+
},
|
|
17
|
+
"category": "Productivity"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -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.7",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tupical"
|
|
7
7
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcpbox",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "MCPBox agent stack for Codex: the daruma tracker plus the MeiSei maturity pipeline behind one MCP server.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "tupical"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://mcpbox.ru",
|
|
9
|
+
"mcpServers": "./.mcp.json",
|
|
10
|
+
"interface": {
|
|
11
|
+
"displayName": "MCPBox",
|
|
12
|
+
"shortDescription": "Task tracker + maturity pipeline for agents.",
|
|
13
|
+
"longDescription": "One MCP endpoint (https://mcpbox.ru/v1/mcp) exposing the daruma tracker (tasks, plans, plan-only intake) and the platform pipeline torii→satori→enma→yatagarasu→fujin→daruma. Ships the routing policy as a skill and /mcpbox-* prompts.",
|
|
14
|
+
"developerName": "tupical",
|
|
15
|
+
"category": "Productivity",
|
|
16
|
+
"websiteURL": "https://mcpbox.ru"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/.mcp.json
ADDED
package/bin/mcpbox-claude.mjs
CHANGED
|
@@ -39,8 +39,9 @@ Usage:
|
|
|
39
39
|
mcpbox-claude init [--dir DIR] Write the managed CLAUDE.md policy block
|
|
40
40
|
(daruma tracker + full pipeline). Idempotent.
|
|
41
41
|
mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
|
|
42
|
-
mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy
|
|
43
|
-
[mcp_servers.mcpbox]
|
|
42
|
+
mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
|
|
43
|
+
[mcp_servers.mcpbox], the mcpbox skill and
|
|
44
|
+
/mcpbox-* prompts. Idempotent.
|
|
44
45
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
45
46
|
mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
|
|
46
47
|
.cursor/mcp.json mcpbox entry. Idempotent.
|
|
@@ -102,16 +103,20 @@ function report(r) {
|
|
|
102
103
|
|
|
103
104
|
async function cmdCodexInit(rest) {
|
|
104
105
|
const { projectDir } = parseDirFlag(rest);
|
|
105
|
-
const { policy, mcp } = await installCodex({ projectDir });
|
|
106
|
+
const { policy, mcp, skill, prompts } = await installCodex({ projectDir });
|
|
106
107
|
report(policy);
|
|
107
108
|
report(mcp);
|
|
109
|
+
report(skill);
|
|
110
|
+
report(prompts);
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
async function cmdCodexUninit(rest) {
|
|
111
114
|
const { projectDir } = parseDirFlag(rest);
|
|
112
|
-
const { policy, mcp } = await removeCodex({ projectDir });
|
|
115
|
+
const { policy, mcp, skill, prompts } = await removeCodex({ projectDir });
|
|
113
116
|
report(policy);
|
|
114
117
|
report(mcp);
|
|
118
|
+
report(skill);
|
|
119
|
+
report(prompts);
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
async function cmdCursorInit(rest) {
|
package/commands/pipeline-run.md
CHANGED
|
@@ -11,15 +11,15 @@ never by materializing a daruma task directly. The server enforces the layer ord
|
|
|
11
11
|
## Steps
|
|
12
12
|
|
|
13
13
|
1. If `$ARGUMENTS` is empty, ask for the raw idea/request and stop.
|
|
14
|
-
2.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
2. Call `mcpbox_pipeline_run { source, kind:"text", body:"<idea>" }`. It returns
|
|
15
|
+
`run_id` immediately while all five hops run in the background. Poll
|
|
16
|
+
`mcpbox_trace_get { run_id }` until the status is no longer `running`.
|
|
17
|
+
3. On failure, report the reason from `mcpbox_trace_get`; do not hand off an
|
|
18
|
+
incomplete run.
|
|
19
|
+
4. Once `fujin` produced a mature Action Packet, call
|
|
20
|
+
`mcpbox_pipeline_handoff { run_id, action_packet, policy_snapshot, project_slug? }`,
|
|
21
|
+
taking `action_packet` from `artifacts.fujin.action_packet` and
|
|
22
|
+
`policy_snapshot` from `artifacts.policy_snapshot` in the trace. This
|
|
23
|
+
materializes the daruma task and returns `task_id`.
|
|
24
24
|
5. Verify with `mcpbox_trace_get { run_id }` (expect `status=handed_off`, a `task_id`) and
|
|
25
25
|
report the run_id + task_id.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// UserPromptSubmit hook: detect capture / sync / status / close / pipeline
|
|
3
3
|
// intent in the user's prompt and prepend a short routing hint so the agent
|
|
4
|
-
// routes to the right
|
|
4
|
+
// routes to the right place rather than improvising. The /mcpbox:* commands
|
|
5
|
+
// exist only in Claude Code, so each hint names the MCP tool as well — Codex,
|
|
6
|
+
// Cursor and Kimi can act on the hint without the plugin.
|
|
5
7
|
//
|
|
6
8
|
// Output goes to stdout — Claude Code injects it as a <system-reminder>; Kimi
|
|
7
9
|
// Code appends it to the context on exit 0. Exit 0 always; this hook must
|
|
@@ -11,7 +13,11 @@
|
|
|
11
13
|
// event JSON on stdin (Kimi Code passes the payload via stdin, and so does
|
|
12
14
|
// Claude Code — this also covers Claude setups without the env var).
|
|
13
15
|
|
|
16
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
14
19
|
import { pathToFileURL } from "node:url";
|
|
20
|
+
|
|
15
21
|
import { readMode } from "../lib/mode.mjs";
|
|
16
22
|
|
|
17
23
|
// Intent patterns. Order matters — first match wins. ASCII keywords use \b;
|
|
@@ -29,23 +35,23 @@ const PATTERNS = [
|
|
|
29
35
|
},
|
|
30
36
|
{
|
|
31
37
|
re: /\b(list|show|view)\s+(all\s+|active\s+|open\s+)?(tasks|issues|backlog)\b|(?<![а-яёА-ЯЁ])(выпиши|покажи|перечисли|список)\s+(активные\s+)?(задачи|задач|таски|бэклог)(?![а-яёА-ЯЁ])/,
|
|
32
|
-
hint: "[mcpbox] Detected task-list intent → /mcpbox:tasks
|
|
38
|
+
hint: "[mcpbox] Detected task-list intent → /mcpbox:tasks in Claude, otherwise daruma_list status=active with a scope.",
|
|
33
39
|
},
|
|
34
40
|
{
|
|
35
41
|
re: /\b(capture|record|lesson)\b|(?<![а-яёА-ЯЁ])(сохрани|запомни|урок)(?![а-яёА-ЯЁ])/,
|
|
36
|
-
hint: "[mcpbox] Detected lesson-capture intent → /mcpbox:capture",
|
|
42
|
+
hint: "[mcpbox] Detected lesson-capture intent → /mcpbox:capture in Claude, otherwise write the lesson as a daruma comment/document.",
|
|
37
43
|
},
|
|
38
44
|
{
|
|
39
45
|
re: /\b(sync|refresh\s+tasks)\b|(?<![а-яёА-ЯЁ])(синх|обнови\s+задачи)(?![а-яёА-ЯЁ])/,
|
|
40
|
-
hint: "[mcpbox] Detected sync intent → /mcpbox:sync",
|
|
46
|
+
hint: "[mcpbox] Detected sync intent → /mcpbox:sync in Claude, otherwise re-read state with daruma_list / daruma_plan_get.",
|
|
41
47
|
},
|
|
42
48
|
{
|
|
43
49
|
re: /\b(status|progress|what.?s\s+(open|next|left))\b|(?<![а-яёА-ЯЁ])(статус|прогресс|что\s+(открыто|осталось|дальше))(?![а-яёА-ЯЁ])/,
|
|
44
|
-
hint: "[mcpbox] Detected status query → /mcpbox:status",
|
|
50
|
+
hint: "[mcpbox] Detected status query → /mcpbox:status in Claude, otherwise daruma_healthz + mcpbox_runs_list.",
|
|
45
51
|
},
|
|
46
52
|
{
|
|
47
53
|
re: /\b(close|complete|mark\s+.*done)\b|(?<![а-яёА-ЯЁ])(закрой|закрыть|завершить|пометь\s+.*выполненной)(?![а-яёА-ЯЁ])/,
|
|
48
|
-
hint: "[mcpbox] Detected close intent → /mcpbox:close",
|
|
54
|
+
hint: "[mcpbox] Detected close intent → /mcpbox:close in Claude, otherwise daruma_complete (or daruma_set_status).",
|
|
49
55
|
},
|
|
50
56
|
];
|
|
51
57
|
|
|
@@ -93,25 +99,73 @@ function readStdin(timeoutMs = 3000) {
|
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
// Kimi's UserPromptSubmit payload carries the prompt text; the exact field
|
|
96
|
-
// name is not documented, so accept the common shapes.
|
|
102
|
+
// name is not documented, so accept the common shapes. Kimi sends it as an
|
|
103
|
+
// array of content blocks — `prompt: [{type: "text", text: "…"}]` — which the
|
|
104
|
+
// string-only lookup missed, so every routing hint stayed silent there.
|
|
97
105
|
export function promptFromHookPayload(payload) {
|
|
98
106
|
if (!payload || typeof payload !== "object") return "";
|
|
99
107
|
for (const key of ["prompt", "user_prompt", "userPrompt", "message", "text"]) {
|
|
100
|
-
|
|
108
|
+
const value = payload[key];
|
|
109
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
const text = value
|
|
112
|
+
.map((block) => (typeof block === "string" ? block : block?.text ?? ""))
|
|
113
|
+
.filter((part) => typeof part === "string" && part.trim())
|
|
114
|
+
.join("\n");
|
|
115
|
+
if (text.trim()) return text;
|
|
116
|
+
}
|
|
101
117
|
}
|
|
102
118
|
return "";
|
|
103
119
|
}
|
|
104
120
|
|
|
121
|
+
// Kimi never fires SessionStart (its hook block registers it, but the event
|
|
122
|
+
// does not arrive) and it reads AGENTS.md from the working directory ONLY —
|
|
123
|
+
// no walk up the tree, no user-level instruction file. A globally-installed
|
|
124
|
+
// policy therefore sits in ~/AGENTS.md where no real project sees it, and the
|
|
125
|
+
// agent answers "no such command" to `mcpbox mode`. UserPromptSubmit does
|
|
126
|
+
// fire, so for Kimi the policy rides in on the first prompt of a session.
|
|
127
|
+
// Claude registers this hook without --policy: it reads CLAUDE.md already.
|
|
128
|
+
async function policyForFirstPrompt(payload) {
|
|
129
|
+
if (!process.argv.includes("--policy")) return "";
|
|
130
|
+
// PLAIN: this path only ever serves non-Claude surfaces, which have no
|
|
131
|
+
// /mcpbox:* commands.
|
|
132
|
+
const { BLOCK_BODY_PLAIN, BEGIN } = await import("../lib/policy.mjs");
|
|
133
|
+
const cwd = typeof payload?.cwd === "string" && payload.cwd ? payload.cwd : process.cwd();
|
|
134
|
+
try {
|
|
135
|
+
// An AGENTS.md right here already carries the block — the agent is
|
|
136
|
+
// reading it, so a second copy would be pure noise.
|
|
137
|
+
if ((await readFile(join(cwd, "AGENTS.md"), "utf8")).includes(BEGIN)) return "";
|
|
138
|
+
} catch { /* no AGENTS.md here — the policy has to come from us */ }
|
|
139
|
+
|
|
140
|
+
const sessionId = typeof payload?.session_id === "string" ? payload.session_id : "";
|
|
141
|
+
if (!sessionId) return BLOCK_BODY_PLAIN; // no session to key on — better twice than never
|
|
142
|
+
// ponytail: one empty marker file per session, never swept. They are 0
|
|
143
|
+
// bytes; add a cleanup pass only if a long-lived install ever complains.
|
|
144
|
+
const marker = join(homedir(), ".agents", "mcpbox", "sessions", sessionId.replace(/[^\w.-]/g, "_"));
|
|
145
|
+
try {
|
|
146
|
+
await mkdir(dirname(marker), { recursive: true });
|
|
147
|
+
// wx fails if it exists → the policy already went out this session.
|
|
148
|
+
await writeFile(marker, "", { flag: "wx" });
|
|
149
|
+
} catch {
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
return BLOCK_BODY_PLAIN;
|
|
153
|
+
}
|
|
154
|
+
|
|
105
155
|
async function main() {
|
|
106
156
|
let prompt = process.env.CLAUDE_USER_PROMPT ?? "";
|
|
157
|
+
let payload = null;
|
|
107
158
|
if (!prompt) {
|
|
108
159
|
const raw = await readStdin();
|
|
109
160
|
if (raw.trim()) {
|
|
110
161
|
try {
|
|
111
|
-
|
|
162
|
+
payload = JSON.parse(raw);
|
|
163
|
+
prompt = promptFromHookPayload(payload);
|
|
112
164
|
} catch { /* not JSON — no prompt to route */ }
|
|
113
165
|
}
|
|
114
166
|
}
|
|
167
|
+
const policy = await policyForFirstPrompt(payload);
|
|
168
|
+
if (policy) process.stdout.write(policy + "\n");
|
|
115
169
|
const hint = promptSubmitHint(prompt, readMode());
|
|
116
170
|
if (hint) process.stdout.write(hint + "\n");
|
|
117
171
|
}
|
package/lib/codex.mjs
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
// Codex surface for the mcpbox harness — parity with the Claude CLAUDE.md
|
|
2
|
-
// plugin.
|
|
3
|
-
// 1. AGENTS.md policy block
|
|
2
|
+
// plugin. Four idempotent writes:
|
|
3
|
+
// 1. AGENTS.md policy block. Measured against Codex 0.146: AGENTS.md is
|
|
4
|
+
// read from the working directory, NOT from a parent — a global install
|
|
5
|
+
// lands it in ~/AGENTS.md where no project sees it, hence (3) and (4).
|
|
4
6
|
// 2. `~/.codex/config.toml` [mcp_servers.mcpbox] pointing at the single
|
|
5
7
|
// canonical HTTP endpoint. Codex's config is global-only, so the entry
|
|
6
8
|
// is fenced with comment markers and replaced in place — surrounding
|
|
7
9
|
// hand-written TOML is preserved.
|
|
10
|
+
// 3. `$CODEX_HOME/skills/mcpbox/SKILL.md` — the same policy, reachable from
|
|
11
|
+
// every working directory instead of just the install one.
|
|
12
|
+
// 4. `$CODEX_HOME/prompts/mcpbox-*.md` — Codex's slash commands. Generated
|
|
13
|
+
// from the plugin's commands/, which already use exactly this shape
|
|
14
|
+
// (frontmatter `description` + "the user invoked" body).
|
|
8
15
|
//
|
|
9
|
-
// The policy body is
|
|
10
|
-
// shared across CLAUDE.md / AGENTS.md / .cursor/rules
|
|
11
|
-
//
|
|
12
|
-
// non-issue, not per-surface forks to maintain.
|
|
16
|
+
// The policy body is BLOCK_BODY_PLAIN from lib/policy.mjs — one source of
|
|
17
|
+
// truth shared across CLAUDE.md / AGENTS.md / .cursor/rules, minus the
|
|
18
|
+
// Claude-only slash commands this surface cannot run.
|
|
13
19
|
|
|
20
|
+
import { promises as fs } from "node:fs";
|
|
14
21
|
import { homedir } from "node:os";
|
|
15
|
-
import { join, resolve } from "node:path";
|
|
22
|
+
import { dirname, join, resolve } from "node:path";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
16
24
|
import {
|
|
17
|
-
|
|
25
|
+
BLOCK_BODY_PLAIN,
|
|
18
26
|
MCP_URL,
|
|
19
27
|
installManagedBlock,
|
|
20
28
|
removeManagedBlock,
|
|
@@ -29,14 +37,26 @@ const TOML_BLOCK = `[mcp_servers.mcpbox]
|
|
|
29
37
|
url = "${MCP_URL}"
|
|
30
38
|
`;
|
|
31
39
|
|
|
40
|
+
// Codex data dir: explicit override (tests) > $CODEX_HOME > ~/.codex.
|
|
41
|
+
export function codexHomeDir(home) {
|
|
42
|
+
if (home) return resolve(home);
|
|
43
|
+
const env = process.env.CODEX_HOME?.trim();
|
|
44
|
+
if (env) return env;
|
|
45
|
+
return join(homedir(), ".codex");
|
|
46
|
+
}
|
|
47
|
+
|
|
32
48
|
function codexConfigPath(configPath) {
|
|
33
|
-
return configPath ? resolve(configPath) : join(
|
|
49
|
+
return configPath ? resolve(configPath) : join(codexHomeDir(), "config.toml");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function packageRoot() {
|
|
53
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
// AGENTS.md policy block in the project directory.
|
|
37
57
|
export function installCodexPolicy({ projectDir } = {}) {
|
|
38
58
|
const dir = projectDir ? resolve(projectDir) : process.cwd();
|
|
39
|
-
return installManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END, block:
|
|
59
|
+
return installManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END, block: BLOCK_BODY_PLAIN });
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
export function removeCodexPolicy({ projectDir } = {}) {
|
|
@@ -54,17 +74,96 @@ export function removeCodexMcp({ configPath } = {}) {
|
|
|
54
74
|
return removeManagedBlock({ target: codexConfigPath(configPath), begin: TOML_BEGIN, end: TOML_END });
|
|
55
75
|
}
|
|
56
76
|
|
|
57
|
-
//
|
|
58
|
-
|
|
77
|
+
// The policy as a user-level Codex skill, so it is reachable from any working
|
|
78
|
+
// directory — AGENTS.md alone only covers the one the installer ran in.
|
|
79
|
+
export async function installCodexSkill({ codexHome } = {}) {
|
|
80
|
+
const target = join(codexHomeDir(codexHome), "skills", "mcpbox", "SKILL.md");
|
|
81
|
+
const body = `---
|
|
82
|
+
name: mcpbox
|
|
83
|
+
description: MCPBox/daruma routing policy — read before creating tasks or plans, choosing between the daruma tracker and the maturity pipeline, or when the user mentions the tracker, backlog, plan, decomposition, or \`mcpbox mode\`.
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
${BLOCK_BODY_PLAIN}`;
|
|
87
|
+
let before = null;
|
|
88
|
+
try {
|
|
89
|
+
before = await fs.readFile(target, "utf8");
|
|
90
|
+
} catch { /* absent → install */ }
|
|
91
|
+
if (before === body) return { action: "unchanged", path: target };
|
|
92
|
+
await fs.mkdir(dirname(target), { recursive: true });
|
|
93
|
+
await fs.writeFile(target, body);
|
|
94
|
+
return { action: before === null ? "installed" : "updated", path: target };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function removeCodexSkill({ codexHome } = {}) {
|
|
98
|
+
const dir = join(codexHomeDir(codexHome), "skills", "mcpbox");
|
|
99
|
+
try {
|
|
100
|
+
await fs.access(dir);
|
|
101
|
+
} catch {
|
|
102
|
+
return { action: "missing", path: join(dir, "SKILL.md") };
|
|
103
|
+
}
|
|
104
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
105
|
+
return { action: "removed-block", path: join(dir, "SKILL.md") };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Codex slash commands live in `$CODEX_HOME/prompts/<name>.md` and are invoked
|
|
109
|
+
// as `/<name>`; the plugin's `commands/tasks.md` becomes `/mcpbox-tasks`.
|
|
110
|
+
// There is no `:` namespace here, so the body's `/mcpbox:tasks` is rewritten
|
|
111
|
+
// to the name the user can actually type.
|
|
112
|
+
export function codexPromptName(commandFile) {
|
|
113
|
+
return `mcpbox-${commandFile.replace(/\.md$/, "")}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function installCodexPrompts({ codexHome } = {}) {
|
|
117
|
+
const source = join(packageRoot(), "commands");
|
|
118
|
+
const targetDir = join(codexHomeDir(codexHome), "prompts");
|
|
119
|
+
const files = (await fs.readdir(source)).filter((f) => f.endsWith(".md")).sort();
|
|
120
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
121
|
+
let written = 0;
|
|
122
|
+
for (const file of files) {
|
|
123
|
+
const name = codexPromptName(file);
|
|
124
|
+
const body = (await fs.readFile(join(source, file), "utf8"))
|
|
125
|
+
.replace(/\/mcpbox:([a-z-]+)/g, "/mcpbox-$1");
|
|
126
|
+
const target = join(targetDir, `${name}.md`);
|
|
127
|
+
let before = null;
|
|
128
|
+
try {
|
|
129
|
+
before = await fs.readFile(target, "utf8");
|
|
130
|
+
} catch { /* absent */ }
|
|
131
|
+
if (before === body) continue;
|
|
132
|
+
await fs.writeFile(target, body);
|
|
133
|
+
written += 1;
|
|
134
|
+
}
|
|
135
|
+
return { action: written ? "installed" : "unchanged", path: targetDir, count: files.length };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function removeCodexPrompts({ codexHome } = {}) {
|
|
139
|
+
const targetDir = join(codexHomeDir(codexHome), "prompts");
|
|
140
|
+
let files = [];
|
|
141
|
+
try {
|
|
142
|
+
files = await fs.readdir(targetDir);
|
|
143
|
+
} catch {
|
|
144
|
+
return { action: "missing", path: targetDir };
|
|
145
|
+
}
|
|
146
|
+
// Only our own `mcpbox-*.md` — a hand-written prompt next to them survives.
|
|
147
|
+
const ours = files.filter((f) => f.startsWith("mcpbox-") && f.endsWith(".md"));
|
|
148
|
+
await Promise.all(ours.map((f) => fs.rm(join(targetDir, f), { force: true })));
|
|
149
|
+
return { action: ours.length ? "removed-block" : "missing", path: targetDir };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Every surface at once (what `mcpbox-claude codex-init` calls).
|
|
153
|
+
export async function installCodex({ projectDir, codexHome } = {}) {
|
|
59
154
|
const policy = await installCodexPolicy({ projectDir });
|
|
60
155
|
const mcp = await installCodexMcp();
|
|
61
|
-
|
|
156
|
+
const skill = await installCodexSkill({ codexHome });
|
|
157
|
+
const prompts = await installCodexPrompts({ codexHome });
|
|
158
|
+
return { policy, mcp, skill, prompts };
|
|
62
159
|
}
|
|
63
160
|
|
|
64
|
-
export async function removeCodex({ projectDir } = {}) {
|
|
161
|
+
export async function removeCodex({ projectDir, codexHome } = {}) {
|
|
65
162
|
const policy = await removeCodexPolicy({ projectDir });
|
|
66
163
|
const mcp = await removeCodexMcp();
|
|
67
|
-
|
|
164
|
+
const skill = await removeCodexSkill({ codexHome });
|
|
165
|
+
const prompts = await removeCodexPrompts({ codexHome });
|
|
166
|
+
return { policy, mcp, skill, prompts };
|
|
68
167
|
}
|
|
69
168
|
|
|
70
169
|
export { BEGIN, END, TOML_BEGIN, TOML_END, codexConfigPath };
|
package/lib/cursor.mjs
CHANGED
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
// 2. `.cursor/mcp.json` — upsert the `mcpbox` HTTP server entry, leaving any
|
|
6
6
|
// other servers the user configured untouched.
|
|
7
7
|
//
|
|
8
|
-
// Rule body is
|
|
8
|
+
// Rule body is BLOCK_BODY_PLAIN from lib/policy.mjs — the shared source of
|
|
9
|
+
// truth, minus the Claude-only slash commands this surface cannot run.
|
|
9
10
|
|
|
10
11
|
import { promises as fs } from "node:fs";
|
|
11
12
|
import { dirname, join, resolve } from "node:path";
|
|
12
13
|
import { fileURLToPath } from "node:url";
|
|
13
|
-
import {
|
|
14
|
+
import { BLOCK_BODY_PLAIN, MCP_URL } from "./policy.mjs";
|
|
14
15
|
|
|
15
16
|
const RULE_FRONTMATTER = `---
|
|
16
17
|
description: Workspace policy — mcpbox is the default tracker AND maturity pipeline (torii→…→fujin→daruma). Triggered by mentions of "трекер", "tracker", "task tracker", "backlog", "pipeline", "план", "задача". Overrides ad-hoc trackers and OMC plan files.
|
|
@@ -21,7 +22,7 @@ alwaysApply: true
|
|
|
21
22
|
`;
|
|
22
23
|
|
|
23
24
|
function ruleContent() {
|
|
24
|
-
return RULE_FRONTMATTER +
|
|
25
|
+
return RULE_FRONTMATTER + BLOCK_BODY_PLAIN;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function rulePath(projectDir) {
|
package/lib/kimi.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// Kimi Code CLI surface for the mcpbox harness — parity with the Claude
|
|
2
2
|
// CLAUDE.md plugin and the Codex AGENTS.md surface. Three idempotent writes:
|
|
3
|
-
// 1. AGENTS.md policy block
|
|
4
|
-
//
|
|
3
|
+
// 1. AGENTS.md policy block — same managed block as the Codex surface.
|
|
4
|
+
// Kimi reads AGENTS.md from the WORKING DIRECTORY only: no walk up the
|
|
5
|
+
// tree, no user-level instruction file. A global install therefore lands
|
|
6
|
+
// it in ~/AGENTS.md, which no real project ever sees — hence the
|
|
7
|
+
// UserPromptSubmit --policy injection below, which covers every cwd.
|
|
5
8
|
// 2. `$KIMI_CODE_HOME/mcp.json` (default `~/.kimi-code/mcp.json`) — upsert
|
|
6
9
|
// the `mcpbox` HTTP server entry, preserving other servers. A bare `url`
|
|
7
10
|
// entry means HTTP transport in Kimi. User-level on purpose: one server
|
|
@@ -13,21 +16,24 @@
|
|
|
13
16
|
// markers and replaced in place; surrounding hand-written TOML is
|
|
14
17
|
// preserved.
|
|
15
18
|
//
|
|
16
|
-
// The policy body is
|
|
17
|
-
// shared across CLAUDE.md / AGENTS.md / .cursor/rules
|
|
19
|
+
// The policy body is BLOCK_BODY_PLAIN from lib/policy.mjs — one source of
|
|
20
|
+
// truth shared across CLAUDE.md / AGENTS.md / .cursor/rules, minus the
|
|
21
|
+
// Claude-only slash commands this surface cannot run.
|
|
18
22
|
//
|
|
19
23
|
// 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
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// config never
|
|
24
|
+
// stdin carries the event JSON; exit 0 + stdout appends text to the context.
|
|
25
|
+
// Measured against Kimi 2026-08: UserPromptSubmit fires and its payload is
|
|
26
|
+
// {hook_event_name, session_id, cwd, prompt: [{type,text}]}; SessionStart is
|
|
27
|
+
// accepted in config.toml but never actually fires. The hook scripts are the
|
|
28
|
+
// same ones the Claude plugin ships (hooks/), copied into the Kimi home so
|
|
29
|
+
// the config never references an ephemeral npx cache path.
|
|
24
30
|
|
|
25
31
|
import { promises as fs } from "node:fs";
|
|
26
32
|
import { homedir } from "node:os";
|
|
27
33
|
import { dirname, join, resolve } from "node:path";
|
|
28
34
|
import { fileURLToPath } from "node:url";
|
|
29
35
|
import {
|
|
30
|
-
|
|
36
|
+
BLOCK_BODY_PLAIN,
|
|
31
37
|
MCP_URL,
|
|
32
38
|
installManagedBlock,
|
|
33
39
|
removeManagedBlock,
|
|
@@ -47,6 +53,8 @@ const HOOK_ASSETS = [
|
|
|
47
53
|
["hooks", "stop.mjs"],
|
|
48
54
|
["lib", "mcp-client.mjs"],
|
|
49
55
|
["lib", "mode.mjs"],
|
|
56
|
+
// user-prompt-submit.mjs --policy reads the policy body from here.
|
|
57
|
+
["lib", "policy.mjs"],
|
|
50
58
|
];
|
|
51
59
|
|
|
52
60
|
const MCP_ENTRY = { url: MCP_URL };
|
|
@@ -67,7 +75,7 @@ export function kimiHomeDir(home) {
|
|
|
67
75
|
|
|
68
76
|
export function installKimiPolicy({ projectDir } = {}) {
|
|
69
77
|
const dir = projectDir ? resolve(projectDir) : process.cwd();
|
|
70
|
-
return installManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END, block:
|
|
78
|
+
return installManagedBlock({ target: join(dir, "AGENTS.md"), begin: BEGIN, end: END, block: BLOCK_BODY_PLAIN });
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
export function removeKimiPolicy({ projectDir } = {}) {
|
|
@@ -124,7 +132,8 @@ export async function removeKimiMcp({ mcpPath, kimiHome } = {}) {
|
|
|
124
132
|
// TOML literal strings (single quotes) keep absolute paths with spaces or
|
|
125
133
|
// backslashes intact without escaping.
|
|
126
134
|
function hooksTomlBlock(assetsRoot) {
|
|
127
|
-
const command = (file
|
|
135
|
+
const command = (file, args = "") =>
|
|
136
|
+
`command = 'node "${join(assetsRoot, "hooks", file)}"${args}'`;
|
|
128
137
|
return [
|
|
129
138
|
"[[hooks]]",
|
|
130
139
|
'event = "SessionStart"',
|
|
@@ -133,7 +142,10 @@ function hooksTomlBlock(assetsRoot) {
|
|
|
133
142
|
"",
|
|
134
143
|
"[[hooks]]",
|
|
135
144
|
'event = "UserPromptSubmit"',
|
|
136
|
-
|
|
145
|
+
// --policy: Kimi reads AGENTS.md from the working directory only and
|
|
146
|
+
// never fires SessionStart, so the managed policy rides in on the first
|
|
147
|
+
// prompt of each session instead.
|
|
148
|
+
command("user-prompt-submit.mjs", " --policy"),
|
|
137
149
|
"",
|
|
138
150
|
"[[hooks]]",
|
|
139
151
|
'event = "Stop"',
|
package/lib/policy.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { join, resolve } from "node:path";
|
|
|
24
24
|
const BEGIN = "<!-- mcpbox:policy:begin -->";
|
|
25
25
|
const END = "<!-- mcpbox:policy:end -->";
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const BLOCK_HEAD = `# MCPBox — default agent stack (project policy)
|
|
28
28
|
|
|
29
29
|
This project uses the **mcpbox** MCP server (\`https://mcpbox.ru/v1/mcp\`) as the
|
|
30
30
|
single source of truth for tasks, plans, AI decomposition, **and** the full
|
|
@@ -193,14 +193,17 @@ daruma execution задача/план (терминальный слой
|
|
|
193
193
|
|
|
194
194
|
### Pipeline tools
|
|
195
195
|
|
|
196
|
-
- \`mcpbox_pipeline_run\` — автопилот:
|
|
197
|
-
|
|
196
|
+
- \`mcpbox_pipeline_run\` — автопилот: сразу возвращает \`run_id\`, а 5 хопов
|
|
197
|
+
torii→fujin идут в фоне; результат получай через \`mcpbox_trace_get\`. Для
|
|
198
|
+
handoff бери \`action_packet\` из \`artifacts.fujin.action_packet\`, а
|
|
199
|
+
\`policy_snapshot\` из \`artifacts.policy_snapshot\`.
|
|
198
200
|
- \`mcpbox_pipeline_advance\` — **один хоп** за вызов \`{run_id, layer}\`; вход
|
|
199
201
|
берётся из выхода предыдущего слоя того же прогона. Пропуск слоя / \`torii\`
|
|
200
202
|
как цель → \`422\`.
|
|
201
203
|
- \`mcpbox_pipeline_handoff\` — **единственный** путь материализации
|
|
202
|
-
daruma-задачи из зрелого Action Packet \`{run_id?, action_packet
|
|
203
|
-
project_slug?}
|
|
204
|
+
daruma-задачи из зрелого Action Packet \`{run_id?, action_packet,
|
|
205
|
+
policy_snapshot?, project_slug?}\`; поля пакета и политики берутся из
|
|
206
|
+
\`mcpbox_trace_get\` по путям выше.
|
|
204
207
|
- \`mcpbox_trace_get\` — трассировка прогона по \`run_id\`: статус, lineage,
|
|
205
208
|
per-hop тайминги/ошибки, артефакты слоёв.
|
|
206
209
|
- \`mcpbox_runs_list\` — список прогонов воркспейса (фильтр \`status\`, \`limit\`).
|
|
@@ -230,6 +233,13 @@ daruma execution задача/план (терминальный слой
|
|
|
230
233
|
материализуй задачу \`mcpbox_pipeline_handoff\`. Не создавай задачу напрямую
|
|
231
234
|
в обход pipeline, если запрос — сырьё.
|
|
232
235
|
|
|
236
|
+
`;
|
|
237
|
+
|
|
238
|
+
// The `/mcpbox:*` commands ship with the Claude Code plugin and exist nowhere
|
|
239
|
+
// else. Advertising them to Codex/Cursor/Kimi produced exactly the confusion
|
|
240
|
+
// you would expect — "no such command" — so those surfaces get the plain-text
|
|
241
|
+
// equivalents instead. Same capabilities, reachable without the plugin.
|
|
242
|
+
const SLASH_COMMANDS = `
|
|
233
243
|
### Useful slash commands
|
|
234
244
|
|
|
235
245
|
- \`/mcpbox:tasks\` — open tasks as a compact table.
|
|
@@ -242,6 +252,27 @@ daruma execution задача/план (терминальный слой
|
|
|
242
252
|
- \`/mcpbox:trace <run_id>\` — trace a run's lineage and per-hop status.
|
|
243
253
|
`;
|
|
244
254
|
|
|
255
|
+
const PLAIN_COMMANDS = `
|
|
256
|
+
### Useful requests
|
|
257
|
+
|
|
258
|
+
This agent has no \`/mcpbox:*\` slash commands — those belong to the Claude
|
|
259
|
+
Code plugin. Ask in plain language; each maps to a tool you already have:
|
|
260
|
+
|
|
261
|
+
- "open tasks" — \`daruma_list status=active\` with a scope.
|
|
262
|
+
- "active plan" — \`daruma_plan_get\` (or \`daruma_plan_progress\`).
|
|
263
|
+
- "what's next" — \`daruma_plan_drain_next\`.
|
|
264
|
+
- "mcpbox status" — \`daruma_healthz\` plus \`mcpbox_runs_list\`.
|
|
265
|
+
- \`mcpbox mode [off|lite|full]\` — run
|
|
266
|
+
\`npx -y @mcpbox/mcpbox-claude@latest mode [value]\` and report the one-line
|
|
267
|
+
result (see Pipeline mode above).
|
|
268
|
+
- "open a pipeline run for <idea>" — \`mcpbox_pipeline_run\`.
|
|
269
|
+
- "trace <run_id>" — \`mcpbox_trace_get\`.
|
|
270
|
+
`;
|
|
271
|
+
|
|
272
|
+
// Claude reads the plugin's commands; every other surface gets plain text.
|
|
273
|
+
const BLOCK_BODY = BLOCK_HEAD + SLASH_COMMANDS;
|
|
274
|
+
export const BLOCK_BODY_PLAIN = BLOCK_HEAD + PLAIN_COMMANDS;
|
|
275
|
+
|
|
245
276
|
// Idempotent write of a delimited managed block to `target`. Surrounding
|
|
246
277
|
// hand-written content is preserved. Shared by the CLAUDE.md, AGENTS.md
|
|
247
278
|
// (Codex), and .cursor/rules (Cursor) policy surfaces — see lib/codex.mjs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"commands/",
|
|
16
16
|
"hooks/",
|
|
17
17
|
".claude-plugin/",
|
|
18
|
+
".codex-plugin/",
|
|
19
|
+
".agents/",
|
|
20
|
+
".mcp.json",
|
|
18
21
|
"README.md"
|
|
19
22
|
],
|
|
20
23
|
"engines": {
|