@productbrain/mcp 0.0.1-beta.14363 → 0.0.1-beta.14430

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.
@@ -33,6 +33,7 @@ import {
33
33
  kernelMutation,
34
34
  kernelQuery,
35
35
  orientationRefusal,
36
+ personStatusTag,
36
37
  questionSeatName,
37
38
  recordSessionActivity,
38
39
  requireActiveSession,
@@ -48,7 +49,7 @@ import {
48
49
  startAgentSession,
49
50
  startTimingLine,
50
51
  withAcceptPrompt
51
- } from "./chunk-RHPRF4OG.js";
52
+ } from "./chunk-FY3VURR4.js";
52
53
 
53
54
  // src/server.ts
54
55
  import { McpServer as McpServer2 } from "@modelcontextprotocol/server";
@@ -81,6 +82,13 @@ var sessionRenewedNotice = (oldId, newId) => `Your session [${oldId}] had closed
81
82
 
82
83
  // src/envelope.ts
83
84
  import { z } from "zod/v3";
85
+
86
+ // src/lib/notFoundLine.ts
87
+ function entryNotFoundLine(entryId) {
88
+ return `Entry (${entryId}) not found. Check the ID, or search for it.`;
89
+ }
90
+
91
+ // src/envelope.ts
84
92
  function success(summary, data, next) {
85
93
  return {
86
94
  ok: true,
@@ -99,11 +107,14 @@ function failure(code, message, recovery, availableActions, diagnostics) {
99
107
  ...diagnostics ? { diagnostics } : {}
100
108
  };
101
109
  }
110
+ var NOT_FOUND_RECOVERY = "Run context action=search with query=<words> to find it.";
111
+ var notFoundText = (id) => `${entryNotFoundLine(id)}
112
+ ${NOT_FOUND_RECOVERY}`;
102
113
  function notFound(id, hint) {
103
114
  return failure(
104
115
  "NOT_FOUND",
105
- `Entry '${id}' not found.`,
106
- hint ?? "Use context action=search to find the correct ID.",
116
+ entryNotFoundLine(id),
117
+ hint ?? NOT_FOUND_RECOVERY,
107
118
  [{ tool: "context", description: "Search entries", parameters: { action: "search", query: id } }]
108
119
  );
109
120
  }
@@ -130,7 +141,7 @@ function failureResult(text, code, message, recovery, availableActions, diagnost
130
141
  return { content: textContent(text), structuredContent: failure(code, message, recovery, availableActions, diagnostics) };
131
142
  }
132
143
  function notFoundResult(id, text, hint) {
133
- return { content: textContent(text ?? `Entry '${id}' not found.`), structuredContent: notFound(id, hint) };
144
+ return { content: textContent(text ?? notFoundText(id)), structuredContent: notFound(id, hint) };
134
145
  }
135
146
  function validationResult(message) {
136
147
  return { content: textContent(message), structuredContent: validationError(message) };
@@ -212,16 +223,16 @@ function servedSchema(schema) {
212
223
  var FIRST_SPINE_SUBJECT = "work_package";
213
224
  var kindWord = (kind) => kind.replace(/_/g, " ");
214
225
  var withArticle = (word) => `${/^[aeiou]/i.test(word) ? "an" : "a"} ${word}`;
215
- var spineSubject = (kind, label = kindWord) => {
216
- const words = withArticle(label(kind));
226
+ var spineSubject = (kind, label2 = kindWord) => {
227
+ const words = withArticle(label2(kind));
217
228
  return words[0].toUpperCase() + words.slice(1);
218
229
  };
219
- function rungLine(rung, label = kindWord) {
230
+ function rungLine(rung, label2 = kindWord) {
220
231
  const index = SPINE_RUNG_SEQUENCE.findIndex((spec) => spec.targetKey === rung);
221
232
  if (index < 0) return null;
222
233
  const { relationType: relationType2, targetKey } = SPINE_RUNG_SEQUENCE[index];
223
- const parent = `an accepted ${label(targetKey)}`;
224
- const subject = spineSubject(index === 0 ? FIRST_SPINE_SUBJECT : SPINE_RUNG_SEQUENCE[index - 1].targetKey, label);
234
+ const parent = `an accepted ${label2(targetKey)}`;
235
+ const subject = spineSubject(index === 0 ? FIRST_SPINE_SUBJECT : SPINE_RUNG_SEQUENCE[index - 1].targetKey, label2);
225
236
  return relationType2 === "part_of" ? `${subject} hangs on ${parent} with ${relationType2}.` : `${subject} ${relationType2} ${parent}.`;
226
237
  }
227
238
  var SPINE_RUNG_LINES = SPINE_RUNG_SEQUENCE.map((spec) => rungLine(spec.targetKey));
@@ -314,6 +325,10 @@ function missingParentLine(parentWord) {
314
325
  return parentWord ? `Link it to the ${parentWord} it belongs to.` : "Link it to what it belongs to.";
315
326
  }
316
327
  var COACHING_HEADER = "Worth asking (does not block):";
328
+ var LINK_VERBS_HEADING = "Link types for this kind";
329
+ function linkVerbsLine(verbs) {
330
+ return verbs.length > 0 ? `${LINK_VERBS_HEADING}: ${verbs.join(", ")}.` : null;
331
+ }
317
332
  function renderChecklist(canonicalKey, criteria, judging) {
318
333
  const lines = CHECKLIST_LINES[canonicalKey];
319
334
  if (!lines) return null;
@@ -328,13 +343,21 @@ function renderChecklist(canonicalKey, criteria, judging) {
328
343
  }
329
344
 
330
345
  // src/lib/createEntryPreviewResult.ts
331
- async function resolvePreviewPreflight(result2, links) {
346
+ async function resolvePreviewPreflight(result2, links, draft) {
332
347
  if (!links?.length) return result2.preflight;
333
348
  try {
334
349
  return await kernelQuery("chain.preflightEntry", {
335
350
  collectionSlug: result2.collection,
336
351
  canonicalKey: result2.preflight.kind ?? void 0,
337
- links: links.map((link) => ({ entryId: link.to, type: link.type }))
352
+ links: links.map((link) => ({ entryId: link.to, type: link.type })),
353
+ ...draft ? {
354
+ name: draft.name,
355
+ data: draft.data,
356
+ ...draft.description ? { description: draft.description } : {},
357
+ ...typeof draft.why === "string" && draft.why.trim() ? { why: draft.why } : {},
358
+ ...draft.sessionId ? { sessionId: draft.sessionId } : {},
359
+ ...draft.ownerRoleEntryId ? { ownerRoleEntryId: draft.ownerRoleEntryId } : {}
360
+ } : {}
338
361
  });
339
362
  } catch {
340
363
  return {
@@ -354,14 +377,14 @@ async function resolvePreviewPreflight(result2, links) {
354
377
  function formatPreflightCheck(check) {
355
378
  if (check.status === "missing" && check.blocking) return `Blocked: ${check.message}`;
356
379
  if (check.status === "incomplete") return `Unverified: ${check.message}`;
357
- if (check.status === "not_checked") return `Checked later: ${check.message}`;
358
380
  return check.message;
359
381
  }
360
382
  function renderEntryPreflight(preflight) {
361
383
  return [
362
- ...preflight.checks.map(formatPreflightCheck),
384
+ ...preflight.checks.flatMap((check) => [formatPreflightCheck(check), ...check.requiredAction ? [check.requiredAction] : []]),
363
385
  ...preflight.requiredFields.length ? [`Required information: ${preflight.requiredFields.join(", ")}.`] : [],
364
- preflight.notice
386
+ ...preflight.verdict ? [preflight.verdict] : [],
387
+ preflight.notRun
365
388
  ];
366
389
  }
367
390
  function isPreviewCreateEntryResult(result2) {
@@ -409,6 +432,9 @@ var KEY_RESULT_BODY_HELP = `For a key result, open with what counts toward it; a
409
432
  var ENTRY_BODY_HELP = `The detail, in Markdown. ${KEY_RESULT_BODY_HELP}`;
