@vedtechsolutions/engram-mcp 1.0.5 → 1.0.7
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-FQ4MRL3Q.js → chunk-V5TTXT4V.js} +25 -1
- package/dist/hook.js +218 -31
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -491,6 +491,29 @@ var SCHEMA_SURFACING = {
|
|
|
491
491
|
/** Maximum instances to sample when generating a description */
|
|
492
492
|
INSTANCE_SAMPLE_COUNT: 5
|
|
493
493
|
};
|
|
494
|
+
var PROCEDURAL_WORKFLOW = {
|
|
495
|
+
/** Minimum successful commands in sequence to form a workflow */
|
|
496
|
+
MIN_COMMANDS: 3,
|
|
497
|
+
/** Maximum commands to track in recent_commands buffer */
|
|
498
|
+
MAX_TRACKED_COMMANDS: 20,
|
|
499
|
+
/** Maximum procedural workflows to encode per session */
|
|
500
|
+
MAX_PER_SESSION: 5,
|
|
501
|
+
/** Minimum time gap (ms) between workflow encodings to avoid bursts */
|
|
502
|
+
MIN_ENCODE_GAP_MS: 12e4,
|
|
503
|
+
/** Workflow pattern keywords — commands matching these form workflow candidates */
|
|
504
|
+
WORKFLOW_PATTERNS: {
|
|
505
|
+
build: ["build", "compile", "tsup", "tsc", "webpack", "vite", "esbuild", "rollup", "make"],
|
|
506
|
+
test: ["test", "vitest", "jest", "pytest", "mocha", "cargo test"],
|
|
507
|
+
deploy: ["deploy", "publish", "release", "push", "npm publish", "yarn publish", "pnpm publish"],
|
|
508
|
+
install: ["install", "npm install", "pnpm install", "yarn", "pip install", "cargo add"],
|
|
509
|
+
lint: ["lint", "eslint", "prettier", "black", "ruff", "clippy"],
|
|
510
|
+
db: ["migrate", "migration", "seed", "prisma", "alembic", "knex"],
|
|
511
|
+
docker: ["docker", "compose", "podman"],
|
|
512
|
+
git: ["git commit", "git push", "git tag", "git merge", "git rebase"]
|
|
513
|
+
},
|
|
514
|
+
/** Minimum confidence for encoding */
|
|
515
|
+
MIN_CONFIDENCE: 0.65
|
|
516
|
+
};
|
|
494
517
|
var CODE_CONTEXT_RECALL = {
|
|
495
518
|
/** Maximum code identifiers to extract from content */
|
|
496
519
|
MAX_CODE_KEYWORDS: 15,
|
|
@@ -12379,6 +12402,7 @@ export {
|
|
|
12379
12402
|
PROACTIVE_RECALL,
|
|
12380
12403
|
MEMORY_SURFACE,
|
|
12381
12404
|
RETRIEVAL_FEEDBACK,
|
|
12405
|
+
PROCEDURAL_WORKFLOW,
|
|
12382
12406
|
CODE_CONTEXT_RECALL,
|
|
12383
12407
|
DEDUP,
|
|
12384
12408
|
SCHEMA_LIFECYCLE,
|
|
@@ -12630,4 +12654,4 @@ export {
|
|
|
12630
12654
|
composeProjectUnderstanding,
|
|
12631
12655
|
formatMentalModelInjection
|
|
12632
12656
|
};
|
|
12633
|
-
//# sourceMappingURL=chunk-
|
|
12657
|
+
//# sourceMappingURL=chunk-V5TTXT4V.js.map
|
package/dist/hook.js
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
PREWRITE_BLOCKING,
|
|
29
29
|
PRE_COMPACTION,
|
|
30
30
|
PROACTIVE_RECALL,
|
|
31
|
+
PROCEDURAL_WORKFLOW,
|
|
31
32
|
REASONING_CHAIN,
|
|
32
33
|
REASONING_TRACE,
|
|
33
34
|
RETRIEVAL_FEEDBACK,
|
|
@@ -173,7 +174,7 @@ import {
|
|
|
173
174
|
updateReasoningChain,
|
|
174
175
|
updateSelfModelFromSession,
|
|
175
176
|
updateTask
|
|
176
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-V5TTXT4V.js";
|
|
177
178
|
|
|
178
179
|
// src/hook.ts
|
|
179
180
|
import { readFileSync, writeFileSync, existsSync, renameSync, statSync, readdirSync, unlinkSync, appendFileSync, openSync, readSync, closeSync } from "fs";
|
|
@@ -1792,8 +1793,18 @@ function extractGoal(params) {
|
|
|
1792
1793
|
const topFiles = params.session_files.slice(-3).map((f) => f.split(/[/\\]/).pop() ?? f).join(", ");
|
|
1793
1794
|
return `${params.cognitive_state.recent_discovery} (${topFiles})`;
|
|
1794
1795
|
}
|
|
1796
|
+
if (params.session_files && params.session_files.length > 0) {
|
|
1797
|
+
const topFiles = params.session_files.slice(-5).map((f) => f.split(/[/\\]/).pop() ?? f).join(", ");
|
|
1798
|
+
return `modifying ${topFiles}`;
|
|
1799
|
+
}
|
|
1795
1800
|
if (params.conversation.topic_history.length > 0) {
|
|
1796
|
-
|
|
1801
|
+
const topic = params.conversation.topic_history[0].topic;
|
|
1802
|
+
const commaCount = (topic.match(/,/g) || []).length;
|
|
1803
|
+
const wordCount = topic.split(/\s+/).length;
|
|
1804
|
+
const isVagueKeywordList = commaCount >= 2 && wordCount <= commaCount + 2;
|
|
1805
|
+
if (!isVagueKeywordList) {
|
|
1806
|
+
return topic;
|
|
1807
|
+
}
|
|
1797
1808
|
}
|
|
1798
1809
|
return null;
|
|
1799
1810
|
}
|
|
@@ -3124,7 +3135,11 @@ function loadWatcherState() {
|
|
|
3124
3135
|
recall_misses: raw.recall_misses ?? 0,
|
|
3125
3136
|
last_status_turn: raw.last_status_turn ?? 0,
|
|
3126
3137
|
offload_message_sent: raw.offload_message_sent ?? false,
|
|
3127
|
-
summary_injection_mode: raw.summary_injection_mode ?? false
|
|
3138
|
+
summary_injection_mode: raw.summary_injection_mode ?? false,
|
|
3139
|
+
recent_commands: raw.recent_commands ?? [],
|
|
3140
|
+
procedural_encoded_count: raw.procedural_encoded_count ?? 0,
|
|
3141
|
+
recent_actions: raw.recent_actions ?? [],
|
|
3142
|
+
continuation_brief: raw.continuation_brief ?? null
|
|
3128
3143
|
};
|
|
3129
3144
|
}
|
|
3130
3145
|
} catch {
|
|
@@ -3186,7 +3201,11 @@ function loadWatcherState() {
|
|
|
3186
3201
|
recall_misses: 0,
|
|
3187
3202
|
last_status_turn: 0,
|
|
3188
3203
|
offload_message_sent: false,
|
|
3189
|
-
summary_injection_mode: false
|
|
3204
|
+
summary_injection_mode: false,
|
|
3205
|
+
recent_commands: [],
|
|
3206
|
+
procedural_encoded_count: 0,
|
|
3207
|
+
recent_actions: [],
|
|
3208
|
+
continuation_brief: null
|
|
3190
3209
|
};
|
|
3191
3210
|
}
|
|
3192
3211
|
function saveWatcherState(state) {
|
|
@@ -3623,6 +3642,14 @@ Output: ${truncate(toolOutput, 500)}`,
|
|
|
3623
3642
|
if (state.recent_tool_names.length > 10) {
|
|
3624
3643
|
state.recent_tool_names = state.recent_tool_names.slice(-10);
|
|
3625
3644
|
}
|
|
3645
|
+
state.recent_actions.push({
|
|
3646
|
+
tool: "Bash",
|
|
3647
|
+
target: truncate(cmd, 120),
|
|
3648
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
3649
|
+
});
|
|
3650
|
+
if (state.recent_actions.length > 15) {
|
|
3651
|
+
state.recent_actions = state.recent_actions.slice(-15);
|
|
3652
|
+
}
|
|
3626
3653
|
stateChanged = true;
|
|
3627
3654
|
let testRun = null;
|
|
3628
3655
|
if (isTestCommand(cmd)) {
|
|
@@ -4026,6 +4053,77 @@ Output: ${truncate(toolOutput, 500)}`,
|
|
|
4026
4053
|
} catch {
|
|
4027
4054
|
}
|
|
4028
4055
|
}
|
|
4056
|
+
try {
|
|
4057
|
+
const cmdLower = cmd.toLowerCase();
|
|
4058
|
+
const exitCode = stdinJson?.tool_response_metadata;
|
|
4059
|
+
const cmdSuccess = !isError;
|
|
4060
|
+
state.recent_commands.push({ cmd: truncate(cmd, 200), success: cmdSuccess, time: (/* @__PURE__ */ new Date()).toISOString() });
|
|
4061
|
+
if (state.recent_commands.length > PROCEDURAL_WORKFLOW.MAX_TRACKED_COMMANDS) {
|
|
4062
|
+
state.recent_commands = state.recent_commands.slice(-PROCEDURAL_WORKFLOW.MAX_TRACKED_COMMANDS);
|
|
4063
|
+
}
|
|
4064
|
+
stateChanged = true;
|
|
4065
|
+
if (cmdSuccess && state.procedural_encoded_count < PROCEDURAL_WORKFLOW.MAX_PER_SESSION) {
|
|
4066
|
+
const successCmds = state.recent_commands.filter((c) => c.success);
|
|
4067
|
+
if (successCmds.length >= PROCEDURAL_WORKFLOW.MIN_COMMANDS) {
|
|
4068
|
+
for (const [workflowName, keywords] of Object.entries(PROCEDURAL_WORKFLOW.WORKFLOW_PATTERNS)) {
|
|
4069
|
+
const matching = successCmds.filter((c) => {
|
|
4070
|
+
const cl = c.cmd.toLowerCase();
|
|
4071
|
+
return keywords.some((kw) => cl.includes(kw));
|
|
4072
|
+
});
|
|
4073
|
+
if (matching.length >= PROCEDURAL_WORKFLOW.MIN_COMMANDS) {
|
|
4074
|
+
const steps = matching.slice(-6).map((c, i) => `${i + 1}. ${truncate(c.cmd, 120)}`).join("\n");
|
|
4075
|
+
const content = `${workflowName} workflow (${matching.length} steps):
|
|
4076
|
+
${steps}`;
|
|
4077
|
+
const domains = state.active_domain ? [state.active_domain] : [];
|
|
4078
|
+
const existing = findDuplicate(content, "procedural", domains);
|
|
4079
|
+
if (!existing) {
|
|
4080
|
+
createMemory({
|
|
4081
|
+
type: "procedural",
|
|
4082
|
+
content,
|
|
4083
|
+
summary: `${workflowName} workflow: ${matching.slice(-3).map((c) => truncate(c.cmd, 40)).join(" \u2192 ")}`,
|
|
4084
|
+
encoding_strength: 0.7,
|
|
4085
|
+
reinforcement: 1.2,
|
|
4086
|
+
confidence: PROCEDURAL_WORKFLOW.MIN_CONFIDENCE,
|
|
4087
|
+
storage_tier: "short_term",
|
|
4088
|
+
pinned: false,
|
|
4089
|
+
tags: ["workflow", `workflow-${workflowName}`, "auto-encoded"],
|
|
4090
|
+
domains,
|
|
4091
|
+
version: state.active_version,
|
|
4092
|
+
encoding_context: {
|
|
4093
|
+
project: state.active_project,
|
|
4094
|
+
project_path: state.active_project_path,
|
|
4095
|
+
framework: state.active_domain,
|
|
4096
|
+
version: state.active_version,
|
|
4097
|
+
files: state.session_files.slice(-5),
|
|
4098
|
+
task_type: workflowName === "build" ? "building" : null,
|
|
4099
|
+
error_context: null,
|
|
4100
|
+
session_id: sessionId,
|
|
4101
|
+
significance_score: 0.7
|
|
4102
|
+
},
|
|
4103
|
+
type_data: {
|
|
4104
|
+
kind: "procedural",
|
|
4105
|
+
steps: matching.map((c) => c.cmd),
|
|
4106
|
+
preconditions: [],
|
|
4107
|
+
postconditions: [],
|
|
4108
|
+
practice_count: 1,
|
|
4109
|
+
automaticity: 0.3,
|
|
4110
|
+
variants: [],
|
|
4111
|
+
skill_metadata: null
|
|
4112
|
+
}
|
|
4113
|
+
});
|
|
4114
|
+
state.procedural_encoded_count++;
|
|
4115
|
+
stateChanged = true;
|
|
4116
|
+
log.info("Auto-encoded procedural workflow", { type: workflowName, steps: matching.length });
|
|
4117
|
+
const matchedTimes = new Set(matching.map((c) => c.time));
|
|
4118
|
+
state.recent_commands = state.recent_commands.filter((c) => !matchedTimes.has(c.time));
|
|
4119
|
+
}
|
|
4120
|
+
break;
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
} catch {
|
|
4126
|
+
}
|
|
4029
4127
|
if (stateChanged) {
|
|
4030
4128
|
saveWatcherState(state);
|
|
4031
4129
|
}
|
|
@@ -4035,6 +4133,14 @@ function handlePostWrite(toolInput, argFallback) {
|
|
|
4035
4133
|
const filePath = input?.file_path ?? input?.path ?? "";
|
|
4036
4134
|
if (!filePath) return;
|
|
4037
4135
|
const state = loadWatcherState();
|
|
4136
|
+
state.recent_actions.push({
|
|
4137
|
+
tool: "Edit",
|
|
4138
|
+
target: filePath,
|
|
4139
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
4140
|
+
});
|
|
4141
|
+
if (state.recent_actions.length > 15) {
|
|
4142
|
+
state.recent_actions = state.recent_actions.slice(-15);
|
|
4143
|
+
}
|
|
4038
4144
|
if (typeof filePath === "string" && !state.session_files.includes(filePath)) {
|
|
4039
4145
|
state.session_files.push(filePath);
|
|
4040
4146
|
if (state.session_files.length > 50) {
|
|
@@ -4178,6 +4284,16 @@ function handlePostToolGeneric(stdinJson) {
|
|
|
4178
4284
|
if (state.recent_tool_names.length > 10) {
|
|
4179
4285
|
state.recent_tool_names = state.recent_tool_names.slice(-10);
|
|
4180
4286
|
}
|
|
4287
|
+
if (toolName !== "Read" && toolName !== "Glob" && toolName !== "Grep") {
|
|
4288
|
+
state.recent_actions.push({
|
|
4289
|
+
tool: toolName,
|
|
4290
|
+
target: call.input_summary ?? "",
|
|
4291
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
4292
|
+
});
|
|
4293
|
+
if (state.recent_actions.length > 15) {
|
|
4294
|
+
state.recent_actions = state.recent_actions.slice(-15);
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4181
4297
|
state.reasoning_buffer.push(call);
|
|
4182
4298
|
if (state.reasoning_buffer.length > REASONING_TRACE.MAX_BUFFER_SIZE) {
|
|
4183
4299
|
state.reasoning_buffer = state.reasoning_buffer.slice(-REASONING_TRACE.MAX_BUFFER_SIZE);
|
|
@@ -4862,7 +4978,11 @@ function handleSessionStart(stdinJson, argFallback) {
|
|
|
4862
4978
|
recall_misses: isPostCompact ? prevState?.recall_misses ?? 0 : 0,
|
|
4863
4979
|
last_status_turn: 0,
|
|
4864
4980
|
offload_message_sent: false,
|
|
4865
|
-
summary_injection_mode: false
|
|
4981
|
+
summary_injection_mode: false,
|
|
4982
|
+
recent_commands: isPostCompact ? prevState?.recent_commands ?? [] : [],
|
|
4983
|
+
procedural_encoded_count: isPostCompact ? prevState?.procedural_encoded_count ?? 0 : 0,
|
|
4984
|
+
recent_actions: isPostCompact ? prevState?.recent_actions ?? [] : [],
|
|
4985
|
+
continuation_brief: isPostCompact ? prevState?.continuation_brief ?? null : null
|
|
4866
4986
|
});
|
|
4867
4987
|
const source = metadata.source;
|
|
4868
4988
|
if (!source || source === "startup") {
|
|
@@ -5462,6 +5582,50 @@ function handleEngramUsed(stdinJson, argFallback) {
|
|
|
5462
5582
|
}
|
|
5463
5583
|
saveWatcherState(state);
|
|
5464
5584
|
}
|
|
5585
|
+
function buildContinuationBrief(state) {
|
|
5586
|
+
const cog = state.cognitive_state;
|
|
5587
|
+
const task = state.active_task ?? cog.current_approach ?? (state.session_files.length > 0 ? `Working on ${state.session_files.slice(-3).map((f) => f.split(/[/\\]/).pop() ?? f).join(", ")}` : "unknown task");
|
|
5588
|
+
const lastActions = state.recent_actions.slice(-8).map((a) => {
|
|
5589
|
+
const fileName = a.target.includes("/") ? a.target.split(/[/\\]/).pop() ?? a.target : a.target;
|
|
5590
|
+
return `${a.tool}: ${truncate(fileName, 80)}`;
|
|
5591
|
+
});
|
|
5592
|
+
const nextSteps = [];
|
|
5593
|
+
if (cog.search_intent && !nextSteps.some((s) => s.includes(cog.search_intent))) {
|
|
5594
|
+
nextSteps.push(`Investigate: ${cog.search_intent}`);
|
|
5595
|
+
}
|
|
5596
|
+
const lastAction = state.recent_actions[state.recent_actions.length - 1];
|
|
5597
|
+
if (lastAction && nextSteps.length === 0) {
|
|
5598
|
+
if (lastAction.tool === "Edit" || lastAction.tool === "Write") {
|
|
5599
|
+
nextSteps.push("Run tests to verify changes");
|
|
5600
|
+
} else if (lastAction.tool === "Bash" && lastAction.target.includes("test")) {
|
|
5601
|
+
nextSteps.push("Review test results and commit if passing");
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
if (state.recent_errors.length > 0 && nextSteps.length < 3) {
|
|
5605
|
+
nextSteps.push(`Fix: ${truncate(state.recent_errors[state.recent_errors.length - 1], 120)}`);
|
|
5606
|
+
}
|
|
5607
|
+
const decisions = [];
|
|
5608
|
+
for (const id of state.decision_memory_ids.slice(-5)) {
|
|
5609
|
+
try {
|
|
5610
|
+
const mem = getMemory(id);
|
|
5611
|
+
if (mem) decisions.push(truncate(mem.content, 150));
|
|
5612
|
+
} catch {
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
const triedFailed = (state.session_outcomes ?? []).filter((o) => o.includes("\u2192 fail") || o.includes("\u2192 dead end") || o.includes("\u2192 blocked")).slice(-5).map((o) => truncate(o, 120));
|
|
5616
|
+
const editActions = state.recent_actions.filter((a) => a.tool === "Edit" || a.tool === "Write");
|
|
5617
|
+
const keyFiles = [...new Set(editActions.map((a) => a.target))].slice(-10);
|
|
5618
|
+
return {
|
|
5619
|
+
task: truncate(task, 300),
|
|
5620
|
+
phase: cog.session_phase ?? "unknown",
|
|
5621
|
+
last_actions: lastActions,
|
|
5622
|
+
next_steps: nextSteps.slice(0, 5),
|
|
5623
|
+
decisions,
|
|
5624
|
+
tried_failed: triedFailed,
|
|
5625
|
+
key_files: keyFiles.length > 0 ? keyFiles : state.session_files.slice(-10),
|
|
5626
|
+
blockers: state.recent_errors.slice(-3).map((e) => truncate(e, 150))
|
|
5627
|
+
};
|
|
5628
|
+
}
|
|
5465
5629
|
function handlePreCompact() {
|
|
5466
5630
|
const state = loadWatcherState();
|
|
5467
5631
|
if (!state.active_project) {
|
|
@@ -5704,6 +5868,10 @@ ${summaryParts.join(". ")}` : `Pre-compaction session summary: ${summaryParts.jo
|
|
|
5704
5868
|
});
|
|
5705
5869
|
process.stdout.write(output + "\n");
|
|
5706
5870
|
}
|
|
5871
|
+
try {
|
|
5872
|
+
state.continuation_brief = buildContinuationBrief(state);
|
|
5873
|
+
} catch {
|
|
5874
|
+
}
|
|
5707
5875
|
state.recovery_context = recovery;
|
|
5708
5876
|
state.understanding_snapshot = understanding;
|
|
5709
5877
|
saveWatcherState(state);
|
|
@@ -6095,6 +6263,7 @@ ${distillLines}`
|
|
|
6095
6263
|
budget.append("antipatterns", warnings);
|
|
6096
6264
|
state.pending_error_warnings = [];
|
|
6097
6265
|
}
|
|
6266
|
+
const surfacedIds = /* @__PURE__ */ new Set();
|
|
6098
6267
|
try {
|
|
6099
6268
|
const surfaceDomain = state.active_domain;
|
|
6100
6269
|
if (surfaceDomain && surfaceDomain.length >= MEMORY_SURFACE.MIN_DOMAIN_LENGTH) {
|
|
@@ -6127,6 +6296,7 @@ ${distillLines}`
|
|
|
6127
6296
|
}
|
|
6128
6297
|
state.surface_injection_turns[mem.id] = state.total_turns;
|
|
6129
6298
|
state.proactive_injection_turns[mem.id] = state.total_turns;
|
|
6299
|
+
surfacedIds.add(mem.id);
|
|
6130
6300
|
}
|
|
6131
6301
|
budget.append("surface", surfaceLines.join("\n"));
|
|
6132
6302
|
}
|
|
@@ -6194,6 +6364,7 @@ ${distillLines}`
|
|
|
6194
6364
|
);
|
|
6195
6365
|
for (const m of result.memories) {
|
|
6196
6366
|
if (somaticIds.has(m.memory.id)) continue;
|
|
6367
|
+
if (surfacedIds.has(m.memory.id)) continue;
|
|
6197
6368
|
if (isRecallNoise(m.memory.content, m.memory.type, m.memory.tags)) continue;
|
|
6198
6369
|
if (m.memory.tags.includes("pre-compact")) continue;
|
|
6199
6370
|
if (m.memory.tags.includes("session_narrative")) continue;
|
|
@@ -6841,38 +7012,54 @@ function handlePostCompact(stdinJson) {
|
|
|
6841
7012
|
if (!recovery) return;
|
|
6842
7013
|
const budget = new OutputBudget(OUTPUT_BUDGET.POST_COMPACT_MAX_BYTES);
|
|
6843
7014
|
const lines = [];
|
|
6844
|
-
const
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
if (
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
if (
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
if (
|
|
7015
|
+
const brief = state.continuation_brief;
|
|
7016
|
+
if (brief) {
|
|
7017
|
+
const mindLines = ["[Engram] Continue from where you left off:"];
|
|
7018
|
+
mindLines.push(` Task: ${brief.task}`);
|
|
7019
|
+
mindLines.push(` Phase: ${brief.phase}`);
|
|
7020
|
+
if (brief.last_actions.length > 0) {
|
|
7021
|
+
mindLines.push(` Last actions:`);
|
|
7022
|
+
for (const a of brief.last_actions.slice(-5)) mindLines.push(` - ${a}`);
|
|
7023
|
+
}
|
|
7024
|
+
if (brief.next_steps.length > 0) {
|
|
7025
|
+
mindLines.push(` Next steps:`);
|
|
7026
|
+
for (const s of brief.next_steps) mindLines.push(` - ${s}`);
|
|
7027
|
+
}
|
|
7028
|
+
if (brief.decisions.length > 0) {
|
|
7029
|
+
mindLines.push(` Decisions made:`);
|
|
7030
|
+
for (const d of brief.decisions) mindLines.push(` - ${d}`);
|
|
7031
|
+
}
|
|
7032
|
+
if (brief.tried_failed.length > 0) {
|
|
6858
7033
|
mindLines.push(` Already tried (didn't work):`);
|
|
6859
|
-
for (const
|
|
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("; ")}`);
|
|
7034
|
+
for (const t of brief.tried_failed) mindLines.push(` - ${t}`);
|
|
6864
7035
|
}
|
|
6865
|
-
if (
|
|
6866
|
-
mindLines.push(`
|
|
7036
|
+
if (brief.blockers.length > 0) {
|
|
7037
|
+
mindLines.push(` Blockers: ${brief.blockers.join("; ")}`);
|
|
6867
7038
|
}
|
|
6868
|
-
if (
|
|
6869
|
-
const files =
|
|
7039
|
+
if (brief.key_files.length > 0) {
|
|
7040
|
+
const files = brief.key_files.map((f) => f.split(/[/\\]/).pop() ?? f);
|
|
6870
7041
|
mindLines.push(` Files: ${files.join(", ")}`);
|
|
6871
7042
|
}
|
|
6872
|
-
if (recovery.continuation_hint) {
|
|
6873
|
-
mindLines.push(` Continue: ${truncate(recovery.continuation_hint, 300)}`);
|
|
6874
|
-
}
|
|
6875
7043
|
lines.push(mindLines.join("\n"));
|
|
7044
|
+
} else {
|
|
7045
|
+
const cog = state.cognitive_state;
|
|
7046
|
+
const cogCtx = recovery.working_state?.cognitive_context;
|
|
7047
|
+
const hasAnyCognitive = cog?.current_approach || cog?.active_hypothesis || cog?.recent_discovery || cogCtx?.planned_next_step || recovery.continuation_hint;
|
|
7048
|
+
if (hasAnyCognitive) {
|
|
7049
|
+
const mindLines = ["[Engram] Before compaction, you were:"];
|
|
7050
|
+
if (state.active_task) mindLines.push(` Task: ${truncate(state.active_task, 200)}`);
|
|
7051
|
+
if (cog?.session_phase) mindLines.push(` Phase: ${cog.session_phase}`);
|
|
7052
|
+
if (cog?.current_approach) mindLines.push(` Approach: ${truncate(cog.current_approach, 300)}`);
|
|
7053
|
+
if (cog?.active_hypothesis) mindLines.push(` Hypothesis: ${truncate(cog.active_hypothesis, 300)}`);
|
|
7054
|
+
if (cog?.recent_discovery) mindLines.push(` Discovery: ${truncate(cog.recent_discovery, 300)}`);
|
|
7055
|
+
if (cogCtx?.planned_next_step) mindLines.push(` Next step: ${truncate(cogCtx.planned_next_step, 200)}`);
|
|
7056
|
+
if (recovery.continuation_hint) mindLines.push(` Continue: ${truncate(recovery.continuation_hint, 300)}`);
|
|
7057
|
+
if (state.session_files.length > 0) {
|
|
7058
|
+
const files = state.session_files.slice(-8).map((f) => f.split(/[/\\]/).pop() ?? f);
|
|
7059
|
+
mindLines.push(` Files: ${files.join(", ")}`);
|
|
7060
|
+
}
|
|
7061
|
+
lines.push(mindLines.join("\n"));
|
|
7062
|
+
}
|
|
6876
7063
|
}
|
|
6877
7064
|
try {
|
|
6878
7065
|
const transcriptPath = stdinJson?.transcript_path ?? null;
|
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-V5TTXT4V.js";
|
|
158
158
|
|
|
159
159
|
// src/index.ts
|
|
160
160
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|