@thehammer/danx-dashboard-mcp 0.1.134 → 0.1.136
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/README.md +1 -1
- package/dist/background-work.js +156 -0
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ All exposed as `mcp__danx-dashboard__<name>` once wired through the workspace `m
|
|
|
26
26
|
| `issue_create` | `POST /api/issues` | Epic REQUIRES non-empty `phase_children[]` (atomic insert). `title` = short domain-naming label; `summary` = 1–3 plain-language sentences, always shown; `description` = the collapsed "Context" body. Root and every phase child take their own `summary` |
|
|
27
27
|
| `issue_edit` | `PATCH /api/issues/:id/edit` | Prose + structured keys (`title`, `summary` (null clears), `description`, `ac`, `checklists`, `effort_level`, `parent_id`, `priority`, `list_id`); semantic keys refused with 400 + pointer to dedicated handler. `priority` (DX-1532) takes a tier word (`low`/`high`/…) or a number in `[0,6)` — the ONLY way to set the numeric column the Trello label + dashboard badge read; never set priority via description prose |
|
|
28
28
|
| `issue_transition` | `POST /api/issues/:id/transition` | Actions: ready, pickup, rollback_pickup, complete, cancel, block, unblock, archive, reopen. `block` is a dispatch hold only — it never marks the card as needing a human; use `issue_problem` add for that |
|
|
29
|
-
| `issue_problem` | `GET/POST/PATCH/DELETE /api/issues/:id/problems[/:pid]` | Actions list / add / edit / remove. A problem is one statement the operator must resolve (a question or a plan flaw) with its own solutions and answers; `add` takes `statement` + optional `solutions[]` in one transaction and IS what puts the card in front of a human (`open_problem_count > 0`) — a successful add also returns `
|
|
29
|
+
| `issue_problem` | `GET/POST/PATCH/DELETE /api/issues/:id/problems[/:pid]` | Actions list / add / edit / remove. A problem is one statement the operator must resolve (a question or a plan flaw) with its own solutions and answers; `add` takes `statement` + optional `solutions[]` in one transaction and IS what puts the card in front of a human (`open_problem_count > 0`) — a successful add also returns a `reminders: [{key, text}]` array (DX-3365 — the reminder registry's middleware, DB-driven and operator-overridable from the dashboard). Edit + remove are hash-guarded (`base_hash`, 409 `stale_problem`); removing the card's last open problem is always allowed — it just means the card no longer needs a human |
|
|
30
30
|
| `issue_solution` | `POST/PATCH/DELETE /api/issues/:id/problems/:pid/solutions[/:sid]` | Actions add / edit / remove, `problem_id` required (list via `issue_problem list`). Edit + remove are hash-guarded (`base_hash`, 409 `stale_solution` with the current row); at most one live `recommended` per problem; a chosen option cannot be edited. No answer action on any tool — the operator answers in the dashboard |
|
|
31
31
|
| `issue_triage` | `POST /api/issues/:id/triage` | Send `{confidence, reason}` — an integer 0-5 score; the server computes the verdict (approve/cancel/keep/defer) against the board's configured thresholds (DX-2086). `keep`/`defer` now block the card. None of these are a cross-card ordering gate; use `issue_dependency` to sequence cards |
|
|
32
32
|
| `issue_comment` | `POST/PATCH/DELETE /api/issues/:id/comments[/:cid]` | Author server-stamped, soft-delete preserved |
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `danx-dashboard-mcp background-work <count|clear>` — the ONE-SHOT client of
|
|
3
|
+
* `PUT /api/plan-sessions/me/background-work` (DX-3367).
|
|
4
|
+
*
|
|
5
|
+
* WHO RUNS IT. The danxbot Claude Code plugin's `Stop` / `SubagentStop` /
|
|
6
|
+
* `SessionStart` / `StopFailure` hooks (`danxbot/hooks/hooks.json` in
|
|
7
|
+
* claude-plugins), via the SAME `npx -y @thehammer/danx-dashboard-mcp` pin
|
|
8
|
+
* the plugin already uses for `bridge` and `plan-state` — no separate
|
|
9
|
+
* install, no deep import of this package's `dist/` internals. The plugin
|
|
10
|
+
* decides WHAT to report (parsing `Stop`/`SubagentStop`'s own
|
|
11
|
+
* `background_tasks` snapshot, counting only `shell` / `subagent` /
|
|
12
|
+
* `workflow` entries, sending `clear` on `SessionStart`/`StopFailure`); this
|
|
13
|
+
* module only delivers the report.
|
|
14
|
+
*
|
|
15
|
+
* THE CONTRACT, mirroring `plan-state.ts`'s (binding the same way, so a
|
|
16
|
+
* future plugin build against this module can trust it without re-reading
|
|
17
|
+
* this file):
|
|
18
|
+
* - print EXACTLY ONE JSON line on stdout, and ALWAYS exit 0 — success or
|
|
19
|
+
* failure alike, because a hook must stay silent rather than spam the
|
|
20
|
+
* session's own turn with a stack trace;
|
|
21
|
+
* - a session with no connection record (never `plan_connect`-ed, e.g. an
|
|
22
|
+
* operator session that never joined a plan) is a silent, expected
|
|
23
|
+
* no-op — `{"ok":false,"reason":"no_connection_record"}` — the plugin
|
|
24
|
+
* hook simply does not forward anything further in this case, exactly
|
|
25
|
+
* what "no-op when the session isn't plan-connected" means in practice;
|
|
26
|
+
* - on success, `{"ok":true,"count":<number|null>}` echoes what was
|
|
27
|
+
* stored;
|
|
28
|
+
* - human-readable diagnostics go to stderr only, never stdout.
|
|
29
|
+
*
|
|
30
|
+
* THE CREDENTIAL — the SAME resolver `bridge` and `plan-state` use, via
|
|
31
|
+
* `resolveBridgeOptions` (`bridge.ts`): the dashboard URL, credential
|
|
32
|
+
* source, and credential come from the connection record this session's OWN
|
|
33
|
+
* danx-dashboard MCP server wrote on its last successful `plan_connect`
|
|
34
|
+
* (`session-connection.ts`), never from this process's own ambient env —
|
|
35
|
+
* the identical DX-2862 reasoning `plan-state.ts` already gives for itself.
|
|
36
|
+
*
|
|
37
|
+
* A HARD TIMEOUT — `BACKGROUND_WORK_REQUEST_TIMEOUT_MS`. A `Stop` hook
|
|
38
|
+
* blocks the session's turn boundary, so this call must never hang: a slow
|
|
39
|
+
* or wedged dashboard is `{ok:false, reason:"timeout"}`, not a stuck hook.
|
|
40
|
+
*/
|
|
41
|
+
import { SESSION_ID_HEADER, resolveBridgeOptions } from "./bridge.js";
|
|
42
|
+
export const BACKGROUND_WORK_SUBCOMMAND = "background-work";
|
|
43
|
+
export const BACKGROUND_WORK_PATH = "/api/plan-sessions/me/background-work";
|
|
44
|
+
/** How long this one-shot call may take before it counts as a timeout. */
|
|
45
|
+
export const BACKGROUND_WORK_REQUEST_TIMEOUT_MS = 5_000;
|
|
46
|
+
const USAGE = `usage: CLAUDE_CODE_SESSION_ID=<session-id> danx-dashboard-mcp ${BACKGROUND_WORK_SUBCOMMAND} <non-negative-integer|clear>`;
|
|
47
|
+
/**
|
|
48
|
+
* Parse the ONE positional argument: `clear`, or a non-negative integer
|
|
49
|
+
* string. Anything else is a usage error — never guessed or floored.
|
|
50
|
+
*/
|
|
51
|
+
export function parseCountArg(raw) {
|
|
52
|
+
if (raw === "clear")
|
|
53
|
+
return null;
|
|
54
|
+
if (!/^\d+$/.test(raw))
|
|
55
|
+
return { error: `count must be "clear" or a non-negative integer, got "${raw}"` };
|
|
56
|
+
return Number.parseInt(raw, 10);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One authenticated PUT, with a hard timeout, classified into the output
|
|
60
|
+
* shape this subcommand always prints — never a throw, never a non-2xx
|
|
61
|
+
* bubbling past this function.
|
|
62
|
+
*/
|
|
63
|
+
export async function putBackgroundWork(options, count, deps) {
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
const timer = setTimeout(() => controller.abort(), deps.requestTimeoutMs);
|
|
66
|
+
let status;
|
|
67
|
+
let text;
|
|
68
|
+
try {
|
|
69
|
+
try {
|
|
70
|
+
const response = await deps.fetch(`${options.dashboardUrl}${BACKGROUND_WORK_PATH}`, {
|
|
71
|
+
method: "PUT",
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: `Bearer ${options.token}`,
|
|
74
|
+
Accept: "application/json",
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
[SESSION_ID_HEADER]: options.sessionId,
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify({ count }),
|
|
79
|
+
signal: controller.signal,
|
|
80
|
+
});
|
|
81
|
+
status = response.status;
|
|
82
|
+
text = await response.text();
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
return { ok: false, reason: controller.signal.aborted ? "timeout" : "request_failed" };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
}
|
|
91
|
+
let body = null;
|
|
92
|
+
try {
|
|
93
|
+
body = text === "" ? null : JSON.parse(text);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return { ok: false, reason: "bad_response" };
|
|
97
|
+
}
|
|
98
|
+
if (status === 401 || status === 403) {
|
|
99
|
+
return { ok: false, reason: "unauthorized" };
|
|
100
|
+
}
|
|
101
|
+
if (status < 200 || status >= 300) {
|
|
102
|
+
return { ok: false, reason: "http_error" };
|
|
103
|
+
}
|
|
104
|
+
if (typeof body !== "object" ||
|
|
105
|
+
body === null ||
|
|
106
|
+
!("count" in body) ||
|
|
107
|
+
(body.count !== null && typeof body.count !== "number")) {
|
|
108
|
+
return { ok: false, reason: "bad_response" };
|
|
109
|
+
}
|
|
110
|
+
return { ok: true, count: body.count };
|
|
111
|
+
}
|
|
112
|
+
/** The bin's `background-work` subcommand, wired to the real process. Always resolves to exit code 0. */
|
|
113
|
+
export async function runBackgroundWorkCommand(argv, env = process.env,
|
|
114
|
+
/** Test seam: the home the session's connection record is read from. */
|
|
115
|
+
resolveFrom = {}) {
|
|
116
|
+
const write = (output) => {
|
|
117
|
+
process.stdout.write(`${JSON.stringify(output)}\n`);
|
|
118
|
+
};
|
|
119
|
+
if (argv.length !== 1) {
|
|
120
|
+
write({ ok: false, reason: "usage" });
|
|
121
|
+
process.stderr.write(`${USAGE}\n`);
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
const parsed = parseCountArg(argv[0]);
|
|
125
|
+
if (typeof parsed === "object" && parsed !== null && "error" in parsed) {
|
|
126
|
+
write({ ok: false, reason: "usage" });
|
|
127
|
+
process.stderr.write(`${parsed.error}\n${USAGE}\n`);
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
const count = parsed;
|
|
131
|
+
const sessionId = env.CLAUDE_CODE_SESSION_ID;
|
|
132
|
+
if (!sessionId) {
|
|
133
|
+
write({ ok: false, reason: "no_session_id" });
|
|
134
|
+
process.stderr.write(`${USAGE}\n`);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
let options;
|
|
138
|
+
try {
|
|
139
|
+
options = resolveBridgeOptions({ sessionId, resumeIds: [] }, env, resolveFrom);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
const start = err;
|
|
143
|
+
// A session that never `plan_connect`-ed has no connection record — this
|
|
144
|
+
// is the ORDINARY "not plan-connected" case, not an error the plugin
|
|
145
|
+
// should surface: it simply forwards nothing further this turn.
|
|
146
|
+
write({ ok: false, reason: start.reason });
|
|
147
|
+
process.stderr.write(`${start.reason}: ${start.message}. Fix: ${start.fix}.\n`);
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
const output = await putBackgroundWork(options, count, {
|
|
151
|
+
fetch: (input, init) => fetch(input, init),
|
|
152
|
+
requestTimeoutMs: BACKGROUND_WORK_REQUEST_TIMEOUT_MS,
|
|
153
|
+
});
|
|
154
|
+
write(output);
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
import { isEntrypointModule } from "./entrypoint.js";
|
|
97
97
|
import { BRIDGE_SUBCOMMAND, runBridgeCommand } from "./bridge.js";
|
|
98
98
|
import { PLAN_STATE_SUBCOMMAND, runPlanStateCommand } from "./plan-state.js";
|
|
99
|
+
import { BACKGROUND_WORK_SUBCOMMAND, runBackgroundWorkCommand } from "./background-work.js";
|
|
99
100
|
import { resolveDeclaredCredential } from "./credential.js";
|
|
100
101
|
import { recordSessionConnectionAfterConnect } from "./session-connection.js";
|
|
101
102
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -1180,9 +1181,16 @@ if (isEntrypointModule(import.meta.url, process.argv[1])) {
|
|
|
1180
1181
|
process.exit(0);
|
|
1181
1182
|
});
|
|
1182
1183
|
}
|
|
1184
|
+
else if (subcommand === BACKGROUND_WORK_SUBCOMMAND) {
|
|
1185
|
+
runBackgroundWorkCommand(rest).then((code) => process.exit(code), (err) => {
|
|
1186
|
+
console.error(`[danx-dashboard-mcp] background-work fatal: ${err.message}`);
|
|
1187
|
+
process.stdout.write(`${JSON.stringify({ ok: false, reason: "fatal" })}\n`);
|
|
1188
|
+
process.exit(0);
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1183
1191
|
else if (subcommand !== undefined) {
|
|
1184
1192
|
console.error(`[danx-dashboard-mcp] unknown subcommand "${subcommand}" (the only ones are ` +
|
|
1185
|
-
`"${BRIDGE_SUBCOMMAND}" and "${
|
|
1193
|
+
`"${BRIDGE_SUBCOMMAND}", "${PLAN_STATE_SUBCOMMAND}", and "${BACKGROUND_WORK_SUBCOMMAND}")`);
|
|
1186
1194
|
process.exit(2);
|
|
1187
1195
|
}
|
|
1188
1196
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thehammer/danx-dashboard-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.136",
|
|
4
4
|
"description": "Stdio MCP server wrapping danxbot's dashboard /api/issues/* normalized DB-backed HTTP routes for dispatched agents (DX-704 Phase 2).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|