@productbrain/mcp 0.0.1-beta.8658 → 0.0.1-beta.8669

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.
@@ -5287,7 +5287,8 @@ Use \`relations action=suggest\` to discover potential connections.`
5287
5287
  maxHops,
5288
5288
  maxResults
5289
5289
  });
5290
- if (!result3 || result3.totalFound === 0) {
5290
+ const shownCount = result3 ? result3.steeringContext.length + result3.supportingContext.length : 0;
5291
+ if (!result3 || shownCount === 0) {
5291
5292
  const taskQuery = task.slice(0, 200);
5292
5293
  const recorded = recordGap({ query: taskQuery, tool: "context", action: "gather", gapType: "context_task_empty" });
5293
5294
  if (recorded) {
@@ -5313,8 +5314,6 @@ _This helps future sessions start with better constraints and context._`
5313
5314
  )
5314
5315
  };
5315
5316
  }
5316
- const bindingGovernanceCollections = result3.bindingGovernance.byCollection ?? [];
5317
- const hasBindingGovernance = bindingGovernanceCollections.some((bucket) => bucket.entries.length > 0) || result3.bindingGovernance.principles.length > 0 || result3.bindingGovernance.standards.length > 0 || result3.bindingGovernance.businessRules.length > 0;
5318
5317
  const byCollection2 = /* @__PURE__ */ new Map();
5319
5318
  for (const entry of result3.supportingContext) {
5320
5319
  const key = entry.collectionName ?? "Uncategorized";
@@ -5334,52 +5333,12 @@ _This helps future sessions start with better constraints and context._`
5334
5333
  `**Confidence:** ${result3.confidence.charAt(0).toUpperCase() + result3.confidence.slice(1)}`,
5335
5334
  `**Grounding:** ${result3.groundingStatus}`,
5336
5335
  `**Strategy:** ${strategyLabel}`,
5337
- `**Matched:** ${result3.totalFound} entries across ${collectionCount} collection${collectionCount === 1 ? "" : "s"}`,
5336
+ `**Matched:** ${shownCount} entries across ${collectionCount} collection${collectionCount === 1 ? "" : "s"}`,
5338
5337
  `**Seeds:** ${seedDisplay}`,
5339
5338
  ""
5340
5339
  ];
5341
5340
  lines2.push("_Use this task gather as the live constraint load for the work you are about to do, then open any cited entries for full details._");
5342
5341
  lines2.push("");
5343
- if (hasBindingGovernance) {
5344
- lines2.push("## Binding governance");
5345
- lines2.push("_These are the non-optional rules and standards that govern this task._");
5346
- if (result3._budget?.truncated) {
5347
- lines2.push("_Note: the governance ranking scan hit its cap \u2014 some entries' governs relations may not be reflected._");
5348
- }
5349
- lines2.push("");
5350
- const renderGovernanceEntries = (entries) => {
5351
- for (const entry of entries) {
5352
- const id = entry.entryId ? `**${entry.entryId}:** ` : "";
5353
- const scoreLabel = typeof entry.score === "number" ? ` ${entry.score}` : "";
5354
- const flagsLabel = entry.scoreFlags?.length ? ` [${entry.scoreFlags.join(", ")}]` : "";
5355
- const originLabel = entry.origin ? ` (origin: ${entry.origin})` : "";
5356
- const tierLabel = entry.tier === 1 ? " `[direct]`" : entry.tier === 2 ? " `[governs]`" : entry.tier === 3 ? " `[ungoverned]`" : "";
5357
- lines2.push(`- ${id}${entry.name}${tierLabel}${scoreLabel}${flagsLabel}${originLabel}`);
5358
- if (entry.preview) lines2.push(` _${entry.preview}_`);
5359
- }
5360
- };
5361
- const visibleCollectionBuckets = bindingGovernanceCollections.filter((bucket) => bucket.entries.length > 0);
5362
- if (visibleCollectionBuckets.length > 0) {
5363
- for (const bucket of visibleCollectionBuckets) {
5364
- const title = bucket.collectionName ?? bucket.collectionSlug ?? "Binding governance";
5365
- lines2.push(`### ${title} (${bucket.entries.length})`);
5366
- renderGovernanceEntries(bucket.entries);
5367
- lines2.push("");
5368
- }
5369
- } else {
5370
- const governanceSections = [
5371
- ["Principles", result3.bindingGovernance.principles],
5372
- ["Standards", result3.bindingGovernance.standards],
5373
- ["Business Rules", result3.bindingGovernance.businessRules]
5374
- ];
5375
- for (const [title, entries] of governanceSections) {
5376
- if (entries.length === 0) continue;
5377
- lines2.push(`### ${title} (${entries.length})`);
5378
- renderGovernanceEntries(entries);
5379
- lines2.push("");
5380
- }
5381
- }
5382
- }
5383
5342
  lines2.push("## Steering context");
5384
5343
  lines2.push("_These entries set the frame for the work before you drop into broader supporting detail._");
5385
5344
  lines2.push("");
@@ -5401,7 +5360,7 @@ _This helps future sessions start with better constraints and context._`
5401
5360
  lines2.push("_These entries add implementation detail, history, and neighboring domain context._");
5402
5361
  lines2.push("");
5403
5362
  if (byCollection2.size === 0) {
5404
- lines2.push("_No supporting context matched yet. Open the binding governance entries first._");
5363
+ lines2.push("_No supporting context matched yet._");
5405
5364
  lines2.push("");
5406
5365
  } else {
5407
5366
  for (const [collName, entries] of byCollection2) {
@@ -5427,14 +5386,13 @@ _This helps future sessions start with better constraints and context._`
5427
5386
  return {
5428
5387
  content: [{ type: "text", text: lines2.join("\n") }],
5429
5388
  structuredContent: success(
5430
- `Loaded ${result3.totalFound} task constraints and related entries (${result3.confidence} confidence, ${strategy} strategy).`,
5389
+ `Loaded ${shownCount} task constraints and related entries (${result3.confidence} confidence, ${strategy} strategy).`,
5431
5390
  {
5432
5391
  entries: taskEntries,
5433
- totalFound: result3.totalFound,
5392
+ totalFound: shownCount,
5434
5393
  confidence: result3.confidence,
5435
5394
  groundingStatus: result3.groundingStatus,
5436
5395
  strategy,
5437
- bindingGovernance: result3.bindingGovernance,
5438
5396
  steeringContext: result3.steeringContext.map((entry) => ({
5439
5397
  entryId: entry.entryId ?? null,
5440
5398
  name: entry.name,
@@ -7360,30 +7318,15 @@ var CORE_PROTOCOL_BASE = [
7360
7318
  "**Check scope.** If the proposed work doesn't fall under an active work package, stop and say so. Do not design implementation for out-of-scope work without explicit user go-ahead.",
7361
7319
  `**Capture continuously.** When a decision, tension, insight, or new term surfaces during work, capture it as a draft immediately. Don't defer to "later."`
7362
7320
  ];
7363
- var RULE5_WITH_GOVERNANCE = "**Validate against governance.** Before proposing any solution, check it against the Workspace Governance directives below. If your proposal conflicts with a principle, standard, or business rule \u2014 stop, name the conflict, and get explicit user confirmation before proceeding.";
7364
- var RULE5_COMPACT = '**Validate against governance.** Before proposing or building anything, call `orient task="<your task>"` to load relevant governance. If your proposal conflicts with a principle, standard, or business rule \u2014 stop, name the conflict, and get explicit user confirmation.';
7321
+ var RULE5 = '**Validate against the rules.** Before proposing or building anything, check it against the rules served in your briefing (`orient task="<your task>"` serves them for a task). If your proposal conflicts with one \u2014 stop, name the rule, and get explicit user confirmation.';
7365
7322
  function provenanceMark(p) {
7366
7323
  if (p === "authoritative") return "\u2605 ";
7367
7324
  if (p === "provisional") return "~ ";
7368
7325
  if (p === "floor") return "\xB7 ";
7369
7326
  return "";
7370
7327
  }
7371
- var MAX_ENTRIES_NO_TASK = 3;
7372
- var MAX_ENTRIES_WITH_TASK = 5;
7373
- function formatGovernanceEntry(entry) {
7374
- const id = entry.entryId ?? entry.name;
7375
- const desc = entry.description ? ` \u2014 ${entry.description.slice(0, 120)}${entry.description.length > 120 ? "..." : ""}` : "";
7376
- const tierLabel = entry.tier === 1 ? " `[direct]`" : entry.tier === 2 ? " `[governs]`" : entry.tier === 3 ? " `[ungoverned]`" : "";
7377
- const mark = provenanceMark(entry.provenance);
7378
- const anchorSuffix = entry.anchoredBy ? ` (${entry.anchoredBy})` : "";
7379
- return `- ${mark}**[${id}]** ${entry.name}${anchorSuffix}${tierLabel}${desc}`;
7380
- }
7381
- function buildOperatingProtocol(governanceOrStandards, task) {
7382
- const governance = Array.isArray(governanceOrStandards) ? { standards: governanceOrStandards } : governanceOrStandards ?? {};
7383
- const { principles = [], standards = [], businessRules = [] } = governance;
7384
- const hasGovernance = principles.length > 0 || standards.length > 0 || businessRules.length > 0;
7385
- const rule5 = hasGovernance ? RULE5_WITH_GOVERNANCE : RULE5_COMPACT;
7386
- const protocol = [...CORE_PROTOCOL_BASE, rule5];
7328
+ function buildOperatingProtocol() {
7329
+ const protocol = [...CORE_PROTOCOL_BASE, RULE5];
7387
7330
  const lines = [
7388
7331
  "## Operating Protocol",
7389
7332
  "_How to work in this workspace. Follow these before and during every task._",
@@ -7392,51 +7335,6 @@ function buildOperatingProtocol(governanceOrStandards, task) {
7392
7335
  for (let i = 0; i < protocol.length; i++) {
7393
7336
  lines.push(`${i + 1}. ${protocol[i]}`);
7394
7337
  }
7395
- if (hasGovernance) {
7396
- lines.push("");
7397
- lines.push("### Workspace governance directives");
7398
- const types = [
7399
- { header: "**Active principles:**", entries: principles },
7400
- { header: "**Active business rules:**", entries: businessRules },
7401
- { header: "**Active standards:**", entries: standards }
7402
- ];
7403
- if (task) {
7404
- let shownCount = 0;
7405
- let totalGovernance = 0;
7406
- let anyTierRanking = false;
7407
- for (const type of types) {
7408
- if (type.entries.length === 0) continue;
7409
- totalGovernance += type.entries.length;
7410
- const bucketHasTiers = type.entries.some((e) => e.tier !== void 0);
7411
- if (bucketHasTiers) anyTierRanking = true;
7412
- const sorted = bucketHasTiers ? [...type.entries].sort((a, b) => (a.tier ?? 99) - (b.tier ?? 99)) : [...type.entries];
7413
- const capped = sorted.slice(0, MAX_ENTRIES_WITH_TASK);
7414
- if (capped.length > 0) {
7415
- shownCount += capped.length;
7416
- lines.push(type.header);
7417
- for (const e of capped) {
7418
- lines.push(formatGovernanceEntry(e));
7419
- }
7420
- lines.push("");
7421
- }
7422
- }
7423
- const filterNote = anyTierRanking ? "ranked by relevance" : "in listing order";
7424
- lines.push(`_${shownCount} of ${totalGovernance} governance entries shown, ${filterNote}._`);
7425
- } else {
7426
- for (const type of types) {
7427
- if (type.entries.length === 0) continue;
7428
- lines.push(type.header);
7429
- for (const e of type.entries.slice(0, MAX_ENTRIES_NO_TASK)) {
7430
- lines.push(formatGovernanceEntry(e));
7431
- }
7432
- lines.push("");
7433
- }
7434
- lines.push('_Showing top governance entries. Use `orient task="..."` for task-relevant filtering._');
7435
- }
7436
- }
7437
- if (governance.truncated) {
7438
- lines.push("_Note: the governance ranking scan hit its cap \u2014 some entries' governs relations may not be reflected._");
7439
- }
7440
7338
  lines.push("");
7441
7339
  return lines;
7442
7340
  }
@@ -7941,10 +7839,8 @@ function rankActiveBets(entries) {
7941
7839
  // src/tools/start_pb.ts
7942
7840
  var startPbSchema = z18.object({
7943
7841
  task: z18.string().max(2e3).optional().describe(
7944
- "What you're about to work on (e.g. 'implementing auth middleware'). Filters governance to show relevant principles, standards, and business rules \u2014 for every workspace state, including a fresh one."
7842
+ "What you're about to work on (e.g. 'implementing auth middleware'). Shapes the opener to the task \u2014 for every workspace state, including a fresh one."
7945
7843
  )
7946
- // TEN-2431: no `scope` param — start_pb's governance matches orient's scope-BLIND RENDERED
7947
- // governance; domain-scoping is deferred to TEN-2429 (must change both together, INS-1864).
7948
7844
  });
7949
7845
  async function tryMarkOriented(agentSessionId, coherenceSnapshot) {
7950
7846
  if (!agentSessionId) return { oriented: false, orientationStatus: "no_session" };
@@ -8027,32 +7923,7 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors, task) {
8027
7923
  activeBets = rankActiveBets((betsEntries ?? []).filter((e) => isActiveBet(e))).map((e) => ({ name: e.name, entryId: e.entryId ?? null })).slice(0, 8);
8028
7924
  } catch {
8029
7925
  }
8030
- let governanceEntries = { principles: [], standards: [], businessRules: [] };
8031
7926
  const ruleListsView = opener.view?.ruleLists ?? void 0;
8032
- let bindingGovernanceView;
8033
- try {
8034
- bindingGovernanceView = await kernelQuery("chain.getBindingGovernanceView", { task });
8035
- } catch {
8036
- }
8037
- if (task) {
8038
- const bg = bindingGovernanceView?.bindingGovernance;
8039
- if (bg) {
8040
- const mapGovEntry = (e) => ({
8041
- entryId: e.entryId ?? void 0,
8042
- name: e.name,
8043
- description: typeof e.preview === "string" ? e.preview : void 0,
8044
- tier: typeof e.tier === "number" ? e.tier : void 0
8045
- });
8046
- governanceEntries = {
8047
- principles: (bg.principles ?? []).map(mapGovEntry),
8048
- standards: (bg.standards ?? []).map(mapGovEntry),
8049
- businessRules: (bg.businessRules ?? []).map(mapGovEntry),
8050
- // TASK-469 (TEN-4004): same _budget.truncated read orient.ts's _handleOrient already
8051
- // applies to getOrientView's envelope — one shared shape, one read pattern.
8052
- truncated: bindingGovernanceView?._budget?.truncated === true
8053
- };
8054
- }
8055
- }
8056
7927
  if (task) {
8057
7928
  if (activeBets.length > 0) {
8058
7929
  lines.push("");
@@ -8064,7 +7935,7 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors, task) {
8064
7935
  }
8065
7936
  lines.push("");
8066
7937
  }
8067
- lines.push(...buildOperatingProtocol(governanceEntries, task));
7938
+ lines.push(...buildOperatingProtocol());
8068
7939
  if (coherence) {
8069
7940
  lines.push(...coherence.lines);
8070
7941
  }
@@ -8109,9 +7980,7 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors, task) {
8109
7980
  }
8110
7981
  lines.push("");
8111
7982
  }
8112
- lines.push(
8113
- ...buildOperatingProtocol({ truncated: bindingGovernanceView?._budget?.truncated === true })
8114
- );
7983
+ lines.push(...buildOperatingProtocol());
8115
7984
  if (coherence) {
8116
7985
  lines.push(...coherence.lines);
8117
7986
  }
@@ -8206,16 +8075,6 @@ ${FEEDBACK_SUBMIT_HINT}` }],
8206
8075
  }
8207
8076
 
8208
8077
  // src/tools/orient.ts
8209
- function mapGovernanceEntry(e) {
8210
- return {
8211
- entryId: e.entryId,
8212
- name: e.name,
8213
- tier: typeof e.tier === "number" ? e.tier : void 0,
8214
- provenance: e.provenance,
8215
- description: typeof e.preview === "string" ? e.preview : void 0,
8216
- anchoredBy: typeof e.anchoredBy === "string" ? e.anchoredBy : void 0
8217
- };
8218
- }
8219
8078
  var PURPOSE_GAP_PREFIX = "purpose-gap-";
8220
8079
  var READINESS_GAPS_MAX = 50;
8221
8080
  function formatRetrievalMissLines(verdict) {
@@ -8311,7 +8170,7 @@ function taskGroundingWarningLines(task, hasTaskGrounding = false) {
8311
8170
  "## Task grounding required",
8312
8171
  "_This is workspace orientation only. Do not start implementation, review, diagnosis, auth, security, or governance-sensitive work until you run task-shaped orient._",
8313
8172
  "",
8314
- 'Run `orient task="describe the work"` to load binding governance and supporting context for the actual task.',
8173
+ 'Run `orient task="describe the work"` to load the rules and context for the actual task.',
8315
8174
  ""
8316
8175
  ];
8317
8176
  }
@@ -8543,16 +8402,7 @@ async function _handleOrient({ mode = "full", tier, task, startupSignals, invoca
8543
8402
  }
8544
8403
  if (orientView) {
8545
8404
  lines.push("");
8546
- if (task) {
8547
- const gov = orientView.startup?.bindingGovernance ?? { principles: [], standards: [], businessRules: [] };
8548
- lines.push(...buildOperatingProtocol({
8549
- principles: (gov.principles ?? []).map(mapGovernanceEntry),
8550
- standards: (gov.standards ?? []).map(mapGovernanceEntry),
8551
- businessRules: (gov.businessRules ?? []).map(mapGovernanceEntry)
8552
- }, task));
8553
- } else {
8554
- lines.push(...buildOperatingProtocol());
8555
- }
8405
+ lines.push(...buildOperatingProtocol());
8556
8406
  }
8557
8407
  let orientationStatus2 = "no_session";
8558
8408
  if (agentSessionId && taskAsked) {
@@ -8830,12 +8680,7 @@ async function _handleOrient({ mode = "full", tier, task, startupSignals, invoca
8830
8680
  fullArchitectureNotes.forEach((e) => lines.push(fmt(e)));
8831
8681
  lines.push("");
8832
8682
  }
8833
- const gov = orientView.startup?.bindingGovernance ?? { principles: [], standards: [], businessRules: [] };
8834
- lines.push(...buildOperatingProtocol({
8835
- principles: (gov.principles ?? []).map(mapGovernanceEntry),
8836
- standards: (gov.standards ?? []).map(mapGovernanceEntry),
8837
- businessRules: (gov.businessRules ?? []).map(mapGovernanceEntry)
8838
- }, task));
8683
+ lines.push(...buildOperatingProtocol());
8839
8684
  }
8840
8685
  let allEntries = [];
8841
8686
  try {
@@ -14433,4 +14278,4 @@ export {
14433
14278
  createProductBrainServer,
14434
14279
  initFeatureFlags
14435
14280
  };
14436
- //# sourceMappingURL=chunk-WKSQMKMW.js.map
14281
+ //# sourceMappingURL=chunk-DXDDM4X7.js.map