@productbrain/mcp 0.0.1-beta.156 → 0.0.1-beta.157

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.
@@ -12,8 +12,11 @@ import {
12
12
  trackKnowledgeGap,
13
13
  trackQualityCheck,
14
14
  trackQualityVerdict,
15
- trackToolCall
16
- } from "./chunk-X3S5UTTZ.js";
15
+ trackSessionCaptureRate,
16
+ trackToolCall,
17
+ trackWriteBackHintServed,
18
+ trackZeroCaptureAuditFired
19
+ } from "./chunk-WYVQARYT.js";
17
20
 
18
21
  // src/auth.ts
19
22
  import { AsyncLocalStorage } from "async_hooks";
@@ -7260,6 +7263,30 @@ async function runWrapupReview() {
7260
7263
  lines.push("- **Commit all:** call `session-wrapup` with action `commit-all`");
7261
7264
  lines.push("- **Skip:** call `session action=close` \u2014 drafts remain for next session's orient recovery.");
7262
7265
  }
7266
+ if (data.captureAudit) {
7267
+ lines.push("");
7268
+ lines.push("### Capture Audit");
7269
+ lines.push("");
7270
+ lines.push(`_${data.captureAudit.message}_`);
7271
+ if (data.captureAudit.suggestions.length > 0) {
7272
+ lines.push("");
7273
+ lines.push("**What to consider capturing:**");
7274
+ for (const s of data.captureAudit.suggestions) {
7275
+ lines.push(`- **${s.collectionSlug}**: ${s.hint}`);
7276
+ }
7277
+ }
7278
+ lines.push("");
7279
+ }
7280
+ lines.push("");
7281
+ lines.push(`> **${data.closeNudge}**`);
7282
+ if (data.captureAudit) {
7283
+ const wsCtx = await getWorkspaceContext();
7284
+ if (wsCtx) {
7285
+ trackZeroCaptureAuditFired(wsCtx.workspaceId, {
7286
+ suggestion_count: data.captureAudit.suggestions.length
7287
+ });
7288
+ }
7289
+ }
7263
7290
  const gapCount = getSessionGaps().length;
7264
7291
  return { text: lines.join("\n"), data, suggestions, gapCount, coherenceVerdict, persistentGaps };
7265
7292
  }
@@ -7583,13 +7610,22 @@ async function handleClose() {
7583
7610
  }
7584
7611
  await closeAgentSession();
7585
7612
  clearSessionGaps();
7613
+ const created = session?.entriesCreated?.length ?? 0;
7614
+ const modified = session?.entriesModified?.length ?? 0;
7615
+ const relations = session?.relationsCreated ?? 0;
7616
+ const wsCtx = await getWorkspaceContext();
7617
+ if (wsCtx) {
7618
+ trackSessionCaptureRate(wsCtx.workspaceId, {
7619
+ entries_created: created,
7620
+ entries_modified: modified,
7621
+ relations_created: relations,
7622
+ had_captures: created > 0
7623
+ });
7624
+ }
7586
7625
  const lines = [
7587
7626
  `Session ${sessionId} closed.`,
7588
7627
  ""
7589
7628
  ];
7590
- const created = session?.entriesCreated?.length ?? 0;
7591
- const modified = session?.entriesModified?.length ?? 0;
7592
- const relations = session?.relationsCreated ?? 0;
7593
7629
  const gates = session?.gateFailures ?? 0;
7594
7630
  const warnings = session?.contradictionWarnings ?? 0;
