@productbrain/mcp 0.0.1-beta.14207 → 0.0.1-beta.14214

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.
@@ -2895,17 +2895,28 @@ async function handleEntryPreflight(collection, canonicalKey, links) {
2895
2895
  const result2 = await kernelQuery("chain.preflightEntry", { collectionSlug: collection, canonicalKey, links });
2896
2896
  return { content: [{ type: "text", text: renderEntryPreflight(result2).join("\n") }], structuredContent: success("Structural requirements checked; nothing saved.", result2) };
2897
2897
  }
2898
+ var getNotFoundText = (entryId) => `Entry '${entryId}' not found. Try search to find the right ID.`;
2898
2899
  async function handleGet(entryId) {
2899
2900
  const entry = await kernelQuery("chain.getEntry", { entryId }, { recall: true });
2900
- if (!entry) {
2901
- return notFoundResult(entryId, `Entry '${entryId}' not found. Try search to find the right ID.`);
2902
- }
2901
+ if (!entry) return notFoundResult(entryId, getNotFoundText(entryId));
2903
2902
  const e = entry;
2903
+ const { lines, entryData } = entryCard(e);
2904
+ return {
2905
+ content: [{ type: "text", text: [`## Get Result`, "", ...lines].join("\n") }],
2906
+ structuredContent: success(
2907
+ `Found ${entryId}: ${String(e.name)} [${String(e.collectionSlug ?? "")}].`,
2908
+ entryData,
2909
+ [
2910
+ { tool: "context", description: "See its connections", parameters: { action: "find", entryId } },
2911
+ { tool: "context", description: "Gather related context", parameters: { action: "gather", entryId } }
2912
+ ]
2913
+ )
2914
+ };
2915
+ }
2916
+ function entryCard(e) {
2904
2917
  const conflictLabel = e.possibleConflict?.label;
2905
2918
  const epistemic = deriveEpistemicStatus(toEpistemicInput(e));
2906
2919
  const lines = [
2907
- `## Get Result`,
2908
- "",
2909
2920
  `# ${e.entryId ? `${e.entryId}: ` : ""}${e.name}`,
2910
2921
  "",
2911
2922
  `**Status:** ${e.status}${e.workflowStatus ? ` / ${e.workflowStatus}` : ""}`,
@@ -2993,108 +3004,20 @@ async function handleGet(entryId) {
2993
3004
  ...e.relationsTruncated === true ? { relationsTruncated: true } : {},
2994
3005
  ...Array.isArray(e.labels) && e.labels.length > 0 ? { labels: e.labels.map((l) => l.slug ?? l.name ?? "") } : {}
2995
3006
  };
2996
- return {
2997
- content: [{ type: "text", text: lines.join("\n") }],
2998
- structuredContent: success(
2999
- `Found ${entryId}: ${String(e.name)} [${String(e.collectionSlug ?? "")}].`,
3000
- entryData,
3001
- [
3002
- { tool: "context", description: "See its connections", parameters: { action: "find", entryId } },
3003
- { tool: "context", description: "Gather related context", parameters: { action: "gather", entryId } }
3004
- ]
3005
- )
3006
- };
3007
+ return { lines, entryData };
3007
3008
  }
3008
3009
  async function handleBatch(entryIds) {
3009
- const results = await kernelQuery("chain.batchGetEntries", { entryIds }, { recall: true });
3010
- const lines = [`## Batch Result`, "", `# Batch Get (${results.length} requested)`, ""];
3011
- for (let i = 0; i < results.length; i++) {
3012
- const r = results[i];
3013
- const requestedId = entryIds[i];
3014
- if (r.error) {
3015
- lines.push(`## ${requestedId}
3016
-
3017
- **Error:** ${r.error}
3018
- `);
3019
- continue;
3020
- }
3021
- const entry = r.entry;
3022
- lines.push(`## ${entry.entryId ? `${entry.entryId}: ` : ""}${entry.name}`);
3023
- lines.push("");
3024
- lines.push(`**Status:** ${entry.status}${entry.workflowStatus ? ` / ${entry.workflowStatus}` : ""}`);
3025
- lines.push(`**Collection:** ${entry.collectionSlug ?? "unknown"}`);
3026
- if (typeof entry.capturedAt === "number") {
3027
- lines.push(`**Captured at:** ${new Date(entry.capturedAt).toISOString()}`);
3028
- }
3029
- if (entry.origin) {
3030
- const detail = entry.originDetail ? ` (${entry.originDetail})` : "";
3031
- lines.push(`**Origin:** ${entry.origin}${detail}`);
3032
- }
3033
- const entryVerificationLine = renderVerificationLine(entry);
3034
- if (entryVerificationLine) lines.push(entryVerificationLine);
3035
- if (entry.sourceRef) {
3036
- lines.push(`**Source ref:** ${entry.sourceRef}`);
3037
- }
3038
- if (entry.sourceExcerpt) {
3039
- lines.push(`**Source excerpt:** ${entry.sourceExcerpt}`);
3040
- }
3041
- const { line: whyLine, whySourceKey } = renderWhyLine(entry);
3042
- if (whyLine !== null) lines.push(whyLine);
3043
- const visibleData = sanitizeEntryData(entry.data);
3044
- const filteredData = visibleData && whySourceKey ? Object.keys(visibleData).filter((k) => k !== whySourceKey).length > 0 ? Object.fromEntries(Object.entries(visibleData).filter(([k]) => k !== whySourceKey)) : void 0 : visibleData;
3045
- lines.push(...entryDataLines(filteredData));
3046
- if (Array.isArray(entry.tags) && entry.tags.length > 0) {
3047
- lines.push("", `**Tags:** ${entry.tags.join(", ")}`);
3048
- }
3049
- if (Array.isArray(entry.labels) && entry.labels.length > 0) {
3050
- const labels = entry.labels;
3051
- lines.push("", `**Labels:** ${labels.map((l) => `\`${l.slug ?? l.name}\``).join(", ")}`);
3052
- }
3053
- if (Array.isArray(entry.relations) && entry.relations.length > 0) {
3054
- lines.push("", "**Relations:**", ...relationLines(entry.relations), ...typeof entry.relationsCutLine === "string" ? [entry.relationsCutLine] : []);
3055
- }
3056
- if (Array.isArray(entry.history) && entry.history.length > 0) {
3057
- lines.push("", "**History (last 5):**", ...entry.historyTruncated === true ? [`Older history left out: only the newest ${entry.history.length} events were read.`] : []);
3058
- for (const h of entry.history.slice(-5)) {
3059
- const date = new Date(h.timestamp).toISOString().split("T")[0];
3060
- lines.push(`- ${date}: ${h.event}`);
3061
- }
3062
- }
3063
- lines.push("");
3064
- }
3065
- const structuredEntries = results.filter((r) => !r.error && r.entry).map((r) => {
3066
- const entry = r.entry;
3067
- const { why: entryWhy, whySourceKey: entryWhySourceKey } = renderWhyLine(entry);
3068
- const entryVisibleData = sanitizeEntryData(entry.data);
3069
- const entryFilteredData = entryVisibleData && entryWhySourceKey ? Object.keys(entryVisibleData).filter((k) => k !== entryWhySourceKey).length > 0 ? Object.fromEntries(Object.entries(entryVisibleData).filter(([k]) => k !== entryWhySourceKey)) : void 0 : entryVisibleData;
3070
- return {
3071
- entryId: String(entry.entryId ?? ""),
3072
- name: String(entry.name ?? ""),
3073
- collection: String(entry.collectionSlug ?? ""),
3074
- status: String(entry.status ?? ""),
3075
- ...typeof entry.capturedAt === "number" ? { capturedAt: entry.capturedAt } : {},
3076
- ...entry.origin ? { origin: String(entry.origin) } : {},
3077
- ...entry.originDetail ? { originDetail: String(entry.originDetail) } : {},
3078
- ...entry.verificationStatus ? { verificationStatus: String(entry.verificationStatus) } : {},
3079
- // Attestation-model finding (PR #341 review): mirror handleGet — forward the
3080
- // honest verifier label + derived attestation on batch's structured payload too.
3081
- ...typeof entry.verifiedBy === "string" ? { verifiedBy: entry.verifiedBy } : {},
3082
- ...entry.attestation && typeof entry.attestation === "object" ? { attestation: entry.attestation } : {},
3083
- ...entry.sourceRef ? { sourceRef: String(entry.sourceRef) } : {},
3084
- ...entry.sourceExcerpt ? { sourceExcerpt: String(entry.sourceExcerpt) } : {},
3085
- ...entry.workflowStatus ? { workflowStatus: String(entry.workflowStatus) } : {},
3086
- // TEN-2191: surface why/whyQuality in structured payload — mirrors handleGet.
3087
- ...entryWhy.length > 0 ? { why: entryWhy } : {},
3088
- ...entry.whyQuality ? { whyQuality: String(entry.whyQuality) } : {},
3089
- ...entryFilteredData ? { data: entryFilteredData } : {},
3090
- ...Array.isArray(entry.relations) && entry.relations.length ? { relations: projectEntryRelations(entry.relations) } : {},
3091
- ...entry.relationsTruncated === true ? { relationsTruncated: true } : {}
3092
- };
3093
- });
3094
- const total = structuredEntries.length;
3010
+ const results = await kernelQuery("chain.batchGetEntries", { entryIds, includeOwner: true }, { recall: true });
3011
+ const cards = entryIds.map((_, i) => results[i]?.entry ? entryCard(results[i].entry) : null);
3012
+ const notFound2 = entryIds.filter((_, i) => !cards[i]);
3013
+ const blocks = entryIds.map((id, i) => cards[i]?.lines.join("\n") ?? getNotFoundText(id));
3014
+ const entries = cards.flatMap((card) => card ? [card.entryData] : []);
3095
3015
  return {
3096
- content: [{ type: "text", text: lines.join("\n") }],
3097
- structuredContent: success(`Fetched ${total} entries in batch.`, { entries: structuredEntries, total })
3016
+ content: [{ type: "text", text: [`## Get Result`, "", blocks.join("\n\n---\n\n")].join("\n") }],
3017
+ structuredContent: success(
3018
+ `Found ${entries.length} of ${entryIds.length} entries.${notFound2.length ? ` Not found: ${notFound2.join(", ")}.` : ""}`,
3019
+ { entries, total: entries.length, ...notFound2.length ? { notFound: notFound2 } : {} }
3020
+ )
3098
3021
  };
3099
3022
  }
3100
3023
  async function handleList(collection, status2, tag, label) {
@@ -4495,10 +4418,10 @@ async function handleOpenTasks(roleId, cursor) {
4495
4418
  var LOOKUP_ACTIONS = ["get", "batch", "history", "list", "search", "find", "people", "outcome", "readings", "accountable", "tasks", "preflight"];
4496
4419
  var statusFilterSchema = z19.union([z19.string().max(200), z19.array(z19.enum(ENTRY_STATUS_READ_WORDS)).max(5)]);
4497
4420
  var preflightLinks = z19.array(z19.object({ type: z19.string().max(200), entryId: z19.string().max(200) })).max(50).optional();
4498
- var LOOKUP_ACTION_DESCRIBE = `'get': one entry in full by ID. 'batch': up to 20 entries by ID. 'history': audit trail for an entry. 'list': browse entries with filters (${TRUST_STATUS_LABELS.current.toLowerCase()} entries by default). 'search': full-text search across entries. 'find': an entry's direct relations (see direction). 'people': the workspace's members with name, email and status. 'outcome': a key result's derived view, its objective and sibling key results. 'readings': its readings, newest first. 'accountable': a role's work and holders. 'tasks': your role's open tasks outside a package, or roleId's. 'preflight': a collection's requirements. `;
4499
- var LOOKUP_TOOL_LINES = "- **get**: Fetch a single entry by ID \u2014 full record with data, labels, relations, history.\n- **batch**: Fetch multiple entries (max 20) in one call. Same shape as get per entry.\n- **history**: Audit trail for an entry.\n- **list**: Browse entries with optional filters (collection, status, tag, label). Use collections action=list first to discover slugs.\n- **search**: Full-text search across entries. Scope by collection or filter by status.\n- **find**: An entry's direct relations, incoming and outgoing. NOT full-text search (use search).\n- **people**: The workspace's members: name, email, status, role. Max 200.\n- **outcome**: A key result's derived view (current, progress, pace, staleness, recorded completion) with its objective and up to 5 sibling key results.\n- **readings**: A key result's readings, newest first; superseded rows are marked with their replacement. Record one with `outcome action=record`.\n- **accountable**: What a role owns, reports on, and who holds it; no roleId: every seat.\n- **preflight**: What an entry in a collection needs before you compose it. Saves nothing.\n";
4421
+ var LOOKUP_ACTION_DESCRIBE = `'get': entries in full by ID (entryIds: up to 20, one call). 'batch': get with entryIds. 'history': audit trail for an entry. 'list': browse entries with filters (${TRUST_STATUS_LABELS.current.toLowerCase()} entries by default). 'search': full-text search across entries. 'find': an entry's direct relations (see direction). 'people': the workspace's members with name, email and status. 'outcome': a key result's view with its objective and siblings. 'readings': its readings, newest first. 'accountable': a role's work and holders. 'tasks': your role's open tasks outside a package, or roleId's. 'preflight': a collection's requirements. `;
4422
+ var LOOKUP_TOOL_LINES = "- **get**: Full entries by ID: data, labels, relations, history. entryIds reads up to 20 in one call.\n- **batch**: get with entryIds.\n- **history**: Audit trail for an entry.\n- **list**: Browse entries by collection, status, tag or label; collections action=list names the slugs.\n- **search**: Full-text search; scope by collection or status.\n- **find**: An entry's direct relations, both ways; not text search.\n- **people**: The workspace's members: name, email, status, role. Max 200.\n- **outcome**: A key result's derived view (current, progress, pace, staleness, completion), its objective and up to 5 sibling key results.\n- **readings**: A key result's readings, newest first; a replaced row names its replacement. Record with `outcome action=record`.\n- **accountable**: What a role owns, reports on, and who holds it; no roleId: every seat.\n- **preflight**: What an entry in a collection needs; saves nothing.\n";
4500
4423
  var lookupParams = {
4501
- entryIds: z19.array(z19.string().max(200)).min(1).max(20).optional().describe("For 'batch': entry IDs."),
4424
+ entryIds: z19.array(z19.string().max(200)).min(1).max(20).optional().describe("For 'get'/'batch': up to 20 entry IDs, one call."),
4502
4425
  collection: z19.string().max(200).optional().describe("For 'list'/'search': collection slug, e.g. 'glossary', 'tracking-events'. Required for 'preflight'."),
4503
4426
  query: z19.string().min(2).max(500).optional().describe("For 'search': search text."),
4504
4427
  // 'active'/'accepted'/'current' are the same trust level (DEC-1575/DEC-1788) — all enumerated, never one substituted.
@@ -4506,7 +4429,7 @@ var lookupParams = {
4506
4429
  `For 'list': defaults to ${TRUST_STATUS_LABELS.current.toLowerCase()} entries (active/accepted/current); use status='draft' to discover drafts. One lifecycle or category value (${ENTRY_STATUS_READ_WORDS.join("|")}). For 'search': one value OR an array of up to 5 (e.g. ['active','accepted']).`
4507
4430
  ),
4508
4431
  tag: z19.string().max(200).optional().describe("For 'list': filter by internal tag."),
4509
- label: z19.string().max(200).optional().describe("For 'list': filter by label slug \u2014 matches entries across all collections."),
4432
+ label: z19.string().max(200).optional().describe("For 'list': a label slug, across all collections."),
4510
4433
  limit: z19.number().int().positive().max(200).optional().describe("For 'readings'/'accountable': max rows (default and maximum 200)."),
4511
4434
  roleId: z19.string().max(200).optional().describe("For 'accountable'/'tasks': the role's id."),
4512
4435
  canonicalKey: z19.string().max(200).optional().describe("For 'accountable'/'preflight': one kind, e.g. tension."),
@@ -4514,7 +4437,7 @@ var lookupParams = {
4514
4437
  links: preflightLinks.describe("For 'preflight': proposed links.")
4515
4438
  };
4516
4439
  var lookupVariants = [
4517
- z19.object({ action: z19.literal("get"), entryId: z19.string().max(200) }),
4440
+ z19.object({ action: z19.literal("get"), entryId: z19.string().max(200).optional(), entryIds: z19.array(z19.string().max(200)).min(1).max(20).optional() }),
4518
4441
  z19.object({ action: z19.literal("batch"), entryIds: z19.array(z19.string().max(200)).min(1).max(20) }),
4519
4442
  z19.object({ action: z19.literal("history"), entryId: z19.string().max(200) }),
4520
4443
  z19.object({
@@ -4555,7 +4478,7 @@ var lookupVariants = [
4555
4478
  })
4556
4479
  ];
4557
4480
  var LOOKUP_ACTION_SPECS = {
4558
- get: { params: ["entryId"], description: "entryId is required." },
4481
+ get: { params: ["entryId", "entryIds"], description: "entryId, or entryIds (1-20) to read several in one call; one of the two." },
4559
4482
  batch: { params: ["entryIds"], description: "entryIds (1-20) is required." },
4560
4483
  history: { params: ["entryId"], description: "entryId is required." },
4561
4484
  list: {
@@ -4573,7 +4496,7 @@ var LOOKUP_ACTION_SPECS = {
4573
4496
  };
4574
4497
  function lookupHandlers(server) {
4575
4498
  return {
4576
- get: (data) => handleGet(data.entryId),
4499
+ get: (data) => data.entryId === void 0 === (data.entryIds === void 0) ? Promise.resolve(backpressureResult("context", "get", LOOKUP_ACTION_SPECS.get, "Pass entryId or entryIds, not both or neither.")) : data.entryIds ? handleBatch(data.entryIds) : handleGet(data.entryId),
4577
4500
  batch: (data) => handleBatch(data.entryIds),
4578
4501
  history: (data) => handleGetHistory(data),
4579
4502
  list: (data) => handleList(data.collection, data.status, data.tag, data.label),
@@ -4609,12 +4532,12 @@ var contextSchema = z20.object({
4609
4532
  action: z20.enum(CONTEXT_ACTIONS).describe(
4610
4533
  LOOKUP_ACTION_DESCRIBE + "'gather': assemble knowledge context (entry graph, task auto-load, journey mode, or graph mode). 'build': structured build spec for an entry. 'neighborhood': typed graph neighborhood for an entry \u2014 blocking chain, dependencies, parent context, tensions, staleness. 'changes': entries modified and relations created since a timestamp. Requires 'since' parameter. 'chain': directed traversal along one relation type to depth 4. Requires entryId. Optional: direction, relationType, maxHops (1-4). 'cross-cut': structural aggregation \u2014 all relations of a given type grouped by source collection. Requires 'relationType' parameter. 'incremental': delta since last brief run for a skill. Requires 'skill' parameter. Returns only entries changed since the skill's last brief. 'brief': compound intelligence query. Requires 'briefType' parameter: 'steering' (changes + structure + delta + readiness), 'confidence' (changes + active bets \u2014 use the pb CLI's `tensions list` for tensions), or 'delta' (changes + relations since timestamp). Optional 'since' for delta type."
4611
4534
  ),
4612
- entryId: z20.string().max(200).optional().describe("For 'get'/'history'/'find'/'outcome'/'readings'/'build'/'neighborhood'/'chain': entry ID. For 'gather': optional (entry-graph mode)."),
4535
+ entryId: z20.string().max(200).optional().describe("The entry ID for the actions that read one entry; optional for 'gather' (entry-graph mode)."),
4613
4536
  ...lookupParams,
4614
4537
  mapEntryId: z20.string().max(200).optional().describe(
4615
4538
  "For 'gather': journey map entry ID for journey-aware context. Returns context organised by journey stage. Takes precedence over entryId when both are supplied. Example: '<PREFIX>-<n>'."
4616
4539
  ),
4617
- task: z20.string().max(2e3).optional().describe("For 'gather': natural-language task description for loading task-relevant governance, binding constraints, and supporting context."),
4540
+ task: z20.string().max(2e3).optional().describe("For 'gather': the task in plain words; loads its binding rules and supporting context."),
4618
4541
  since: z20.string().max(200).optional().describe(
4619
4542
  "For 'changes': ISO 8601 timestamp \u2014 returns entries/relations modified since this time. For 'brief' briefType='delta': optional custom timestamp. Example: '2026-03-24T00:00:00Z'."
4620
4543
  ),
@@ -4625,7 +4548,7 @@ var contextSchema = z20.object({
4625
4548
  mode: z20.enum(["search", "graph"]).default("search").optional().describe("For gather: 'search' (default) or 'graph' (enhanced with provenance paths). Ignored when mapEntryId is provided."),
4626
4549
  maxHops: z20.number().min(1).max(4).default(2).describe("Relation traversal depth (1=direct only, 2=default, 3=wide net, 4=deep chain walk)"),
4627
4550
  maxResults: z20.number().min(1).max(25).default(10).optional().describe("Max entries to return in gather task mode (default 10)"),
4628
- strategy: z20.enum(["hybrid", "keyword"]).default("keyword").optional().describe("Seed strategy for task-based gather: 'keyword' (FTS only, default) or 'hybrid' (vector + FTS). Only affects task mode."),
4551
+ strategy: z20.enum(["hybrid", "keyword"]).default("keyword").optional().describe("For gather task mode: 'keyword' (text search, default) or 'hybrid' (vector plus text)."),
4629
4552
  skill: z20.string().max(200).optional().describe(
4630
4553
  "Skill name for 'incremental' action \u2014 identifies which skill's brief history to compare against. Examples: 'preflight', 'shaping', 'review'. Required when action is 'incremental'."
4631
4554
  ),
@@ -12186,4 +12109,4 @@ export {
12186
12109
  SERVER_VERSION,
12187
12110
  createProductBrainServer
12188
12111
  };
12189
- //# sourceMappingURL=chunk-3N3TYFXZ.js.map
12112
+ //# sourceMappingURL=chunk-V5WZ3G7W.js.map