@vedtechsolutions/engram-mcp 1.0.7 → 1.0.9
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.
- package/dist/{chunk-V5TTXT4V.js → chunk-OY2XHPUF.js} +20 -2
- package/dist/hook.js +31 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -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-
|
|
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-
|
|
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
|
-
|
|
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) {
|
|
@@ -6278,7 +6305,7 @@ ${distillLines}`
|
|
|
6278
6305
|
}
|
|
6279
6306
|
const rawCandidates = getTopDomainMemories(surfaceDomain, MEMORY_SURFACE.CANDIDATE_POOL_SIZE, excludeIds, state.active_project ?? void 0);
|
|
6280
6307
|
const candidates = rawCandidates.filter(
|
|
6281
|
-
(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("
|
|
6308
|
+
(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")
|
|
6282
6309
|
// narratives are for model composition, not surfacing
|
|
6283
6310
|
);
|
|
6284
6311
|
const surfaced = selectDiverseSurface(candidates, MEMORY_SURFACE.MAX_SURFACE_ITEMS);
|
|
@@ -6367,7 +6394,7 @@ ${distillLines}`
|
|
|
6367
6394
|
if (surfacedIds.has(m.memory.id)) continue;
|
|
6368
6395
|
if (isRecallNoise(m.memory.content, m.memory.type, m.memory.tags)) continue;
|
|
6369
6396
|
if (m.memory.tags.includes("pre-compact")) continue;
|
|
6370
|
-
if (m.memory.tags.includes("
|
|
6397
|
+
if (m.memory.tags.includes("session-narrative")) continue;
|
|
6371
6398
|
const isFailure = m.memory.type === "episodic" && isEpisodicData(m.memory.type_data) && m.memory.type_data.outcome === "negative";
|
|
6372
6399
|
const prefix = m.somatic_marker ? "[ENGRAM GUT]" : isFailure ? "[ENGRAM CAUTION]" : "[ENGRAM CONTEXT]";
|
|
6373
6400
|
const outcomeHint = m.memory.type === "episodic" && (m.somatic_marker || isFailure) ? getEpisodicOutcomeHint(m.memory) : "";
|
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ import {
|
|
|
154
154
|
vaccinate,
|
|
155
155
|
vacuumDatabase,
|
|
156
156
|
validateMultiPerspective
|
|
157
|
-
} from "./chunk-
|
|
157
|
+
} from "./chunk-OY2XHPUF.js";
|
|
158
158
|
|
|
159
159
|
// src/index.ts
|
|
160
160
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|