@mcpbox/mcpbox-claude 0.1.25 → 0.1.27

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 for Claude Code: the mcpbox task tracker and idea pipeline over one MCP server. Ships /mcpbox:* commands, session hooks, and a managed CLAUDE.md policy that makes mcpbox the default tracker.",
4
- "version": "0.1.25",
4
+ "version": "0.1.27",
5
5
  "author": {
6
6
  "name": "tupical"
7
7
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcpbox",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "MCPBox for Codex: the mcpbox task tracker and idea pipeline behind one MCP server.",
5
5
  "author": {
6
6
  "name": "tupical"
package/README.md CHANGED
@@ -46,9 +46,17 @@ codex plugin add mcpbox --marketplace mcpbox
46
46
  codex plugin marketplace upgrade mcpbox # later, to update
47
47
  ```
48
48
 
49
- Codex exposes the plugin's command workflows as skills. `codex-init` installs
50
- the managed policy, MCP server, and routing skill; it does not write the unused
51
- `~/.codex/prompts` surface. `codex-uninit` still removes legacy `mcpbox-*.md`
49
+ Codex exposes the plugin's command workflows as skills, and the plugin ships
50
+ the routing policy itself as the `mcpbox` skill. `codex-init` is for Codex
51
+ without the plugin: it installs the managed policy, MCP server, and a
52
+ user-level copy of that skill (`$CODEX_HOME/skills/mcpbox`); it does not write
53
+ the unused `~/.codex/prompts` surface. With the plugin, that copy is a
54
+ duplicate: a Codex plugin session (and `mcpbox setup`, via
55
+ `codex-skill-retire`) removes it when it is a copy mcpbox wrote, after saving
56
+ a copy that differs from the current text to `$CODEX_HOME/mcpbox-skill-backup-*`.
57
+ A skill without the mcpbox header, with extra files, from a newer release,
58
+ inside Git, or beneath a linked directory is left alone. Cleanup also skips
59
+ paths when Git ownership cannot be checked. `codex-uninit` still removes legacy `mcpbox-*.md`
52
60
  prompt files left by older installs.
53
61
 
54
62
  Cursor and Kimi have no plugin manager; they are file installs, so re-run their
@@ -62,12 +70,40 @@ npx -y @mcpbox/mcpbox-claude@latest opencode-init
62
70
 
63
71
  On Claude and Codex a plugin update also reaches the policy you already
64
72
  installed: at session start the hook rewrites every existing `mcpbox:policy`
65
- block from the working directory up (`CLAUDE.md` on Claude, `AGENTS.md` plus
66
- the `mcpbox` skill on Codex) to the running version, and says so in the
73
+ block from the working directory up (`CLAUDE.md` on Claude, `AGENTS.md` on
74
+ Codex; Claude also refreshes a user-level Codex `mcpbox` skill) to the running version, and says so in the
67
75
  session context. It never adds a block and never touches text outside the
68
76
  markers; `doctor --json` reports `policy_stale` until it has run. Set
69
77
  `MCPBOX_NO_POLICY_SYNC=1` to keep installed blocks as they are.
70
78
 
79
+ The block text comes from the server, not only from the package: the hook asks
80
+ `GET /v1/policy/claude` and `/v1/policy/plain` (the paired server from
81
+ `login`, else `https://mcpbox.ru`) with `If-None-Match`, so a rule changed on
82
+ the server reaches installed blocks at the next session start; `304` downloads
83
+ nothing. The copy and its ETag live in `~/.agents/mcpbox/policy-<surface>.json`.
84
+ Offline the last copy stays (failures back off for an hour); the text baked into
85
+ the package is written only when no server copy was ever fetched. `doctor`
86
+ shows the ETag and when the copy was fetched and last checked
87
+ (`policy_server` in `--json`). `MCPBOX_NO_POLICY_FETCH=1` keeps the baked text.
88
+ The served bodies are `policy/{claude,plain}.md`, generated from
89
+ `lib/policy.mjs` by `node scripts/generate-policy-snapshot.mjs` — rerun it
90
+ after editing the block text (a test fails on drift).
91
+
92
+ Three carriers, one text, the server wins: every place this package writes the
93
+ policy gets the same server copy. `plain` goes into `AGENTS.md`, the Codex
94
+ user skill `$CODEX_HOME/skills/mcpbox/SKILL.md` and the Cursor rule
95
+ `.cursor/rules/mcpbox-policy.mdc`; the session start refreshes all of them
96
+ (rules and blocks in the working directory and every ancestor up to `/`,
97
+ including `~`; the skill when one is installed), and `doctor` reports a
98
+ stale one (`codex_skill_stale_paths`, `cursor_rule_stale_paths`). The
99
+ `*-init` / `*-policy` / `codex-skill` commands write the copy already on disk
100
+ and never ask the server themselves. The Cursor `sessionStart` hook in
101
+ `~/.cursor/hooks.json` reads `~/.agents/mcpbox/policy-plain.json` each time it
102
+ runs, so it follows the server without a reinstall. Two copies stay baked
103
+ until the next release: the skill shipped inside the Codex plugin package
104
+ (a session of that plugin keeps `AGENTS.md` on the server text) and the
105
+ Kimi hooks frozen at `kimi-init`.
106
+
71
107
  ### Project knowledge in every session
72
108
 
73
109
  Agents answer repo questions right when they have the project's knowledge
@@ -87,6 +123,7 @@ call instead of the text. Knowledge rows arrive
87
123
  marked as workspace data, not instructions. Mode `off` disables both.
88
124
 
89
125
  Paired, the `Stop` hook blocks a stop once per task left `in_progress` that was taken in this session, asking the agent to complete, send to review, or release it.
126
+ If the lookup times out, it exits silently; lingering network connections do not delay process exit. Any blocking response is flushed before exit.
90
127
 
91
128
  A stale version announces itself at session start on Claude, Codex, and Kimi.
92
129
  The Cursor adapter's only hook is the user-level `sessionStart` that carries
@@ -107,7 +144,8 @@ installs, CI).
107
144
  | OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
108
145
 
109
146
  Codex skills are generated at package time from the same `commands/*.md` files
110
- that provide Claude's `/mcpbox:*` commands. Codex selects these skills by their
147
+ that provide Claude's `/mcpbox:*` commands, plus `skills/mcpbox` from the shared
148
+ plain policy (`BLOCK_BODY_PLAIN`). Codex selects these skills by their
111
149
  descriptions; they are not user-entered slash commands.
112
150
 
113
151
  All four agents accept `mcpbox mode [off|lite|full]` through the managed
@@ -131,6 +169,8 @@ mcpbox-claude init [--dir DIR] Managed CLAUDE.md policy block. Idempote
131
169
  mcpbox-claude uninit [--dir DIR] Remove the CLAUDE.md policy block.
132
170
  mcpbox-claude codex-init [--dir DIR] AGENTS.md policy + config.toml server + routing skill.
133
171
  mcpbox-claude codex-uninit [--dir DIR]
172
+ mcpbox-claude codex-skill User-level routing skill only (Codex without the plugin).
173
+ mcpbox-claude codex-skill-retire Remove that user-level copy once the plugin ships it.
134
174
  mcpbox-claude cursor-init [--dir DIR] .cursor/rules policy + .cursor/mcp.json server
135
175
  (in $HOME: ~/.cursor/hooks.json sessionStart hook).
136
176
  mcpbox-claude cursor-uninit [--dir DIR]
@@ -19,9 +19,18 @@ import { homedir } from "node:os";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { dirname, join, resolve } from "node:path";
21
21
  import { spawnSync } from "node:child_process";
22
- import { installPolicy, removePolicy, policyHierarchy, stalePolicyPaths, competingPolicyPaths } from "../lib/policy.mjs";
22
+ import { installPolicy, removePolicy, policyHierarchy, stalePolicyPaths, competingPolicyPaths, versionedBlock, BLOCK_BODY, BLOCK_BODY_PLAIN } from "../lib/policy.mjs";
23
+ import { policyBlocks, readPolicyCache } from "../lib/update-check.mjs";
24
+ import { VERSION } from "../lib/version.mjs";
23
25
  import { credentialsPath, login, logout, readCredentials } from "../lib/cloud-knowledge.mjs";
24
- import { installCodex, removeCodex, installCodexPolicy } from "../lib/codex.mjs";
26
+ import {
27
+ installCodex,
28
+ removeCodex,
29
+ installCodexPolicy,
30
+ installCodexSkill,
31
+ retireCodexSkill,
32
+ syncCodexSkill,
33
+ } from "../lib/codex.mjs";
25
34
  import {
26
35
  installCursor,
27
36
  removeCursor,
@@ -33,6 +42,7 @@ import {
33
42
  removeCursorModeCommand,
34
43
  installCursorSessionHook,
35
44
  removeCursorSessionHook,
45
+ syncCursorRules,
36
46
  } from "../lib/cursor.mjs";
37
47
  import { installKimi, removeKimi } from "../lib/kimi.mjs";
38
48
  import { installOpencode, removeOpencode } from "../lib/opencode.mjs";
@@ -48,8 +58,9 @@ Usage:
48
58
  (daruma tracker + full pipeline). Idempotent.
49
59
  mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
50
60
  mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
51
- [mcp_servers.mcpbox] and the mcpbox skill.
52
- Idempotent.
61
+ [mcp_servers.mcpbox] and the mcpbox skill
62
+ (for Codex without the plugin, which ships
63
+ that skill itself). Idempotent.
53
64
  mcpbox-claude codex-uninit [--dir DIR]
54
65
  mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
55
66
  .cursor/mcp.json mcpbox entry. Idempotent.
@@ -104,7 +115,7 @@ const VERB = {
104
115
 
105
116
  async function cmdInit(rest) {
106
117
  const { projectDir } = parseDirFlag(rest);
107
- const r = await installPolicy({ projectDir });
118
+ const r = await installPolicy({ projectDir, block: (await installBlocks()).claude });
108
119
  process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
109
120
  process.stdout.write("Open Claude Code in this directory to pick it up.\n");
110
121
  }
@@ -115,13 +126,17 @@ async function cmdUninit(rest) {
115
126
  process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
116
127
  }
117
128
 
129
+ // What an install writes: the server's text this machine last fetched, else
130
+ // the baked one — the text the next session start would sync to anyway.
131
+ const installBlocks = () => policyBlocks({ fetch: false });
132
+
118
133
  function report(r) {
119
134
  process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
120
135
  }
121
136
 
122
137
  async function cmdCodexInit(rest) {
123
138
  const { projectDir } = parseDirFlag(rest);
124
- const { policy, mcp, skill } = await installCodex({ projectDir });
139
+ const { policy, mcp, skill } = await installCodex({ projectDir, block: (await installBlocks()).plain });
125
140
  report(policy);
126
141
  report(mcp);
127
142
  report(skill);
@@ -156,7 +171,7 @@ async function cmdCursorInit(rest) {
156
171
  report(await installCursorMcp({ projectDir: homedir() }));
157
172
  return;
158
173
  }
159
- const { rule, mcp, mode } = await installCursor({ projectDir });
174
+ const { rule, mcp, mode } = await installCursor({ projectDir, block: (await installBlocks()).plain });
160
175
  report(rule);
161
176
  report(mcp);
162
177
  report(mode);
@@ -211,13 +226,27 @@ async function cmdOpencodeUninit(rest) {
211
226
  // MCP-server wiring and just need the managed policy file dropped.
212
227
  async function cmdCodexPolicy(rest) {
213
228
  const { projectDir } = parseDirFlag(rest);
214
- report(await installCodexPolicy({ projectDir }));
229
+ report(await installCodexPolicy({ projectDir, block: (await installBlocks()).plain }));
230
+ }
231
+
232
+ // The user-level policy skill alone: `codex-skill` for Codex without the
233
+ // plugin, `codex-skill-retire` once the plugin (which ships it) is installed.
234
+ async function cmdCodexSkill() {
235
+ report(await installCodexSkill({ block: (await installBlocks()).plain }));
236
+ }
237
+
238
+ async function cmdCodexSkillRetire() {
239
+ const { removed, backups, kept } = await retireCodexSkill({ block: (await installBlocks()).plain });
240
+ for (const path of removed) process.stdout.write(`✓ Removed duplicate ${path}\n`);
241
+ for (const path of backups) process.stdout.write(`✓ Saved the differing copy to ${path}\n`);
242
+ for (const path of kept) process.stdout.write(`! Left alone (not a copy mcpbox wrote) ${path}\n`);
243
+ if (!removed.length && !kept.length) process.stdout.write("✓ No user-level mcpbox skill to retire\n");
215
244
  }
216
245
 
217
246
  async function cmdCursorPolicy(rest) {
218
247
  const { projectDir } = parseDirFlag(rest);
219
248
  if (isHomeDir(projectDir)) return installCursorHome(homedir());
220
- report(await installCursorRule({ projectDir }));
249
+ report(await installCursorRule({ projectDir, block: (await installBlocks()).plain }));
221
250
  report(await installCursorModeCommand({ projectDir }));
222
251
  }
223
252
 
@@ -267,8 +296,32 @@ async function cmdDoctor(rest) {
267
296
  const policy = hierarchy.present;
268
297
  const mcp = mcpServerPresent();
269
298
  const ready = policy && !hierarchy.duplicate && mcp === true;
299
+ // Which server text this machine holds and when it last asked; blocks are
300
+ // compared with that copy, the baked text only when none was ever fetched.
301
+ const served = {};
302
+ for (const surface of ["claude", "plain"]) {
303
+ const { etag, body, fetchedAt, checkedAt, failedAt } = await readPolicyCache(surface);
304
+ const iso = (t) => (Number.isFinite(t) ? new Date(t).toISOString() : null);
305
+ served[surface] = typeof etag === "string" && typeof body === "string"
306
+ ? { etag, fetched_at: iso(fetchedAt), checked_at: iso(checkedAt), failed_at: iso(failedAt), body }
307
+ : null;
308
+ }
309
+ const claudeBlock = served.claude ? versionedBlock(served.claude.body) : BLOCK_BODY;
310
+ const plainBlock = served.plain ? versionedBlock(served.plain.body) : BLOCK_BODY_PLAIN;
311
+ const policyServer = Object.fromEntries(Object.entries(served).map(([k, v]) => {
312
+ if (!v) return [k, null];
313
+ const { body: _, ...meta } = v;
314
+ return [k, meta];
315
+ }));
270
316
  // Stale is a warning, not NOT READY: the next SessionStart refreshes it.
271
- const stale = await stalePolicyPaths(hierarchy.paths);
317
+ const stale = await stalePolicyPaths(hierarchy.paths, claudeBlock);
318
+ // Codex carriers (no Codex hooks exist): AGENTS.md up the tree and the user skill.
319
+ const agents = await policyHierarchy({ projectDir, file: "AGENTS.md" }).catch(() => ({ paths: [] }));
320
+ const agentsStale = await stalePolicyPaths(agents.paths, plainBlock);
321
+ const skill = await syncCodexSkill({ dryRun: true, block: plainBlock }).catch(() => ({ action: "missing" }));
322
+ const skillStale = skill.action === "stale" ? [skill.path] : [];
323
+ // Cursor rules up the tree carry the same plain text.
324
+ const cursorStale = await syncCursorRules({ cwd: resolve(projectDir ?? process.cwd()), block: plainBlock, dryRun: true });
272
325
  // Also a warning: two policies in one file, one of them from the daruma CLI.
273
326
  const competing = await competingPolicyPaths({ projectDir });
274
327
  // Not required: without it hooks hint at the knowledge instead of loading it.
@@ -282,7 +335,12 @@ async function cmdDoctor(rest) {
282
335
  policy_stale: stale.length > 0,
283
336
  policy_stale_paths: stale,
284
337
  policy_competing_paths: competing,
338
+ agents_md_paths: agents.paths,
339
+ agents_md_stale_paths: agentsStale,
340
+ codex_skill_stale_paths: skillStale,
341
+ cursor_rule_stale_paths: cursorStale,
285
342
  knowledge_paired: paired,
343
+ policy_server: policyServer,
286
344
  }) + "\n");
287
345
  } else {
288
346
  const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
@@ -290,6 +348,13 @@ async function cmdDoctor(rest) {
290
348
  `mcpbox MCP server: ${mark(mcp)}${mcp === null ? " (claude CLI not found)" : ""}\n` +
291
349
  `CLAUDE.md policy: ${mark(policy)}${hierarchy.duplicate ? " (duplicate managed blocks)" : ""}\n` +
292
350
  hierarchy.paths.map((p) => ` ${p}${stale.includes(p) ? " (stale — the next session start of this plugin version refreshes it)" : ""}\n`).join("") +
351
+ Object.entries(policyServer).map(([surface, meta]) => meta
352
+ ? ` server text (${surface}): ETag ${meta.etag}, fetched ${meta.fetched_at ?? "?"}, checked ${meta.checked_at ?? "?"}${meta.failed_at ? `, last failure ${meta.failed_at}` : ""}\n`
353
+ : ` server text (${surface}): not fetched yet — blocks carry plugin ${VERSION} text\n`).join("") +
354
+ (agents.paths.length ? `AGENTS.md policy: ✓\n` : "") +
355
+ agents.paths.map((p) => ` ${p}${agentsStale.includes(p) ? " (stale — run: mcpbox-claude codex-init)" : ""}\n`).join("") +
356
+ skillStale.map((p) => ` ${p} (stale — run: mcpbox-claude codex-init)\n`).join("") +
357
+ cursorStale.map((p) => ` ${p} (stale — run: mcpbox-claude cursor-init)\n`).join("") +
293
358
  competing.map((p) => ` ! ${p} also holds a daruma CLI policy block — keep one\n`).join("") +
294
359
  `Project knowledge: ${paired ? "✓ paired" : "hint only — run: npx -y @mcpbox/mcpbox-claude login"}\n` +
295
360
  `${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
@@ -352,6 +417,10 @@ async function main(argv) {
352
417
  return cmdOpencodeUninit(rest);
353
418
  case "codex-policy":
354
419
  return cmdCodexPolicy(rest);
420
+ case "codex-skill":
421
+ return cmdCodexSkill();
422
+ case "codex-skill-retire":
423
+ return cmdCodexSkillRetire();
355
424
  case "cursor-policy":
356
425
  return cmdCursorPolicy(rest);
357
426
  case "doctor":
package/commands/mode.md CHANGED
@@ -6,8 +6,9 @@ The user invoked `/mcpbox:mode` with `$ARGUMENTS` = `off` | `lite` | `full` (emp
6
6
 
7
7
  ## What each level does
8
8
 
9
- - **off** — no pipeline nudging; don't raise the pipeline on your own. Raw material still
10
- isn't materialized straight into daruma — ask the user instead.
9
+ Mode sets how eagerly to suggest `mcpbox_pipeline_run`: `off` never, `lite` only when asked, `full` for any substantive request.
10
+
11
+ - **off** — no pipeline nudging; don't raise the pipeline on your own.
11
12
  - **lite** (default) — nudge toward the pipeline only when the input explicitly mentions it
12
13
  (pipeline / maturity / handoff / конвейер …).
13
14
  - **full** — assess every substantive request for **rawness**. A raw idea, hypothesis, or
@@ -22,6 +23,9 @@ anything belonging to a run still in flight — goes through the pipeline.
22
23
  The level persists across sessions (stored in `~/.agents/mcpbox/mode`) and is read by the
23
24
  UserPromptSubmit hook, which injects the matching reminder on each prompt.
24
25
 
26
+ Codex/Cursor/Kimi/OpenCode have no such hook: their `*-init` command writes the mode into the
27
+ MCP URL (`?mode=`), so re-run it after changing the mode.
28
+
25
29
  ## Steps
26
30
 
27
31
  1. Run:
package/commands/next.md CHANGED
@@ -8,11 +8,13 @@ to the user/agent to actually execute it.
8
8
  ## Steps
9
9
 
10
10
  1. Resolve project (`daruma_workspace_info` → `default_project`).
11
- 2. Active plan: `daruma_plan_list` filtered to `status = "active"`, most recent.
12
- If none, stop with "no active plan — create one with `daruma_plan_materialize`".
11
+ 2. Active plan: `daruma_plan_list` with `status = "active"`, `sort = "updated"`,
12
+ `limit = 1` — the most recently updated plan (the default order is by creation).
13
+ If none, stop with "no active plan — decided work: `daruma_plan_materialize`; raw idea: `/mcpbox:pipeline-run`".
13
14
  3. `daruma_plan_drain_next` with the plan id. The server atomically picks the next
14
15
  ready (unblocked) task and claims it for this session; it returns null when no
15
- unclaimed ready task remains.
16
+ unclaimed ready task remains. Keep the returned `run_id`: the server opened that
17
+ run for this claim. A null drain already aborted its own run — nothing to close.
16
18
  4. If "no ready task": print the server reason (e.g. "3 tasks blocked by X") and
17
19
  suggest `/mcpbox:plan` to inspect dependencies. Stop.
18
20
  5. Otherwise render the briefing:
@@ -22,6 +24,7 @@ to the user/agent to actually execute it.
22
24
 
23
25
  id: <task_id>
24
26
  plan: <plan_id>
27
+ run: <run_id>
25
28
  priority: <pX>
26
29
  status: 🟢 in_progress
27
30
  ```
@@ -32,7 +35,12 @@ to the user/agent to actually execute it.
32
35
 
33
36
  ```
34
37
  → When done: daruma_complete id=<task_id> [result_summary="<summary>"]
38
+ then daruma_run_complete run_id=<run_id>
35
39
  → On failure: daruma_set_status status=todo comment={ body, kind: "blocker" }
40
+ then daruma_run_abort run_id=<run_id> reason=<reason>
36
41
  ```
37
42
 
43
+ An open run keeps the plan from auto-closing after its last task; the
44
+ `plan_close_blocked_by_run` warning names it in `details.run_id`.
45
+
38
46
  7. Briefing only — do not start executing the task in this command.
@@ -10,15 +10,26 @@ never by materializing it directly.
10
10
  ## Steps
11
11
 
12
12
  1. If `$ARGUMENTS` is empty, ask for the raw idea/request and stop.
13
- 2. Call `mcpbox_pipeline_run { source, kind:"text", body:"<idea>" }`. It returns
13
+ 2. Call `mcpbox_pipeline_run { source, kind:"text", body:"<idea>", project_id }`.
14
+ `source` is a URI or short label of where the idea came from (as `plan.source`;
15
+ never an invented link); `project_id` comes from `daruma_workspace_info` for this
16
+ repo (omit it only if unbound). Any `kind` outside text/document/reference/binary/event
17
+ is a 422. It returns
14
18
  `run_id` immediately while the run proceeds in the background. Poll
15
19
  `mcpbox_trace_get { run_id }` until the status is no longer `running`.
16
20
  3. On failure, report the reason from `mcpbox_trace_get`; do not hand off an
17
- incomplete run.
21
+ incomplete run. Recovery: a run `failed` at layer L → retry with
22
+ `mcpbox_pipeline_advance { run_id, layer: L }` after fixing the input; fujin
23
+ `not_ready` → advance from `yatagarasu`; or ask the owner. Never
24
+ `daruma_plan_materialize` the idea directly to get around a failed run.
25
+ A 409 with `existing_run_id` means the same intake is already a run: follow that
26
+ run instead of opening another. If `mcpbox_runs_list` shows a *running* run of the
27
+ same idea you are restating, pass `relation:{supersedes:<run_id>}` to replace it.
18
28
  4. Once the run is ready for handoff, call
19
- `mcpbox_pipeline_handoff { run_id, action_packet, policy_snapshot, project_slug? }`,
20
- taking `action_packet` from `artifacts.fujin.action_packet` and
21
- `policy_snapshot` from `artifacts.policy_snapshot` in the trace. This
22
- materializes the daruma task and returns `task_id`.
29
+ `mcpbox_pipeline_handoff { run_id, project_slug? }`: the packet and policy
30
+ come from the run (an `action_packet` with another id is a 422). Without
31
+ `run_id`, pass `action_packet` and `policy_snapshot` from the trace. This
32
+ materializes the daruma task, returns `task_id` and any `warnings`
33
+ (`plan_source_*`, `source_upstream_kept`) — fix the source or ask.
23
34
  5. Verify with `mcpbox_trace_get { run_id }` (expect `status=handed_off`, a `task_id`) and
24
35
  report the run_id + task_id.
package/commands/plan.md CHANGED
@@ -7,19 +7,22 @@ The user invoked `/mcpbox:plan`.
7
7
  ## Steps
8
8
 
9
9
  1. Resolve project (`daruma_workspace_info` → `default_project`).
10
- 2. `daruma_plan_list status="draft,active"`, most recent first.
11
- If none, stop with "no active plan".
12
- 3. For the chosen plan, `daruma_plan_get` (single call — do not enumerate the archive).
10
+ 2. `daruma_plan_list status="draft,active" sort="updated" limit=1` — the most recently
11
+ updated plan (the default order is by creation, and its first page can miss it).
12
+ If none, stop with "no active plan — decided work: `daruma_plan_materialize`; raw idea: `/mcpbox:pipeline-run`".
13
+ 3. For the chosen plan, `daruma_plan_get view="tasks"` (single call — do not enumerate the archive).
14
+ It lists every plan task (done included) with `status`, `priority`, `depends_on` and
15
+ `blocked_by`; the default `progress` view caps each group at five open tasks.
13
16
  4. Render:
14
17
 
15
18
  ```
16
19
  ## <plan title>
17
- goal: <goal>
18
20
  progress: [████░░░░] 4/9 done
19
21
 
20
22
  | # | Status | Pri | Task | Depends on |
21
23
  |---|--------|-----|------|-----------|
22
24
  ```
23
25
 
24
- - Progress bar from done/total; blocked tasks marked ⛔ with their blocker ids.
26
+ - Progress bar from `progress.tasks_done`/`progress.tasks_total`; one row per task in plan order.
27
+ - Tasks with a non-empty `blocked_by` marked ⛔ with those blocker ids.
25
28
  5. Do not call `daruma_plan_list status=completed` (token-heavy). Read-only.
@@ -19,7 +19,11 @@ The user invoked `/mcpbox:status`.
19
19
  may be absent. Omit the line entirely — never print `null` or a bare UUID.
20
20
  2. Resolve the project **title** for that `project_id` via `daruma_project_list`
21
21
  (the `name` inside `scopes` is only the directory basename, not the project's
22
- title). Skip if the cwd matches no scope.
22
+ title). Skip if the cwd matches no scope. If that project carries
23
+ `possible_duplicates`, the repo was registered twice and its history is
24
+ split: add a `duplicates:` line with those ids (title, slug) and, when the
25
+ user asks about tasks, plans or findings, check each id — never conclude
26
+ history is missing from the bound id alone.
23
27
  3. One scoped `daruma_list status=active` → count open tasks (do not enumerate
24
28
  the archive).
25
29
  4. `mcpbox_runs_list` with `limit=5` (and `status=failed` if the user asked about
@@ -31,6 +35,7 @@ The user invoked `/mcpbox:status`.
31
35
  workspace: <title> (<slug>)
32
36
  account: <email>
33
37
  project: <project title> — <repo path>
38
+ duplicates: <id> (<slug>) · … — only when `possible_duplicates` is set
34
39
  open: <N> tasks
35
40
  server: ok (v<version>, sha <git_sha>) — only when `/mcpbox:doctor` ran
36
41
  runs: <run_id> <status> · <run_id> <status> …
@@ -18,8 +18,8 @@
18
18
 
19
19
  import { isCodexSurface, writeHookOutput } from "../lib/hook-output.mjs";
20
20
  import { MCPClient } from "../lib/mcp-client.mjs";
21
- import { BLOCK_BODY_PLAIN, syncPolicyBlocks } from "../lib/policy.mjs";
22
- import { checkForUpdate, updateNotice } from "../lib/update-check.mjs";
21
+ import { syncPolicyBlocks } from "../lib/policy.mjs";
22
+ import { checkForUpdate, policyBlocks, updateNotice } from "../lib/update-check.mjs";
23
23
  import { VERSION } from "../lib/version.mjs";
24
24
  import { pathToFileURL } from "node:url";
25
25
 
@@ -102,29 +102,52 @@ async function fetchSummary() {
102
102
  }
103
103
  }
104
104
 
105
- // Bring the policy blocks already installed around cwd up to this plugin
106
- // version (see syncPolicyBlocks). Failures stay silent: a read-only tree must
105
+ // Block text to write: the server's copy, else the baked text (see policyBlocks).
106
+ export { policyBlocks };
107
+
108
+ // Bring the policy blocks already installed around cwd up to the server's
109
+ // text (see syncPolicyBlocks). Failures stay silent: a read-only tree must
107
110
  // never block the session. MCPBOX_NO_POLICY_SYNC=1 opts out. Only the plugin
108
111
  // surfaces sync: Kimi runs a copy frozen at kimi-init (no CLAUDE_PLUGIN_ROOT,
109
112
  // no PLUGIN_DATA), whose policy would be stale by construction.
110
113
  export async function syncPolicy(cwd = process.cwd(), env = process.env) {
111
- if (env.MCPBOX_NO_POLICY_SYNC) return [];
114
+ if (env.MCPBOX_NO_POLICY_SYNC) return { paths: [], origin: null };
115
+ if (!env.CLAUDE_PLUGIN_ROOT && !isCodexSurface(env)) return { paths: [], origin: null };
116
+ const blocks = await policyBlocks();
112
117
  const paths = [];
113
- if (isCodexSurface(env)) {
114
- paths.push(...await syncPolicyBlocks({ cwd, file: "AGENTS.md", block: BLOCK_BODY_PLAIN }).catch(() => []));
118
+ // Codex has no hooks of its own (.codex-plugin declares none), so any plugin
119
+ // surface refreshes the Codex carriers too: AGENTS.md up the tree, plus the
120
+ // user-level SKILL.md — refreshed from Claude, retired from the Codex plugin.
121
+ // Cursor rules up the tree likewise: Cursor runs no hook of this plugin.
122
+ // Every plain carrier gets the same text as AGENTS.md.
123
+ if (env.CLAUDE_PLUGIN_ROOT && !isCodexSurface(env)) {
124
+ paths.push(...await syncPolicyBlocks({ cwd, block: blocks.claude }).catch(() => []));
125
+ }
126
+ if (isCodexSurface(env) || env.CLAUDE_PLUGIN_ROOT) {
127
+ paths.push(...await syncPolicyBlocks({ cwd, file: "AGENTS.md", block: blocks.plain }).catch(() => []));
115
128
  try {
116
- const { syncCodexSkill } = await import("../lib/codex.mjs");
117
- const skill = await syncCodexSkill();
118
- if (skill.action === "updated") paths.push(skill.path);
129
+ const { retireCodexSkill, syncCodexSkill } = await import("../lib/codex.mjs");
130
+ if (isCodexSurface(env)) {
131
+ // Running as the Codex plugin, which ships the policy skill itself:
132
+ // a user-level copy is now a duplicate (see retireCodexSkill).
133
+ const { removed, backups } = await retireCodexSkill({ block: blocks.plain });
134
+ paths.push(...removed.map((dir) => `${dir} (duplicate removed: the plugin ships this skill)`));
135
+ paths.push(...backups.map((file) => `${file} (the differing copy, kept)`));
136
+ } else {
137
+ const skill = await syncCodexSkill({ block: blocks.plain });
138
+ if (skill.action === "updated") paths.push(skill.path);
139
+ }
119
140
  } catch { /* skill dir unwritable — AGENTS.md sync still counts */ }
120
- } else if (env.CLAUDE_PLUGIN_ROOT) {
121
- paths.push(...await syncPolicyBlocks({ cwd }).catch(() => []));
141
+ try {
142
+ const { syncCursorRules } = await import("../lib/cursor.mjs");
143
+ paths.push(...await syncCursorRules({ cwd, block: blocks.plain }));
144
+ } catch { /* same: a rule we cannot write never blocks the session */ }
122
145
  }
123
- return paths;
146
+ return { paths, origin: blocks.origin };
124
147
  }
125
148
 
126
149
  export async function main() {
127
- const [data, update, synced] = await Promise.all([
150
+ const [data, update, { paths: synced, origin }] = await Promise.all([
128
151
  fetchSummary().catch((err) => {
129
152
  if (process.env.MCPBOX_DEBUG) {
130
153
  process.stderr.write(`[mcpbox-claude/session-start] error: ${err?.message ?? err}\n`);
@@ -135,14 +158,14 @@ export async function main() {
135
158
  syncPolicy(),
136
159
  ]);
137
160
  const syncNote = synced.length
138
- ? `[mcpbox] Policy block refreshed to plugin ${VERSION}: ${synced.join(", ")}\n`
161
+ ? `[mcpbox] Policy block refreshed to ${origin}: ${synced.join(", ")}\n`
139
162
  : "";
140
163
  // The user sees what we wrote into their files, not just the model.
141
164
  const notices = [
142
165
  update?.outdated
143
166
  ? updateNotice(update.current, update.latest, isCodexSurface() ? "codex" : "claude")
144
167
  : null,
145
- synced.length ? `mcpbox: policy block refreshed to ${VERSION} in ${synced.join(", ")}` : null,
168
+ synced.length ? `mcpbox: policy block refreshed to ${origin} in ${synced.join(", ")}` : null,
146
169
  ].filter(Boolean);
147
170
  const systemMessage = notices.length ? notices.join("\n") : undefined;
148
171
 
@@ -172,7 +195,7 @@ export async function main() {
172
195
 
173
196
  const lines = [header, ...shown.map(formatTask)];
174
197
  if (extra > 0) lines.push(` …and ${extra} more — /mcpbox:tasks for full list`);
175
- lines.push("→ /mcpbox:next to claim the next task | /mcpbox:status for server + pipeline health");
198
+ lines.push("→ /mcpbox:next to claim the next task | /mcpbox:status for server + pipeline health | raw idea: /mcpbox:pipeline-run");
176
199
 
177
200
  writeHookOutput("SessionStart", syncNote + lines.join("\n"), { systemMessage });
178
201
  process.exit(0);
package/hooks/stop.mjs CHANGED
@@ -99,5 +99,8 @@ async function main() {
99
99
  }
100
100
 
101
101
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
102
- main().catch(() => {});
102
+ main().catch(() => {}).finally(() => {
103
+ // Aborted fetch connections can outlive main; flush the decision before exiting.
104
+ process.stdout.write("", () => process.exit(0));
105
+ });
103
106
  }
@@ -41,7 +41,7 @@ const PATTERNS = [
41
41
  {
42
42
  // create / import — ACTION + task/issue OBJECT (avoids bare-verb false positives).
43
43
  re: /\b(add|create|new|log|move|import)\s+(a\s+|an\s+)?(task|issue|ticket|subtask)\b|(?<![а-яёА-ЯЁ])(добавь|добавить|заведи|завести|создай|создать)\s+(задачу|таск|подзадачу|тикет)(?![а-яёА-ЯЁ])|(?<![а-яёА-ЯЁ])(перенеси|перенести|импортируй|заведи)\s+(ишью|задачу|таск|тикет|issue)(?![а-яёА-ЯЁ])/,
44
- hint: "[mcpbox] Detected task-intake/import intent → daruma_plan_materialize (tasks are created only with a plan; an external issue is its source — plan.source.ref = the issue URL, not a second tracker). 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.",
44
+ hint: "[mcpbox] Detected task-intake/import intent → daruma_plan_materialize (tasks are created only with a plan; an external issue is its source — plan.source.ref = the issue URL, not a second tracker). Raw / undecided → mcpbox_pipeline_run instead. 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.",
45
45
  },
46
46
  {
47
47
  // "Создай план" / "make a plan": the plan goes to mcpbox, not into chat.
@@ -93,6 +93,11 @@ const PATTERNS = [
93
93
  const OPERATIONAL_EXIT =
94
94
  "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: ";
95
95
 
96
+ // full mode: after the exit and before any pattern hint — raw material goes to
97
+ // the pipeline first, so no hint reads as "straight to daruma".
98
+ const RAW_FIRST =
99
+ "Raw material (idea, hypothesis, undecided direction) → mcpbox_pipeline_run first; only decided, bounded work follows the hint: ";
100
+
96
101
  const FULL_ASSESS_HINT =
97
102
  "[mcpbox:full] " + OPERATIONAL_EXIT + "assess rawness: only raw material — an idea, hypothesis, or undecided direction — goes to mcpbox_pipeline_run. 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.";
98
103
 
@@ -109,8 +114,8 @@ export function promptSubmitHint(promptText = "", mode = "lite") {
109
114
  for (const { re, hint } of patterns) {
110
115
  if (re.test(prompt)) {
111
116
  // A keyword match is a guess about intent, not a verdict on it — in full
112
- // mode the operational exit goes ahead of the guess.
113
- return mode === "full" ? `[mcpbox:full] ${OPERATIONAL_EXIT}${hint}` : hint;
117
+ // mode the operational exit and the rawness check go ahead of the guess.
118
+ return mode === "full" ? `[mcpbox:full] ${OPERATIONAL_EXIT}${RAW_FIRST}${hint}` : hint;
114
119
  }
115
120
  }
116
121
  if (mode === "full" && prompt.length >= SUBSTANTIVE_MIN) return FULL_ASSESS_HINT;