@vedtechsolutions/engram-mcp 1.0.7 → 1.0.8

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.
@@ -1737,7 +1737,15 @@ var CONTEXTUAL = {
1737
1737
  /** Boost when memory files share the same module directory as current file */
1738
1738
  MODULE_PROXIMITY_BOOST: 0.2,
1739
1739
  /** Penalty multiplier when memory files are all from a different module (0.3 = 70% reduction) */
1740
- MODULE_MISMATCH_PENALTY: 0.3
1740
+ MODULE_MISMATCH_PENALTY: 0.3,
1741
+ /** Minimum access_count before staleness penalty applies */
1742
+ STALE_ACCESS_THRESHOLD: 15,
1743
+ /** access_count / reinforcement ratio above which staleness kicks in */
1744
+ STALE_RATIO_THRESHOLD: 8,
1745
+ /** Penalty reduction per unit above STALE_RATIO_THRESHOLD */
1746
+ STALE_PENALTY_PER_UNIT: 0.05,
1747
+ /** Maximum staleness penalty (caps the reduction) */
1748
+ MAX_STALE_PENALTY: 0.4
1741
1749
  };
1742
1750
  var REWARD = {
1743
1751
  /** Seed activation boost for positively-reinforced memories */
@@ -9114,6 +9122,16 @@ function contextualBoost(memory, context) {
9114
9122
  if (isEpisodicData(memory.type_data) && memory.type_data.outcome === "negative" && memory.type_data.lesson) {
9115
9123
  boost += CONTEXTUAL.FAILURE_EXPERIENCE_BOOST;
9116
9124
  }
9125
+ if (memory.access_count >= CONTEXTUAL.STALE_ACCESS_THRESHOLD) {
9126
+ const accessToReinforcementRatio = memory.access_count / Math.max(memory.reinforcement, 0.5);
9127
+ if (accessToReinforcementRatio > CONTEXTUAL.STALE_RATIO_THRESHOLD) {
9128
+ const stalePenalty = Math.min(
9129
+ (accessToReinforcementRatio - CONTEXTUAL.STALE_RATIO_THRESHOLD) * CONTEXTUAL.STALE_PENALTY_PER_UNIT,
9130
+ CONTEXTUAL.MAX_STALE_PENALTY
9131
+ );
9132
+ boost -= stalePenalty;
9133
+ }
9134
+ }
9117
9135
  return 1 + boost;
9118
9136
  }
9119
9137
  function rewardModifier(memory) {
@@ -12654,4 +12672,4 @@ export {
12654
12672
  composeProjectUnderstanding,
12655
12673
  formatMentalModelInjection
12656
12674
  };
12657
- //# sourceMappingURL=chunk-V5TTXT4V.js.map
12675
+ //# sourceMappingURL=chunk-OY2XHPUF.js.map
package/dist/hook.js CHANGED
@@ -174,7 +174,7 @@ import {
174
174
  updateReasoningChain,
175
175
  updateSelfModelFromSession,
176
176
  updateTask
177
- } from "./chunk-V5TTXT4V.js";
177
+ } from "./chunk-OY2XHPUF.js";
178
178
 
179
179
  // src/hook.ts
180
180
  import { readFileSync, writeFileSync, existsSync, renameSync, statSync, readdirSync, unlinkSync, appendFileSync, openSync, readSync, closeSync } from "fs";
@@ -2830,7 +2830,9 @@ function extractSearchIntent(query) {
2830
2830
  function updateCognitiveState(current, signal, recentTools, recentErrors) {
2831
2831
  const updated = { ...current };
2832
2832
  updated.last_updated = (/* @__PURE__ */ new Date()).toISOString();
2833
- updated.session_phase = recentErrors.length > 0 ? "debugging" : inferSessionPhase(recentTools);
2833
+ const recentWindow = recentTools.slice(-3);
2834
+ const hasRecentErrorContext = recentErrors.length > 0 && recentWindow.some((t) => t === "Bash") && recentWindow.length >= 2;
2835
+ updated.session_phase = hasRecentErrorContext ? "debugging" : inferSessionPhase(recentTools);
2834
2836
  switch (signal.type) {
2835
2837
  case "tool_call":
2836
2838
  break;
@@ -6213,7 +6215,32 @@ ${distillLines}`
6213
6215
  }
6214
6216
  }
6215
6217
  }
6218
+ if (!state.active_task || state.active_task === "write a comprehensive report") {
6219
+ const editedFiles = state.recent_actions.filter((a) => a.tool === "Edit" || a.tool === "Write").map((a) => a.target.split(/[/\\]/).pop() ?? a.target);
6220
+ const uniqueFiles = [...new Set(editedFiles)].slice(-5);
6221
+ if (uniqueFiles.length > 0) {
6222
+ const cog = state.cognitive_state;
6223
+ if (cog.current_approach && cog.current_approach.length > 5 && cog.current_approach !== "X") {
6224
+ state.active_task = truncate(cog.current_approach, 150);
6225
+ } else {
6226
+ state.active_task = `Working on ${uniqueFiles.join(", ")}`;
6227
+ }
6228
+ }
6229
+ }
6216
6230
  try {
6231
+ const cog = state.cognitive_state;
6232
+ if (cog.current_approach === "X" || cog.current_approach === "X.") {
6233
+ state.cognitive_state.current_approach = null;
6234
+ }
6235
+ if (cog.active_hypothesis === "Y" || cog.active_hypothesis === "Y.") {
6236
+ state.cognitive_state.active_hypothesis = null;
6237
+ }
6238
+ if (cog.recent_discovery === "Z" || cog.recent_discovery === "Z.") {
6239
+ state.cognitive_state.recent_discovery = null;
6240
+ }
6241
+ if (cog.active_hypothesis && cog.active_hypothesis.startsWith("/")) {
6242
+ state.cognitive_state.active_hypothesis = null;
6243
+ }
6217
6244
  if (content.length >= 20 && !state.cognitive_state.current_approach) {
6218
6245
  const approach = extractApproachFromPrompt(content);
6219
6246
  if (approach) {
package/dist/index.js CHANGED
@@ -154,7 +154,7 @@ import {
154
154
  vaccinate,
155
155
  vacuumDatabase,
156
156
  validateMultiPerspective
157
- } from "./chunk-V5TTXT4V.js";
157
+ } from "./chunk-OY2XHPUF.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.7",
3
+ "version": "1.0.8",
4
4
  "description": "Cognitive memory system for AI — persistent, cross-session learning via MCP",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",