@mcpbox/mcpbox-claude 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +59 -5
- package/bin/mcpbox-claude.mjs +83 -14
- package/commands/next.md +10 -2
- package/commands/plan.md +7 -4
- package/hooks/hooks.json +27 -1
- package/hooks/prepare-commit-msg.mjs +11 -0
- package/hooks/session-gate.mjs +84 -0
- package/hooks/session-start.mjs +25 -143
- package/hooks/stop.mjs +35 -78
- package/hooks/track-claims.mjs +32 -0
- package/lib/codex.mjs +25 -21
- package/lib/cursor.mjs +54 -14
- package/lib/git-trailer.mjs +104 -0
- package/lib/harness-hooks.mjs +138 -0
- package/lib/kimi.mjs +7 -1
- package/lib/policy.mjs +26 -10
- package/lib/session-gate.mjs +205 -0
- package/lib/update-check.mjs +114 -0
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/mcpbox/SKILL.md +11 -9
- package/skills/mcpbox-next/SKILL.md +10 -2
- package/skills/mcpbox-plan/SKILL.md +7 -4
|
@@ -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.
|
|
4
|
+
"version": "0.1.28",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tupical"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -76,6 +76,34 @@ session context. It never adds a block and never touches text outside the
|
|
|
76
76
|
markers; `doctor --json` reports `policy_stale` until it has run. Set
|
|
77
77
|
`MCPBOX_NO_POLICY_SYNC=1` to keep installed blocks as they are.
|
|
78
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
|
+
|
|
79
107
|
### Project knowledge in every session
|
|
80
108
|
|
|
81
109
|
Agents answer repo questions right when they have the project's knowledge
|
|
@@ -94,7 +122,8 @@ unbound in the paired workspace, the hook adds a ready `mcpbox_knowledge_read`
|
|
|
94
122
|
call instead of the text. Knowledge rows arrive
|
|
95
123
|
marked as workspace data, not instructions. Mode `off` disables both.
|
|
96
124
|
|
|
97
|
-
Paired, the `Stop`
|
|
125
|
+
Paired, `PostToolUse` records successful task claims for the current session. `Stop` only checks these tasks and nudges once while the exact claim is still live and the task remains `in_progress`. Reads of another plan never change this set. An unknown session, an expired claim, or a claim now held by another session produces no nudge; there is no timestamp or project-wide fallback. `SessionStart` refreshes policy and update notices without injecting task inventories.
|
|
126
|
+
If the lookup times out, it exits silently; lingering network connections do not delay process exit. Any blocking response is flushed before exit.
|
|
98
127
|
|
|
99
128
|
A stale version announces itself at session start on Claude, Codex, and Kimi.
|
|
100
129
|
The Cursor adapter's only hook is the user-level `sessionStart` that carries
|
|
@@ -109,8 +138,8 @@ installs, CI).
|
|
|
109
138
|
| Agent | Policy surface | MCP server | Hooks |
|
|
110
139
|
|--------|----------------------------------------|-------------------------------------|-------|
|
|
111
140
|
| Claude | `CLAUDE.md` block + plugin (hooks, `/mcpbox:*`) | `claude mcp add` (`.mcp.json` / `~/.claude.json`) | plugin `hooks.json` |
|
|
112
|
-
| Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` |
|
|
113
|
-
| Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` (repo); in `$HOME` a `sessionStart` hook in `~/.cursor/hooks.json` instead — Cursor reads no `~/.cursor/rules` | `mcpbox` entry in `.cursor/mcp.json` | `~/.cursor/hooks.json
|
|
141
|
+
| Codex | `AGENTS.md` block + model-invoked plugin skills | `[mcp_servers.mcpbox]` in `~/.codex/config.toml` | session gate in `~/.codex/hooks.json` |
|
|
142
|
+
| Cursor | `.cursor/rules/mcpbox-policy.mdc` + `/mcpbox-mode` (repo); in `$HOME` a `sessionStart` hook in `~/.cursor/hooks.json` instead — Cursor reads no `~/.cursor/rules` | `mcpbox` entry in `.cursor/mcp.json` | `~/.cursor/hooks.json`: `sessionStart` policy (global only) + session gate (`failClosed`) |
|
|
114
143
|
| Kimi | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` entry in `~/.kimi-code/mcp.json` | `[[hooks]]` block in `~/.kimi-code/config.toml` |
|
|
115
144
|
| OpenCode | `AGENTS.md` block (`mcpbox:policy`) | `mcpbox` remote entry under `mcp` in `~/.config/opencode/opencode.json` | — |
|
|
116
145
|
|
|
@@ -128,11 +157,28 @@ Kimi specifics:
|
|
|
128
157
|
- MCP and hooks are **user-level** (Kimi reads hooks only from
|
|
129
158
|
`~/.kimi-code/config.toml`; `$KIMI_CODE_HOME` is honored). One
|
|
130
159
|
`/mcp-config login mcpbox` OAuth then covers every project.
|
|
131
|
-
- The hook scripts (`SessionStart`
|
|
132
|
-
hints, `Stop` guard) are the same ones the Claude plugin ships;
|
|
160
|
+
- The hook scripts (`SessionStart` notices, `UserPromptSubmit` routing
|
|
161
|
+
hints, `PostToolUse` claim tracking, `Stop` guard) are the same ones the Claude plugin ships;
|
|
133
162
|
`kimi-init` copies them into `~/.kimi-code/mcpbox/` so the config never
|
|
134
163
|
references an ephemeral npx cache path. `kimi-uninit` removes that directory.
|
|
135
164
|
|
|
165
|
+
Session gate (Claude, Codex, Cursor, Kimi) — one set of scripts, different
|
|
166
|
+
configs; `--surface=codex|cursor` selects the host's stdin/stdout wire:
|
|
167
|
+
|
|
168
|
+
- `hooks/session-gate.mjs start` — SessionStart (also after compaction): this
|
|
169
|
+
agent's `in_progress` claims and the repo's `in_review` tasks.
|
|
170
|
+
- `hooks/track-claims.mjs` — PostToolUse (Cursor: `afterMCPExecution`):
|
|
171
|
+
successful claims plus `daruma_plan_materialize` / `daruma_set_status` /
|
|
172
|
+
`daruma_comment` writes; a `kind=outcome` comment marks its task reported.
|
|
173
|
+
- `hooks/stop.mjs` — blocks while a tracked task is `todo`/`in_progress`
|
|
174
|
+
without an outcome comment; two reminders per pending set, then a warning
|
|
175
|
+
(Cursor: `followup_message`).
|
|
176
|
+
- `hooks/session-gate.mjs end` — SessionEnd: `daruma_release` of this
|
|
177
|
+
session's claims the server still shows as its own.
|
|
178
|
+
|
|
179
|
+
Codex and Cursor run copies in `~/.agents/mcpbox/harness/` (written by
|
|
180
|
+
`codex-init` / `cursor-init`), never the ephemeral npx cache.
|
|
181
|
+
|
|
136
182
|
## CLI
|
|
137
183
|
|
|
138
184
|
```
|
|
@@ -153,8 +199,16 @@ mcpbox-claude opencode-init [--dir DIR] AGENTS.md policy + `mcpbox` entry under
|
|
|
153
199
|
mcpbox-claude opencode-uninit [--dir DIR]
|
|
154
200
|
mcpbox-claude doctor [--json] Check the mcpbox MCP server + policy are wired.
|
|
155
201
|
mcpbox-claude mode [off|lite|full] Show or set the shared pipeline mode.
|
|
202
|
+
mcpbox-claude git-hook [install|uninstall] [--dir DIR]
|
|
203
|
+
git prepare-commit-msg hook: adds
|
|
204
|
+
"Daruma-Task: <id>" for the work/<id> branch,
|
|
205
|
+
else for tasks this session claimed.
|
|
156
206
|
```
|
|
157
207
|
|
|
208
|
+
CI on `main` posts an outcome for each `Daruma-Task` (task → `in_review`) and a
|
|
209
|
+
gated deploy completes it; see `docs/CI.md` in mcpbox.ru. The hook never
|
|
210
|
+
overwrites a foreign `prepare-commit-msg` and never blocks a commit.
|
|
211
|
+
|
|
158
212
|
All writes are idempotent and preserve surrounding hand-written content.
|
|
159
213
|
Set `MCPBOX_NO_UPDATE_CHECK=1` to disable hook update checks.
|
|
160
214
|
|
package/bin/mcpbox-claude.mjs
CHANGED
|
@@ -19,7 +19,9 @@ 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, BLOCK_BODY_PLAIN } 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
26
|
import {
|
|
25
27
|
installCodex,
|
|
@@ -40,10 +42,13 @@ import {
|
|
|
40
42
|
removeCursorModeCommand,
|
|
41
43
|
installCursorSessionHook,
|
|
42
44
|
removeCursorSessionHook,
|
|
45
|
+
syncCursorRules,
|
|
43
46
|
} from "../lib/cursor.mjs";
|
|
44
47
|
import { installKimi, removeKimi } from "../lib/kimi.mjs";
|
|
48
|
+
import { installCodexHooks, installCursorHooks, removeCodexHooks, removeCursorHooks } from "../lib/harness-hooks.mjs";
|
|
45
49
|
import { installOpencode, removeOpencode } from "../lib/opencode.mjs";
|
|
46
50
|
import { readMode, writeMode, MODES } from "../lib/mode.mjs";
|
|
51
|
+
import { installGitHook, prepareCommitMsg, removeGitHook } from "../lib/git-trailer.mjs";
|
|
47
52
|
|
|
48
53
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
49
54
|
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
|
|
@@ -55,12 +60,15 @@ Usage:
|
|
|
55
60
|
(daruma tracker + full pipeline). Idempotent.
|
|
56
61
|
mcpbox-claude uninit [--dir DIR] Remove the managed CLAUDE.md policy block.
|
|
57
62
|
mcpbox-claude codex-init [--dir DIR] Write AGENTS.md policy, ~/.codex/config.toml
|
|
58
|
-
[mcp_servers.mcpbox]
|
|
63
|
+
[mcp_servers.mcpbox], the mcpbox skill
|
|
59
64
|
(for Codex without the plugin, which ships
|
|
60
|
-
that skill itself)
|
|
65
|
+
that skill itself) and the session-gate
|
|
66
|
+
hooks in ~/.codex/hooks.json. Idempotent.
|
|
61
67
|
mcpbox-claude codex-uninit [--dir DIR]
|
|
62
68
|
mcpbox-claude cursor-init [--dir DIR] Write .cursor/rules/mcpbox-policy.mdc +
|
|
63
|
-
.cursor/mcp.json mcpbox entry
|
|
69
|
+
.cursor/mcp.json mcpbox entry, plus the
|
|
70
|
+
session-gate hooks in ~/.cursor/hooks.json.
|
|
71
|
+
Idempotent.
|
|
64
72
|
In $HOME the policy goes to a sessionStart
|
|
65
73
|
hook in ~/.cursor/hooks.json instead.
|
|
66
74
|
mcpbox-claude cursor-uninit [--dir DIR]
|
|
@@ -76,6 +84,11 @@ Usage:
|
|
|
76
84
|
mcpbox-claude login Pair this machine so hooks load project knowledge.
|
|
77
85
|
mcpbox-claude logout Forget the pairing token.
|
|
78
86
|
mcpbox-claude mode [off|lite|full] Get/set pipeline strictness (how raw ideas route).
|
|
87
|
+
mcpbox-claude git-hook [install|uninstall] [--dir DIR]
|
|
88
|
+
Manage the git prepare-commit-msg hook that adds
|
|
89
|
+
"Daruma-Task: <id>" trailers (work/<id> branch or
|
|
90
|
+
tasks claimed in this session). Never overwrites a
|
|
91
|
+
foreign hook.
|
|
79
92
|
mcpbox-claude export-marketplace [--dir DIR]
|
|
80
93
|
Mirror this package to a stable directory usable as
|
|
81
94
|
a Claude Code marketplace; prints the path.
|
|
@@ -112,7 +125,7 @@ const VERB = {
|
|
|
112
125
|
|
|
113
126
|
async function cmdInit(rest) {
|
|
114
127
|
const { projectDir } = parseDirFlag(rest);
|
|
115
|
-
const r = await installPolicy({ projectDir });
|
|
128
|
+
const r = await installPolicy({ projectDir, block: (await installBlocks()).claude });
|
|
116
129
|
process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
|
|
117
130
|
process.stdout.write("Open Claude Code in this directory to pick it up.\n");
|
|
118
131
|
}
|
|
@@ -123,16 +136,21 @@ async function cmdUninit(rest) {
|
|
|
123
136
|
process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
|
|
124
137
|
}
|
|
125
138
|
|
|
139
|
+
// What an install writes: the server's text this machine last fetched, else
|
|
140
|
+
// the baked one — the text the next session start would sync to anyway.
|
|
141
|
+
const installBlocks = () => policyBlocks({ fetch: false });
|
|
142
|
+
|
|
126
143
|
function report(r) {
|
|
127
144
|
process.stdout.write(`✓ ${VERB[r.action] ?? r.action} ${r.path}\n`);
|
|
128
145
|
}
|
|
129
146
|
|
|
130
147
|
async function cmdCodexInit(rest) {
|
|
131
148
|
const { projectDir } = parseDirFlag(rest);
|
|
132
|
-
const { policy, mcp, skill } = await installCodex({ projectDir });
|
|
149
|
+
const { policy, mcp, skill } = await installCodex({ projectDir, block: (await installBlocks()).plain });
|
|
133
150
|
report(policy);
|
|
134
151
|
report(mcp);
|
|
135
152
|
report(skill);
|
|
153
|
+
report(await installCodexHooks());
|
|
136
154
|
}
|
|
137
155
|
|
|
138
156
|
async function cmdCodexUninit(rest) {
|
|
@@ -142,6 +160,7 @@ async function cmdCodexUninit(rest) {
|
|
|
142
160
|
report(mcp);
|
|
143
161
|
report(skill);
|
|
144
162
|
report(prompts);
|
|
163
|
+
report(await removeCodexHooks());
|
|
145
164
|
}
|
|
146
165
|
|
|
147
166
|
// Cursor ignores ~/.cursor/rules: in the home dir the policy goes through the
|
|
@@ -162,12 +181,15 @@ async function cmdCursorInit(rest) {
|
|
|
162
181
|
if (isHomeDir(projectDir)) {
|
|
163
182
|
await installCursorHome(homedir());
|
|
164
183
|
report(await installCursorMcp({ projectDir: homedir() }));
|
|
184
|
+
report(await installCursorHooks());
|
|
165
185
|
return;
|
|
166
186
|
}
|
|
167
|
-
const { rule, mcp, mode } = await installCursor({ projectDir });
|
|
187
|
+
const { rule, mcp, mode } = await installCursor({ projectDir, block: (await installBlocks()).plain });
|
|
168
188
|
report(rule);
|
|
169
189
|
report(mcp);
|
|
170
190
|
report(mode);
|
|
191
|
+
// The session gate is user-level: Cursor runs ~/.cursor/hooks.json in every project.
|
|
192
|
+
report(await installCursorHooks());
|
|
171
193
|
}
|
|
172
194
|
|
|
173
195
|
async function cmdCursorUninit(rest) {
|
|
@@ -177,6 +199,7 @@ async function cmdCursorUninit(rest) {
|
|
|
177
199
|
report(await removeCursorRule({ projectDir: homedir() }));
|
|
178
200
|
report(await removeCursorMcp({ projectDir: homedir() }));
|
|
179
201
|
report(await removeCursorModeCommand({ projectDir: homedir() }));
|
|
202
|
+
report(await removeCursorHooks());
|
|
180
203
|
return;
|
|
181
204
|
}
|
|
182
205
|
const { rule, mcp, mode } = await removeCursor({ projectDir });
|
|
@@ -219,17 +242,17 @@ async function cmdOpencodeUninit(rest) {
|
|
|
219
242
|
// MCP-server wiring and just need the managed policy file dropped.
|
|
220
243
|
async function cmdCodexPolicy(rest) {
|
|
221
244
|
const { projectDir } = parseDirFlag(rest);
|
|
222
|
-
report(await installCodexPolicy({ projectDir }));
|
|
245
|
+
report(await installCodexPolicy({ projectDir, block: (await installBlocks()).plain }));
|
|
223
246
|
}
|
|
224
247
|
|
|
225
248
|
// The user-level policy skill alone: `codex-skill` for Codex without the
|
|
226
249
|
// plugin, `codex-skill-retire` once the plugin (which ships it) is installed.
|
|
227
250
|
async function cmdCodexSkill() {
|
|
228
|
-
report(await installCodexSkill());
|
|
251
|
+
report(await installCodexSkill({ block: (await installBlocks()).plain }));
|
|
229
252
|
}
|
|
230
253
|
|
|
231
254
|
async function cmdCodexSkillRetire() {
|
|
232
|
-
const { removed, backups, kept } = await retireCodexSkill();
|
|
255
|
+
const { removed, backups, kept } = await retireCodexSkill({ block: (await installBlocks()).plain });
|
|
233
256
|
for (const path of removed) process.stdout.write(`✓ Removed duplicate ${path}\n`);
|
|
234
257
|
for (const path of backups) process.stdout.write(`✓ Saved the differing copy to ${path}\n`);
|
|
235
258
|
for (const path of kept) process.stdout.write(`! Left alone (not a copy mcpbox wrote) ${path}\n`);
|
|
@@ -239,7 +262,7 @@ async function cmdCodexSkillRetire() {
|
|
|
239
262
|
async function cmdCursorPolicy(rest) {
|
|
240
263
|
const { projectDir } = parseDirFlag(rest);
|
|
241
264
|
if (isHomeDir(projectDir)) return installCursorHome(homedir());
|
|
242
|
-
report(await installCursorRule({ projectDir }));
|
|
265
|
+
report(await installCursorRule({ projectDir, block: (await installBlocks()).plain }));
|
|
243
266
|
report(await installCursorModeCommand({ projectDir }));
|
|
244
267
|
}
|
|
245
268
|
|
|
@@ -289,13 +312,32 @@ async function cmdDoctor(rest) {
|
|
|
289
312
|
const policy = hierarchy.present;
|
|
290
313
|
const mcp = mcpServerPresent();
|
|
291
314
|
const ready = policy && !hierarchy.duplicate && mcp === true;
|
|
315
|
+
// Which server text this machine holds and when it last asked; blocks are
|
|
316
|
+
// compared with that copy, the baked text only when none was ever fetched.
|
|
317
|
+
const served = {};
|
|
318
|
+
for (const surface of ["claude", "plain"]) {
|
|
319
|
+
const { etag, body, fetchedAt, checkedAt, failedAt } = await readPolicyCache(surface);
|
|
320
|
+
const iso = (t) => (Number.isFinite(t) ? new Date(t).toISOString() : null);
|
|
321
|
+
served[surface] = typeof etag === "string" && typeof body === "string"
|
|
322
|
+
? { etag, fetched_at: iso(fetchedAt), checked_at: iso(checkedAt), failed_at: iso(failedAt), body }
|
|
323
|
+
: null;
|
|
324
|
+
}
|
|
325
|
+
const claudeBlock = served.claude ? versionedBlock(served.claude.body) : BLOCK_BODY;
|
|
326
|
+
const plainBlock = served.plain ? versionedBlock(served.plain.body) : BLOCK_BODY_PLAIN;
|
|
327
|
+
const policyServer = Object.fromEntries(Object.entries(served).map(([k, v]) => {
|
|
328
|
+
if (!v) return [k, null];
|
|
329
|
+
const { body: _, ...meta } = v;
|
|
330
|
+
return [k, meta];
|
|
331
|
+
}));
|
|
292
332
|
// Stale is a warning, not NOT READY: the next SessionStart refreshes it.
|
|
293
|
-
const stale = await stalePolicyPaths(hierarchy.paths);
|
|
333
|
+
const stale = await stalePolicyPaths(hierarchy.paths, claudeBlock);
|
|
294
334
|
// Codex carriers (no Codex hooks exist): AGENTS.md up the tree and the user skill.
|
|
295
335
|
const agents = await policyHierarchy({ projectDir, file: "AGENTS.md" }).catch(() => ({ paths: [] }));
|
|
296
|
-
const agentsStale = await stalePolicyPaths(agents.paths,
|
|
297
|
-
const skill = await syncCodexSkill({ dryRun: true }).catch(() => ({ action: "missing" }));
|
|
336
|
+
const agentsStale = await stalePolicyPaths(agents.paths, plainBlock);
|
|
337
|
+
const skill = await syncCodexSkill({ dryRun: true, block: plainBlock }).catch(() => ({ action: "missing" }));
|
|
298
338
|
const skillStale = skill.action === "stale" ? [skill.path] : [];
|
|
339
|
+
// Cursor rules up the tree carry the same plain text.
|
|
340
|
+
const cursorStale = await syncCursorRules({ cwd: resolve(projectDir ?? process.cwd()), block: plainBlock, dryRun: true });
|
|
299
341
|
// Also a warning: two policies in one file, one of them from the daruma CLI.
|
|
300
342
|
const competing = await competingPolicyPaths({ projectDir });
|
|
301
343
|
// Not required: without it hooks hint at the knowledge instead of loading it.
|
|
@@ -312,7 +354,9 @@ async function cmdDoctor(rest) {
|
|
|
312
354
|
agents_md_paths: agents.paths,
|
|
313
355
|
agents_md_stale_paths: agentsStale,
|
|
314
356
|
codex_skill_stale_paths: skillStale,
|
|
357
|
+
cursor_rule_stale_paths: cursorStale,
|
|
315
358
|
knowledge_paired: paired,
|
|
359
|
+
policy_server: policyServer,
|
|
316
360
|
}) + "\n");
|
|
317
361
|
} else {
|
|
318
362
|
const mark = (v) => (v === true ? "✓" : v === false ? "✗" : "?");
|
|
@@ -320,9 +364,13 @@ async function cmdDoctor(rest) {
|
|
|
320
364
|
`mcpbox MCP server: ${mark(mcp)}${mcp === null ? " (claude CLI not found)" : ""}\n` +
|
|
321
365
|
`CLAUDE.md policy: ${mark(policy)}${hierarchy.duplicate ? " (duplicate managed blocks)" : ""}\n` +
|
|
322
366
|
hierarchy.paths.map((p) => ` ${p}${stale.includes(p) ? " (stale — the next session start of this plugin version refreshes it)" : ""}\n`).join("") +
|
|
367
|
+
Object.entries(policyServer).map(([surface, meta]) => meta
|
|
368
|
+
? ` server text (${surface}): ETag ${meta.etag}, fetched ${meta.fetched_at ?? "?"}, checked ${meta.checked_at ?? "?"}${meta.failed_at ? `, last failure ${meta.failed_at}` : ""}\n`
|
|
369
|
+
: ` server text (${surface}): not fetched yet — blocks carry plugin ${VERSION} text\n`).join("") +
|
|
323
370
|
(agents.paths.length ? `AGENTS.md policy: ✓\n` : "") +
|
|
324
371
|
agents.paths.map((p) => ` ${p}${agentsStale.includes(p) ? " (stale — run: mcpbox-claude codex-init)" : ""}\n`).join("") +
|
|
325
372
|
skillStale.map((p) => ` ${p} (stale — run: mcpbox-claude codex-init)\n`).join("") +
|
|
373
|
+
cursorStale.map((p) => ` ${p} (stale — run: mcpbox-claude cursor-init)\n`).join("") +
|
|
326
374
|
competing.map((p) => ` ! ${p} also holds a daruma CLI policy block — keep one\n`).join("") +
|
|
327
375
|
`Project knowledge: ${paired ? "✓ paired" : "hint only — run: npx -y @mcpbox/mcpbox-claude login"}\n` +
|
|
328
376
|
`${ready ? "READY" : "NOT READY — run: npx @mcpbox/mcpbox setup"}\n`
|
|
@@ -350,6 +398,21 @@ async function cmdExportMarketplace(rest) {
|
|
|
350
398
|
process.stdout.write(`${target}\n`);
|
|
351
399
|
}
|
|
352
400
|
|
|
401
|
+
async function cmdGitHook(rest) {
|
|
402
|
+
const [action = "install", ...flags] = rest;
|
|
403
|
+
const dir = parseDirFlag(flags).projectDir ?? process.cwd();
|
|
404
|
+
if (action === "install") {
|
|
405
|
+
const r = await installGitHook(dir);
|
|
406
|
+
process.stdout.write(r.installed ? `installed ${r.path}\n` : `skipped ${r.path}: ${r.reason}\n`);
|
|
407
|
+
if (!r.installed) process.exitCode = 1;
|
|
408
|
+
} else if (action === "uninstall") {
|
|
409
|
+
const r = await removeGitHook(dir);
|
|
410
|
+
process.stdout.write(r.removed ? `removed ${r.path}\n` : `nothing to remove at ${r.path}\n`);
|
|
411
|
+
} else {
|
|
412
|
+
throw new Error(`git-hook: unknown action ${action} (install|uninstall)`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
353
416
|
async function main(argv) {
|
|
354
417
|
const [, , cmd, ...rest] = argv;
|
|
355
418
|
switch (cmd) {
|
|
@@ -399,6 +462,12 @@ async function main(argv) {
|
|
|
399
462
|
return cmdLogout();
|
|
400
463
|
case "mode":
|
|
401
464
|
return cmdMode(rest);
|
|
465
|
+
case "git-hook":
|
|
466
|
+
return cmdGitHook(rest);
|
|
467
|
+
case "prepare-commit-msg":
|
|
468
|
+
// The git hook shim's fallback when the plugin path moved; never fails a commit.
|
|
469
|
+
await prepareCommitMsg({ messageFile: rest[0] }).catch(() => {});
|
|
470
|
+
return;
|
|
402
471
|
case "export-marketplace":
|
|
403
472
|
return cmdExportMarketplace(rest);
|
|
404
473
|
default:
|
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`
|
|
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).
|
|
12
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.
|
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"
|
|
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).
|
|
11
12
|
If none, stop with "no active plan — decided work: `daruma_plan_materialize`; raw idea: `/mcpbox:pipeline-run`".
|
|
12
|
-
3. For the chosen plan, `daruma_plan_get` (single call — do not enumerate the archive).
|
|
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
|
|
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.
|
package/hooks/hooks.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "mcpbox-claude hooks: proactive session summary, capture/pipeline hints,
|
|
2
|
+
"description": "mcpbox-claude hooks: proactive session summary with this agent's open tasks, capture/pipeline hints, a Stop gate against tasks left open without an outcome comment, and SessionEnd release of this session's claims",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"SessionStart": [
|
|
5
5
|
{
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"type": "command",
|
|
9
9
|
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.mjs\"",
|
|
10
10
|
"timeout": 15
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "command",
|
|
14
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-gate.mjs\" start",
|
|
15
|
+
"timeout": 10
|
|
11
16
|
}
|
|
12
17
|
]
|
|
13
18
|
}
|
|
@@ -53,6 +58,27 @@
|
|
|
53
58
|
"timeout": 15
|
|
54
59
|
}
|
|
55
60
|
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"matcher": ".*daruma_(plan_drain_next|ready_drain|claim|plan_materialize|set_status|comment)$",
|
|
64
|
+
"hooks": [
|
|
65
|
+
{
|
|
66
|
+
"type": "command",
|
|
67
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/track-claims.mjs\"",
|
|
68
|
+
"timeout": 5
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"SessionEnd": [
|
|
74
|
+
{
|
|
75
|
+
"hooks": [
|
|
76
|
+
{
|
|
77
|
+
"type": "command",
|
|
78
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-gate.mjs\" end",
|
|
79
|
+
"timeout": 10
|
|
80
|
+
}
|
|
81
|
+
]
|
|
56
82
|
}
|
|
57
83
|
]
|
|
58
84
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// git prepare-commit-msg: add "Daruma-Task: <id>" for the work/<id> branch or
|
|
3
|
+
// the tasks this agent session claimed. Installed by `mcpbox-claude git-hook
|
|
4
|
+
// install`; any failure leaves the message untouched and the commit proceeds.
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
import { prepareCommitMsg } from "../lib/git-trailer.mjs";
|
|
8
|
+
|
|
9
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
10
|
+
prepareCommitMsg({ messageFile: process.argv[2] }).catch(() => {}).finally(() => process.exit(0));
|
|
11
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Session lifecycle half of the gate, one script for every CLI surface:
|
|
3
|
+
// session-gate.mjs start [--surface=…] SessionStart (also after compaction):
|
|
4
|
+
// print this agent's open tasks.
|
|
5
|
+
// session-gate.mjs end [--surface=…] SessionEnd: release the claims this
|
|
6
|
+
// session still holds.
|
|
7
|
+
// Failures stay silent: the tracker being away never blocks a session.
|
|
8
|
+
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
|
|
11
|
+
import { callCloudTool, readCredentials } from "../lib/cloud-knowledge.mjs";
|
|
12
|
+
import { readStdin } from "../lib/hook-input.mjs";
|
|
13
|
+
import {
|
|
14
|
+
localClaimAgents, openTasksNote, readRecords, sessionIdOf, sessionStartOutput, surfaceOf, validClaims,
|
|
15
|
+
} from "../lib/session-gate.mjs";
|
|
16
|
+
|
|
17
|
+
const TIMEOUT_MS = 2500;
|
|
18
|
+
const DETAIL_MAX = 10;
|
|
19
|
+
|
|
20
|
+
export async function openTasks(cwd, { creds, call = callCloudTool } = {}) {
|
|
21
|
+
const opts = { creds, timeoutMs: TIMEOUT_MS };
|
|
22
|
+
const [info, local, list] = await Promise.all([
|
|
23
|
+
call("daruma_workspace_info", {}, opts).catch(() => null),
|
|
24
|
+
localClaimAgents(),
|
|
25
|
+
call("daruma_list", { status: "in_progress,in_review", scope_path: cwd, limit: 50 }, opts),
|
|
26
|
+
]);
|
|
27
|
+
const items = Array.isArray(list?.items) ? list.items : [];
|
|
28
|
+
// Summary rows carry no claim: read the in_progress ones back to keep only ours.
|
|
29
|
+
const detailed = await Promise.all(items.map((t, i) => (
|
|
30
|
+
t.status === "in_progress" && i < DETAIL_MAX
|
|
31
|
+
? call("daruma_get", { id: t.id }, opts).then((full) => ({ ...t, current_claim: full?.current_claim }), () => t)
|
|
32
|
+
: t
|
|
33
|
+
)));
|
|
34
|
+
// This agent: the pairing token's (workspace_info) and the MCP connections
|
|
35
|
+
// that claimed on this machine (local session records).
|
|
36
|
+
const agents = [info?.mcp_agent_id, ...local].filter(Boolean);
|
|
37
|
+
return openTasksNote(detailed.filter((t) => t.status === "in_review" || t.current_claim), agents);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Claims recorded in this session that the server still shows as ours.
|
|
41
|
+
export function releasable(tasks, claimed) {
|
|
42
|
+
return (Array.isArray(tasks) ? tasks : []).filter((t) => t?.status === "in_progress" && claimed.some(
|
|
43
|
+
(c) => c.task_id === String(t.id) && c.claim_id === t.current_claim?.claim_id && c.agent_id === t.current_claim?.agent_id,
|
|
44
|
+
)).map((t) => String(t.id));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function start(payload, surface) {
|
|
48
|
+
const creds = await readCredentials();
|
|
49
|
+
if (!creds) return;
|
|
50
|
+
const note = await openTasks(payload?.cwd ?? payload?.workspace_roots?.[0] ?? process.cwd(), { creds });
|
|
51
|
+
const out = sessionStartOutput(surface, note);
|
|
52
|
+
if (out) process.stdout.write(typeof out === "string" ? `${out}\n` : `${JSON.stringify(out)}\n`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function end(payload) {
|
|
56
|
+
const sessionId = sessionIdOf(payload);
|
|
57
|
+
if (!sessionId) return;
|
|
58
|
+
const claimed = validClaims(await readRecords(sessionId, "claims"));
|
|
59
|
+
if (!claimed.length) return;
|
|
60
|
+
const creds = await readCredentials();
|
|
61
|
+
if (!creds) return;
|
|
62
|
+
const opts = { creds, timeoutMs: TIMEOUT_MS };
|
|
63
|
+
const ids = [...new Set(claimed.map((c) => c.task_id))];
|
|
64
|
+
const tasks = await Promise.all(ids.map((id) => callCloudTool("daruma_get", { id }, opts).catch(() => null)));
|
|
65
|
+
// The claim's own agent: the hook's pairing token is a different agent than
|
|
66
|
+
// the MCP connection that claimed, and release defaults to the token's.
|
|
67
|
+
await Promise.all(releasable(tasks, claimed).map((task_id) => (
|
|
68
|
+
callCloudTool("daruma_release", { task_id, agent_id: claimed.find((c) => c.task_id === task_id).agent_id }, opts).catch(() => null)
|
|
69
|
+
)));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function main() {
|
|
73
|
+
const event = process.argv[2];
|
|
74
|
+
let payload = {};
|
|
75
|
+
try { payload = JSON.parse((await readStdin()) || "{}"); } catch { /* no payload */ }
|
|
76
|
+
if (event === "start") await start(payload, surfaceOf());
|
|
77
|
+
else if (event === "end") await end(payload);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
81
|
+
main().catch(() => {}).finally(() => {
|
|
82
|
+
process.stdout.write("", () => process.exit(0));
|
|
83
|
+
});
|
|
84
|
+
}
|