@productbrain/mcp 0.0.1-beta.14069 → 0.0.1-beta.14080

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.
@@ -416,6 +416,52 @@ async function listEntriesWithCut(args, next = LIST_COUNTS_OF_ROWS_READ) {
416
416
  // src/tools/entries.ts
417
417
  import { z as z13 } from "zod/v3";
418
418
 
419
+ // src/lib/conflictResolution.ts
420
+ var CONFLICT_RESOLUTIONS = ["replaces", "refines", "unrelated"];
421
+ var CONFLICT_RESOLUTION_REASON_MAX = 200;
422
+ var signed = (line) => line;
423
+ var CLASH = {
424
+ one: "possible clash",
425
+ many: "possible clashes",
426
+ mayWith: "May clash with",
427
+ check: "possible-clash check",
428
+ kinds: { contradiction: "may contradict", supersession: "may replace" },
429
+ /** A count by kind reads the kind's noun (QUE-527, KR-7): it names the kind of possible clash, never the flag (Voice, RULE-705 check 4). */
430
+ kindNouns: { contradiction: ["contradiction", "contradictions"], supersession: ["supersession", "supersessions"] }
431
+ };
432
+ var clashKind = (kind) => CLASH.kinds[kind] ?? kind;
433
+ var Clash = { one: CLASH.one[0].toUpperCase() + CLASH.one.slice(1), many: CLASH.many[0].toUpperCase() + CLASH.many.slice(1) };
434
+ var clashCount = (n, more = false) => `${n}${more ? "+" : ""} ${n === 1 && !more ? CLASH.one : CLASH.many}`;
435
+ var RESOLUTION_WORDS = {
436
+ choose: signed(`Choose ${CONFLICT_RESOLUTIONS.slice(0, -1).join(", ")} or ${CONFLICT_RESOLUTIONS[CONFLICT_RESOLUTIONS.length - 1]}.`),
437
+ both: signed("Give either the answer (real or false alarm) or the choice, not both."),
438
+ reasonTooLong: signed(`Keep the reason to one line of ${CONFLICT_RESOLUTION_REASON_MAX} characters or fewer.`),
439
+ target: "replaces or refines: the entry it replaces or refines, one of the two",
440
+ reason: `For unrelated: one line on why (${CONFLICT_RESOLUTION_REASON_MAX} characters at most); for an amendment: why the answer changes`,
441
+ /** The receipt an older backend's answer gets when it carries no line of its own (the MCP's fallback): the choice in words. */
442
+ recorded: (choice2) => `Recorded: ${choice2 === "unrelated" ? "unrelated" : `${choice2} the other entry`}.`,
443
+ /** TASK-1560 (QUE-518, QUE-501): what the propose verb does, as pb's help and the MCP tool say it (Voice signs). */
444
+ proposeHelp: `Propose the answer to a ${CLASH.one}; its owner confirms it`,
445
+ /** TASK-1571 (QUE-554, DEC-2299): what only a person does, as the person-only floor says it ("Only a person answers a possible
446
+ * clash."); the CLI and MCP read it to add their propose command to the gateway's refusal. */
447
+ answerVerb: `answers a ${CLASH.one}`,
448
+ /** What the CLI and MCP match the gateway's answer refusal by: stable across QUE-540's pick (see CLASH). */
449
+ answerMatch: "answers a possible ",
450
+ tool: `List ${CLASH.many}; propose an answer; a person answers in Cortex.`,
451
+ /** TASK-1571 (TEN-6206): the answer verbs' help on the CLI and MCP, which the gateway now refuses for every caller (QUE-554). */
452
+ answerHelp: "A key proposes; a person answers in Cortex.",
453
+ /** The list's header, one for the CLI and the MCP (DEC-2443): the open possible clashes, then the closed ones beside them when `closed` is given.
454
+ * A plus after a count means more exist than were read (RULE-17). */
455
+ openHeader: (open, closed) => `Open ${CLASH.many} (${open.n}${open.more ? "+" : ""})${closed ? `, ${closed.n}${closed.more ? "+" : ""} closed` : ""}`,
456
+ /** The list when nothing is open (all) or nothing is unanswered (the default list); the surface adds how to see the rest. */
457
+ noneOpen: `No open ${CLASH.many}.`,
458
+ noneUnanswered: `No unanswered ${CLASH.many}.`,
459
+ /** A stored answer as a person reads it: never the stored code. */
460
+ answer: (answer2) => answer2 === "real" ? "real" : "false alarm",
461
+ /** The receipt for an answer given in the older form (real or noise), on the CLI and MCP alike. */
462
+ answeredAs: (answer2) => answer2 === "real" ? `Answered as real: the ${CLASH.one} stays open until an entry changes.` : `Answered as a false alarm: the ${CLASH.one} is closed.`
463
+ };
464
+
419
465
  // src/tools/knowledge-helpers.ts
420
466
  import { z as z2 } from "zod/v3";
421
467
 
@@ -2804,7 +2850,7 @@ function registerEntriesTools(server) {
2804
2850
  description: `Write entries on the Chain: the entry lifecycle after capture. Reads live on \`context\`.
2805
2851
 
2806
2852
  - **update**: Change fields on an existing entry (publishes whenever the entry is not draft \u2014 includes archived, not just ${TRUST_STATUS_LABELS.current.toLowerCase()} entries; autoPublish is accepted but ignored).
2807
- - **accept**: Accept a draft entry onto the Chain. Runs the contradiction preflight first.
2853
+ - **accept**: Accept a draft entry onto the Chain. Runs the ${CLASH.check} first.
2808
2854
  - **move**: Relocate an entry to a different collection; pass canonicalKey too for an atomic move+retype.
2809
2855
  - **verify**: Mark verified (lightweight, no scan \u2014 see \`quality action=verify-chain\`).
2810
2856
  - **replace**: one accepted entry replaces another of its kind, with a reason.
@@ -10340,7 +10386,7 @@ async function handleClose() {
10340
10386
  `| Entries created | ${created} |`,
10341
10387
  `| Entries modified | ${modified} |`,
10342
10388
  `| Relations created | ${relations} |`,
10343
- ...session ? [`| Gate failures | ${gates} |`, `| Contradiction warnings | ${warnings} |`] : []
10389
+ ...session ? [`| Gate failures | ${gates} |`, `| ${Clash.one} warnings | ${warnings} |`] : []
10344
10390
  );
10345
10391
  if (capLine) lines.push("", capLine);
10346
10392
  if (callLine) lines.push("", callLine);
@@ -11196,39 +11242,6 @@ function registerFeedbackTool(server) {
11196
11242
 
11197
11243
  // src/tools/conflicts.ts
11198
11244
  import { z as z32 } from "zod/v3";
11199
-
11200
- // src/lib/conflictResolution.ts
11201
- var CONFLICT_RESOLUTIONS = ["replaces", "refines", "unrelated"];
11202
- var CONFLICT_RESOLUTION_REASON_MAX = 200;
11203
- var signed = (line) => line;
11204
- var RESOLUTION_WORDS = {
11205
- choose: signed(`Choose ${CONFLICT_RESOLUTIONS.slice(0, -1).join(", ")} or ${CONFLICT_RESOLUTIONS[CONFLICT_RESOLUTIONS.length - 1]}.`),
11206
- both: signed("Give either the answer (real or false alarm) or the choice, not both."),
11207
- reasonTooLong: signed(`Keep the reason to one line of ${CONFLICT_RESOLUTION_REASON_MAX} characters or fewer.`),
11208
- target: "replaces or refines: the entry it replaces or refines, one of the two",
11209
- reason: `For unrelated: one line on why (${CONFLICT_RESOLUTION_REASON_MAX} characters at most); for an amendment: why the answer changes`,
11210
- recorded: (choice2) => `Recorded: ${choice2}.`,
11211
- /** TASK-1560 (QUE-518, QUE-501): what the propose verb does, as pb's help and the MCP tool say it (Voice signs). */
11212
- proposeHelp: "Propose the answer to a possible clash; its owner confirms it",
11213
- /** TASK-1571 (QUE-554, DEC-2299): what only a person does, as the person-only floor says it ("Only a person answers a possible
11214
- * clash."); the CLI and MCP read it to add their propose command to the gateway's refusal. */
11215
- answerVerb: "answers a possible clash",
11216
- tool: "List possible clashes; propose an answer; a person answers in Cortex.",
11217
- /** TASK-1571 (TEN-6206): the answer verbs' help on the CLI and MCP, which the gateway now refuses for every caller (QUE-554). */
11218
- answerHelp: "A key proposes; a person answers in Cortex.",
11219
- /** The list's header, one for the CLI and the MCP (DEC-2443): the open contradictions, then the closed ones beside them when `closed` is given.
11220
- * A plus after a count means more exist than were read (RULE-17). */
11221
- openHeader: (open, closed) => `Open contradictions (${open.n}${open.more ? "+" : ""})${closed ? `, ${closed.n}${closed.more ? "+" : ""} closed` : ""}`,
11222
- /** The list when nothing is open (all) or nothing is unanswered (the default list); the surface adds how to see the rest. */
11223
- noneOpen: "No open contradictions.",
11224
- noneUnanswered: "No unanswered contradictions.",
11225
- /** A stored answer as a person reads it: never the stored code. */
11226
- answer: (answer2) => answer2 === "real" ? "real" : "false alarm",
11227
- /** The receipt for an answer given in the older form (real or noise), on the CLI and MCP alike. */
11228
- answeredAs: (answer2) => answer2 === "real" ? "Answered as real: the contradiction stays open until an entry changes." : "Answered as a false alarm: the contradiction is closed."
11229
- };
11230
-
11231
- // src/tools/conflicts.ts
11232
11245
  var ACTIONS = ["list", "resolve", "propose"];
11233
11246
  var mode = z32.enum(["actionable", "all"]);
11234
11247
  var verdict = z32.enum(["real", "noise"]);
@@ -11257,12 +11270,12 @@ var CONFLICTS_ACTION_SPECS = {
11257
11270
  async function handleConflictsList(listMode = "actionable") {
11258
11271
  const rows = await kernelCall("conflicts.list", { mode: listMode });
11259
11272
  const side = (name, id) => `${sanitizeSingleLineField(name)} (${id ? sanitizeSingleLineField(id) : "gone"})`;
11260
- const lines = rows.map((r) => `${r.id} \xB7 ${side(r.entryAName, r.entryAId)} \u2194 ${side(r.entryBName, r.entryBId)} \xB7 ${r.conflictType} ${r.confidence.toFixed(2)}${r.rankLabel ? ` \xB7 ${sanitizeSingleLineField(r.rankLabel)}` : ""} \xB7 ${sanitizeSingleLineField(r.explanation)}` + (r.guidance ? ` \xB7 ${sanitizeSingleLineField(r.guidance)}` : "") + (r.resolvedLine ? ` \xB7 ${sanitizeSingleLineField(r.resolvedLine)}` : "") + // who answered and how (DEC-2443)
11273
+ const lines = rows.map((r) => `${r.id} \xB7 ${side(r.entryAName, r.entryAId)} \u2194 ${side(r.entryBName, r.entryBId)} \xB7 ${clashKind(r.conflictType)} ${r.confidence.toFixed(2)}${r.rankLabel ? ` \xB7 ${sanitizeSingleLineField(r.rankLabel)}` : ""} \xB7 ${sanitizeSingleLineField(r.explanation)}` + (r.guidance ? ` \xB7 ${sanitizeSingleLineField(r.guidance)}` : "") + (r.resolvedLine ? ` \xB7 ${sanitizeSingleLineField(r.resolvedLine)}` : "") + // who answered and how (DEC-2443)
11261
11274
  (r.proposedLine ? ` \xB7 ${sanitizeSingleLineField(r.proposedLine)}` : ""));
11262
11275
  const truncated = rows[0]?.listTruncated === true;
11263
11276
  const answered = rows.filter((r) => r.answered).length;
11264
11277
  const open = rows.length - answered;
11265
- const count = `${open}${truncated ? "+" : ""} contradiction${open === 1 && !truncated ? "" : "s"}`;
11278
+ const count = clashCount(open, truncated);
11266
11279
  const summary = rows.length === 0 ? listMode === "all" ? RESOLUTION_WORDS.noneOpen : `${RESOLUTION_WORDS.noneUnanswered} mode=all shows answered and snoozed ones.` : listMode === "all" ? RESOLUTION_WORDS.openHeader({ n: open, more: truncated }, answered > 0 || rows[0]?.closedTruncated ? { n: answered, more: rows[0]?.closedTruncated === true } : void 0) : `${count}. Propose an answer for its owner to confirm: conflicts action=propose issueId=<id> choice=${CONFLICT_RESOLUTIONS.join("|")}`;
11267
11280
  const order = rows[0]?.rankOrderNote ? [sanitizeSingleLineField(rows[0].rankOrderNote)] : [];
11268
11281
  return successResult([summary, ...order, ...lines].join("\n"), summary, { mode: listMode, rows });
@@ -11272,7 +11285,7 @@ async function handleConflictsResolve(issueId, args) {
11272
11285
  try {
11273
11286
  return await resolveOnce(issueId, args);
11274
11287
  } catch (err) {
11275
- if (err instanceof Error && err.message.includes(RESOLUTION_WORDS.answerVerb)) return validationResult(PROPOSE_INSTEAD(err.message, issueId));
11288
+ if (err instanceof Error && err.message.includes(RESOLUTION_WORDS.answerMatch)) return validationResult(PROPOSE_INSTEAD(err.message, issueId));
11276
11289
  throw err;
11277
11290
  }
11278
11291
  }
@@ -11317,7 +11330,8 @@ function registerConflictsTool(server) {
11317
11330
  propose: (data) => handleConflictsPropose(data.issueId, data)
11318
11331
  };
11319
11332
  server.registerTool("conflicts", {
11320
- title: "Conflicts",
11333
+ title: "Possible clashes",
11334
+ // a literal for scripts/generate-public-docs.mjs; conflicts.test.ts pins it to Clash.many (TASK-1556)
11321
11335
  description: RESOLUTION_WORDS.tool,
11322
11336
  inputSchema: conflictsSchema,
11323
11337
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
@@ -12157,4 +12171,4 @@ export {
12157
12171
  SERVER_VERSION,
12158
12172
  createProductBrainServer
12159
12173
  };
12160
- //# sourceMappingURL=chunk-GJ5R7G3X.js.map
12174
+ //# sourceMappingURL=chunk-ZUNF674E.js.map