@productbrain/mcp 0.0.1-beta.16389 → 0.0.1-beta.16412
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.
|
@@ -7120,6 +7120,7 @@ import { readFileSync as readFileSync3 } from "fs";
|
|
|
7120
7120
|
var WORKSPACE_SCOPE_BINDING_VERSION = 1;
|
|
7121
7121
|
var WORKSPACE_SCOPE_RELATIVE_PATH = ".productbrain/.local/workspace-scope.json";
|
|
7122
7122
|
var BOUND_PACKAGE_ID = /^(?:WP|BET)-\d+$/;
|
|
7123
|
+
var BIND_REASON_PASSED = ["none", "open-pull-requests", "pull-requests-not-read"];
|
|
7123
7124
|
var WorkspaceCompletionError = class extends Error {
|
|
7124
7125
|
name = "WorkspaceCompletionError";
|
|
7125
7126
|
};
|
|
@@ -7136,6 +7137,14 @@ function normalizeOwnedSliceIds(value) {
|
|
|
7136
7137
|
if (bad >= 0) throw new WorkspaceCompletionError(`${String(value[bad])} is not a TASK-NNN id; a workspace owns tasks only (ownedSliceIds).`);
|
|
7137
7138
|
return [...new Set(value)];
|
|
7138
7139
|
}
|
|
7140
|
+
function parseReason(value) {
|
|
7141
|
+
const passed = isRecord(value) ? BIND_REASON_PASSED.find((p) => p === value["passed"]) : void 0;
|
|
7142
|
+
const open = isRecord(value) ? value["open"] : void 0;
|
|
7143
|
+
if (!isRecord(value) || !passed || !Array.isArray(open) || !open.every((n) => Number.isInteger(n) && n > 0)) {
|
|
7144
|
+
throw new WorkspaceCompletionError("Workspace scope binding has no valid reason.");
|
|
7145
|
+
}
|
|
7146
|
+
return { text: requiredString(value["text"], "reason"), passed, open, ...value["atLimit"] === true ? { atLimit: true } : {} };
|
|
7147
|
+
}
|
|
7139
7148
|
function parseWorkspaceScopeBinding(raw) {
|
|
7140
7149
|
let parsed;
|
|
7141
7150
|
try {
|
|
@@ -7155,10 +7164,12 @@ function parseWorkspaceScopeBinding(raw) {
|
|
|
7155
7164
|
scopeName: requiredString(parsed["scopeName"], "scopeName"),
|
|
7156
7165
|
chainWorkspaceId: requiredString(parsed["chainWorkspaceId"], "chainWorkspaceId"),
|
|
7157
7166
|
boundAt,
|
|
7158
|
-
..."ownedSliceIds" in parsed ? { ownedSliceIds: normalizeOwnedSliceIds(parsed["ownedSliceIds"]) } : {}
|
|
7167
|
+
..."ownedSliceIds" in parsed ? { ownedSliceIds: normalizeOwnedSliceIds(parsed["ownedSliceIds"]) } : {},
|
|
7168
|
+
..."reason" in parsed ? { reason: parseReason(parsed["reason"]) } : {}
|
|
7159
7169
|
};
|
|
7160
7170
|
}
|
|
7161
7171
|
var BIND_AGAIN = "npm run workspace:bind -- <WP-ID> [TASK-ID ...]";
|
|
7172
|
+
var GH_NOT_INSTALLED = "gh is not installed";
|
|
7162
7173
|
var BOUND_SCOPE_WORDS = {
|
|
7163
7174
|
heading: "## Bound scope",
|
|
7164
7175
|
// a task's ticks and "no stage" come from WORK_PACKAGE_LIST_WORDS, shared with the brief's rows (TASK-1872)
|
|
@@ -7169,10 +7180,19 @@ var BOUND_SCOPE_WORDS = {
|
|
|
7169
7180
|
wholePackage: "No tasks named at bind: the lane owns the whole package.",
|
|
7170
7181
|
pr: (branch, pr) => `Open PR on ${branch}: #${pr.number} at ${pr.headSha.slice(0, 9)} \xB7 ${pr.labels.join(", ") || "no labels"}`,
|
|
7171
7182
|
noPr: (branch) => `No open PR on ${branch}.`,
|
|
7172
|
-
prsNotRead: (reason2) => `
|
|
7173
|
-
|
|
7183
|
+
prsNotRead: (reason2) => `Pull requests not read: ${reason2}.`,
|
|
7184
|
+
// DEC-2928 point 28
|
|
7185
|
+
/** The cause clause pb orient and workspace:bind both print; each adds its own way out (DEC-2928 point 21). */
|
|
7186
|
+
ghNotInstalled: GH_NOT_INSTALLED,
|
|
7187
|
+
ghMissing: `${GH_NOT_INSTALLED}; install gh, or read the pull requests on GitHub`,
|
|
7174
7188
|
/** gh's own first line; the auth step only when that line is about signing in. */
|
|
7175
7189
|
ghFailed: (detail) => `gh failed (${detail})${/auth|log ?in|token|credential/i.test(detail) ? "; gh auth status says whether it is signed in" : ""}`,
|
|
7190
|
+
/** The causes of a gh read that ran but gave no list: ghFailed's detail, in pb orient and workspace:bind (DEC-2928 point 15). */
|
|
7191
|
+
noAnswer: "no answer in time",
|
|
7192
|
+
notAList: (message) => `its answer was not a list of pull requests: ${message}`,
|
|
7193
|
+
// DEC-2928 point 22
|
|
7194
|
+
/** The reason a first bind was given, as its bind file holds it (DEC-2928 point 9). */
|
|
7195
|
+
reason: (text) => `Bound with a reason: ${text}`,
|
|
7176
7196
|
noBranch: "this worktree is on no branch; check out the lane branch",
|
|
7177
7197
|
/** The bind file does not parse: orient prints fileError, workspace:done its parts (RULE-664). */
|
|
7178
7198
|
fileNotRead: "The bind file could not be read.",
|
|
@@ -7181,12 +7201,15 @@ var BOUND_SCOPE_WORDS = {
|
|
|
7181
7201
|
fileError: (message) => `${BOUND_SCOPE_WORDS.fileNotRead} ${WORKSPACE_SCOPE_RELATIVE_PATH}: ${message} ${BOUND_SCOPE_WORDS.fileFix}: ${BIND_AGAIN}`
|
|
7182
7202
|
};
|
|
7183
7203
|
var TIMEOUT_MS = { git: 3e3, gh: 8e3 };
|
|
7204
|
+
function failedRun(error, stderr) {
|
|
7205
|
+
const timedOut = error.killed === true || error.code === "ETIMEDOUT";
|
|
7206
|
+
const detail = (stderr.trim().split("\n")[0] || (timedOut ? BOUND_SCOPE_WORDS.noAnswer : error.message)).trim();
|
|
7207
|
+
return { ok: false, detail, ...error.code === "ENOENT" ? { missing: true } : {} };
|
|
7208
|
+
}
|
|
7184
7209
|
function nodeBoundScopeIo(cwd, readEntries) {
|
|
7185
7210
|
const run = (command, args, dir) => new Promise((resolve5) => {
|
|
7186
7211
|
execFile(command, args, { cwd: dir, timeout: TIMEOUT_MS[command], encoding: "utf8", windowsHide: true }, (error, stdout, stderr) => {
|
|
7187
|
-
|
|
7188
|
-
const detail = (stderr.trim().split("\n")[0] || (error.killed ? "no answer in time" : error.message)).trim();
|
|
7189
|
-
resolve5({ ok: false, detail, ...error.code === "ENOENT" ? { missing: true } : {} });
|
|
7212
|
+
resolve5(error ? failedRun(error, stderr) : { ok: true, stdout });
|
|
7190
7213
|
});
|
|
7191
7214
|
});
|
|
7192
7215
|
const readText = (path) => {
|
|
@@ -7235,7 +7258,7 @@ async function readPrs(io, root, branch) {
|
|
|
7235
7258
|
}))
|
|
7236
7259
|
};
|
|
7237
7260
|
} catch (error) {
|
|
7238
|
-
return { prsNotRead: BOUND_SCOPE_WORDS.ghFailed(
|
|
7261
|
+
return { prsNotRead: BOUND_SCOPE_WORDS.ghFailed(BOUND_SCOPE_WORDS.notAList(messageOf(error))) };
|
|
7239
7262
|
}
|
|
7240
7263
|
}
|
|
7241
7264
|
async function readBoundScope(io) {
|
|
@@ -7252,7 +7275,14 @@ async function readBoundScope(io) {
|
|
|
7252
7275
|
}
|
|
7253
7276
|
const branch = head && head !== "HEAD" ? head : null;
|
|
7254
7277
|
const [rows, prs] = await Promise.all([readRows(io, [binding.scopeEntryId, ...binding.ownedSliceIds ?? []], binding.chainWorkspaceId), readPrs(io, root, branch)]);
|
|
7255
|
-
return {
|
|
7278
|
+
return {
|
|
7279
|
+
scopeEntryId: binding.scopeEntryId,
|
|
7280
|
+
rows,
|
|
7281
|
+
ownsWholePackage: !binding.ownedSliceIds,
|
|
7282
|
+
branch,
|
|
7283
|
+
...prs,
|
|
7284
|
+
...binding.reason ? { reason: binding.reason.text } : {}
|
|
7285
|
+
};
|
|
7256
7286
|
}
|
|
7257
7287
|
function rowLine(row, isTask) {
|
|
7258
7288
|
if (row.notRead) return BOUND_SCOPE_WORDS.notRead(row.entryId, row.notRead);
|
|
@@ -7271,6 +7301,7 @@ function boundScopeLines(view) {
|
|
|
7271
7301
|
const elsewhere = view.rows.filter((row) => row.otherWorkspace).map((row) => row.entryId);
|
|
7272
7302
|
if (elsewhere.length > 0) item(BOUND_SCOPE_WORDS.otherWorkspace(elsewhere));
|
|
7273
7303
|
if (view.ownsWholePackage) item(BOUND_SCOPE_WORDS.wholePackage);
|
|
7304
|
+
if (view.reason) item(BOUND_SCOPE_WORDS.reason(sanitizeSingleLineField(view.reason)));
|
|
7274
7305
|
if (view.prsNotRead !== void 0) item(BOUND_SCOPE_WORDS.prsNotRead(view.prsNotRead));
|
|
7275
7306
|
else if (view.branch && view.prs?.length) for (const pr of view.prs) item(BOUND_SCOPE_WORDS.pr(view.branch, pr));
|
|
7276
7307
|
else if (view.branch) item(BOUND_SCOPE_WORDS.noPr(view.branch));
|
|
@@ -12470,4 +12501,4 @@ export {
|
|
|
12470
12501
|
SERVER_VERSION,
|
|
12471
12502
|
createProductBrainServer
|
|
12472
12503
|
};
|
|
12473
|
-
//# sourceMappingURL=chunk-
|
|
12504
|
+
//# sourceMappingURL=chunk-XHWFAFLF.js.map
|