@productbrain/mcp 0.0.1-beta.13215 → 0.0.1-beta.13225
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.
|
@@ -1475,22 +1475,6 @@ Use \`context action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
1475
1475
|
return toolResult;
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
-
// src/tools/conflict-preflight.ts
|
|
1479
|
-
async function runConflictPreflight(name, description, collectionHint, subjectId) {
|
|
1480
|
-
try {
|
|
1481
|
-
const conflicts = await kernelQuery("chain.detectSemanticConflicts", {
|
|
1482
|
-
name,
|
|
1483
|
-
description,
|
|
1484
|
-
...collectionHint ? { collectionHint } : {},
|
|
1485
|
-
...subjectId ? { subjectId } : {}
|
|
1486
|
-
});
|
|
1487
|
-
return { conflicts: conflicts ?? [] };
|
|
1488
|
-
} catch (err) {
|
|
1489
|
-
console.error("[conflict-preflight] Semantic conflict detection unavailable:", err instanceof Error ? err.message : String(err));
|
|
1490
|
-
return { conflicts: [] };
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
1478
|
// src/lib/judgeWait.ts
|
|
1495
1479
|
var JUDGE_TIMEOUT_MS = 3e4;
|
|
1496
1480
|
var JUDGE_CALLS_PER_RUN = 1;
|
|
@@ -1521,10 +1505,6 @@ async function settleVerdictBeforeAccept(evaluate, readLatest, opts = {}) {
|
|
|
1521
1505
|
await sleep(POLL_MS);
|
|
1522
1506
|
}
|
|
1523
1507
|
}
|
|
1524
|
-
function judgedAcceptedLine(wait) {
|
|
1525
|
-
if (!wait?.judged) return null;
|
|
1526
|
-
return `Judged in ${Math.max(1, Math.round(wait.waitedMs / 1e3))} s, accepted.`;
|
|
1527
|
-
}
|
|
1528
1508
|
|
|
1529
1509
|
// src/tools/knowledge/updateEntryAppliedFields.ts
|
|
1530
1510
|
function computeUpdateEntryAppliedFields(args, normalization, provenanceApplied = {}, revertedFields = []) {
|
|
@@ -1823,36 +1803,10 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
|
|
|
1823
1803
|
if (!entry) {
|
|
1824
1804
|
return notFoundResult(entryId, `Entry '${entryId}' not found. Try search to find the right ID.`);
|
|
1825
1805
|
}
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
entry.collectionSlug ?? entry.collection?.slug ?? entry.collection?.name,
|
|
1831
|
-
entry.entryId
|
|
1832
|
-
// TASK-938: the reason names this entry
|
|
1833
|
-
);
|
|
1834
|
-
const advisoryWarnings = preflight.conflicts.map((conflict) => ({
|
|
1835
|
-
entryId: conflict.chainEntryId,
|
|
1836
|
-
name: conflict.chainEntryName,
|
|
1837
|
-
explanation: conflict.explanation
|
|
1838
|
-
}));
|
|
1839
|
-
if (advisoryWarnings.length > 0) {
|
|
1840
|
-
await recordSessionActivity({ contradictionWarning: true });
|
|
1841
|
-
}
|
|
1842
|
-
const conflictEvidence = preflight.conflicts.map((c) => ({
|
|
1843
|
-
chainEntryId: c.chainEntryId,
|
|
1844
|
-
chainEntryName: c.chainEntryName,
|
|
1845
|
-
...c.chainEntryDescription ? { chainEntryDescription: c.chainEntryDescription } : {},
|
|
1846
|
-
type: c.type,
|
|
1847
|
-
confidence: c.confidence,
|
|
1848
|
-
explanation: c.explanation
|
|
1849
|
-
}));
|
|
1850
|
-
const judgeWait = preview ? null : await settleVerdictBeforeAccept(
|
|
1851
|
-
() => kernelMutation("quality.evaluateHeuristicAndSchedule", { entryId, context: "commit" }),
|
|
1852
|
-
() => kernelQuery("quality.getLatestVerdictForEntry", { entryId })
|
|
1853
|
-
);
|
|
1854
|
-
const stored = judgeWait?.latest?.verdict;
|
|
1855
|
-
const coachingResult = stored ? { verdict: stored, source: stored.source } : judgeWait?.evaluation ?? null;
|
|
1806
|
+
const coachingResult = preview ? null : await kernelMutation(
|
|
1807
|
+
"quality.evaluateHeuristicAndSchedule",
|
|
1808
|
+
{ entryId, context: "commit" }
|
|
1809
|
+
).catch(() => null);
|
|
1856
1810
|
const result2 = await kernelMutation("chain.commitEntry", {
|
|
1857
1811
|
entryId,
|
|
1858
1812
|
author: getAgentSessionId() ? `agent:${getAgentSessionId()}` : void 0,
|
|
@@ -1862,7 +1816,6 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
|
|
|
1862
1816
|
...qualityOverrideReason ? { qualityOverrideReason } : {},
|
|
1863
1817
|
// TASK-954
|
|
1864
1818
|
...coherencyAcknowledgement ? { coherencyAcknowledgement } : {},
|
|
1865
|
-
...conflictEvidence.length > 0 ? { conflicts: conflictEvidence } : {},
|
|
1866
1819
|
...replaces ? { replaces, ...reason !== void 0 ? { replacesReason: reason } : {} } : {}
|
|
1867
1820
|
// TASK-1030; DEC-2006: the reason rides with it
|
|
1868
1821
|
}).catch((err) => {
|
|
@@ -1890,7 +1843,9 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
|
|
|
1890
1843
|
wouldSetStatus: result2.wouldSetStatus,
|
|
1891
1844
|
wouldBlock,
|
|
1892
1845
|
...wouldBlock && result2.blockingReason ? { blockingReason: result2.blockingReason } : {},
|
|
1893
|
-
...previewContradictionAdvisory ? { contradictionAdvisory: previewContradictionAdvisory } : {}
|
|
1846
|
+
...previewContradictionAdvisory ? { contradictionAdvisory: previewContradictionAdvisory } : {},
|
|
1847
|
+
...typeof result2.conflictCheck === "string" ? { conflictCheck: result2.conflictCheck } : {}
|
|
1848
|
+
// TASK-1040: as a real accept says it
|
|
1894
1849
|
},
|
|
1895
1850
|
[{ tool: toolName, description: "Accept for real", parameters: { action: "accept", entryId, ...replaces ? { replaces, ...reason !== void 0 ? { reason } : {} } : {} } }]
|
|
1896
1851
|
// TASK-1030
|
|
@@ -1910,7 +1865,9 @@ ${previewContradictionAdvisory.conflictDetails.map((c) => `- \`${c.chainEntryId}
|
|
|
1910
1865
|
return {
|
|
1911
1866
|
content: [{ type: "text", text: `# Preview: ${entryId} ${previewVerdict}
|
|
1912
1867
|
|
|
1913
|
-
Current status: \`${result2.currentStatus}\`${wouldBlock ? "" : ` \u2192 would become \`${result2.wouldSetStatus}\``}.${blockingNote}${advisoryNote}
|
|
1868
|
+
Current status: \`${result2.currentStatus}\`${wouldBlock ? "" : ` \u2192 would become \`${result2.wouldSetStatus}\``}.${blockingNote}${advisoryNote}${typeof result2.conflictCheck === "string" ? `
|
|
1869
|
+
|
|
1870
|
+
${result2.conflictCheck}` : ""}
|
|
1914
1871
|
|
|
1915
1872
|
No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
1916
1873
|
structuredContent: previewEnvelope
|
|
@@ -1919,10 +1876,8 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
1919
1876
|
const docId = result2?._id ?? entry._id;
|
|
1920
1877
|
const wsCtx = await getWorkspaceContext();
|
|
1921
1878
|
await recordSessionActivity({ entryModified: docId });
|
|
1922
|
-
const judged = judgedAcceptedLine(judgeWait);
|
|
1923
1879
|
const lines = [
|
|
1924
1880
|
`# Accepted: ${entryId}`,
|
|
1925
|
-
...judged ? [judged] : [],
|
|
1926
1881
|
`**${entry.name}** accepted onto the Chain.`,
|
|
1927
1882
|
`**Workspace:** ${wsCtx.workspaceSlug} (${wsCtx.workspaceId})`
|
|
1928
1883
|
];
|
|
@@ -1932,9 +1887,15 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
1932
1887
|
lines.push("");
|
|
1933
1888
|
lines.push(`_Auto-verified as part of this accept \u2014 ${autoVerified.strength}${who}._`);
|
|
1934
1889
|
}
|
|
1890
|
+
const advisoryWarnings = (Array.isArray(result2?.conflicts) ? result2.conflicts : []).map((conflict) => ({
|
|
1891
|
+
entryId: conflict.chainEntryId,
|
|
1892
|
+
name: conflict.chainEntryName,
|
|
1893
|
+
explanation: conflict.explanation
|
|
1894
|
+
}));
|
|
1935
1895
|
if (advisoryWarnings.length > 0) {
|
|
1896
|
+
await recordSessionActivity({ contradictionWarning: true });
|
|
1936
1897
|
lines.push("");
|
|
1937
|
-
lines.push("\u26A0
|
|
1898
|
+
lines.push("\u26A0 Stored conflict check: advisory conflict(s) found.");
|
|
1938
1899
|
for (const w of advisoryWarnings) {
|
|
1939
1900
|
lines.push(`- ${w.name} (${w.entryId}) \u2014 ${w.explanation}`);
|
|
1940
1901
|
}
|
|
@@ -1971,6 +1932,8 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
1971
1932
|
lines.push(`- \`${c.chainEntryId}\` ${c.chainEntryName}: ${c.explanation}`);
|
|
1972
1933
|
}
|
|
1973
1934
|
}
|
|
1935
|
+
const conflictCheck = typeof result2?.conflictCheck === "string" && result2.conflictCheck ? result2.conflictCheck : void 0;
|
|
1936
|
+
if (conflictCheck) lines.push("", conflictCheck);
|
|
1974
1937
|
const publishAdvisories = Array.isArray(result2?.publishAdvisories) ? result2.publishAdvisories.filter((a) => typeof a === "string") : void 0;
|
|
1975
1938
|
if (publishAdvisories && publishAdvisories.length > 0) {
|
|
1976
1939
|
lines.push("");
|
|
@@ -2013,9 +1976,9 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
2013
1976
|
outcome: "committed",
|
|
2014
1977
|
qualityVerdict: coachingResult?.verdict ?? void 0,
|
|
2015
1978
|
source: coachingResult?.source ?? void 0,
|
|
2016
|
-
...judgeWait?.judged ? { judgedInMs: judgeWait.waitedMs } : {},
|
|
2017
|
-
// TASK-612
|
|
2018
1979
|
contradictions: advisoryWarnings.length,
|
|
1980
|
+
...conflictCheck ? { conflictCheck } : {},
|
|
1981
|
+
// TASK-1040
|
|
2019
1982
|
...epistemic ? { epistemicStatus: epistemic } : {},
|
|
2020
1983
|
...steeringAdvisory ? { steeringAdvisory } : {},
|
|
2021
1984
|
...heldFlag ? { heldFlag, ...heldReason ? { heldReason } : {} } : {},
|
|
@@ -6948,6 +6911,49 @@ function formatGapOneLiner(gap) {
|
|
|
6948
6911
|
return `Next gap: ${prompt}`;
|
|
6949
6912
|
}
|
|
6950
6913
|
|
|
6914
|
+
// src/lib/priority.ts
|
|
6915
|
+
var PRIORITY_LEVELS = {
|
|
6916
|
+
urgent: { word: "Urgent", order: 1, linearInt: 1, icon: "alert" },
|
|
6917
|
+
high: { word: "High", order: 2, linearInt: 2, icon: "bars-3" },
|
|
6918
|
+
medium: { word: "Medium", order: 3, linearInt: 3, icon: "bars-2" },
|
|
6919
|
+
low: { word: "Low", order: 4, linearInt: 4, icon: "bars-1" }
|
|
6920
|
+
};
|
|
6921
|
+
var PRIORITY_TOKENS = Object.keys(PRIORITY_LEVELS);
|
|
6922
|
+
var NO_PRIORITY = { word: "No priority", order: 5, linearInt: 0, icon: "dashes" };
|
|
6923
|
+
function priorityOf(value) {
|
|
6924
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(PRIORITY_LEVELS, value) ? value : null;
|
|
6925
|
+
}
|
|
6926
|
+
|
|
6927
|
+
// src/lib/workPackageList.ts
|
|
6928
|
+
var WORK_PACKAGE_LIST_WORDS = {
|
|
6929
|
+
yours: "[yours]",
|
|
6930
|
+
count: (shown, { team, otherTeams, noSingleOwner }) => `showing ${shown} of ${team} \xB7 other teams ${otherTeams}${noSingleOwner > 0 ? ` \xB7 no single owner ${noSingleOwner}` : ""}`,
|
|
6931
|
+
setOne: "Set one (urgent, high, medium or low):",
|
|
6932
|
+
/** The command each surface prints after setOne, ending the line so it pastes whole; a live priority change asks one line of why (DEC-2418). */
|
|
6933
|
+
setCommand: {
|
|
6934
|
+
cli: 'pb update <WP-ID> -f priority=high --change-reason "<why>"',
|
|
6935
|
+
mcp: '`entries action=update entryId="<WP-ID>" data={"priority":"high"} changeReason="<why>"`'
|
|
6936
|
+
}
|
|
6937
|
+
};
|
|
6938
|
+
function priorityWord(value) {
|
|
6939
|
+
const token = priorityOf(value);
|
|
6940
|
+
return token ? PRIORITY_LEVELS[token].word : NO_PRIORITY.word;
|
|
6941
|
+
}
|
|
6942
|
+
function workPackageListLines(rows, counts, surface) {
|
|
6943
|
+
const lines = [];
|
|
6944
|
+
const anyPriority = rows.some((row) => priorityOf(row.priority) !== null);
|
|
6945
|
+
if (counts) lines.push(WORK_PACKAGE_LIST_WORDS.count(rows.length, counts));
|
|
6946
|
+
if (counts && rows.length > 0 && !anyPriority) lines.push(`${WORK_PACKAGE_LIST_WORDS.setOne} ${surface.setCommand}`);
|
|
6947
|
+
let level;
|
|
6948
|
+
for (const row of rows) {
|
|
6949
|
+
const word = priorityWord(row.priority);
|
|
6950
|
+
if (anyPriority && word !== level) lines.push(surface.heading(word));
|
|
6951
|
+
level = word;
|
|
6952
|
+
lines.push(...surface.row(row, row.yours ? ` ${WORK_PACKAGE_LIST_WORDS.yours}` : ""));
|
|
6953
|
+
}
|
|
6954
|
+
return lines;
|
|
6955
|
+
}
|
|
6956
|
+
|
|
6951
6957
|
// src/lib/canonicalRefs.ts
|
|
6952
6958
|
function getCollectionLabel(canonicalKey, form, workspaceCtx, collectionCtx) {
|
|
6953
6959
|
const wsLabels = workspaceCtx?.collectionLabels?.[canonicalKey];
|
|
@@ -7191,15 +7197,16 @@ async function _handleOrient({ mode: mode2 = "full", tier, task, startupSignals,
|
|
|
7191
7197
|
const degradedLineBrief = buildDegradedPreloadsLine(orientView?.degradedPreloads);
|
|
7192
7198
|
if (degradedLineBrief) lines.push(degradedLineBrief);
|
|
7193
7199
|
lines.push(...buildRitualsSurfaceLines(orientView, { fetchFailed: orientFetchFailed || orientView?.fetchFailed === true }));
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7200
|
+
lines.push(...workPackageListLines(orientView?.activeWorkPackages ?? [], orientView?.strategicContext?.workPackageTeamCounts, {
|
|
7201
|
+
heading: (word) => `${word}:`,
|
|
7202
|
+
setCommand: WORK_PACKAGE_LIST_WORDS.setCommand.mcp,
|
|
7203
|
+
row: (e, mark) => {
|
|
7197
7204
|
const tensions = e.linkedTensions;
|
|
7198
7205
|
const tensionPart = tensions?.length ? ` \u2014 ${tensions.map((t) => `${t.entryId ?? t.name} (${t.severity ?? "\u2014"})`).join(", ")}` : "";
|
|
7199
7206
|
const originPart = e.origin ? ` (origin: ${e.origin})` : "";
|
|
7200
|
-
|
|
7207
|
+
return [`- \`${e.entryId ?? e._id}\` ${e.name}${originPart}${tensionPart}${mark}${coherencyCheckTag(e.coherencyCheckStatus)}`];
|
|
7201
7208
|
}
|
|
7202
|
-
}
|
|
7209
|
+
}));
|
|
7203
7210
|
if (orientView?.trustMetrics) {
|
|
7204
7211
|
const tm = orientView.trustMetrics;
|
|
7205
7212
|
if (tm.unverified > 0 || tm.verified > 0) {
|
|
@@ -7329,14 +7336,14 @@ async function _handleOrient({ mode: mode2 = "full", tier, task, startupSignals,
|
|
|
7329
7336
|
if (readiness.gaps.length > 5) lines.push(`_...and ${readiness.gaps.length - 5} more gap(s) \u2014 see structuredContent.data.readinessGaps._`);
|
|
7330
7337
|
lines.push("");
|
|
7331
7338
|
}
|
|
7332
|
-
const fmt = (e) => {
|
|
7339
|
+
const fmt = (e, yoursMark = "") => {
|
|
7333
7340
|
const type = e.canonicalKey ?? "generic";
|
|
7334
7341
|
const stratum = e.stratum ?? "?";
|
|
7335
7342
|
const originPart = e.origin ? ` (origin: ${e.origin})` : "";
|
|
7336
7343
|
const mark = provenanceMark(e.provenance);
|
|
7337
7344
|
const anchorSuffix = e.anchoredBy ? ` (${e.anchoredBy})` : "";
|
|
7338
7345
|
const coherencyPart = coherencyCheckTag(e.coherencyCheckStatus);
|
|
7339
|
-
return `- ${mark}\`${e.entryId ?? e._id}\` [${type} \xB7 ${stratum}] ${e.name}${anchorSuffix}${originPart}${coherencyPart}`;
|
|
7346
|
+
return `- ${mark}\`${e.entryId ?? e._id}\` [${type} \xB7 ${stratum}] ${e.name}${anchorSuffix}${originPart}${yoursMark}${coherencyPart}`;
|
|
7340
7347
|
};
|
|
7341
7348
|
const fullCoherence = await buildCoherenceSection();
|
|
7342
7349
|
if (fullCoherence) {
|
|
@@ -7457,22 +7464,23 @@ async function _handleOrient({ mode: mode2 = "full", tier, task, startupSignals,
|
|
|
7457
7464
|
}
|
|
7458
7465
|
}
|
|
7459
7466
|
if (orientView) {
|
|
7460
|
-
const fullActiveWps = orientView.activeWorkPackages ?? [];
|
|
7461
|
-
if (fullActiveWps.length > 0) {
|
|
7467
|
+
const fullActiveWps = orientView.activeWorkPackages ?? [], teamCounts = orientView.strategicContext?.workPackageTeamCounts;
|
|
7468
|
+
if (fullActiveWps.length > 0 || teamCounts) {
|
|
7462
7469
|
lines.push("## Active work packages \u2014 current scope");
|
|
7463
7470
|
lines.push("_Work outside these work packages requires explicit user confirmation._");
|
|
7464
7471
|
lines.push("");
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7472
|
+
lines.push(...workPackageListLines(fullActiveWps, teamCounts, {
|
|
7473
|
+
// DEC-2426
|
|
7474
|
+
heading: (word) => `**${word}**`,
|
|
7475
|
+
setCommand: WORK_PACKAGE_LIST_WORDS.setCommand.mcp,
|
|
7476
|
+
row: (e, mark) => {
|
|
7477
|
+
const tensionLines = (e.linkedTensions ?? []).map((t) => {
|
|
7470
7478
|
const meta = [t.severity, t.priority].filter(Boolean).join(", ");
|
|
7471
7479
|
return `\`${t.entryId ?? t.name}\` (${t.name}${meta ? `, ${meta}` : ""})`;
|
|
7472
7480
|
});
|
|
7473
|
-
|
|
7481
|
+
return [fmt(e, mark), ...tensionLines.length ? [` Tensions: ${tensionLines.join("; ")}`] : []];
|
|
7474
7482
|
}
|
|
7475
|
-
}
|
|
7483
|
+
}));
|
|
7476
7484
|
lines.push("");
|
|
7477
7485
|
}
|
|
7478
7486
|
const fullActiveGoals = orientView.activeGoals ?? [];
|
|
@@ -11994,4 +12002,4 @@ export {
|
|
|
11994
12002
|
SERVER_VERSION,
|
|
11995
12003
|
createProductBrainServer
|
|
11996
12004
|
};
|
|
11997
|
-
//# sourceMappingURL=chunk-
|
|
12005
|
+
//# sourceMappingURL=chunk-I2JXAGTV.js.map
|