@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
package/lib/update-check.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { DEFAULT_BASE_URL, normalizeBaseUrl, readCredentials } from "./cloud-knowledge.mjs";
|
|
5
|
+
import { BLOCK_BODY, BLOCK_BODY_PLAIN, versionedBlock } from "./policy.mjs";
|
|
6
|
+
import { VERSION } from "./version.mjs";
|
|
4
7
|
|
|
5
8
|
const REGISTRY_URL = "https://registry.npmjs.org/@mcpbox/mcpbox-claude";
|
|
6
9
|
const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -64,6 +67,117 @@ export async function checkForUpdate({
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
// The managed policy block as the server holds it now (GET /v1/policy/{surface}).
|
|
71
|
+
// Invalidation is the ETag alone: every call is one conditional request, and
|
|
72
|
+
// 304 means nothing is downloaded — no TTL guessing which copy is fresh.
|
|
73
|
+
// Failures back off for FAILED_TTL_MS and fall back to the last copy (an old
|
|
74
|
+
// copy beats none); null means no server copy was ever seen, so the caller
|
|
75
|
+
// writes the text baked into the plugin. MCPBOX_NO_POLICY_FETCH=1 opts out.
|
|
76
|
+
// One cache file per surface: the hook fetches both surfaces at once.
|
|
77
|
+
// Result: { surface, etag, body, fetchedAt, checkedAt, source }, where source is
|
|
78
|
+
// "server" (downloaded), "server-unchanged" (304) or "cache" (server unreachable).
|
|
79
|
+
const POLICY_MAX_BYTES = 64 * 1024;
|
|
80
|
+
|
|
81
|
+
export function policyCachePath(surface, home = homedir()) {
|
|
82
|
+
return join(home, ".agents", "mcpbox", `policy-${surface}.json`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A served body must fit between the managed markers and carry no version
|
|
86
|
+
// line of its own (the writing plugin adds it).
|
|
87
|
+
function acceptablePolicyBody(body) {
|
|
88
|
+
return typeof body === "string"
|
|
89
|
+
&& body.trim().length > 0
|
|
90
|
+
&& Buffer.byteLength(body) <= POLICY_MAX_BYTES
|
|
91
|
+
&& !body.includes("<!-- mcpbox:policy:")
|
|
92
|
+
&& !body.includes("<!-- mcpbox-claude:policy-version");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function readPolicyCache(surface, home = homedir()) {
|
|
96
|
+
try {
|
|
97
|
+
const cached = JSON.parse(await readFile(policyCachePath(surface, home), "utf8"));
|
|
98
|
+
return cached && typeof cached === "object" ? cached : {};
|
|
99
|
+
} catch {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// The server copy already on disk, without asking the server; null if none.
|
|
105
|
+
function knownPolicy(surface, cached) {
|
|
106
|
+
return typeof cached.etag === "string" && acceptablePolicyBody(cached.body)
|
|
107
|
+
? { surface, etag: cached.etag, body: cached.body, fetchedAt: cached.fetchedAt, checkedAt: cached.checkedAt }
|
|
108
|
+
: null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function cachedPolicyBody(surface, home = homedir()) {
|
|
112
|
+
const known = knownPolicy(surface, await readPolicyCache(surface, home));
|
|
113
|
+
return known && { ...known, source: "cache" };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function fetchPolicyBody(surface, {
|
|
117
|
+
baseUrl = DEFAULT_BASE_URL,
|
|
118
|
+
home = homedir(),
|
|
119
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
120
|
+
} = {}) {
|
|
121
|
+
if (process.env.MCPBOX_NO_POLICY_FETCH) return null;
|
|
122
|
+
const cacheFile = policyCachePath(surface, home);
|
|
123
|
+
const cached = await readPolicyCache(surface, home);
|
|
124
|
+
const known = knownPolicy(surface, cached);
|
|
125
|
+
const fallback = known && { ...known, source: "cache" };
|
|
126
|
+
if (Number.isFinite(cached.failedAt) && Date.now() - cached.failedAt < FAILED_TTL_MS) return fallback;
|
|
127
|
+
try {
|
|
128
|
+
const response = await fetch(`${normalizeBaseUrl(baseUrl)}/v1/policy/${surface}`, {
|
|
129
|
+
headers: {
|
|
130
|
+
Accept: "text/markdown",
|
|
131
|
+
"X-Daruma-Plugin-Contract": "1",
|
|
132
|
+
...(known ? { "If-None-Match": known.etag } : {}),
|
|
133
|
+
},
|
|
134
|
+
redirect: "error",
|
|
135
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
136
|
+
});
|
|
137
|
+
const checkedAt = Date.now();
|
|
138
|
+
let result;
|
|
139
|
+
if (response.status === 304 && known) {
|
|
140
|
+
result = { ...known, checkedAt, source: "server-unchanged" };
|
|
141
|
+
} else if (response.status === 200) {
|
|
142
|
+
const etag = response.headers.get("etag");
|
|
143
|
+
const body = await response.text();
|
|
144
|
+
if (!etag || !acceptablePolicyBody(body)) throw new Error("invalid policy response");
|
|
145
|
+
result = { surface, etag, body, fetchedAt: checkedAt, checkedAt, source: "server" };
|
|
146
|
+
} else {
|
|
147
|
+
throw new Error(`policy returned ${response.status}`);
|
|
148
|
+
}
|
|
149
|
+
const { source: _, ...entry } = result;
|
|
150
|
+
await writeCache(cacheFile, entry).catch(() => {});
|
|
151
|
+
return result;
|
|
152
|
+
} catch {
|
|
153
|
+
await writeCache(cacheFile, { ...cached, failedAt: Date.now() }).catch(() => {});
|
|
154
|
+
return fallback;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Block text every carrier writes — CLAUDE.md (claude), and AGENTS.md, the
|
|
159
|
+
// Codex SKILL.md and the Cursor .mdc (plain): the server's copy when one was
|
|
160
|
+
// ever fetched, else the text baked into this plugin. Three carriers, one
|
|
161
|
+
// text, the server wins. `fetch: false` (install commands) reads only the
|
|
162
|
+
// copy on disk: asking the server is the session start's job, and an install
|
|
163
|
+
// stays offline and deterministic. A paired machine asks the server it is
|
|
164
|
+
// paired with. `origin` names where the text came from.
|
|
165
|
+
export async function policyBlocks({ fetch = true, home = homedir() } = {}) {
|
|
166
|
+
const baseUrl = fetch ? (await readCredentials())?.base_url ?? DEFAULT_BASE_URL : null;
|
|
167
|
+
const [claude, plain] = await Promise.all(["claude", "plain"].map((surface) => (fetch
|
|
168
|
+
? fetchPolicyBody(surface, { baseUrl, home })
|
|
169
|
+
: cachedPolicyBody(surface, home)).catch(() => null)));
|
|
170
|
+
// Each surface's ETag: the plain carriers hold a different text than CLAUDE.md.
|
|
171
|
+
const served = Object.entries({ claude, plain }).filter(([, copy]) => copy);
|
|
172
|
+
return {
|
|
173
|
+
claude: claude ? versionedBlock(claude.body) : BLOCK_BODY,
|
|
174
|
+
plain: plain ? versionedBlock(plain.body) : BLOCK_BODY_PLAIN,
|
|
175
|
+
origin: served.length
|
|
176
|
+
? `server policy ${served.map(([surface, copy]) => `${copy.etag} (${surface})`).join(", ")}`
|
|
177
|
+
: `plugin ${VERSION}`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
67
181
|
async function writeCache(cacheFile, value) {
|
|
68
182
|
await mkdir(dirname(cacheFile), { recursive: true });
|
|
69
183
|
await writeFile(cacheFile, `${JSON.stringify(value)}\n`);
|
package/lib/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.28";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpbox/mcpbox-claude",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
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": {
|
package/skills/mcpbox/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mcpbox
|
|
|
3
3
|
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`.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- mcpbox-claude:policy-version 0.1.
|
|
6
|
+
<!-- mcpbox-claude:policy-version 0.1.28 -->
|
|
7
7
|
# MCPBox — default agent stack
|
|
8
8
|
|
|
9
9
|
The **mcpbox** MCP server (`https://mcpbox.ru/v1/mcp`) is this workspace's task
|
|
@@ -18,13 +18,15 @@ tracker. "Daruma", "дарума", "трекер", "tracker", "таск-мене
|
|
|
18
18
|
"Составь план", "Распланируй", "make/write/create a plan" — or about to
|
|
19
19
|
answer with a plan, step list or task breakdown for it, in Plan mode too —
|
|
20
20
|
first create it with `daruma_plan_materialize`, then reply with a short
|
|
21
|
-
summary and the plan id; never a plan only as chat text.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`
|
|
21
|
+
summary and the plan id; never a plan only as chat text. Same subject as a
|
|
22
|
+
plan (follow-up, check, commit): its `plan.id` — a completed plan reopens;
|
|
23
|
+
another subject gets its own plan even on one branch/source;
|
|
24
|
+
`plan_choice_required`: pick by subject. `plan.source` = nearest source of
|
|
25
|
+
this request (meeting, message; chat: a label), `upstream` to the issue, not
|
|
26
|
+
the broadest umbrella; never invent links. In git: `plan.git_context.repo`,
|
|
27
|
+
`plan.git_context.branch`. A decided GitLab/GitHub/Jira issue or work item is
|
|
28
|
+
a source, not a second tracker: `plan.source.ref` = its URL, then
|
|
29
|
+
`daruma_plan_drain_next` → `daruma_complete`.
|
|
28
30
|
|
|
29
31
|
Roles: GitLab/GitHub/Jira holds the request itself (the issue or work item);
|
|
30
32
|
mcpbox extends it and holds the small technical tasks nobody files there.
|
|
@@ -85,7 +87,7 @@ it at once; two active tasks need the human's call or a `relates_to` link.
|
|
|
85
87
|
how eagerly to suggest `mcpbox_pipeline_run`: `off` never, `lite` only when asked, `full` for any substantive request. To change it, run
|
|
86
88
|
`npx -y @mcpbox/mcpbox-claude@latest mode <value>` and report the result.
|
|
87
89
|
|
|
88
|
-
Routing. 0) An action (run,
|
|
90
|
+
Routing. 0) An action (run, check, answer) leaves nothing to track: do it, record NOTHING. 1) Decided work: daruma_plan_materialize; same subject as a plan (its follow-up, check, commit): plan.id, a completed one reopens; other subject: own plan even on one branch/source. 2) Pipeline run follow-up: status=handed_off → rule 1 + daruma_link to task_id; not handed off yet: finish it first. 3) Raw idea: mcpbox_pipeline_run, then mcpbox_pipeline_handoff — never straight into daruma; handoff is rejected: explain why, never work around it. Can't tell 1 from 3: take 1; pipeline only if the user asks or mode=full.
|
|
89
91
|
|
|
90
92
|
### Useful requests
|
|
91
93
|
|
|
@@ -9,11 +9,13 @@ to the user/agent to actually execute it.
|
|
|
9
9
|
## Steps
|
|
10
10
|
|
|
11
11
|
1. Resolve project (`daruma_workspace_info` → `default_project`).
|
|
12
|
-
2. Active plan: `daruma_plan_list`
|
|
12
|
+
2. Active plan: `daruma_plan_list` with `status = "active"`, `sort = "updated"`,
|
|
13
|
+
`limit = 1` — the most recently updated plan (the default order is by creation).
|
|
13
14
|
If none, stop with "no active plan — decided work: `daruma_plan_materialize`; raw idea: `/mcpbox:pipeline-run`".
|
|
14
15
|
3. `daruma_plan_drain_next` with the plan id. The server atomically picks the next
|
|
15
16
|
ready (unblocked) task and claims it for this session; it returns null when no
|
|
16
|
-
unclaimed ready task remains.
|
|
17
|
+
unclaimed ready task remains. Keep the returned `run_id`: the server opened that
|
|
18
|
+
run for this claim. A null drain already aborted its own run — nothing to close.
|
|
17
19
|
4. If "no ready task": print the server reason (e.g. "3 tasks blocked by X") and
|
|
18
20
|
suggest `/mcpbox:plan` to inspect dependencies. Stop.
|
|
19
21
|
5. Otherwise render the briefing:
|
|
@@ -23,6 +25,7 @@ to the user/agent to actually execute it.
|
|
|
23
25
|
|
|
24
26
|
id: <task_id>
|
|
25
27
|
plan: <plan_id>
|
|
28
|
+
run: <run_id>
|
|
26
29
|
priority: <pX>
|
|
27
30
|
status: 🟢 in_progress
|
|
28
31
|
```
|
|
@@ -33,7 +36,12 @@ to the user/agent to actually execute it.
|
|
|
33
36
|
|
|
34
37
|
```
|
|
35
38
|
→ When done: daruma_complete id=<task_id> [result_summary="<summary>"]
|
|
39
|
+
then daruma_run_complete run_id=<run_id>
|
|
36
40
|
→ On failure: daruma_set_status status=todo comment={ body, kind: "blocker" }
|
|
41
|
+
then daruma_run_abort run_id=<run_id> reason=<reason>
|
|
37
42
|
```
|
|
38
43
|
|
|
44
|
+
An open run keeps the plan from auto-closing after its last task; the
|
|
45
|
+
`plan_close_blocked_by_run` warning names it in `details.run_id`.
|
|
46
|
+
|
|
39
47
|
7. Briefing only — do not start executing the task in this command.
|
|
@@ -8,19 +8,22 @@ The user invoked `/mcpbox:plan`.
|
|
|
8
8
|
## Steps
|
|
9
9
|
|
|
10
10
|
1. Resolve project (`daruma_workspace_info` → `default_project`).
|
|
11
|
-
2. `daruma_plan_list status="draft,active"
|
|
11
|
+
2. `daruma_plan_list status="draft,active" sort="updated" limit=1` — the most recently
|
|
12
|
+
updated plan (the default order is by creation, and its first page can miss it).
|
|
12
13
|
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` (single call — do not enumerate the archive).
|
|
14
|
+
3. For the chosen plan, `daruma_plan_get view="tasks"` (single call — do not enumerate the archive).
|
|
15
|
+
It lists every plan task (done included) with `status`, `priority`, `depends_on` and
|
|
16
|
+
`blocked_by`; the default `progress` view caps each group at five open tasks.
|
|
14
17
|
4. Render:
|
|
15
18
|
|
|
16
19
|
```
|
|
17
20
|
## <plan title>
|
|
18
|
-
goal: <goal>
|
|
19
21
|
progress: [████░░░░] 4/9 done
|
|
20
22
|
|
|
21
23
|
| # | Status | Pri | Task | Depends on |
|
|
22
24
|
|---|--------|-----|------|-----------|
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
- Progress bar from
|
|
27
|
+
- Progress bar from `progress.tasks_done`/`progress.tasks_total`; one row per task in plan order.
|
|
28
|
+
- Tasks with a non-empty `blocked_by` marked ⛔ with those blocker ids.
|
|
26
29
|
5. Do not call `daruma_plan_list status=completed` (token-heavy). Read-only.
|