@productbrain/mcp 0.0.1-beta.10521 → 0.0.1-beta.10534

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.
@@ -45,7 +45,7 @@ import {
45
45
  trackQualityVerdict,
46
46
  trackSessionCaptureRate,
47
47
  trackZeroCaptureAuditFired
48
- } from "./chunk-L3QEFWAV.js";
48
+ } from "./chunk-VQ6P44A3.js";
49
49
 
50
50
  // src/server.ts
51
51
  import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -3190,31 +3190,24 @@ ${recovery}`,
3190
3190
 
3191
3191
  // src/lib/platformGlossary.ts
3192
3192
  var PRODUCT_NAME = "Product Brain";
3193
+ var PLATFORM_TERM_LABEL = "Platform";
3193
3194
  var PLATFORM_GLOSSARY_TERMS = [
3194
3195
  { name: "Team", definition: "A group of people and agents working toward one purpose; its roles own its decisions, rules and work." },
3195
3196
  { name: "Team Lead", definition: "The role accountable for a team's purpose; it decides anything that belongs to a role nobody holds." },
3196
3197
  { name: "Role", definition: "A named set of responsibilities a person holds; whoever sits in it decides and accepts the entries it owns." },
3197
3198
  { name: "Tension", definition: "A gap someone notices between how things are and how they should be; linking one to an entry is how you say you disagree with it." }
3198
3199
  ];
3199
- function matchPlatformGlossaryTerms(query) {
3200
- const words = query.toLowerCase().split(/\s+/).filter(Boolean);
3201
- if (query.trim().length < 2 || words.length === 0) return [];
3202
- return PLATFORM_GLOSSARY_TERMS.filter((term) => {
3203
- const name = term.name.toLowerCase();
3204
- return words.every((word) => name.includes(word));
3205
- });
3206
- }
3207
3200
 
3208
- // src/tools/platformGlossarySearch.ts
3209
- function platformGlossarySearch(query, collection, status2) {
3210
- const statusFiltered = Array.isArray(status2) ? status2.length > 0 : !!status2;
3211
- const terms = !statusFiltered && (!collection || collection === "glossary") ? matchPlatformGlossaryTerms(query) : [];
3201
+ // src/tools/searchResultLines.ts
3202
+ function ownerWords(owner) {
3203
+ return owner.kind === "role" ? owner.role : owner.kind === "home" ? `Home: ${owner.team}` : owner.text;
3204
+ }
3205
+ function platformSearchLines(platform) {
3212
3206
  return {
3213
- count: terms.length,
3214
- lines: terms.map((t) => `- **${t.name}** (platform term) [glossary]
3207
+ count: platform.length,
3208
+ lines: platform.map((t) => `- **${t.name}** (${PLATFORM_TERM_LABEL}) [glossary]
3215
3209
  ${t.definition}`),
3216
- structured: terms.map((t) => ({ entryId: null, name: t.name, collection: "glossary", definition: t.definition })),
3217
- summaryLabel: terms.length ? `${terms.length} platform glossary` : ""
3210
+ structured: platform.map((t) => ({ entryId: null, name: t.name, collection: "glossary", definition: t.definition }))
3218
3211
  };
3219
3212
  }
3220
3213
 
@@ -3686,9 +3679,6 @@ async function handleBatch(entryIds) {
3686
3679
  structuredContent: success(`Fetched ${total} entries in batch.`, { entries: structuredEntries, total })
3687
3680
  };
3688
3681
  }
3689
- function buildCollectionSlugMap(collections) {
3690
- return new Map(collections.map((c) => [c._id, c.slug]));
3691
- }
3692
3682
  async function handleList(collection, status2, tag, label) {
3693
3683
  let entries;
3694
3684
  if (label) {
@@ -3747,11 +3737,9 @@ async function handleSearch(server, query, collection, status2) {
3747
3737
  data: `Searching${scope} for "${query}"...`,
3748
3738
  logger: "product-os"
3749
3739
  });
3750
- const [results, collections] = await Promise.all([
3751
- kernelQuery("chain.searchEntries", { query, collectionSlug: collection, status: status2 }),
3752
- kernelQuery("chain.listCollections")
3753
- ]);
3754
- const platform = platformGlossarySearch(query, collection, status2);
3740
+ const answer = await kernelQuery("chain.search", { query, collectionSlug: collection, status: status2 });
3741
+ const results = answer.rows;
3742
+ const platform = platformSearchLines(answer.platform);
3755
3743
  const matches = results.length + platform.count;
3756
3744
  if (matches === 0) {
3757
3745
  const recorded = recordGap({ query, tool: "context", action: "search", gapType: "search_zero", collectionScope: collection });
@@ -3774,37 +3762,32 @@ async function handleSearch(server, query, collection, status2) {
3774
3762
  )
3775
3763
  };
3776
3764
  }
