@productbrain/mcp 0.0.1-beta.25 → 0.0.1-beta.26

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.
@@ -1103,7 +1103,21 @@ async function queryPlannedWork() {
1103
1103
  function hasPlannedWork(work) {
1104
1104
  return work.uncommittedDrafts.length > 0 || work.inProgressEntries.length > 0 || work.openTensions.length > 0;
1105
1105
  }
1106
- function buildPlannedWorkSection(work, priorSessions) {
1106
+ function formatRecoveryBlock(block) {
1107
+ const fmt = (items, overflow) => items.map((e) => `${e.entryId} [${e.collection}] ${e.name}`).join(", ") + (overflow && overflow > 0 ? ` (+${overflow} more)` : "");
1108
+ const lines = [
1109
+ "## Previous Session Recovery",
1110
+ "",
1111
+ `Session ${block.sessionId} \u2014 ${block.date}, ${block.duration}, status: ${block.status}`,
1112
+ `Created (${block.created.length + (block.createdOverflow ?? 0)}): ${fmt(block.created, block.createdOverflow)}`,
1113
+ `Modified (${block.modified.length + (block.modifiedOverflow ?? 0)}): ${fmt(block.modified, block.modifiedOverflow)}`,
1114
+ `Drafts needing attention (${block.draftsNeedingAttention.length + (block.draftsOverflow ?? 0)}): ${fmt(block.draftsNeedingAttention, block.draftsOverflow)}`,
1115
+ `Relations created: ${block.relationsCreated}`,
1116
+ ""
1117
+ ];
1118
+ return lines;
1119
+ }
1120
+ function buildPlannedWorkSection(work, priorSessions, recoveryBlock) {
1107
1121
  if (!hasPlannedWork(work) && priorSessions.length === 0) return [];
1108
1122
  const lines = [];
1109
1123
  lines.push("## Continue from where you left off");
@@ -1133,7 +1147,7 @@ function buildPlannedWorkSection(work, priorSessions) {
1133
1147
  lines.push(`- **${count} open tensions** \u2014 top: ${top.name}`);
1134
1148
  }
1135
1149
  }
1136
- if (priorSessions.length > 0 && !hasPlannedWork(work)) {
1150
+ if (priorSessions.length > 0 && !hasPlannedWork(work) && !recoveryBlock) {
1137
1151
  const last = priorSessions[0];
1138
1152
  const date = new Date(last.startedAt).toISOString().split("T")[0];
1139
1153
  const created = Array.isArray(last.entriesCreated) ? last.entriesCreated.length : last.entriesCreated ?? 0;
@@ -1142,6 +1156,10 @@ function buildPlannedWorkSection(work, priorSessions) {
1142
1156
  lines.push(`- **Last session** (${date}): ${created} created, ${modified} modified`);
1143
1157
  }
1144
1158
  }
1159
+ if (recoveryBlock) {
1160
+ lines.push("");
1161
+ lines.push(...formatRecoveryBlock(recoveryBlock));
1162
+ }
1145
1163
  lines.push("");
1146
1164
  return lines;
1147
1165
  }
@@ -1362,9 +1380,12 @@ function registerHealthTools(server) {
1362
1380
  errors.push(`Workspace: ${e.message}`);
1363
1381
  }
1364
1382
  let priorSessions = [];
1383
+ let recoveryBlock = null;
1365
1384
  if (wsCtx) {
1366
1385
  try {
1367
- priorSessions = await mcpQuery("agent.recentSessions", { limit: 3 });
1386
+ const sessionsResult = await mcpQuery("agent.recentSessions", { limit: 3 });
1387
+ priorSessions = sessionsResult?.sessions ?? [];
1388
+ recoveryBlock = sessionsResult?.recoveryBlock ?? null;
1368
1389
  } catch {
1369
1390
  }
1370
1391
  }
@@ -1415,7 +1436,10 @@ function registerHealthTools(server) {
1415
1436
  lines.push(`- \`${e.entryId ?? e._id}\` ${e.name}${tensionPart}`);
1416
1437
  }
1417
1438
  }
1418
- if (priorSessions.length > 0) {
1439
+ if (recoveryBlock) {
1440
+ lines.push("");
1441
+ lines.push(...formatRecoveryBlock(recoveryBlock));
1442
+ } else if (priorSessions.length > 0) {
1419
1443
  const last = priorSessions[0];
1420
1444
  const date = new Date(last.startedAt).toISOString().split("T")[0];
1421
1445
  const created = Array.isArray(last.entriesCreated) ? last.entriesCreated.length : last.entriesCreated ?? 0;
@@ -1561,10 +1585,10 @@ function registerHealthTools(server) {
1561
1585
  }
1562
1586
  const plannedWork = await queryPlannedWork();
1563
1587
  if (hasPlannedWork(plannedWork)) {
1564
- lines.push(...buildPlannedWorkSection(plannedWork, priorSessions));
1588
+ lines.push(...buildPlannedWorkSection(plannedWork, priorSessions, recoveryBlock));
1565
1589
  } else {
1566
1590
  const briefingItems = [];
1567
- if (priorSessions.length > 0) {
1591
+ if (priorSessions.length > 0 && !recoveryBlock) {
1568
1592
  const last = priorSessions[0];
1569
1593
  const date = new Date(last.startedAt).toISOString().split("T")[0];
1570
1594
  const created = Array.isArray(last.entriesCreated) ? last.entriesCreated.length : last.entriesCreated ?? 0;
@@ -1581,6 +1605,10 @@ function registerHealthTools(server) {
1581
1605
  }
1582
1606
  lines.push("");
1583
1607
  }
1608
+ if (recoveryBlock) {
1609
+ lines.push("");
1610
+ lines.push(...formatRecoveryBlock(recoveryBlock));
1611
+ }
1584
1612
  }
1585
1613
  lines.push("What would you like to work on?");
1586
1614
  lines.push("");
@@ -4030,8 +4058,11 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
4030
4058
  const wsFullCtx = await getWorkspaceContext();
4031
4059
  const { ageDays, isNeglected } = computeWorkspaceAge(wsFullCtx.createdAt);
4032
4060
  let priorSessions = [];
4061
+ let recoveryBlock = null;
4033
4062
  try {
4034
- priorSessions = await mcpQuery("agent.recentSessions", { limit: 3 });
4063
+ const sessionsResult = await mcpQuery("agent.recentSessions", { limit: 3 });
4064
+ priorSessions = sessionsResult?.sessions ?? [];
4065
+ recoveryBlock = sessionsResult?.recoveryBlock ?? null;
4035
4066
  } catch {
4036
4067
  }
4037
4068
  let openTensions = [];
@@ -4086,10 +4117,10 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
4086
4117
  const plannedWork = await queryPlannedWork();
4087
4118
  if (hasPlannedWork(plannedWork)) {
4088
4119
  lines.push("");
4089
- lines.push(...buildPlannedWorkSection(plannedWork, priorSessions));
4120
+ lines.push(...buildPlannedWorkSection(plannedWork, priorSessions, recoveryBlock));
4090
4121
  } else {
4091
4122
  const briefingItems = [];
4092
- if (priorSessions.length > 0) {
4123
+ if (priorSessions.length > 0 && !recoveryBlock) {
4093
4124
  const last = priorSessions[0];
4094
4125
  const date = new Date(last.startedAt).toISOString().split("T")[0];
4095
4126
  const created = Array.isArray(last.entriesCreated) ? last.entriesCreated.length : last.entriesCreated ?? 0;
@@ -4107,6 +4138,10 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
4107
4138
  }
4108
4139
  lines.push("");
4109
4140
  }
4141
+ if (recoveryBlock) {
4142
+ lines.push("");
4143
+ lines.push(...formatRecoveryBlock(recoveryBlock));
4144
+ }
4110
4145
  }
4111
4146
  lines.push("What would you like to work on?");
4112
4147
  lines.push("");
@@ -4692,4 +4727,4 @@ export {
4692
4727
  SERVER_VERSION,
4693
4728
  createProductBrainServer
4694
4729
  };
4695
- //# sourceMappingURL=chunk-E75NDP6K.js.map
4730
+ //# sourceMappingURL=chunk-PVWT5LIB.js.map