@productbrain/mcp 0.0.1-beta.8812 → 0.0.1-beta.8814
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.
|
@@ -10658,9 +10658,7 @@ async function suggestLinksForEntries(entries) {
|
|
|
10658
10658
|
fromEntryId: entry.entryId,
|
|
10659
10659
|
toEntryId: s.entryId,
|
|
10660
10660
|
type: s.recommendedRelationType,
|
|
10661
|
-
label: `${entry.entryId} \u2192 ${s.entryId} (${s.name}) [${s.recommendedRelationType}]
|
|
10662
|
-
// WP-474 E4-REWIRE: carry the suggestion score forward (was dropped here).
|
|
10663
|
-
confidence: s.score
|
|
10661
|
+
label: `${entry.entryId} \u2192 ${s.entryId} (${s.name}) [${s.recommendedRelationType}]`
|
|
10664
10662
|
});
|
|
10665
10663
|
}
|
|
10666
10664
|
}
|
|
@@ -10738,7 +10736,7 @@ async function runWrapupReview() {
|
|
|
10738
10736
|
);
|
|
10739
10737
|
const suggestions = lowConnEntries.length > 0 ? await suggestLinksForEntries(lowConnEntries.slice(0, 10)) : [];
|
|
10740
10738
|
if (suggestions.length > 0) {
|
|
10741
|
-
lines.push("### Suggested Links", "");
|
|
10739
|
+
lines.push("### Suggested Links (not written; wrapup-commit writes none \u2014 create the ones you want with `relations action=create`)", "");
|
|
10742
10740
|
for (const s of suggestions) {
|
|
10743
10741
|
lines.push(`- ${s.label}`);
|
|
10744
10742
|
}
|
|
@@ -10851,18 +10849,14 @@ async function runWrapupReview() {
|
|
|
10851
10849
|
kernelMeta: kernelEnvelope._meta
|
|
10852
10850
|
};
|
|
10853
10851
|
}
|
|
10854
|
-
async function runWrapupCommitAll(data
|
|
10852
|
+
async function runWrapupCommitAll(data) {
|
|
10855
10853
|
requireWriteAccess();
|
|
10856
10854
|
const sessionId = getAgentSessionId();
|
|
10857
10855
|
if (!sessionId) {
|
|
10858
|
-
return { text: "No active session.", committed: 0,
|
|
10856
|
+
return { text: "No active session.", committed: 0, failed: 0, overflowUnscanned: 0 };
|
|
10859
10857
|
}
|
|
10860
10858
|
const wsCtx = await getWorkspaceContext();
|
|
10861
10859
|
const results = [];
|
|
10862
|
-
let linksCreated = 0;
|
|
10863
|
-
let linksFailed = 0;
|
|
10864
|
-
let linksAdvised = 0;
|
|
10865
|
-
const linkFailureDetails = [];
|
|
10866
10860
|
const allDrafts = [...data.drafts, ...data.overflowDrafts ?? []];
|
|
10867
10861
|
const overflowUnscanned = data.overflowUnscanned ?? 0;
|
|
10868
10862
|
for (const draft of allDrafts) {
|
|
@@ -10893,51 +10887,6 @@ async function runWrapupCommitAll(data, cachedSuggestions) {
|
|
|
10893
10887
|
results.push({ entryId: draft.entryId, ok: false, error: msg });
|
|
10894
10888
|
}
|
|
10895
10889
|
}
|
|
10896
|
-
const suggestionsToApply = cachedSuggestions.length > 0 ? cachedSuggestions : await suggestLinksForEntries(
|
|
10897
|
-
[...data.drafts, ...data.committed].filter(
|
|
10898
|
-
(e) => (data.connectionCounts[e.entryId] ?? 0) < 2
|
|
10899
|
-
).slice(0, 10)
|
|
10900
|
-
);
|
|
10901
|
-
const linkableSourceIds = /* @__PURE__ */ new Set([
|
|
10902
|
-
...data.committed.map((entry) => entry.entryId),
|
|
10903
|
-
...results.filter((r) => r.ok).map((r) => r.entryId)
|
|
10904
|
-
]);
|
|
10905
|
-
const toApply = suggestionsToApply.filter((s) => linkableSourceIds.has(s.fromEntryId)).slice(0, 15);
|
|
10906
|
-
const batchRels = toApply;
|
|
10907
|
-
if (batchRels.length > 0) {
|
|
10908
|
-
try {
|
|
10909
|
-
const batchResult = await kernelMutation("chain.createEntryRelations", {
|
|
10910
|
-
// WP-474 E4-REWIRE: wrapup-applied suggestions are auto-inferred (no one chose the
|
|
10911
|
-
// type) → mark "auto-link" + carry confidence (DEC-1399), matching smart-capture.
|
|
10912
|
-
relations: batchRels.map((s) => ({
|
|
10913
|
-
fromEntryId: s.fromEntryId,
|
|
10914
|
-
toEntryId: s.toEntryId,
|
|
10915
|
-
type: s.type,
|
|
10916
|
-
proposedBy: "auto-link",
|
|
10917
|
-
...s.confidence !== void 0 ? { confidence: s.confidence } : {}
|
|
10918
|
-
})),
|
|
10919
|
-
sessionId
|
|
10920
|
-
});
|
|
10921
|
-
linksCreated += batchResult?.created ?? 0;
|
|
10922
|
-
linksAdvised += batchResult?.advised ?? 0;
|
|
10923
|
-
if (batchResult && batchResult.failed > 0) {
|
|
10924
|
-
linksFailed += batchResult.failed;
|
|
10925
|
-
const failedResults = batchResult.results.map((r, i) => ({ ...r, index: i })).filter((r) => !r.ok && r.status !== "advised");
|
|
10926
|
-
for (const fr of failedResults) {
|
|
10927
|
-
const rel = batchRels[fr.index];
|
|
10928
|
-
if (rel) {
|
|
10929
|
-
linkFailureDetails.push(
|
|
10930
|
-
`${rel.fromEntryId} \u2192 ${rel.toEntryId} [${rel.type}]: ${fr.error ?? "unknown error"}`
|
|
10931
|
-
);
|
|
10932
|
-
}
|
|
10933
|
-
}
|
|
10934
|
-
}
|
|
10935
|
-
} catch (err) {
|
|
10936
|
-
linksFailed += batchRels.length;
|
|
10937
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
10938
|
-
linkFailureDetails.push(`Batch creation failed (${batchRels.length} relations): ${msg}`);
|
|
10939
|
-
}
|
|
10940
|
-
}
|
|
10941
10890
|
const committed = results.filter((r) => r.ok).length;
|
|
10942
10891
|
const failed = results.filter((r) => !r.ok);
|
|
10943
10892
|
const cleanDrain = failed.length === 0 && overflowUnscanned === 0;
|
|
@@ -10946,20 +10895,14 @@ async function runWrapupCommitAll(data, cachedSuggestions) {
|
|
|
10946
10895
|
sessionId,
|
|
10947
10896
|
draftsReviewed: allDrafts.length,
|
|
10948
10897
|
draftsCommitted: committed,
|
|
10949
|
-
linksCreated
|
|
10898
|
+
linksCreated: 0
|
|
10950
10899
|
});
|
|
10951
10900
|
}
|
|
10952
10901
|
const lines = [
|
|
10953
10902
|
"## Wrapup Complete",
|
|
10954
10903
|
"",
|
|
10955
|
-
`**${committed}** drafts accepted
|
|
10904
|
+
`**${committed}** drafts accepted.`
|
|
10956
10905
|
];
|
|
10957
|
-
if (linksFailed > 0) {
|
|
10958
|
-
lines.push(`**${linksFailed}** link${linksFailed === 1 ? "" : "s"} failed to create.`);
|
|
10959
|
-
}
|
|
10960
|
-
if (linksAdvised > 0) {
|
|
10961
|
-
lines.push(`**${linksAdvised}** auto-link(s) advised, not written (untypeable) \u2014 accept with \`relations action=create\` to promote.`);
|
|
10962
|
-
}
|
|
10963
10906
|
if (failed.length > 0) {
|
|
10964
10907
|
lines.push("");
|
|
10965
10908
|
lines.push("### Failed to accept");
|
|
@@ -10968,31 +10911,20 @@ async function runWrapupCommitAll(data, cachedSuggestions) {
|
|
|
10968
10911
|
}
|
|
10969
10912
|
lines.push("_These remain as drafts for next session._");
|
|
10970
10913
|
}
|
|
10971
|
-
if (linkFailureDetails.length > 0) {
|
|
10972
|
-
lines.push("");
|
|
10973
|
-
lines.push("### Failed to create links");
|
|
10974
|
-
for (const detail of linkFailureDetails) {
|
|
10975
|
-
lines.push(`- ${detail}`);
|
|
10976
|
-
}
|
|
10977
|
-
lines.push("_You can create these links manually with `entries action=create-relation`._");
|
|
10978
|
-
}
|
|
10979
10914
|
return {
|
|
10980
10915
|
text: lines.join("\n"),
|
|
10981
10916
|
committed,
|
|
10982
|
-
linksCreated,
|
|
10983
|
-
linksFailed,
|
|
10984
10917
|
failed: failed.length,
|
|
10985
10918
|
overflowUnscanned
|
|
10986
10919
|
};
|
|
10987
10920
|
}
|
|
10988
10921
|
var wrapupSchema = z22.object({
|
|
10989
10922
|
action: z22.enum(["review", "commit-all"]).optional().describe(
|
|
10990
|
-
"Action to perform. 'review' (default) shows the wrapup summary. 'commit-all' accepts all uncommitted drafts
|
|
10923
|
+
"Action to perform. 'review' (default) shows the wrapup summary. 'commit-all' accepts all uncommitted drafts; it writes no relations."
|
|
10991
10924
|
)
|
|
10992
10925
|
});
|
|
10993
10926
|
function createWrapupHandler() {
|
|
10994
10927
|
let lastReviewData = null;
|
|
10995
|
-
let lastReviewSuggestions = [];
|
|
10996
10928
|
let lastReviewSessionId = null;
|
|
10997
10929
|
return async ({ action }) => {
|
|
10998
10930
|
if (action === "commit-all") {
|
|
@@ -11021,11 +10953,9 @@ function createWrapupHandler() {
|
|
|
11021
10953
|
if (data2.drafts.length === 0 && (data2.overflowDrafts ?? []).length === 0) {
|
|
11022
10954
|
return failureResult("No uncommitted drafts to accept.", "NOT_FOUND", "No uncommitted drafts to accept.", "Nothing to accept.");
|
|
11023
10955
|
}
|
|
11024
|
-
const result2 = await runWrapupCommitAll(data2
|
|
10956
|
+
const result2 = await runWrapupCommitAll(data2);
|
|
11025
10957
|
lastReviewData = null;
|
|
11026
|
-
lastReviewSuggestions = [];
|
|
11027
10958
|
lastReviewSessionId = null;
|
|
11028
|
-
const linkWarnSuffix = result2.linksFailed > 0 ? `, ${result2.linksFailed} link(s) failed` : "";
|
|
11029
10959
|
const commitNext = result2.overflowUnscanned > 0 ? [
|
|
11030
10960
|
{
|
|
11031
10961
|
tool: "session",
|
|
@@ -11035,11 +10965,9 @@ function createWrapupHandler() {
|
|
|
11035
10965
|
] : result2.failed > 0 ? [{ tool: "session", description: "Re-review remaining drafts before closing", parameters: { action: "wrapup-review" } }] : [{ tool: "session", description: "Close the session now that drafts are committed", parameters: { action: "close" } }];
|
|
11036
10966
|
return successResult(
|
|
11037
10967
|
result2.text,
|
|
11038
|
-
`Wrapup processed: ${result2.committed} accepted
|
|
10968
|
+
`Wrapup processed: ${result2.committed} accepted.`,
|
|
11039
10969
|
{
|
|
11040
10970
|
committed: result2.committed,
|
|
11041
|
-
linksCreated: result2.linksCreated,
|
|
11042
|
-
linksFailed: result2.linksFailed,
|
|
11043
10971
|
failed: result2.failed
|
|
11044
10972
|
},
|
|
11045
10973
|
commitNext
|
|
@@ -11047,7 +10975,6 @@ function createWrapupHandler() {
|
|
|
11047
10975
|
}
|
|
11048
10976
|
const { text, data, suggestions, failureCode, gapCount, coherenceVerdict, persistentGaps, kernelSummary, kernelNext, kernelMeta } = await runWrapupReview();
|
|
11049
10977
|
lastReviewData = data;
|
|
11050
|
-
lastReviewSuggestions = suggestions;
|
|
11051
10978
|
lastReviewSessionId = getAgentSessionId();
|
|
11052
10979
|
const composed = data ? composeWrapupView(data) : null;
|
|
11053
10980
|
const fullText = composed && (composed.drafts.length > 0 || composed.committed.length > 0) ? `## Session Wrapup
|
|
@@ -11446,7 +11373,7 @@ function registerSessionTools(server) {
|
|
|
11446
11373
|
"session",
|
|
11447
11374
|
{
|
|
11448
11375
|
title: "Session \u2014 Lifecycle & Facilitation",
|
|
11449
|
-
description: "Session lifecycle, wrapup review, and work package facilitation.\n\n- **start**: Begin a tracked write session for attribution. **This is the ONLY call that creates a session** \u2014 write tools (capture, entries action=update/commit, relations) require it. `orient action=start` orients an existing session and loads stage-aware context, but does NOT create one: call `session action=start` first, then `orient action=start`.\n- **close**: End the current session. Records structured data (entries created, modified, relations). Run `session action=wrapup-review` before closing.\n- **status**: Check current session \u2014 active or not, oriented, activity counts.\n- **wrapup-review**: Review uncommitted drafts with quality scores, suggested links. Run before close.\n- **wrapup-commit**: Accept all uncommitted drafts
|
|
11376
|
+
description: "Session lifecycle, wrapup review, and work package facilitation.\n\n- **start**: Begin a tracked write session for attribution. **This is the ONLY call that creates a session** \u2014 write tools (capture, entries action=update/commit, relations) require it. `orient action=start` orients an existing session and loads stage-aware context, but does NOT create one: call `session action=start` first, then `orient action=start`.\n- **close**: End the current session. Records structured data (entries created, modified, relations). Run `session action=wrapup-review` before closing.\n- **status**: Check current session \u2014 active or not, oriented, activity counts.\n- **wrapup-review**: Review uncommitted drafts with quality scores, suggested links. Run before close.\n- **wrapup-commit**: Accept all uncommitted drafts. Writes no relations; create the ones you want with relations action=create.\n- **resume**: Load session state (work package data, constellation, drafts) from an existing work package entry.\n- **commit-constellation**: Atomically accept a work package and all its linked draft entries in one call.",
|
|
11450
11377
|
inputSchema: sessionSchema,
|
|
11451
11378
|
// Mixed read/write noun (§3 R3): wrapup-commit/resume/commit-constellation write.
|
|
11452
11379
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
@@ -13976,4 +13903,4 @@ export {
|
|
|
13976
13903
|
createProductBrainServer,
|
|
13977
13904
|
initFeatureFlags
|
|
13978
13905
|
};
|
|
13979
|
-
//# sourceMappingURL=chunk-
|
|
13906
|
+
//# sourceMappingURL=chunk-JCENVG5F.js.map
|