3777
- const collMap = buildCollectionSlugMap(collections);
3778
3765
  const countsBySlug = /* @__PURE__ */ new Map();
3779
- for (const e of results) {
3780
- const slug = collMap.get(e.collectionId) ?? "unknown";
3781
- countsBySlug.set(slug, (countsBySlug.get(slug) ?? 0) + 1);
3782
- }
3766
+ for (const e of results) countsBySlug.set(e.collectionSlug ?? "unknown", (countsBySlug.get(e.collectionSlug ?? "unknown") ?? 0) + 1);
3783
3767
  if (platform.count) countsBySlug.set("platform glossary", platform.count);
3784
3768
  const collSummary = [...countsBySlug.entries()].sort((a, b) => b[1] - a[1]).map(([slug, count]) => `${count} ${slug}`).join(", ");
3785
3769
  const formatted = results.map((e) => {
3786
3770
  const id = e.entryId ? `**${e.entryId}:** ` : "";
3787
3771
  const statusDisplay = e.workflowStatus ? `${e.status} / ${e.workflowStatus}` : e.status;
3788
- const slug = collMap.get(e.collectionId ?? "");
3789
- const colTag = slug ? ` [${slug}]` : "";
3772
+ const colTag = e.collectionSlug ? ` [${e.collectionSlug}]` : "";
3790
3773
  const desc = extractPreview(e.data, 150);
3791
3774
  const preview = desc ? `
3792
3775
  ${desc}` : "";
3793
- return `- ${id}${e.name} \`${statusDisplay}\`${colTag}${preview}`;
3776
+ return `- ${id}${e.name} \`${statusDisplay}\`${colTag} \xB7 ${ownerWords(e.owner)}${preview}`;
3794
3777
  }).join("\n");
3795
3778
  const header = `## Search Result
3796
3779
 
3797
- # Search Results for "${query}"${scope} (${matches} match${matches === 1 ? "" : "es"})
3780
+ # Search Results for "${query}"${scope} (${matches}${answer.truncated ? "+" : ""} match${matches === 1 ? "" : "es"})
3798
3781
 
3799
3782
  **By collection:** ${collSummary}`;
3800
3783
  const footer = `_Tip: Use \`collection\` param to scope search. Use context action=get with an entry ID for full details._`;
3801
3784
  const structuredResults = results.map((e) => ({
3802
3785
  entryId: String(e.entryId ?? ""),
3803
3786
  name: String(e.name ?? ""),
3804
- collection: collMap.get(e.collectionId ?? "") ?? "unknown",
3787
+ collection: e.collectionSlug ?? "unknown",
3805
3788
  status: String(e.status ?? ""),
3806
3789
  ...e.workflowStatus ? { workflowStatus: e.workflowStatus } : {},
3807
- ...e.score != null ? { score: e.score } : {}
3790
+ owner: ownerWords(e.owner)
3808
3791
  }));
3809
3792
  const entriesForView = structuredResults.map((e) => ({
3810
3793
  entryId: e.entryId,
@@ -3816,7 +3799,7 @@ async function handleSearch(server, query, collection, status2) {
3816
3799
  return {
3817
3800
  content: [{ type: "text", text: `${header}
3818
3801
 
3819
- ${[...platform.lines, formatted].filter(Boolean).join("\n")}
3802
+ ${[...platform.lines, formatted, answer.cutLine].filter(Boolean).join("\n")}
3820
3803
 
3821
3804
  ${footer}` }],
3822
3805
  structuredContent: success(`Found ${total} entries${platform.count ? ` and ${platform.count} platform glossary terms` : ""} matching '${query}'.`, {
@@ -3824,6 +3807,8 @@ ${footer}` }],
3824
3807
  results: structuredResults,
3825
3808
  entries: entriesForView,
3826
3809
  total,
3810
+ truncated: answer.truncated,
3811
+ cutLine: answer.cutLine,
3827
3812
  query
3828
3813
  })
3829
3814
  };
@@ -11099,6 +11084,8 @@ var CALL_CATEGORIES = {
11099
11084
  "chain.listEntryRelations": "read",
11100
11085
  "chain.listEntriesByLabel": "read",
11101
11086
  "chain.searchEntries": "search",
11087
+ "chain.search": "search",
11088
+ // TASK-854: pb search and MCP search (PR #1768 Codex P2), same-line combine
11102
11089
  "chain.createEntry": "write",
11103
11090
  "chain.updateEntry": "write",
11104
11091
  "chain.moveToCollection": "write",
@@ -12778,4 +12765,4 @@ export {
12778
12765
  createProductBrainServer,
12779
12766
  initFeatureFlags
12780
12767
  };
12781
- //# sourceMappingURL=chunk-FTKQF7PG.js.map
12768
+ //# sourceMappingURL=chunk-DX2W5QVT.js.map