410
433
  var SOURCE_EXCERPT_MAX_CHARS = 4e3;
411
434
  var LABEL_DESCRIPTION_MAX_CHARS = 2e3;
435
+ var REASON_MAX_LENGTH = 200;
436
+ var REASON_LENGTH_FIX = `Keep the reason to one line of at most ${REASON_MAX_LENGTH} characters.`;
437
+ var REASON_WITHOUT_REPLACES = "A reason goes only with the entry this one replaces. Nothing was accepted.";
412
438
  var RELATION_BATCH_MAX = 25;
413
439
  var BATCH_GET_CHUNK = 4;
414
440
  async function readInChunks(ids, read) {
@@ -515,21 +541,21 @@ function ownerLineParts(owner) {
515
541
  function formatOwnerLine(owner, options = {}) {
516
542
  const ids = options.ids ?? true;
517
543
  const word = owner.kind === "placed" ? PLACED_WORD : "Owner:";
518
- const label = options.bold ? `**${word}**` : word;
544
+ const label2 = options.bold ? `**${word}**` : word;
519
545
  switch (owner.kind) {
520
546
  case "one": {
521
547
  const { role, team } = ownerLineParts(owner);
522
- return `${label} ${role} in ${team}`;
548
+ return `${label2} ${role} in ${team}`;
523
549
  }
524
550
  case "none":
525
- return `${label} none`;
551
+ return `${label2} none`;
526
552
  case "placed":
527
- return `${label} ${owner.team.name}`;
553
+ return `${label2} ${owner.team.name}`;
528
554
  case "many":
529
- return `${label} conflicting \u2014 ${owner.count}${owner.truncated ? "+" : ""} owners recorded`;
555
+ return `${label2} conflicting \u2014 ${owner.count}${owner.truncated ? "+" : ""} owners recorded`;
530
556
  case "dangling": {
531
557
  const named = owner.team && owner.role ? `${owner.role.name} in ${owner.team.name} is archived` : owner.role ? `role ${owner.role.name} is archived` : owner.team ? `team ${owner.team.name} is archived` : "the owning team or role is archived";
532
- return ids ? `${label} couldn't be resolved \u2014 ${named} (team ${owner.teamId}, role ${owner.roleId})` : `${label} couldn't be resolved \u2014 ${named}`;
558
+ return ids ? `${label2} couldn't be resolved \u2014 ${named} (team ${owner.teamId}, role ${owner.roleId})` : `${label2} couldn't be resolved \u2014 ${named}`;
533
559
  }
534
560
  default: {
535
561
  const _exhaustive = owner;
@@ -895,17 +921,76 @@ function restsOnCountLine(count, bounded = false) {
895
921
  }
896
922
  function restsOnLine(item) {
897
923
  const date = new Date(item.changedAt).toISOString().split("T")[0];
898
- const label = item.kind === "past" ? item.label : "";
899
- return RESTS_ON_SENTENCES[item.kind].replace("{id}", item.entryId).replace("{label}", label).replace("{date}", date);
924
+ const label2 = item.kind === "past" ? item.label : "";
925
+ return RESTS_ON_SENTENCES[item.kind].replace("{id}", item.entryId).replace("{label}", label2).replace("{date}", date);
900
926
  }
901
927
 
902
928
  // src/lib/historyLine.ts
929
+ var label = (s) => s.replace(/[_-]/g, " ");
930
+ var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
931
+ var newOf = (changes, key) => asRecord(asRecord(changes)?.[key])?.new;
932
+ function newStatusOf(event, changes) {
933
+ if (event !== "status_changed" && event !== "workflow_status_changed") return null;
934
+ const w = newOf(changes, "workflowStatus");
935
+ const s = newOf(changes, "status");
936
+ if (typeof w === "string" && w) return w;
937
+ if (typeof s === "string" && s) return s;
938
+ return null;
939
+ }
940
+ function holderOf(event, changes) {
941
+ if (event !== "role_seated" && event !== "role_unseated") return null;
942
+ const c = asRecord(changes);
943
+ if (typeof c?.holder !== "string") return null;
944
+ return { name: c.holder, status: typeof c.holderStatus === "string" ? c.holderStatus : null };
945
+ }
946
+ var holderName = (h) => {
947
+ const tag = personStatusTag(h.status);
948
+ return tag ? `${h.name} (${tag})` : h.name;
949
+ };
950
+ function historyVerb(item) {
951
+ if (item.holder) return `${item.event === "role_seated" ? "seated" : "unseated"} ${holderName(item.holder)}`;
952
+ switch (item.event) {
953
+ case "created":
954
+ return "created";
955
+ case "accepted":
956
+ return "accepted";
957
+ case "version_published":
958
+ return "saved";
959
+ case "status_changed":
960
+ case "workflow_status_changed":
961
+ return item.newStatus ? `set status to ${label(item.newStatus)}` : "changed status";
962
+ case "verified":
963
+ case "confirmed":
964
+ return "confirmed";
965
+ case "superseded":
966
+ return "superseded";
967
+ case "collection_moved":
968
+ return "moved";
969
+ case "direction_trace_deferred":
970
+ return "deferred the strategy link";
971
+ default:
972
+ return label(item.event);
973
+ }
974
+ }
975
+ var RESTATED = [
976
+ /^Accepted onto (the )?Chain(\.(\s+|$)|$)/i,
977
+ /^Committed to chain(\.(\s+|$)|$)/i,
978
+ /^Updated( \w+(, \w+)*)?( \(via agent\))?\.\s+/i,
979
+ /^Updated( \w+(, \w+)*)?( \(via agent\))?\.?$/i,
980
+ /^Entry verified by .+$/i
981
+ ];
982
+ function shownNote(note) {
983
+ const rest = RESTATED.reduce((n, pattern) => n.replace(pattern, ""), (note ?? "").trim()).trim();
984
+ return rest || null;
985
+ }
903
986
  function historyLine(h, clean) {
904
987
  const date = new Date(h.timestamp).toISOString().split("T")[0];
988
+ const verb = historyVerb({ event: h.event, newStatus: newStatusOf(h.event, h.changes), holder: holderOf(h.event, h.changes) });
905
989
  const who = h.actingAs ? `${clean(h.displayAuthor)}, ${clean(h.actingAs)}` : clean(h.displayAuthor);
906
- const note = h.note ? ` \u2014 ${clean(h.note)}` : "";
990
+ const shownText = shownNote(h.note);
991
+ const note = shownText ? ` \u2014 ${clean(shownText)}` : "";
907
992
  const qualifier = h.legacyQualifier ? ` [${clean(h.legacyQualifier)}]` : "";
908
- return `${date}: ${clean(h.event)} (${who})${note}${qualifier}`;
993
+ return `${date}: ${clean(verb)} (${who})${note}${qualifier}`;
909
994
  }
910
995
 
911
996
  // src/tools/knowledge.ts
@@ -951,10 +1036,13 @@ function resumeReplayedCapture(replay, name) {
951
1036
  const summary = `Already captured as ${replay.entryId}; this re-send returned that entry and wrote no second one.`;
952
1037
  const linkLines = links.map((l) => `- ${l.line}`);
953
1038
  const draftLines = status2 === "draft" ? draftReplyLines(name, replay.entryId, replay.spineFloor, replay.missingFieldLines) : [];
954
- const linkBlock = linkLines.length ? `
1039
+ const typedLinks = replay.typedLinks ?? [];
1040
+ const linkBlock = (linkLines.length ? `
955
1041
 
956
1042
  **Links:**
957
- ${linkLines.join("\n")}` : "";
1043
+ ${linkLines.join("\n")}` : "") + (typedLinks.length ? `
1044
+
1045
+ ${typedLinks.map((l) => l.line).join("\n")}` : "");
958
1046
  return {
959
1047
  content: [{
960
1048
  type: "text",
@@ -971,7 +1059,8 @@ Read it with \`context action=get\`.`
971
1059
  name,
972
1060
  status: status2,
973
1061
  replayed: true,
974
- ...links.length ? { links } : {}
1062
+ ...links.length ? { links } : {},
1063
+ ...typedLinks.length ? { typedLinks } : {}
975
1064
  })
976
1065
  };
977
1066
  }
@@ -1193,6 +1282,7 @@ var captureSuccessOutputSchema = z5.object({
1193
1282
  collection: z5.string(),
1194
1283
  name: z5.string(),
1195
1284
  status: z5.enum(["draft", "committed", "proposed", "draft_on_failure"]),
1285
+ // "committed": only a re-send of an entry accepted since (captureTimeoutOutcome.ts); a create never accepts (DEC-2331)
1196
1286
  // WP-480 S1: `qualityScore` deleted (accepted breaking output change); the server verdict stays as `qualityVerdict`.
1197
1287
  qualityVerdict: z5.record(z5.unknown()).optional(),
1198
1288
  qualityHints: z5.array(z5.record(z5.unknown())).optional(),
@@ -1226,6 +1316,9 @@ var captureSuccessOutputSchema = z5.object({
1226
1316
  // TASK-898: a re-sent capture answered with the first capture's entry
1227
1317
  // TASK-897: the kernel's outcome per link, on a create and on a replay.
1228
1318
  links: z5.array(z5.object({ toEntryId: z5.string(), type: z5.string(), outcome: z5.enum(CAPTURE_LINK_OUTCOMES), reason: z5.string().optional(), line: z5.string() }).passthrough()).optional(),
1319
+ typedLinks: z5.array(z5.object({ toEntryId: z5.string(), outcome: z5.enum(["written", "reported"]), line: z5.string() })).optional(),
1320
+ linkVerbs: z5.array(z5.string()).optional(),
1321
+ // TASK-1672
1229
1322
  fallbackApplied: z5.boolean().optional()
1230
1323
  // never set since TASK-964 (the kernel classifies among live collections only); kept, never narrowed (DEC-1831)
1231
1324
  }).strict();
@@ -1276,7 +1369,7 @@ function registerSmartCaptureTools(server) {
1276
1369
  "capture",
1277
1370
  {
1278
1371
  title: "Capture",
1279
- description: "The tool for creating a single knowledge entry. Creates an entry and returns a quality scorecard \u2014 all in one call. Provide a name and description; `collection` is optional \u2014 the kernel classifies when omitted and files a low-confidence pick as a draft with one line saying so. An agent capturing several atoms from one text calls this once per atom.\n\n**Explicit data:** When you know the schema, pass `data: { field: value }` to set fields directly. A value in `data` is kept as sent; `description` is the entry's text and fills the collection's prose field only when `data` leaves it empty (the same rule as `pb capture`); when `data` carries the prose field, `description` and `context` are used for classification and judging only and are not stored. Governance entries also require a top-level `why`.\n\n**Compound capture:** Pass `links` to create relations in the same call; a capture writes no other relations. A capture is a `draft` until `entries action=accept`; questions use `question action=create`. The reply names possible duplicates; only an exact name in the collection is refused.",
1372
+ description: "The tool for creating a single knowledge entry. Creates an entry and returns a quality scorecard \u2014 all in one call. Provide a name and description; `collection` is optional \u2014 the kernel classifies when omitted and files a low-confidence pick as a draft with one line saying so. An agent capturing several atoms from one text calls this once per atom.\n\n**Explicit data:** When you know the schema, pass `data: { field: value }` to set fields directly. A value in `data` is kept as sent; `description` is the entry's text and fills the collection's prose field only when `data` leaves it empty (the same rule as `pb capture`); when `data` carries the prose field, `description` and `context` are used for classification and judging only and are not stored. Governance entries also require a top-level `why`.\n\n**Compound capture:** Pass `links` to create relations in the same call. An entry id typed in the text is linked as `references` and named in the reply; a capture writes no other relations. A capture is a `draft` until `entries action=accept`; questions use `question action=create`. The reply names possible duplicates; only an exact name in the collection is refused.",
1280
1373
  inputSchema: captureCompoundSchema,
1281
1374
  annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
1282
1375
  },
@@ -1333,11 +1426,12 @@ ${context.trim()}` : description;
1333
1426
  const entryWarnings = [];
1334
1427
  let formativeHints = [];
1335
1428
  let coachingFromCreate;
1336
- let wasAutoCommittedServerSide = false;
1337
1429
  let missingFieldLines = [];
1338
1430
  let possibleClashes = [];
1339
1431
  let spineFloor;
1340
1432
  let linkOutcomes = [];
1433
+ let typedLinks = [];
1434
+ let linkVerbs = [];
1341
1435
  try {
1342
1436
  const result2 = await kernelMutation("chain.createEntry", {
1343
1437
  // TASK-964: the slug only when the caller named one; otherwise the kernel classifies (entries.ts, the auto branch).
@@ -1345,7 +1439,7 @@ ${context.trim()}` : description;
1345
1439
  name,
1346
1440
  description: text,
1347
1441
  // the classifier's, the judge's and the shaper's text; the kernel files it in the collection's prose field when that is empty
1348
- // DEC-896 / BR-76: omit status — server resolves from governanceMode (Open→active, else draft).
1442
+ // No status: every create lands a draft (DEC-2331); only the accept door makes it current.
1349
1443
  data: userData ?? {},
1350
1444
  // as sent (WP-574/TEN-2916: no key is filtered); the kernel shapes it (DEC-2172)
1351
1445
  ...canonicalKey ? { canonicalKey } : {},
@@ -1366,7 +1460,7 @@ ${context.trim()}` : description;
1366
1460
  });
1367
1461
  if (result2 && "replayed" in result2) return resumeReplayedCapture(result2, name);
1368
1462
  if (result2 && isPreviewCreateEntryResult(result2)) {
1369
- const preflight = await resolvePreviewPreflight(result2, links);
1463
+ const preflight = await resolvePreviewPreflight(result2, links, { name, data: userData ?? {}, description: text, why, sessionId: agentId ?? void 0, ownerRoleEntryId });
1370
1464
  const previewCollection = resolveEffectiveCollection(result2, preview, collectionSlug ?? "");
1371
1465
  const dupCount = groundingReport.duplicates.length;
1372
1466
  const groundingSummary = dupCount > 0 ? `
@@ -1437,9 +1531,9 @@ No DB writes \u2014 call without \`preview:true\` to capture for real.${result2.
1437
1531
  linkOutcomes = created.links ?? [];
1438
1532
  missingFieldLines = created.missingFieldLines ?? [];
1439
1533
  possibleClashes = created.possibleClashes ?? [];
1440
- const createdStatus = created.status;
1441
- if (createdStatus !== void 0 && isTrustAccepted(createdStatus)) wasAutoCommittedServerSide = true;
1442
1534
  spineFloor = created.spineFloor;
1535
+ typedLinks = created.typedLinks ?? [];
1536
+ linkVerbs = created.linkVerbs ?? [];
1443
1537
  const matches = created.verdict?.kind === "ask" ? created.verdict.matches : [];
1444
1538
  groundingReport.duplicates = matches.map((m) => ({ entryId: m.entryId, name: m.name, collectionSlug: m.collectionSlug, denseScore: m.score, overlapRatio: m.score }));
1445
1539
  if (created.verdict) groundingReport.scanTruncated = false;
@@ -1477,7 +1571,7 @@ Use \`context action=get\` to inspect the existing entry, or \`entries action=up
1477
1571
  if (verdictResult?.verdict && verdictResult.verdict.tier !== "passive" && verdictResult.verdict.criteria.length > 0) {
1478
1572
  coachingSection = formatRubricCoaching(verdictResult);
1479
1573
  }
1480
- const finalStatus = wasAutoCommittedServerSide ? "committed" : "draft";
1574
+ const finalStatus = "draft";
1481
1575
  const lines = [
1482
1576
  `# Captured: ${finalEntryId || name}`,
1483
1577
  `**${name}** added to \`${landedCollection}\` as \`${finalStatus}\``,
@@ -1496,11 +1590,8 @@ Use \`context action=get\` to inspect the existing entry, or \`entries action=up
1496
1590
  lines.push("## Requested links");
1497
1591
  for (const l of linkOutcomes) lines.push(`- ${l.line}`);
1498
1592
  }
1499
- if (finalStatus === "committed") {
1500
- lines.push("");
1501
- lines.push(`## Accepted: ${finalEntryId}`);
1502
- lines.push(`**${name}** added to your knowledge base.`);
1503
- } else lines.push(...draftReplyLines(name, finalEntryId, spineFloor, missingFieldLines), ...possibleClashes.length ? ["", ...possibleClashes] : []);
1593
+ if (typedLinks.length > 0) lines.push("", ...typedLinks.map((l) => l.line));
1594
+ lines.push(...draftReplyLines(name, finalEntryId, spineFloor, missingFieldLines), ...possibleClashes.length ? ["", ...possibleClashes] : []);
1504
1595
  if (groundingCaveat) lines.push("", groundingCaveat);
1505
1596
  const named = groundingReport.duplicates.slice(0, 3).map((d) => `${d.entryId} "${d.name}"`).join(", ");
1506
1597
  if (named) lines.push("", `**Possible match:** ${named}. Nothing was written to it; to change it, use \`entries action=update\`.`);
@@ -1527,29 +1618,19 @@ Use \`context action=get\` to inspect the existing entry, or \`entries action=up
1527
1618
  lines.push("");
1528
1619
  lines.push("## Next Steps");
1529
1620
  const eid = finalEntryId || "(check entry ID)";
1530
- if (finalStatus === "committed") {
1621
+ if (linkOutcomes.length === 0) {
1531
1622
  lines.push(`1. **Connect it:** find related entries with \`context action=search\`, then \`relations action=create from="${eid}" to="<ID>" type="<verb>"\``);
1532
- if (hasQualityGaps) {
1533
- lines.push(`2. **Improve quality:** \`entries action=update entryId="${eid}"\` \u2014 fill missing fields`);
1534
- }
1535
- } else {
1536
- if (linkOutcomes.length === 0) {
1537
- lines.push(`1. **Connect it:** find related entries with \`context action=search\`, then \`relations action=create from="${eid}" to="<ID>" type="<verb>"\``);
1538
- }
1539
- lines.push(`${linkOutcomes.length === 0 ? "2" : "1"}. **Review the possibility:** Keep this visible draft while it is an alternative. Accept only when commitment is intended and your role is authorized. Types reserved for human acceptance require human ratification. An audit advisory is not a reason to accept it.`);
1540
- if (hasQualityGaps) {
1541
- lines.push(`${linkOutcomes.length === 0 ? "3" : "2"}. **Improve quality:** \`entries action=update entryId="${eid}"\` \u2014 fill missing fields`);
1542
- }
1543
1623
  }
1544
- const next = [];
1545
- if (finalStatus === "committed") {
1546
- next.push({ tool: "context", description: "See its connections", parameters: { action: "find", entryId: finalEntryId } });
1547
- } else {
1548
- next.push({ tool: "context", description: "Review the draft alternative", parameters: { action: "get", entryId: finalEntryId } });
1549
- next.push(spineFloor && !spineFloor.exempt && !spineFloor.linkWritten ? { tool: "relations", description: missingParentLine(spineFloor.parentKind.replace(/_/g, " ")), parameters: { action: "create", from: finalEntryId, type: spineFloor.relationType } } : { tool: "entries", description: "Accept onto Chain", parameters: { action: "accept", entryId: finalEntryId } });
1624
+ const verbs = linkVerbsLine(linkVerbs);
1625
+ if (verbs) lines.push(verbs);
1626
+ lines.push(`${linkOutcomes.length === 0 ? "2" : "1"}. **Review the possibility:** Keep this visible draft while it is an alternative. Accept only when commitment is intended and your role is authorized. Types reserved for human acceptance require human ratification. An audit advisory is not a reason to accept it.`);
1627
+ if (hasQualityGaps) {
1628
+ lines.push(`${linkOutcomes.length === 0 ? "3" : "2"}. **Improve quality:** \`entries action=update entryId="${eid}"\` \u2014 fill missing fields`);
1550
1629
  }
1630
+ const next = [{ tool: "context", description: "Review the draft alternative", parameters: { action: "get", entryId: finalEntryId } }];
1631
+ next.push(spineFloor && !spineFloor.exempt && !spineFloor.linkWritten ? { tool: "relations", description: missingParentLine(spineFloor.parentKind.replace(/_/g, " ")), parameters: { action: "create", from: finalEntryId, type: spineFloor.relationType } } : { tool: "entries", description: "Accept onto Chain", parameters: { action: "accept", entryId: finalEntryId } });
1551
1632
  const qualityPhrase = verdictQualityPhrase(verdictResult);
1552
- const summary = finalStatus === "committed" ? `Captured and accepted ${finalEntryId} (${name}) onto ${landedCollection}. ${qualityPhrase}` : `Captured ${finalEntryId} (${name}) as draft in ${landedCollection}. ${qualityPhrase}`;
1633
+ const summary = `Captured ${finalEntryId} (${name}) as draft in ${landedCollection}. ${qualityPhrase}`;
1553
1634
  const expectedFields = replyFields.map((f) => ({ key: f.key, type: f.type, ...f.required && { required: true } }));
1554
1635
  const captureContractForEnvelope = {
1555
1636
  requiredFields: replyFields.filter((f) => f.required === true).map((f) => f.key),
@@ -1591,6 +1672,9 @@ Use \`context action=get\` to inspect the existing entry, or \`entries action=up
1591
1672
  ...linkOutcomes.length > 0 && { links: linkOutcomes },
1592
1673
  ...possibleClashes.length > 0 && { possibleClashes },
1593
1674
  // TASK-897; TASK-1553
1675
+ ...typedLinks.length > 0 && { typedLinks },
1676
+ ...linkVerbs.length > 0 && { linkVerbs },
1677
+ // TASK-1672
1594
1678
  // WP-318 S2: the possible-duplicate report — always included (empty when no ask match)
1595
1679
  groundingReport
1596
1680
  },
@@ -1778,6 +1862,8 @@ var updateEntrySchema = z7.object({
1778
1862
  // DEC-1716
1779
1863
  changeReason: z7.string().optional().describe("Change reason: required when this update changes a promise field (or the name of a collection that declares one) of an accepted entry \u2014 why what the entry promises is changing. Recorded on the history event and the version. Not the same as changeNote."),
1780
1864
  changeNote: z7.string().optional().describe("Strongly recommended: short human-readable rationale for WHY this change was made (e.g. 'Aligned description with F1-themed copy'). Surfaces in activity feed and pb get. If omitted, falls back to session purpose or auto-generated field summary."),
1865
+ changedByEntry: z7.string().max(200).optional(),
1866
+ // TASK-1674 (TASK-711): described once, on the served entries schema
1781
1867
  sourceRef: z7.string().optional().describe("URI or path of the source document backing this entry. Write-once: can only be set if currently empty."),
1782
1868
  sourceExcerpt: z7.string().optional().describe("Verbatim excerpt from the source that backs this entry's claims. Write-once: can only be set if currently empty."),
1783
1869
  // WP-465 slice ⑤ — relay-only (TEN-2233): validation/min-length/recording live in Convex.
@@ -1805,10 +1891,10 @@ var commitEntrySchema = z7.object({
1805
1891
  }).optional().describe("Your answer when an entry links to nothing."),
1806
1892
  replaces: z7.string().max(200).optional(),
1807
1893
  // TASK-1030: described once, on the served entries schema
1808
- reason: z7.string().max(2e3).optional()
1809
- // DEC-2006: with replaces, why; the kernel refuses a replace without one (one line, 200 chars)
1894
+ // DEC-2006: with replaces, why; the kernel refuses a replace without one, and a reason without replaces (TEN-5678). The kernel's one limit.
1895
+ reason: z7.string().trim().max(REASON_MAX_LENGTH, { message: REASON_LENGTH_FIX }).optional()
1810
1896
  });
1811
- async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowStatus: rawWorkflowStatus, data, order, canonicalKey, autoPublish, changeNote, changeReason, sourceRef, sourceExcerpt, steeringOverrideReason, qualityOverrideReason, coherencyAcknowledgement }, toolName = "entries") {
1897
+ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowStatus: rawWorkflowStatus, data, order, canonicalKey, autoPublish, changeNote, changeReason, changedByEntry, sourceRef, sourceExcerpt, steeringOverrideReason, qualityOverrideReason, coherencyAcknowledgement }, toolName = "entries") {
1812
1898
  requireWriteAccess();
1813
1899
  const fieldsProvided = [];
1814
1900
  for (const [k, v] of [["name", name], ["status", rawStatus], ["workflowStatus", rawWorkflowStatus], ["data", data], ["order", order]]) if (v !== void 0) fieldsProvided.push(k);
@@ -1826,6 +1912,8 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
1826
1912
  autoPublish,
1827
1913
  changeNote,
1828
1914
  ...changeReason ? { changeReason } : {},
1915
+ ...changedByEntry !== void 0 ? { changedByEntry: changedByEntry.trim() } : {},
1916
+ // TASK-1674: the door refuses a blank one
1829
1917
  changedBy: getAgentSessionId() ? `agent:${getAgentSessionId()}` : void 0,
1830
1918
  ...sourceRef !== void 0 ? { sourceRef } : {},
1831
1919
  ...sourceExcerpt !== void 0 ? { sourceExcerpt } : {},
@@ -1861,12 +1949,14 @@ ${mcp}`, "QUALITY_HELD", mcp.split("\n")[0] ?? mcp, mcp.split("\n")[1] ?? mcp, v
1861
1949
  const wsCtx = await getWorkspaceContext();
1862
1950
  const updated = await kernelQuery("chain.getEntry", { entryId });
1863
1951
  const entryStatus = updated?.status ?? "draft";
1952
+ const changedLine = applied.changedLine ? sanitizeSingleLineField(applied.changedLine) : null;
1864
1953
  const versionMode = isTrustAccepted(entryStatus) ? "published" : `saved as ${entryStatus}`;
1865
1954
  const responseLines = [
1866
1955
  `# Entry Updated`,
1867
1956
  ``,
1868
1957
  applied.receipt ?? `**${entryId}** \u2014 ${versionMode}.`,
1869
1958
  // TASK-773: a draft team's discard names the drafts it took
1959
+ ...changedLine ? [changedLine] : [],
1870
1960
  ...applied.qualityOverride ? [applied.qualityOverride] : [],
1871
1961
  // TASK-954: the recorded line, never a silent clear
1872
1962
  ...applied.restsOnCount !== void 0 ? [restsOnCountLine(applied.restsOnCount, applied.restsOnBounded === true)] : [],
@@ -1918,17 +2008,19 @@ ${mcp}`, "QUALITY_HELD", mcp.split("\n")[0] ?? mcp, mcp.split("\n")[1] ?? mcp, v
1918
2008
  },
1919
2009
  ...revertedFields.length > 0 && { revertedFields },
1920
2010
  // #1026 R2: symmetric with the text above
1921
- ...applied.restsOnCount !== void 0 ? { restsOnCount: applied.restsOnCount, restsOnBounded: applied.restsOnBounded } : {}
2011
+ ...applied.restsOnCount !== void 0 ? { restsOnCount: applied.restsOnCount, restsOnBounded: applied.restsOnBounded } : {},
1922
2012
  // TASK-935
2013
+ ...changedLine ? { changedLine } : {}
1923
2014
  }, next)
1924
2015
  };
1925
2016
  }
2017
+ var reasonWithoutReplacesNext = (entryId) => `Next: ${acceptCall(entryId, "<id>")}, or accept without a reason.`;
1926
2018
  var possibleClashesOf = (result2) => Array.isArray(result2?.possibleClashes) ? result2.possibleClashes.filter((line) => typeof line === "string") : [];
1927
2019
  async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qualityOverrideReason, coherencyAcknowledgement, replaces, reason: reason2 }, toolName = "entries") {
1928
2020
  requireWriteAccess();
1929
2021
  const entry = await kernelQuery("chain.getEntry", { entryId });
1930
2022
  if (!entry) {
1931
- return notFoundResult(entryId, `Entry '${entryId}' not found. Try search to find the right ID.`);
2023
+ return notFoundResult(entryId);
1932
2024
  }
1933
2025
  const coachingResult = preview ? null : await kernelMutation(
1934
2026
  "quality.evaluateHeuristicAndSchedule",
@@ -1943,16 +2035,23 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
1943
2035
  ...qualityOverrideReason ? { qualityOverrideReason } : {},
1944
2036
  // TASK-954
1945
2037
  ...coherencyAcknowledgement ? { coherencyAcknowledgement } : {},
1946
- ...replaces ? { replaces, ...reason2 !== void 0 ? { replacesReason: reason2 } : {} } : {}
1947
- // TASK-1030; DEC-2006: the reason rides with it
2038
+ ...replaces ? { replaces } : {},
2039
+ ...reason2 !== void 0 ? { replacesReason: reason2 } : {}
2040
+ // TASK-1030; DEC-2006; TEN-5678: the kernel refuses a reason alone
1948
2041
  }).catch((err) => {
1949
2042
  const { code, details } = err;
2043
+ if (err instanceof Error && err.message.includes(REASON_WITHOUT_REPLACES)) return { status: "reason_refused" };
1950
2044
  const fix = code === "GROUNDING_GATE_BLOCKED" ? refusalFixOf(details) : null;
1951
2045
  if (!fix) throw err;
1952
2046
  const reason3 = err.message.replace(/^MCP call "[^"]+" failed \(\d+\): /s, "");
1953
2047
  const acceptRefusal = details?.find((d) => typeof d === "object" && d !== null && "acceptRefusal" in d);
1954
2048
  return { status: "coherency_refused", refusal: { reason: reason3, fix, acceptRefusal: acceptRefusal?.acceptRefusal } };
1955
2049
  });
2050
+ if (result2?.status === "reason_refused") {
2051
+ const next2 = reasonWithoutReplacesNext(entryId);
2052
+ return failureResult(`${REASON_WITHOUT_REPLACES}
2053
+ ${next2}`, "VALIDATION_ERROR", REASON_WITHOUT_REPLACES, next2);
2054
+ }
1956
2055
  if (result2?.status === "coherency_refused" && result2?.refusal) {
1957
2056
  return coherencyRefusedResult(`${toolName} action=accept`, entryId, result2.refusal);
1958
2057
  }
@@ -2511,7 +2610,8 @@ import { z as z10 } from "zod/v3";
2511
2610
  var replaceEntrySchema = z10.object({
2512
2611
  entryId: z10.string().max(200).describe("Human entry ID of the entry being replaced (e.g. '<PREFIX>-<n>')."),
2513
2612
  newEntryId: z10.string().max(200).describe("Human entry ID of the accepted entry of the same kind that replaces it."),
2514
- reason: z10.string().max(2e3).optional().describe("Why it is replaced, one line (required; the kernel refuses without one).")
2613
+ // TEN-5678: the kernel's one limit.
2614
+ reason: z10.string().trim().max(REASON_MAX_LENGTH, { message: REASON_LENGTH_FIX }).optional().describe(`Why it is replaced, one line of at most ${REASON_MAX_LENGTH} characters (required; the kernel refuses without one).`)
2515
2615
  });
2516
2616
  async function handleReplaceEntry({ entryId, newEntryId, reason: reason2 }) {
2517
2617
  requireWriteAccess();
@@ -2674,6 +2774,10 @@ var entriesSchema = z12.object({
2674
2774
  changeReason: z12.string().max(2e3).optional().describe(
2675
2775
  "For 'update': Change reason \u2014 required when the update changes a promise field of an accepted entry. Recorded on the history event and the version."
2676
2776
  ),
2777
+ changedByEntry: z12.string().max(200).optional().describe(
2778
+ `For 'update': the newer entry this update answers a ${CLASH.one} with; needs changeReason.`
2779
+ ),
2780
+ // TASK-1674 (TASK-711)
2677
2781
  changeNote: z12.string().max(2e3).optional().describe(
2678
2782
  "For 'update': short human-readable rationale for WHY this change was made. Surfaces in activity feed."
2679
2783
  ),
@@ -2697,8 +2801,10 @@ var entriesSchema = z12.object({
2697
2801
  ),
2698
2802
  replaces: z12.string().max(200).optional().describe("For 'accept': the accepted entry of the same kind this one replaces; it is archived."),
2699
2803
  // TASK-1030
2700
- reason: z12.string().max(2e3).optional().describe("For 'accept' with replaces, and for 'replace': why, one line (required)."),
2701
- // DEC-2006
2804
+ // DEC-2006; TEN-5678: the kernel's one limit.
2805
+ reason: z12.string().trim().max(REASON_MAX_LENGTH, { message: REASON_LENGTH_FIX }).optional().describe(
2806
+ `For 'accept' with replaces, and for 'replace': why, one line of at most ${REASON_MAX_LENGTH} characters (required).`
2807
+ ),
2702
2808
  toCollection: z12.string().max(200).optional().describe("For 'move': target collection slug, e.g. 'decisions', 'architecture'.")
2703
2809
  });
2704
2810
  var entriesUpdateVariant = updateEntrySchema.extend({ action: z12.literal("update") });
@@ -2722,7 +2828,7 @@ var entriesActionUnion = z12.discriminatedUnion("action", [
2722
2828
  entriesReplaceVariant
2723
2829
  ]);
2724
2830
  var ENTRIES_ACTION_SPECS = {
2725
- update: { params: ["entryId", "name", "status", "workflowStatus", "data", "order", "canonicalKey", "autoPublish", "changeNote", "changeReason", "sourceRef", "sourceExcerpt", "steeringOverrideReason", "qualityOverrideReason", "coherencyAcknowledgement"], description: "entryId is required; every other field is optional." },
2831
+ update: { params: ["entryId", "name", "status", "workflowStatus", "data", "order", "canonicalKey", "autoPublish", "changeNote", "changeReason", "changedByEntry", "sourceRef", "sourceExcerpt", "steeringOverrideReason", "qualityOverrideReason", "coherencyAcknowledgement"], description: "entryId is required; every other field is optional." },
2726
2832
  accept: { params: ["entryId", "preview", "steeringOverrideReason", "qualityOverrideReason", "coherencyAcknowledgement", "replaces", "reason"], description: "entryId is required." },
2727
2833
  move: { params: ["entryId", "toCollection", "canonicalKey"], description: "entryId and toCollection are required; canonicalKey is optional (atomic move+retype)." },
2728
2834
  verify: { params: ["entryId"], description: "entryId is required." },
@@ -2915,10 +3021,9 @@ async function handleEntryPreflight(collection, canonicalKey, links) {
2915
3021
  const result2 = await kernelQuery("chain.preflightEntry", { collectionSlug: collection, canonicalKey, links });
2916
3022
  return { content: [{ type: "text", text: renderEntryPreflight(result2).join("\n") }], structuredContent: success("Structural requirements checked; nothing saved.", result2) };
2917
3023
  }
2918
- var getNotFoundText = (entryId) => `Entry '${entryId}' not found. Try search to find the right ID.`;
2919
3024
  async function handleGet(entryId) {
2920
3025
  const entry = await kernelQuery("chain.getEntry", { entryId }, { recall: true });
2921
- if (!entry) return notFoundResult(entryId, getNotFoundText(entryId));
3026
+ if (!entry) return notFoundResult(entryId);
2922
3027
  const e = entry;
2923
3028
  const { lines, entryData } = entryCard(e);
2924
3029
  return {
@@ -2937,11 +3042,11 @@ function entryCard(e) {
2937
3042
  const conflictLabel = e.possibleConflict?.label;
2938
3043
  const epistemic = deriveEpistemicStatus(toEpistemicInput(e));
2939
3044
  const lines = [
3045
+ // under the status, the kernel's Replaced by and Changed by lines (DEC-2006; TASK-1674)
2940
3046
  `# ${e.entryId ? `${e.entryId}: ` : ""}${e.name}`,
2941
3047
  "",
2942
3048
  `**Status:** ${e.status}${e.workflowStatus ? ` / ${e.workflowStatus}` : ""}`,
2943
- ...typeof e.replacedLine === "string" ? [sanitizeSingleLineField(e.replacedLine)] : [],
2944
- // DEC-2006
3049
+ ...[e.replacedLine, e.changedLine].flatMap((l) => typeof l === "string" ? [sanitizeSingleLineField(l)] : []),
2945
3050
  ...typeof conflictLabel === "string" ? [`\u26A0 ${sanitizeSingleLineField(conflictLabel)}`] : [],
2946
3051
  `**Collection:** ${e.collectionSlug ?? "unknown"}`
2947
3052
  ];
@@ -3000,7 +3105,7 @@ function entryCard(e) {
3000
3105
  ...e.sourceExcerpt ? { sourceExcerpt: String(e.sourceExcerpt) } : {},
3001
3106
  ...parsedOwner ? { owner: parsedOwner } : {},
3002
3107
  // TASK-954, TASK-1027: the kernel's lines as served
3003
- ...Object.fromEntries(["heldLine", "pendingMove", "qualityOverride", "spineLine", "replacedLine"].filter((k) => typeof e[k] === "string").map((k) => [k, e[k]])),
3108
+ ...Object.fromEntries(["heldLine", "pendingMove", "qualityOverride", "spineLine", "replacedLine", "changedLine"].filter((k) => typeof e[k] === "string").map((k) => [k, e[k]])),
3004
3109
  ...e.coveredBy !== void 0 ? { coveredBy: e.coveredBy } : {},
3005
3110
  // DEC-2257: the Team Lead holding a role with no one seated
3006
3111
  ...restsOnChanged.length > 0 ? { restsOnChanged } : {},
@@ -3027,7 +3132,7 @@ async function handleBatch(entryIds) {
3027
3132
  const results = await readInChunks(entryIds, read);
3028
3133
  const cards = entryIds.map((_, i) => results[i]?.entry ? entryCard(results[i].entry) : null);
3029
3134
  const notFound2 = entryIds.filter((_, i) => !cards[i]);
3030
- const blocks = entryIds.map((id, i) => cards[i]?.lines.join("\n") ?? getNotFoundText(id));
3135
+ const blocks = entryIds.map((id, i) => cards[i]?.lines.join("\n") ?? notFoundText(id));
3031
3136
  const entries = cards.flatMap((card) => card ? [card.entryData] : []);
3032
3137
  return {
3033
3138
  content: [{ type: "text", text: [`## Get Result`, "", blocks.join("\n\n---\n\n")].join("\n") }],
@@ -3037,11 +3142,11 @@ async function handleBatch(entryIds) {
3037
3142
  )
3038
3143
  };
3039
3144
  }
3040
- async function handleList(collection, status2, tag, label) {
3145
+ async function handleList(collection, status2, tag, label2) {
3041
3146
  let entries;
3042
3147
  let cutLine = null;
3043
- if (label) {
3044
- entries = await kernelQuery("chain.listEntriesByLabel", { labelSlug: label, acceptedOnly: !status2 });
3148
+ if (label2) {
3149
+ entries = await kernelQuery("chain.listEntriesByLabel", { labelSlug: label2, acceptedOnly: !status2 });
3045
3150
  if (status2) {
3046
3151
  entries = entries.filter((e) => e.status === status2);
3047
3152
  }
@@ -3657,7 +3762,7 @@ async function handleFind(entryId, direction) {
3657
3762
  }
3658
3763
  const sourceEntry = await kernelQuery("chain.getEntry", { entryId });
3659
3764
  if (!sourceEntry) {
3660
- return notFoundResult(entryId, `Entry '${entryId}' not found. Try context action=search to find the right ID.`);
3765
+ return notFoundResult(entryId);
3661
3766
  }
3662
3767
  const sourceInternalId = sourceEntry._id;
3663
3768
  const MAX_RELATIONS = 25;
@@ -4241,9 +4346,9 @@ function formatRow(row) {
4241
4346
  const collectionSlug = row.collectionSlug ? sanitizeSingleLineField(row.collectionSlug) : "?";
4242
4347
  return ` ${id} ${sanitizeSingleLineField(row.name)} [${collectionSlug}/${statusDisplay}]`;
4243
4348
  }
4244
- function formatSection(label, rows, truncated, cursorHint) {
4245
- if (rows.length === 0 && !truncated) return [` ${label}: not recorded yet`];
4246
- const lines = rows.length === 0 ? [` ${label}: not recorded yet, but the scan is incomplete`] : [` ${label}:`, ...rows.map(formatRow)];
4349
+ function formatSection(label2, rows, truncated, cursorHint) {
4350
+ if (rows.length === 0 && !truncated) return [` ${label2}: not recorded yet`];
4351
+ const lines = rows.length === 0 ? [` ${label2}: not recorded yet, but the scan is incomplete`] : [` ${label2}:`, ...rows.map(formatRow)];
4247
4352
  if (truncated) lines.push(` (scan incomplete, more may exist \u2014 ${cursorHint ?? "raise limit (capped at 200, no cursor for this list)"})`);
4248
4353
  return lines;
4249
4354
  }
@@ -4693,7 +4798,7 @@ async function handleGather(server, entryId, task, mode2, maxHops, maxResults, s
4693
4798
  maxHops
4694
4799
  });
4695
4800
  if (!result3?.root) {
4696
- return notFoundResult(entryId, `Entry '${entryId}' not found. Try search to find the right ID.`);
4801
+ return notFoundResult(entryId);
4697
4802
  }
4698
4803
  const root2 = result3.root;
4699
4804
  if (result3.context.length === 0) {
@@ -4917,7 +5022,7 @@ _This helps future sessions start with better constraints and context._`
4917
5022
  });
4918
5023
  const result2 = await kernelQuery("chain.gatherContext", { entryId, maxHops });
4919
5024
  if (!result2?.root) {
4920
- return notFoundResult(entryId, `Entry '${entryId}' not found. Try search to find the right ID.`);
5025
+ return notFoundResult(entryId);
4921
5026
  }
4922
5027
  const root = result2.root;
4923
5028
  if (result2.related.length === 0) {
@@ -5255,7 +5360,7 @@ async function handleChainWalk(entryId, direction, maxHops, relationType2) {
5255
5360
  ...relationType2 ? { relationType: relationType2 } : {}
5256
5361
  });
5257
5362
  if (result2.error) {
5258
- return notFoundResult(entryId, result2.error);
5363
+ return notFoundResult(entryId);
5259
5364
  }
5260
5365
  if (result2.totalNodes <= 1) {
5261
5366
  return {
@@ -5283,8 +5388,8 @@ Try \`context action=chain entryId="${entryId}" direction="${direction === "outg
5283
5388
  for (let d = 0; d <= maxDepth; d++) {
5284
5389
  const atDepth = result2.nodes.filter((n) => n.depth === d);
5285
5390
  if (atDepth.length === 0) continue;
5286
- const label = d === 0 ? "Root" : `Depth ${d}`;
5287
- lines.push(`## ${label} (${atDepth.length})`);
5391
+ const label2 = d === 0 ? "Root" : `Depth ${d}`;
5392
+ lines.push(`## ${label2} (${atDepth.length})`);
5288
5393
  for (const node of atDepth) {
5289
5394
  const indent = " ".repeat(d);
5290
5395
  const id = node.entryId ? `**${node.entryId}:** ` : "";
@@ -5697,9 +5802,9 @@ async function handleLabelsList() {
5697
5802
  }
5698
5803
  if (ungrouped.length > 0) {
5699
5804
  lines.push("\n## Ungrouped");
5700
- for (const label of ungrouped) {
5701
- const c = label.color ? ` ${label.color}` : "";
5702
- lines.push(`- \`${label.slug}\` ${label.name}${c}${label.description ? ` \u2014 _${label.description}_` : ""}`);
5805
+ for (const label2 of ungrouped) {
5806
+ const c = label2.color ? ` ${label2.color}` : "";
5807
+ lines.push(`- \`${label2.slug}\` ${label2.name}${c}${label2.description ? ` \u2014 _${label2.description}_` : ""}`);
5703
5808
  }
5704
5809
  }
5705
5810
  return {
@@ -6223,9 +6328,9 @@ function buildPlannedWorkSection(work, priorSessions, recoveryBlock) {
6223
6328
  lines.push("");
6224
6329
  if (work.uncommittedDrafts.length > 0) {
6225
6330
  const count = work.uncommittedDrafts.length;
6226
- const label = `${work.draftsTruncated ? `${count}+` : count} draft(s) of yours pending`;
6331
+ const label2 = `${work.draftsTruncated ? `${count}+` : count} draft(s) of yours pending`;
6227
6332
  const topNames = work.uncommittedDrafts.slice(0, 3).map((d) => d.name).join(", ");
6228
- lines.push(`- **${label}** \u2014 ${topNames}${count > 3 ? ", ..." : ""}`);
6333
+ lines.push(`- **${label2}** \u2014 ${topNames}${count > 3 ? ", ..." : ""}`);
6229
6334
  if (work.draftsTruncated) lines.push(` - ${MORE_DRAFTS_LINE}`);
6230
6335
  }
6231
6336
  if (work.openTensions.length > 0) {
@@ -6844,8 +6949,8 @@ function formatBetConstellationLines(constellationEntries, constellationBetName)
6844
6949
  for (const slug of order) {
6845
6950
  const entries = bySlug.get(slug);
6846
6951
  if (!entries?.length) continue;
6847
- const label = slug.charAt(0).toUpperCase() + slug.slice(1);
6848
- lines.push(`**${label}:**`);
6952
+ const label2 = slug.charAt(0).toUpperCase() + slug.slice(1);
6953
+ lines.push(`**${label2}:**`);
6849
6954
  for (const e of entries) {
6850
6955
  lines.push(`- \`${e.entryId}\` \u2014 ${e.name}`);
6851
6956
  }
@@ -7003,8 +7108,8 @@ var WorkspaceCompletionError = class extends Error {
7003
7108
  function isRecord(value) {
7004
7109
  return value !== null && typeof value === "object" && !Array.isArray(value);
7005
7110
  }
7006
- function requiredString(value, label) {
7007
- if (typeof value !== "string" || value.trim().length === 0) throw new WorkspaceCompletionError(`Workspace scope binding has no valid ${label}.`);
7111
+ function requiredString(value, label2) {
7112
+ if (typeof value !== "string" || value.trim().length === 0) throw new WorkspaceCompletionError(`Workspace scope binding has no valid ${label2}.`);
7008
7113
  return value;
7009
7114
  }
7010
7115
  function normalizeOwnedSliceIds(value) {
@@ -7107,7 +7212,7 @@ async function readPrs(io, root, branch) {
7107
7212
  prs: parsed.filter(isRecord).map((pr) => ({
7108
7213
  number: Number(pr["number"]),
7109
7214
  headSha: typeof pr["headRefOid"] === "string" ? pr["headRefOid"] : "",
7110
- labels: (Array.isArray(pr["labels"]) ? pr["labels"] : []).flatMap((label) => isRecord(label) && typeof label["name"] === "string" ? [label["name"]] : [])
7215
+ labels: (Array.isArray(pr["labels"]) ? pr["labels"] : []).flatMap((label2) => isRecord(label2) && typeof label2["name"] === "string" ? [label2["name"]] : [])
7111
7216
  }))
7112
7217
  };
7113
7218
  } catch (error) {
@@ -10707,12 +10812,12 @@ function buildSessionSummary(log) {
10707
10812
  ["label", "Labels"],
10708
10813
  ["meta", "Meta"]
10709
10814
  ];
10710
- for (const [cat, label] of categoryLabels) {
10815
+ for (const [cat, label2] of categoryLabels) {
10711
10816
  const fnCounts = byCategory.get(cat);
10712
10817
  if (!fnCounts || fnCounts.size === 0) continue;
10713
10818
  const total = [...fnCounts.values()].reduce((a, b) => a + b, 0);
10714
10819
  const detail = [...fnCounts.entries()].sort((a, b) => b[1] - a[1]).map(([fn, count]) => `${fn.replace("chain.", "")} x${count}`).join(", ");
10715
- lines.push(`- **${label}:** ${total} call${total === 1 ? "" : "s"} (${detail})`);
10820
+ lines.push(`- **${label2}:** ${total} call${total === 1 ? "" : "s"} (${detail})`);
10716
10821
  }
10717
10822
  lines.push(`- **Errors:** ${errorCount}`);
10718
10823
  if (writeCreates > 0 || writeUpdates > 0) {
@@ -11522,10 +11627,10 @@ var QUESTION_ACTION_SPECS = {
11522
11627
  list: { params: ["mine", "role"], description: "mine and role are optional, not together \u2014 omit both for what you owe, mine:true for what you asked, role for what waits on that role." }
11523
11628
  };
11524
11629
  var HUMAN_ID_PATTERN = /^[A-Za-z]+-\d+$/;
11525
- async function resolveEntryRef(raw, label) {
11630
+ async function resolveEntryRef(raw, label2) {
11526
11631
  if (!HUMAN_ID_PATTERN.test(raw)) return raw;
11527
11632
  const entry = await kernelQuery("chain.getEntry", { entryId: raw });
11528
- if (!entry) throw new Error(`${label} '${raw}' not found.`);
11633
+ if (!entry) throw new Error(`${label2} '${raw}' not found.`);
11529
11634
  return entry._id;
11530
11635
  }
11531
11636
  async function displayName(id) {
@@ -12316,4 +12421,4 @@ export {
12316
12421
  SERVER_VERSION,
12317
12422
  createProductBrainServer
12318
12423
  };
12319
- //# sourceMappingURL=chunk-KLURBSRA.js.map
12424
+ //# sourceMappingURL=chunk-3P364LMS.js.map