@vedtechsolutions/engram-mcp 1.0.11 → 1.0.13

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.
Files changed (2) hide show
  1. package/dist/hook.js +43 -15
  2. package/package.json +1 -1
package/dist/hook.js CHANGED
@@ -3141,7 +3141,8 @@ function loadWatcherState() {
3141
3141
  recent_commands: raw.recent_commands ?? [],
3142
3142
  procedural_encoded_count: raw.procedural_encoded_count ?? 0,
3143
3143
  recent_actions: raw.recent_actions ?? [],
3144
- continuation_brief: raw.continuation_brief ?? null
3144
+ continuation_brief: raw.continuation_brief ?? null,
3145
+ recent_prompts: raw.recent_prompts ?? []
3145
3146
  };
3146
3147
  }
3147
3148
  } catch {
@@ -3207,7 +3208,8 @@ function loadWatcherState() {
3207
3208
  recent_commands: [],
3208
3209
  procedural_encoded_count: 0,
3209
3210
  recent_actions: [],
3210
- continuation_brief: null
3211
+ continuation_brief: null,
3212
+ recent_prompts: []
3211
3213
  };
3212
3214
  }
3213
3215
  function saveWatcherState(state) {
@@ -3311,18 +3313,19 @@ function writeSessionHandoff(state, narrative) {
3311
3313
  const queries = state.search_queries.slice(-5);
3312
3314
  reasoningTrail.push(`Investigated: ${queries.join(" \u2192 ")}`);
3313
3315
  }
3316
+ const brief = state.continuation_brief ?? buildContinuationBrief(state);
3314
3317
  const handoff = {
3315
3318
  ended_at: (/* @__PURE__ */ new Date()).toISOString(),
3316
3319
  project: state.active_project,
3317
3320
  domain: state.active_domain,
3318
- task: state.active_task,
3321
+ task: brief.task !== "unknown task" ? brief.task : state.active_task,
3319
3322
  approach: (state.cognitive_state.current_approach ?? narrative?.approach ?? null)?.substring(0, SESSION_HANDOFF.MAX_APPROACH_LENGTH) ?? null,
3320
3323
  hypothesis: state.cognitive_state.active_hypothesis?.substring(0, SESSION_HANDOFF.MAX_APPROACH_LENGTH) ?? null,
3321
3324
  discoveries: state.cognitive_state.recent_discovery ? [state.cognitive_state.recent_discovery.substring(0, SESSION_HANDOFF.MAX_LESSON_LENGTH)] : [],
3322
- decisions,
3323
- unfinished: narrative?.unfinished && narrative.unfinished.length > 0 ? narrative.unfinished.join("; ").substring(0, SESSION_HANDOFF.MAX_UNFINISHED_LENGTH) : null,
3325
+ decisions: decisions.length > 0 ? decisions : brief.decisions,
3326
+ unfinished: narrative?.unfinished && narrative.unfinished.length > 0 ? narrative.unfinished.join("; ").substring(0, SESSION_HANDOFF.MAX_UNFINISHED_LENGTH) : brief.next_steps.length > 0 ? brief.next_steps.join("; ").substring(0, SESSION_HANDOFF.MAX_UNFINISHED_LENGTH) : null,
3324
3327
  blockers: state.recent_errors.slice(0, SESSION_HANDOFF.MAX_BLOCKERS).map((e) => e.substring(0, 200)),
3325
- files: state.session_files.slice(-SESSION_HANDOFF.MAX_FILES).map((f) => f.split(/[/\\]/).pop() ?? f),
3328
+ files: brief.key_files.length > 0 ? brief.key_files.slice(-SESSION_HANDOFF.MAX_FILES) : state.session_files.slice(-SESSION_HANDOFF.MAX_FILES).map((f) => f.split(/[/\\]/).pop() ?? f),
3326
3329
  lessons,
3327
3330
  phase: state.cognitive_state.session_phase ?? null,
3328
3331
  turns: state.total_turns,
@@ -4176,13 +4179,18 @@ function handlePostWrite(toolInput, argFallback) {
4176
4179
  const filePath = input?.file_path ?? input?.path ?? "";
4177
4180
  if (!filePath) return;
4178
4181
  const state = loadWatcherState();
4179
- state.recent_actions.push({
4180
- tool: "Edit",
4181
- target: filePath,
4182
- time: (/* @__PURE__ */ new Date()).toISOString()
4183
- });
4184
- if (state.recent_actions.length > 15) {
4185
- state.recent_actions = state.recent_actions.slice(-15);
4182
+ {
4183
+ const newStr = input?.new_string ?? "";
4184
+ const firstNewLine = newStr.split("\n").find((l) => l.trim().length > 0) ?? "";
4185
+ const actionTarget = firstNewLine ? `${filePath} \u2192 ${firstNewLine}`.slice(0, 250) : filePath;
4186
+ state.recent_actions.push({
4187
+ tool: "Edit",
4188
+ target: actionTarget,
4189
+ time: (/* @__PURE__ */ new Date()).toISOString()
4190
+ });
4191
+ if (state.recent_actions.length > 15) {
4192
+ state.recent_actions = state.recent_actions.slice(-15);
4193
+ }
4186
4194
  }
4187
4195
  if (typeof filePath === "string" && !state.session_files.includes(filePath)) {
4188
4196
  state.session_files.push(filePath);
@@ -4706,6 +4714,14 @@ function summarizeToolInput(tool, input) {
4706
4714
  `pattern=${input.pattern ?? ""} path=${input.path ?? ""}`,
4707
4715
  200
4708
4716
  );
4717
+ case "Edit": {
4718
+ const filePath = input.file_path ?? "";
4719
+ const newStr = input.new_string ?? "";
4720
+ const firstNewLine = newStr.split("\n").find((l) => l.trim().length > 0) ?? "";
4721
+ return truncate(`${filePath} \u2192 ${firstNewLine}`, 250);
4722
+ }
4723
+ case "Write":
4724
+ return truncate(input.file_path ?? "", 200);
4709
4725
  case "Agent":
4710
4726
  return truncate(input.prompt ?? "", 300);
4711
4727
  case "WebSearch":
@@ -5025,7 +5041,8 @@ function handleSessionStart(stdinJson, argFallback) {
5025
5041
  recent_commands: isPostCompact ? prevState?.recent_commands ?? [] : [],
5026
5042
  procedural_encoded_count: isPostCompact ? prevState?.procedural_encoded_count ?? 0 : 0,
5027
5043
  recent_actions: isPostCompact ? prevState?.recent_actions ?? [] : [],
5028
- continuation_brief: isPostCompact ? prevState?.continuation_brief ?? null : null
5044
+ continuation_brief: isPostCompact ? prevState?.continuation_brief ?? null : null,
5045
+ recent_prompts: isPostCompact ? prevState?.recent_prompts ?? [] : []
5029
5046
  });
5030
5047
  const source = metadata.source;
5031
5048
  if (!source || source === "startup") {
@@ -5690,7 +5707,8 @@ function buildContinuationBrief(state) {
5690
5707
  decisions,
5691
5708
  tried_failed: triedFailed,
5692
5709
  key_files: keyFiles.length > 0 ? keyFiles : state.session_files.slice(-10),
5693
- blockers: state.recent_errors.slice(-3).map((e) => truncate(e, 150))
5710
+ blockers: state.recent_errors.slice(-3).map((e) => truncate(e, 150)),
5711
+ user_requests: state.recent_prompts.slice(-5).map((p) => truncate(p, 200))
5694
5712
  };
5695
5713
  }
5696
5714
  function handlePreCompact() {
@@ -6280,6 +6298,12 @@ ${distillLines}`
6280
6298
  }
6281
6299
  }
6282
6300
  }
6301
+ if (content.length >= 10) {
6302
+ state.recent_prompts.push(truncate(content, 300));
6303
+ if (state.recent_prompts.length > 8) {
6304
+ state.recent_prompts = state.recent_prompts.slice(-8);
6305
+ }
6306
+ }
6283
6307
  try {
6284
6308
  if (content.length >= 20 && !state.cognitive_state.current_approach) {
6285
6309
  const approach = extractApproachFromPrompt(content);
@@ -7110,6 +7134,10 @@ function handlePostCompact(stdinJson) {
7110
7134
  const files = brief.key_files.map((f) => f.split(/[/\\]/).pop() ?? f);
7111
7135
  mindLines.push(` Files: ${files.join(", ")}`);
7112
7136
  }
7137
+ if (brief.user_requests && brief.user_requests.length > 0) {
7138
+ mindLines.push(` User asked:`);
7139
+ for (const req of brief.user_requests.slice(-3)) mindLines.push(` - ${req}`);
7140
+ }
7113
7141
  lines.push(mindLines.join("\n"));
7114
7142
  } else {
7115
7143
  const cog = state.cognitive_state;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vedtechsolutions/engram-mcp",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Cognitive memory system for AI — persistent, cross-session learning via MCP",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",