7595
7631
  if (session) {
@@ -8370,7 +8406,7 @@ var IMPLEMENTATION_REVIEW_WORKFLOW_DESCRIPTOR = {
8370
8406
 
8371
8407
  ## Your Behavior
8372
8408
 
8373
- 1. **Tool-heavy, not chat-heavy.** Each round calls specific tools: orient, quality, verify, chain-review, context action=gather, review-against-rules. Use Context7 (query-docs) for relevant testing and framework docs \u2014 not for Chain truth.
8409
+ 1. **Tool-heavy, not chat-heavy.** Each round calls specific tools: orient, quality, verify, chain-review, context action=gather, review-against-rules. Use Context7 **CLI** (\`npx ctx7@latest library\` then \`docs\`) for relevant testing and framework docs \u2014 not for Chain truth. Do not use Context7 MCP.
8374
8410
  2. **Spawn sub-agents** for parallel review: (a) code/architecture review, (b) test honesty (did we edit tests to pass or do they validate real behavior?). Max 2 agents in parallel, 30s budget each. **Constrain each sub-agent to the stated review scope only.**
8375
8411
  3. **Fix-as-you-go (FEAT-172).** When you find a HIGH or MEDIUM issue: fix it immediately, verify (lints, types), then proceed. The user sees clean work, not a list of issues. Only defer if estimated >5 min \u2014 capture deferred items as tensions. If user says "skip", capture as tension and continue.
8376
8412
  4. **Chain is SSOT.** Call orient or start first. Use entries action=search and context action=gather to load relevant BETs, DECs, BRs. If findings conflict with Chain entries, report the conflict and cite the entry ID.
@@ -8387,7 +8423,7 @@ var IMPLEMENTATION_REVIEW_WORKFLOW_DESCRIPTOR = {
8387
8423
  - \`verify\` \u2014 glossary code mappings, cross-references vs codebase
8388
8424
  - \`review-against-rules\` (domain) \u2014 business rule compliance
8389
8425
  - \`context action=gather task="implementation review for [BET-ID]"\` \u2014 related knowledge
8390
- - Context7 \`query-docs\` \u2014 relevant testing and framework best practices (resolve-library-id first)
8426
+ - Context7 CLI \u2014 \`npx ctx7@latest library\` then \`npx ctx7@latest docs\` for framework/testing docs (not Chain truth)
8391
8427
  - \`session-wrapup\` \u2014 before close
8392
8428
 
8393
8429
  ## Sub-Agent Classification (for test failures)
@@ -8439,7 +8475,7 @@ This block is the final deliverable of the review. Everything else is supporting
8439
8475
  label: "Code & Test Honesty",
8440
8476
  type: "open",
8441
8477
  instruction: "Spawn sub-agents to review implementation and tests for the stated scope only. Fix every HIGH/MEDIUM finding before proceeding. Did we meet high standards? Are tests validating real behavior or did we edit them just to pass?",
8442
- facilitatorGuidance: "Restrict all review to the scope stated in Round 01 (by default, work in this conversation only). Spawn 1\u20132 sub-agents in parallel: (1) explore agent \u2014 code review, architecture boundaries, type-safety for scoped files only. (2) explore agent \u2014 test review for scoped code: are tests asserting real behavior or were they edited to pass? Pass the scope (files/BET) explicitly to sub-agents so they do not touch other work. Use Context7 (query-docs) for relevant testing and framework best practices if needed. Classify any test failures: staleness, regression, or flaky. **Fix-as-you-go (FEAT-172):** For every HIGH/MEDIUM finding: fix immediately, run lints, verify types. Only defer fixes estimated >5 min \u2014 capture deferred items as tensions on the Chain. After fixing, do a boy-scout pass on each scoped file: clean imports, improve naming, remove dead code. **Counter-Metric Mandate (STD-19):** When reporting test coverage, accuracy, or any quantitative result, include the denominator, what was excluded, and at least one counter-metric. Never report accuracy without recall. Never report pass rate without coverage. Synthesize: findings, fixes applied, implementation grade, test honesty verdict.",
8478
+ facilitatorGuidance: "Restrict all review to the scope stated in Round 01 (by default, work in this conversation only). Spawn 1\u20132 sub-agents in parallel: (1) explore agent \u2014 code review, architecture boundaries, type-safety for scoped files only. (2) explore agent \u2014 test review for scoped code: are tests asserting real behavior or were they edited to pass? Pass the scope (files/BET) explicitly to sub-agents so they do not touch other work. Use Context7 CLI (npx ctx7 library/docs) for relevant testing and framework best practices if needed. Classify any test failures: staleness, regression, or flaky. **Fix-as-you-go (FEAT-172):** For every HIGH/MEDIUM finding: fix immediately, run lints, verify types. Only defer fixes estimated >5 min \u2014 capture deferred items as tensions on the Chain. After fixing, do a boy-scout pass on each scoped file: clean imports, improve naming, remove dead code. **Counter-Metric Mandate (STD-19):** When reporting test coverage, accuracy, or any quantitative result, include the denominator, what was excluded, and at least one counter-metric. Never report accuracy without recall. Never report pass rate without coverage. Synthesize: findings, fixes applied, implementation grade, test honesty verdict.",
8443
8479
  outputSchema: {
8444
8480
  field: "codeAndTests",
8445
8481
  description: "Implementation grade, test honesty, refactor suggestions",
@@ -8515,7 +8551,7 @@ This block is the final deliverable of the review. Everything else is supporting
8515
8551
 
8516
8552
  1. **Tool failure**: Explain what failed. Continue with what you have. The conversation is the record.
8517
8553
  2. **Sub-agent timeout**: Proceed without that agent's output. Note what wasn't checked.
8518
- 3. **Context7 unavailable**: Skip library doc validation. Rely on Chain and codebase review.
8554
+ 3. **Context7 CLI unavailable** (e.g. auth/network): Skip library doc validation. Rely on Chain and codebase review.
8519
8555
  4. **MCP unreachable**: Run from conversation knowledge. Summarize findings. Offer to capture manually later.
8520
8556
 
8521
8557
  The review must never fail silently. Always end with BET/chain IDs.`
@@ -13249,6 +13285,15 @@ function registerOrientTool(server) {
13249
13285
  } catch {
13250
13286
  }
13251
13287
  const hasTaskGrounding = Boolean(task && orientEntries?.taskContext?.context?.length > 0);
13288
+ if (wsCtx && hasTaskGrounding && orientEntries?.writeBackHints) {
13289
+ const hints = Array.isArray(orientEntries.writeBackHints) ? orientEntries.writeBackHints : [];
13290
+ if (hints.length > 0) {
13291
+ trackWriteBackHintServed(wsCtx.workspaceId, {
13292
+ hint_count: hints.length,
13293
+ has_task: !!task
13294
+ });
13295
+ }
13296
+ }
13252
13297
  let openTensions = [];
13253
13298
  try {
13254
13299
  const tensions = await mcpQuery("chain.listEntries", { collectionSlug: "tensions" });
@@ -13327,6 +13372,13 @@ function registerOrientTool(server) {
13327
13372
  if (orientEntries?.taskContext && orientEntries.taskContext.context.length > 0) {
13328
13373
  lines.push(`Task context: ${orientEntries.taskContext.totalFound} relevant entries (${orientEntries.taskContext.confidence} confidence).`);
13329
13374
  }
13375
+ if (orientEntries?.writeBackHints && orientEntries.writeBackHints.length > 0) {
13376
+ lines.push("");
13377
+ lines.push("Write-back hints (what to capture this session):");
13378
+ for (const h of orientEntries.writeBackHints) {
13379
+ lines.push(` ${h.collectionSlug}: ${h.hint}`);
13380
+ }
13381
+ }
13330
13382
  if (orientEntries?.activeBets?.length > 0) {
13331
13383
  for (const e of orientEntries.activeBets) {
13332
13384
  const tensions = e.linkedTensions;
@@ -13574,6 +13626,16 @@ function registerOrientTool(server) {
13574
13626
  orientEntries.taskContext.constellationBetName
13575
13627
  ));
13576
13628
  }
13629
+ if (orientEntries?.writeBackHints && orientEntries.writeBackHints.length > 0) {
13630
+ lines.push("");
13631
+ lines.push("## Write-Back Hints");
13632
+ lines.push("_What to capture this session (derived from task context):_");
13633
+ lines.push("");
13634
+ for (const h of orientEntries.writeBackHints) {
13635
+ lines.push(`- **${h.collectionSlug}**: ${h.hint}`);
13636
+ }
13637
+ lines.push("");
13638
+ }
13577
13639
  if (orientEntries) {
13578
13640
  const result = await runAlignmentCheck(
13579
13641
  task,
@@ -15319,4 +15381,4 @@ export {
15319
15381
  SERVER_VERSION,
15320
15382
  createProductBrainServer
15321
15383
  };
15322
- //# sourceMappingURL=chunk-GMSHWOXT.js.map
15384
+ //# sourceMappingURL=chunk-NRP3DF6E.js.map