memento-mcp 0.3.18 → 0.3.19
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/package.json +1 -1
- package/src/cli.js +27 -6
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -597,12 +597,25 @@ async function runUpdate() {
|
|
|
597
597
|
const versionPath = path.join(cwd, ".memento", "version");
|
|
598
598
|
fs.writeFileSync(versionPath, pkgVersion + "\n");
|
|
599
599
|
|
|
600
|
-
//
|
|
601
|
-
// Detect by config agents field or directory presence (older configs may lack agents)
|
|
600
|
+
// Read .memento.json to determine which hooks are enabled
|
|
602
601
|
const config = readJsonFile(configPath) || {};
|
|
603
602
|
const agents = config.agents || [];
|
|
603
|
+
const hooks = config.hooks || {};
|
|
604
|
+
const features = config.features || {};
|
|
605
|
+
|
|
606
|
+
// Hook script paths
|
|
604
607
|
const instructionsCmd = path.join(localScriptsDir, "memento-instructions.sh");
|
|
608
|
+
const recallCmd = path.join(localScriptsDir, "memento-userprompt-recall.sh");
|
|
609
|
+
const stopCmd = path.join(localScriptsDir, "memento-stop-recall.sh");
|
|
610
|
+
const precompactCmd = path.join(localScriptsDir, "memento-precompact-distill.sh");
|
|
605
611
|
const sessionStartCmd = path.join(localScriptsDir, "memento-sessionstart-identity.sh");
|
|
612
|
+
|
|
613
|
+
// Hook enabled flags (default to true for recall/stop/precompact if not specified)
|
|
614
|
+
const enableUserPrompt = hooks["userprompt-recall"]?.enabled !== false;
|
|
615
|
+
const enableStop = hooks["stop-recall"]?.enabled !== false;
|
|
616
|
+
const enablePreCompact = hooks["precompact-distill"]?.enabled !== false;
|
|
617
|
+
const enableSessionStart = hooks["sessionstart-identity"]?.enabled && features.identity;
|
|
618
|
+
|
|
606
619
|
const registeredHooks = [];
|
|
607
620
|
|
|
608
621
|
// Claude Code
|
|
@@ -611,8 +624,12 @@ async function runUpdate() {
|
|
|
611
624
|
if (hasClaude) {
|
|
612
625
|
const settingsPath = path.join(cwd, ".claude", "settings.local.json");
|
|
613
626
|
const settings = readJsonFile(settingsPath) || {};
|
|
614
|
-
let changed =
|
|
615
|
-
changed = ensureHook(settings, "SessionStart",
|
|
627
|
+
let changed = false;
|
|
628
|
+
changed = ensureHook(settings, "SessionStart", instructionsCmd, 5000) || changed;
|
|
629
|
+
if (enableUserPrompt) changed = ensureHook(settings, "UserPromptSubmit", recallCmd, 5000) || changed;
|
|
630
|
+
if (enableStop) changed = ensureHook(settings, "Stop", stopCmd, 5000) || changed;
|
|
631
|
+
if (enablePreCompact) changed = ensureHook(settings, "PreCompact", precompactCmd, 30000) || changed;
|
|
632
|
+
if (enableSessionStart) changed = ensureHook(settings, "SessionStart", sessionStartCmd, 10000) || changed;
|
|
616
633
|
if (changed) {
|
|
617
634
|
writeJsonFile(settingsPath, settings);
|
|
618
635
|
registeredHooks.push("Claude Code → .claude/settings.local.json");
|
|
@@ -625,8 +642,12 @@ async function runUpdate() {
|
|
|
625
642
|
if (hasGemini) {
|
|
626
643
|
const settingsPath = path.join(cwd, ".gemini", "settings.json");
|
|
627
644
|
const settings = readJsonFile(settingsPath) || {};
|
|
628
|
-
let changed =
|
|
629
|
-
changed = ensureHook(settings, "SessionStart",
|
|
645
|
+
let changed = false;
|
|
646
|
+
changed = ensureHook(settings, "SessionStart", instructionsCmd, 5000) || changed;
|
|
647
|
+
if (enableUserPrompt) changed = ensureHook(settings, "BeforeAgent", recallCmd, 5000) || changed;
|
|
648
|
+
if (enableStop) changed = ensureHook(settings, "SessionEnd", stopCmd, 5000) || changed;
|
|
649
|
+
if (enablePreCompact) changed = ensureHook(settings, "PreCompress", precompactCmd, 30000) || changed;
|
|
650
|
+
if (enableSessionStart) changed = ensureHook(settings, "SessionStart", sessionStartCmd, 10000) || changed;
|
|
630
651
|
if (changed) {
|
|
631
652
|
writeJsonFile(settingsPath, settings);
|
|
632
653
|
registeredHooks.push("Gemini CLI → .gemini/settings.json");
|