@vedtechsolutions/engram-mcp 1.0.3 → 1.0.5

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.
@@ -446,16 +446,16 @@ var PROACTIVE_RECALL = {
446
446
  var MEMORY_SURFACE = {
447
447
  /** Maximum memories surfaced per prompt check */
448
448
  MAX_SURFACE_ITEMS: 3,
449
- /** Candidate pool fetched from DB (filtered down to MAX_SURFACE_ITEMS) */
450
- CANDIDATE_POOL_SIZE: 8,
449
+ /** Candidate pool fetched from DB (wider pool = more rotation diversity) */
450
+ CANDIDATE_POOL_SIZE: 15,
451
451
  /** Minimum turns before re-surfacing the same memory */
452
- MIN_TURNS_BETWEEN_SAME: 8,
452
+ MIN_TURNS_BETWEEN_SAME: 12,
453
453
  /** Minimum domain string length to trigger surface injection */
454
454
  MIN_DOMAIN_LENGTH: 2,
455
455
  /** Minimum confidence for surface injection */
456
456
  MIN_SURFACE_CONFIDENCE: 0.5,
457
457
  /** Minimum reinforcement for surface injection (below default 1.0 to allow fresh memories) */
458
- MIN_SURFACE_REINFORCEMENT: 0.8
458
+ MIN_SURFACE_REINFORCEMENT: 0.5
459
459
  };
460
460
  var RETRIEVAL_FEEDBACK = {
461
461
  /** Maximum recalled memory IDs to track (ring buffer) */
@@ -9664,9 +9664,12 @@ function removeProficiency(model, domain) {
9664
9664
  function computeProficiency(prof, domain) {
9665
9665
  let avgConfidence = 0.5;
9666
9666
  try {
9667
- const domainMemories = getMemoriesByDomain(domain, 50);
9668
- if (domainMemories.length > 0) {
9669
- avgConfidence = domainMemories.reduce((sum, m) => sum + m.confidence, 0) / domainMemories.length;
9667
+ const domainMemories = getMemoriesByDomain(domain, 100);
9668
+ const qualityMemories = domainMemories.filter(
9669
+ (m) => m.type === "semantic" || m.type === "procedural" || m.type === "antipattern" || m.type === "episodic" && isEpisodicData(m.type_data) && m.type_data.lesson && m.type_data.lesson.length > 10
9670
+ );
9671
+ if (qualityMemories.length > 0) {
9672
+ avgConfidence = qualityMemories.reduce((sum, m) => sum + m.confidence, 0) / qualityMemories.length;
9670
9673
  }
9671
9674
  } catch {
9672
9675
  }
@@ -12627,4 +12630,4 @@ export {
12627
12630
  composeProjectUnderstanding,
12628
12631
  formatMentalModelInjection
12629
12632
  };
12630
- //# sourceMappingURL=chunk-QU7DOPA4.js.map
12633
+ //# sourceMappingURL=chunk-FQ4MRL3Q.js.map
package/dist/hook.js CHANGED
@@ -173,7 +173,7 @@ import {
173
173
  updateReasoningChain,
174
174
  updateSelfModelFromSession,
175
175
  updateTask
176
- } from "./chunk-QU7DOPA4.js";
176
+ } from "./chunk-FQ4MRL3Q.js";
177
177
 
178
178
  // src/hook.ts
179
179
  import { readFileSync, writeFileSync, existsSync, renameSync, statSync, readdirSync, unlinkSync, appendFileSync, openSync, readSync, closeSync } from "fs";
@@ -1743,7 +1743,11 @@ function composeSessionNarrative(params) {
1743
1743
  if (params.total_turns < SESSION_NARRATIVE.MIN_TURNS_FOR_NARRATIVE) {
1744
1744
  return null;
1745
1745
  }
1746
- const goal = extractGoal(params);
1746
+ const goal = extractGoal({
1747
+ ...params,
1748
+ cognitive_state: params.cognitive_state,
1749
+ session_files: params.session_files
1750
+ });
1747
1751
  const approach = params.cognitive_state?.current_approach ?? extractApproach(params.conversation);
1748
1752
  const challenges = extractChallenges(params);
1749
1753
  const baseLessons = extractLessons(params);
@@ -1781,6 +1785,13 @@ function composeSessionNarrative(params) {
1781
1785
  }
1782
1786
  function extractGoal(params) {
1783
1787
  if (params.active_task) return params.active_task;
1788
+ if (params.cognitive_state?.current_approach) {
1789
+ return params.cognitive_state.current_approach;
1790
+ }
1791
+ if (params.cognitive_state?.recent_discovery && params.session_files && params.session_files.length > 0) {
1792
+ const topFiles = params.session_files.slice(-3).map((f) => f.split(/[/\\]/).pop() ?? f).join(", ");
1793
+ return `${params.cognitive_state.recent_discovery} (${topFiles})`;
1794
+ }
1784
1795
  if (params.conversation.topic_history.length > 0) {
1785
1796
  return params.conversation.topic_history[0].topic;
1786
1797
  }
@@ -6098,7 +6109,8 @@ ${distillLines}`
6098
6109
  }
6099
6110
  const rawCandidates = getTopDomainMemories(surfaceDomain, MEMORY_SURFACE.CANDIDATE_POOL_SIZE, excludeIds, state.active_project ?? void 0);
6100
6111
  const candidates = rawCandidates.filter(
6101
- (m) => m.confidence >= MEMORY_SURFACE.MIN_SURFACE_CONFIDENCE && m.reinforcement >= MEMORY_SURFACE.MIN_SURFACE_REINFORCEMENT && !isRecallNoise(m.content, m.type, m.tags)
6112
+ (m) => m.confidence >= MEMORY_SURFACE.MIN_SURFACE_CONFIDENCE && m.reinforcement >= MEMORY_SURFACE.MIN_SURFACE_REINFORCEMENT && !isRecallNoise(m.content, m.type, m.tags) && !m.tags.includes("session_narrative")
6113
+ // narratives are for model composition, not surfacing
6102
6114
  );
6103
6115
  const surfaced = selectDiverseSurface(candidates, MEMORY_SURFACE.MAX_SURFACE_ITEMS);
6104
6116
  if (surfaced.length > 0) {
@@ -6184,6 +6196,7 @@ ${distillLines}`
6184
6196
  if (somaticIds.has(m.memory.id)) continue;
6185
6197
  if (isRecallNoise(m.memory.content, m.memory.type, m.memory.tags)) continue;
6186
6198
  if (m.memory.tags.includes("pre-compact")) continue;
6199
+ if (m.memory.tags.includes("session_narrative")) continue;
6187
6200
  const isFailure = m.memory.type === "episodic" && isEpisodicData(m.memory.type_data) && m.memory.type_data.outcome === "negative";
6188
6201
  const prefix = m.somatic_marker ? "[ENGRAM GUT]" : isFailure ? "[ENGRAM CAUTION]" : "[ENGRAM CONTEXT]";
6189
6202
  const outcomeHint = m.memory.type === "episodic" && (m.somatic_marker || isFailure) ? getEpisodicOutcomeHint(m.memory) : "";
@@ -6828,6 +6841,39 @@ function handlePostCompact(stdinJson) {
6828
6841
  if (!recovery) return;
6829
6842
  const budget = new OutputBudget(OUTPUT_BUDGET.POST_COMPACT_MAX_BYTES);
6830
6843
  const lines = [];
6844
+ const cog = state.cognitive_state;
6845
+ const cogCtx = recovery.working_state?.cognitive_context;
6846
+ const hasAnyCognitive = cog?.current_approach || cog?.active_hypothesis || cog?.recent_discovery || cogCtx?.planned_next_step || recovery.continuation_hint;
6847
+ if (hasAnyCognitive) {
6848
+ const mindLines = ["[Engram] Before compaction, you were:"];
6849
+ if (state.active_task) mindLines.push(` Task: ${truncate(state.active_task, 200)}`);
6850
+ if (cog?.session_phase) mindLines.push(` Phase: ${cog.session_phase}`);
6851
+ if (cog?.current_approach) mindLines.push(` Approach: ${truncate(cog.current_approach, 300)}`);
6852
+ if (cog?.active_hypothesis) mindLines.push(` Hypothesis: ${truncate(cog.active_hypothesis, 300)}`);
6853
+ if (cog?.recent_discovery) mindLines.push(` Discovery: ${truncate(cog.recent_discovery, 300)}`);
6854
+ if (cogCtx?.planned_next_step) mindLines.push(` Next step: ${truncate(cogCtx.planned_next_step, 200)}`);
6855
+ if (cog?.search_intent) mindLines.push(` Investigating: ${truncate(cog.search_intent, 200)}`);
6856
+ const ruledOut = (state.session_outcomes ?? []).filter((o) => o.includes("\u2192 fail") || o.includes("\u2192 dead end") || o.includes("\u2192 blocked"));
6857
+ if (ruledOut.length > 0) {
6858
+ mindLines.push(` Already tried (didn't work):`);
6859
+ for (const o of ruledOut.slice(-3)) mindLines.push(` - ${truncate(o, 150)}`);
6860
+ }
6861
+ const blockers = recovery.working_state?.active_blockers ?? [];
6862
+ if (blockers.length > 0) {
6863
+ mindLines.push(` Blockers: ${blockers.slice(0, 3).map((b) => truncate(b, 100)).join("; ")}`);
6864
+ }
6865
+ if (state.recent_errors.length > 0) {
6866
+ mindLines.push(` Recent errors: ${state.recent_errors.slice(-2).map((e) => truncate(e, 100)).join("; ")}`);
6867
+ }
6868
+ if (state.session_files.length > 0) {
6869
+ const files = state.session_files.slice(-8).map((f) => f.split(/[/\\]/).pop() ?? f);
6870
+ mindLines.push(` Files: ${files.join(", ")}`);
6871
+ }
6872
+ if (recovery.continuation_hint) {
6873
+ mindLines.push(` Continue: ${truncate(recovery.continuation_hint, 300)}`);
6874
+ }
6875
+ lines.push(mindLines.join("\n"));
6876
+ }
6831
6877
  try {
6832
6878
  const transcriptPath = stdinJson?.transcript_path ?? null;
6833
6879
  if (transcriptPath) {
package/dist/index.js CHANGED
@@ -154,7 +154,7 @@ import {
154
154
  vaccinate,
155
155
  vacuumDatabase,
156
156
  validateMultiPerspective
157
- } from "./chunk-QU7DOPA4.js";
157
+ } from "./chunk-FQ4MRL3Q.js";
158
158
 
159
159
  // src/index.ts
160
160
  import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vedtechsolutions/engram-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Cognitive memory system for AI — persistent, cross-session learning via MCP",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",