@mcpbox/mcpbox-claude 0.1.3 → 0.1.4

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.
@@ -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} 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.0",
4
+ "version": "0.1.4",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
package/README.md CHANGED
@@ -16,9 +16,13 @@ just the policy.
16
16
  |--------|----------------------------------------|-------------------------------------|-------|
17
17
  | Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
18
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` | — |
19
+ | Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` | `mcpbox` entry in `.cursor/mcp.json` | — |
20
20
  | Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
21
21
 
22
+ All four agents accept `mcpbox mode [off|lite|full]` through the managed
23
+ policy. Claude also exposes `/mcpbox:mode`, Cursor exposes `/mcpbox-mode`, and
24
+ the shared value lives in `~/.agents/mcpbox/mode`.
25
+
22
26
  Kimi specifics:
23
27
 
24
28
  - MCP and hooks are **user-level** (Kimi reads hooks only from
@@ -42,6 +46,7 @@ mcpbox-claude kimi-init [--dir DIR] AGENTS.md policy + ~/.kimi-code/mcp.json
42
46
  + ~/.kimi-code/config.toml [[hooks]].
43
47
  mcpbox-claude kimi-uninit [--dir DIR]
44
48
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
49
+ mcpbox-claude mode [off|lite|full] Show or set the shared pipeline mode.
45
50
  ```
46
51
 
47
52
  All writes are idempotent and preserve surrounding hand-written content.
@@ -6,6 +6,7 @@
6
6
  // (daruma tracker + full pipeline). Idempotent.
7
7
  // mcpbox-claude uninit [--dir DIR] Remove the managed policy block.
8
8
  // mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
9
+ // mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (raw-idea routing).
9
10
  // mcpbox-claude --version | --help
10
11
  //
11
12
  // ponytail: no orchestrator (start/team-from-plan) or self-update here — the
@@ -19,8 +20,14 @@ import { dirname, join, resolve } from "node:path";
19
20
  import { spawnSync } from "node:child_process";
20
21
  import { installPolicy, removePolicy, BEGIN } from "../lib/policy.mjs";
21
22
  import { installCodex, removeCodex, installCodexPolicy } from "../lib/codex.mjs";
22
- import { installCursor, removeCursor, installCursorRule } from "../lib/cursor.mjs";
23
+ import {
24
+ installCursor,
25
+ removeCursor,
26
+ installCursorRule,
27
+ installCursorModeCommand,
28
+ } from "../lib/cursor.mjs";
23
29
  import { installKimi, removeKimi } from "../lib/kimi.mjs";
30
+ import { readMode, writeMode, MODES } from "../lib/mode.mjs";
24
31
 
25
32
  const __dirname = dirname(fileURLToPath(import.meta.url));
26
33
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
@@ -42,6 +49,7 @@ Usage:
42
49
  Idempotent.
43
50
  mcpbox-claude kimi-uninit [--dir DIR]
44
51
  mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
52
+ mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (how raw ideas route).
45
53
  mcpbox-claude --version | -v
46
54
  mcpbox-claude --help | -h
47
55
  `;
@@ -103,16 +111,18 @@ async function cmdCodexUninit(rest) {
103
111
 
104
112
  async function cmdCursorInit(rest) {
105
113
  const { projectDir } = parseDirFlag(rest);
106
- const { rule, mcp } = await installCursor({ projectDir });
114
+ const { rule, mcp, mode } = await installCursor({ projectDir });
107
115
  report(rule);
108
116
  report(mcp);
117
+ report(mode);
109
118
  }
110
119
 
111
120
  async function cmdCursorUninit(rest) {
112
121
  const { projectDir } = parseDirFlag(rest);
113
- const { rule, mcp } = await removeCursor({ projectDir });
122
+ const { rule, mcp, mode } = await removeCursor({ projectDir });
114
123
  report(rule);
115
124
  report(mcp);
125
+ report(mode);
116
126
  }
117
127
 
118
128
  async function cmdKimiInit(rest) {
@@ -141,6 +151,7 @@ async function cmdCodexPolicy(rest) {
141
151
  async function cmdCursorPolicy(rest) {
142
152
  const { projectDir } = parseDirFlag(rest);
143
153
  report(await installCursorRule({ projectDir }));
154
+ report(await installCursorModeCommand({ projectDir }));
144
155
  }
145
156
 
146
157
  async function policyPresent(projectDir) {
@@ -160,6 +171,16 @@ function mcpServerPresent() {
160
171
  return /(^|\n)\s*mcpbox\b/.test(r.stdout);
161
172
  }
162
173
 
174
+ async function cmdMode(rest) {
175
+ const [arg] = rest;
176
+ if (!arg || arg === "--show") {
177
+ process.stdout.write(`mcpbox pipeline mode: ${readMode()} (${MODES.join(" | ")})\n`);
178
+ return;
179
+ }
180
+ const m = await writeMode(arg); // throws on invalid → caught by main().catch
181
+ process.stdout.write(`✓ mcpbox pipeline mode: ${m}\n`);
182
+ }
183
+
163
184
  async function cmdDoctor(rest) {
164
185
  const json = rest.includes("--json");
165
186
  const flags = rest.filter((a) => a !== "--json");
@@ -217,6 +238,8 @@ async function main(argv) {
217
238
  return cmdCursorPolicy(rest);
218
239
  case "doctor":
219
240
  return cmdDoctor(rest);
241
+ case "mode":
242
+ return cmdMode(rest);
220
243
  default:
221
244
  process.stderr.write(`Unknown command: ${cmd}\n\n${HELP}`);
222
245
  process.exit(2);
@@ -0,0 +1,26 @@
1
+ ---
2
+ description: Set how strictly raw ideas route through the mcpbox maturity pipeline (off | lite | full).
3
+ ---
4
+
5
+ The user invoked `/mcpbox:mode` with `$ARGUMENTS` = `off` | `lite` | `full` (empty → show current).
6
+
7
+ ## What each level does
8
+
9
+ - **off** — no pipeline nudging. Treat every request as direct daruma task tracking.
10
+ - **lite** (default) — nudge toward the pipeline only when the input explicitly mentions it
11
+ (pipeline / maturity / handoff / конвейер …).
12
+ - **full** — assess every substantive request for **rawness**. A raw idea, hypothesis, or
13
+ undecided direction matures through the pipeline (`mcpbox_pipeline_run` → …fujin → handoff)
14
+ before any daruma task; a concrete, bounded task goes straight to daruma.
15
+
16
+ The level persists across sessions (stored in `~/.agents/mcpbox/mode`) and is read by the
17
+ UserPromptSubmit hook, which injects the matching reminder on each prompt.
18
+
19
+ ## Steps
20
+
21
+ 1. Run:
22
+ - Claude plugin: `node "${CLAUDE_PLUGIN_ROOT}/bin/mcpbox-claude.mjs" mode $ARGUMENTS`
23
+ - Other agents: `npx -y @mcpbox/mcpbox-claude@latest mode $ARGUMENTS`
24
+ - empty `$ARGUMENTS` → prints the current mode.
25
+ - invalid value → the CLI errors with the allowed set (`off | lite | full`); relay it verbatim.
26
+ 2. Report the resulting mode in one line.
@@ -12,9 +12,11 @@
12
12
  // Claude Code — this also covers Claude setups without the env var).
13
13
 
14
14
  import { pathToFileURL } from "node:url";
15
+ import { readMode } from "../lib/mode.mjs";
15
16
 
16
17
  // Intent patterns. Order matters — first match wins. ASCII keywords use \b;
17
18
  // Cyrillic uses whitespace/edge guards since \b is ASCII-only.
19
+ // PATTERNS[0] is the pipeline pattern — mode "off" drops it (see promptSubmitHint).
18
20
  const PATTERNS = [
19
21
  {
20
22
  re: /\b(pipeline|maturity|handoff|action\s*packet)\b|(?<![а-яёА-ЯЁ])(пайплайн|конвейер|зрелость|хендофф)(?![а-яёА-ЯЁ])/,
@@ -47,14 +49,25 @@ const PATTERNS = [
47
49
  },
48
50
  ];
49
51
 
50
- export function promptSubmitHint(promptText = "") {
52
+ // full mode: remind the agent to judge rawness itself — a regex can't. Only
53
+ // fires on substantive prompts that didn't already match an explicit intent.
54
+ const FULL_ASSESS_HINT =
55
+ "[mcpbox:full] Assess this request for rawness before acting: a raw idea / hypothesis / undecided direction matures through the pipeline (mcpbox_pipeline_run → …fujin → handoff) before any daruma task; a concrete, bounded task goes straight to daruma.";
56
+
57
+ // ponytail: length heuristic for "substantive" — cheap and good enough to skip
58
+ // "ok"/"yes"/"go". Swap for a token/keyword check only if it nags in practice.
59
+ const SUBSTANTIVE_MIN = 40;
60
+
61
+ export function promptSubmitHint(promptText = "", mode = "lite") {
51
62
  // Strip fenced code blocks so a keyword pasted inside ``` … ``` doesn't
52
63
  // trigger a routing hint (OMC-style false-positive guard, kept minimal —
53
64
  // these hints are low-stakes suggestions, not mode activation).
54
65
  const prompt = promptText.replace(/```[\s\S]*?```/g, " ").toLowerCase().trim();
55
- for (const { re, hint } of PATTERNS) {
66
+ const patterns = mode === "off" ? PATTERNS.slice(1) : PATTERNS;
67
+ for (const { re, hint } of patterns) {
56
68
  if (re.test(prompt)) return hint;
57
69
  }
70
+ if (mode === "full" && prompt.length >= SUBSTANTIVE_MIN) return FULL_ASSESS_HINT;
58
71
  return "";
59
72
  }
60
73
 
@@ -99,7 +112,7 @@ async function main() {
99
112
  } catch { /* not JSON — no prompt to route */ }
100
113
  }
101
114
  }
102
- const hint = promptSubmitHint(prompt);
115
+ const hint = promptSubmitHint(prompt, readMode());
103
116
  if (hint) process.stdout.write(hint + "\n");
104
117
  }
105
118
 
package/lib/cursor.mjs CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { promises as fs } from "node:fs";
11
11
  import { dirname, join, resolve } from "node:path";
12
+ import { fileURLToPath } from "node:url";
12
13
  import { BLOCK_BODY, MCP_URL } from "./policy.mjs";
13
14
 
14
15
  const RULE_FRONTMATTER = `---
@@ -34,6 +35,38 @@ function mcpPath(projectDir) {
34
35
  }
35
36
 
36
37
  const MCP_ENTRY = { type: "http", url: MCP_URL };
38
+ const MODE_COMMAND_SOURCE = join(dirname(fileURLToPath(import.meta.url)), "..", "commands", "mode.md");
39
+
40
+ function modeCommandPath(projectDir) {
41
+ const dir = projectDir ? resolve(projectDir) : process.cwd();
42
+ return join(dir, ".cursor", "commands", "mcpbox-mode.md");
43
+ }
44
+
45
+ export async function installCursorModeCommand({ projectDir } = {}) {
46
+ const target = modeCommandPath(projectDir);
47
+ const content = await fs.readFile(MODE_COMMAND_SOURCE, "utf8");
48
+ await fs.mkdir(dirname(target), { recursive: true });
49
+ let existing = null;
50
+ try {
51
+ existing = await fs.readFile(target, "utf8");
52
+ } catch (err) {
53
+ if (err.code !== "ENOENT") throw err;
54
+ }
55
+ if (existing === content) return { action: "unchanged", path: target };
56
+ await fs.writeFile(target, content);
57
+ return { action: existing === null ? "installed" : "updated", path: target };
58
+ }
59
+
60
+ export async function removeCursorModeCommand({ projectDir } = {}) {
61
+ const target = modeCommandPath(projectDir);
62
+ try {
63
+ await fs.unlink(target);
64
+ return { action: "removed-file", path: target };
65
+ } catch (err) {
66
+ if (err.code === "ENOENT") return { action: "missing", path: target };
67
+ throw err;
68
+ }
69
+ }
37
70
 
38
71
  // `.cursor/rules/mcpbox-policy.mdc` — whole-file managed rule.
39
72
  export async function installCursorRule({ projectDir } = {}) {
@@ -109,13 +142,15 @@ export async function removeCursorMcp({ projectDir } = {}) {
109
142
  export async function installCursor({ projectDir } = {}) {
110
143
  const rule = await installCursorRule({ projectDir });
111
144
  const mcp = await installCursorMcp({ projectDir });
112
- return { rule, mcp };
145
+ const mode = await installCursorModeCommand({ projectDir });
146
+ return { rule, mcp, mode };
113
147
  }
114
148
 
115
149
  export async function removeCursor({ projectDir } = {}) {
116
150
  const rule = await removeCursorRule({ projectDir });
117
151
  const mcp = await removeCursorMcp({ projectDir });
118
- return { rule, mcp };
152
+ const mode = await removeCursorModeCommand({ projectDir });
153
+ return { rule, mcp, mode };
119
154
  }
120
155
 
121
- export { rulePath, mcpPath };
156
+ export { rulePath, mcpPath, modeCommandPath };
package/lib/kimi.mjs CHANGED
@@ -46,6 +46,7 @@ const HOOK_ASSETS = [
46
46
  ["hooks", "user-prompt-submit.mjs"],
47
47
  ["hooks", "stop.mjs"],
48
48
  ["lib", "mcp-client.mjs"],
49
+ ["lib", "mode.mjs"],
49
50
  ];
50
51
 
51
52
  const MCP_ENTRY = { url: MCP_URL };
package/lib/mode.mjs ADDED
@@ -0,0 +1,44 @@
1
+ // Pipeline strictness mode: how aggressively raw ideas get routed through the
2
+ // mcpbox maturity pipeline (torii→…→fujin→handoff) vs. tracked directly in daruma.
3
+ //
4
+ // off — no pipeline nudging; every request is treated as direct daruma work.
5
+ // lite — nudge toward the pipeline only when the input explicitly mentions it. (default)
6
+ // full — remind the agent to assess every substantive request for "rawness":
7
+ // raw ideas mature through the pipeline; concrete bounded tasks go to daruma.
8
+ //
9
+ // The `mcpbox-claude mode` CLI writes it; hooks and the shared agent policy
10
+ // read it. The old Claude-only file remains a read fallback for upgrades.
11
+
12
+ import { promises as fs, readFileSync } from "node:fs";
13
+ import { homedir } from "node:os";
14
+ import { dirname, join } from "node:path";
15
+
16
+ export const MODES = ["off", "lite", "full"];
17
+ export const DEFAULT_MODE = "lite";
18
+
19
+ // ponytail: one shared file for every agent. Key it on cwd only if per-repo
20
+ // strictness is ever needed.
21
+ export const modeFile = (home = homedir()) => join(home, ".agents", "mcpbox", "mode");
22
+ const legacyModeFile = (home = homedir()) => join(home, ".claude", "mcpbox-mode");
23
+
24
+ export function readMode(home = homedir()) {
25
+ for (const file of [modeFile(home), legacyModeFile(home)]) {
26
+ try {
27
+ const v = readFileSync(file, "utf8").trim();
28
+ if (MODES.includes(v)) return v;
29
+ } catch {
30
+ // missing / unreadable → try the legacy file, then default
31
+ }
32
+ }
33
+ return DEFAULT_MODE;
34
+ }
35
+
36
+ export async function writeMode(mode, home = homedir()) {
37
+ if (!MODES.includes(mode)) {
38
+ throw new Error(`invalid mode "${mode}" — want one of: ${MODES.join(" | ")}`);
39
+ }
40
+ const file = modeFile(home);
41
+ await fs.mkdir(dirname(file), { recursive: true });
42
+ await fs.writeFile(file, mode + "\n");
43
+ return mode;
44
+ }
package/lib/policy.mjs CHANGED
@@ -158,6 +158,23 @@ rule is enforced by the **server**: each layer takes only the persisted output
158
158
  of the previous layer (except \`torii\`), and skipping a layer or targeting
159
159
  \`torii\` returns \`422\`. The agent cannot invent a layer's input.
160
160
 
161
+ ### Pipeline mode
162
+
163
+ The shared mode is stored in \`~/.agents/mcpbox/mode\` (missing means
164
+ \`lite\`) and applies to Claude, Codex, Cursor, and Kimi:
165
+
166
+ - \`off\` — never nudge toward the pipeline.
167
+ - \`lite\` — use it only when the request explicitly asks for pipeline,
168
+ maturity, handoff, or «конвейер».
169
+ - \`full\` — assess every substantive request for rawness; raw ideas go
170
+ through the pipeline, concrete bounded work goes directly to daruma.
171
+
172
+ Before routing a substantive request, read and honor that file. If the user
173
+ enters \`mcpbox mode\` or \`mcpbox mode off|lite|full\`, run
174
+ \`npx -y @mcpbox/mcpbox-claude@latest mode [value]\` and report its one-line
175
+ result. Do not confuse this pipeline mode with the daruma cloud/self-host
176
+ profile.
177
+
161
178
  ### Maturity route
162
179
 
163
180
  \`\`\`
@@ -220,6 +237,7 @@ daruma execution задача/план (терминальный слой
220
237
  - \`/mcpbox:next\` — claim the next ready task.
221
238
  - \`/mcpbox:mine\` — tasks claimed by this session.
222
239
  - \`/mcpbox:status\` — server + pipeline health (\`daruma_healthz\`, recent runs).
240
+ - \`mcpbox mode [off|lite|full]\` — show or set the shared pipeline mode.
223
241
  - \`/mcpbox:pipeline-run "<idea>"\` — open a maturity run from raw input.
224
242
  - \`/mcpbox:trace <run_id>\` — trace a run's lineage and per-hop status.
225
243
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpbox/mcpbox-claude",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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": {