@rlabs-inc/memory 0.5.8 → 0.5.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/README.md
CHANGED
|
@@ -424,6 +424,11 @@ This isn't just about remembering facts. It's about preserving:
|
|
|
424
424
|
|
|
425
425
|
## Changelog
|
|
426
426
|
|
|
427
|
+
### v0.5.9
|
|
428
|
+
- **Fix**: Updated Gemini CLI hooks to correctly log injected context using stderr
|
|
429
|
+
- **Fix**: Removed unsupported `systemMessage` field from `BeforeAgent` hook
|
|
430
|
+
- **Improvement**: Added colorful `[Memory]` logs to terminal for visibility of memory injection
|
|
431
|
+
|
|
427
432
|
### v0.5.1
|
|
428
433
|
- **Improvement**: Gemini CLI hooks now show injected content to user via `systemMessage`
|
|
429
434
|
- Users see exactly what memories are surfaced (session primer, retrieved memories)
|
package/hooks/gemini/curation.ts
CHANGED
|
@@ -55,9 +55,10 @@ async function main() {
|
|
|
55
55
|
const primer = result.context_text || ''
|
|
56
56
|
|
|
57
57
|
if (primer) {
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// Log to stderr for visibility
|
|
59
|
+
console.error(`\x1b[36m[Memory] Injecting session primer (${primer.length} chars)\x1b[0m`)
|
|
60
|
+
|
|
61
|
+
// systemMessage IS supported for SessionStart
|
|
61
62
|
console.log(JSON.stringify({
|
|
62
63
|
systemMessage: primer,
|
|
63
64
|
hookSpecificOutput: {
|
|
@@ -65,6 +66,8 @@ async function main() {
|
|
|
65
66
|
additionalContext: primer
|
|
66
67
|
}
|
|
67
68
|
}))
|
|
69
|
+
} else {
|
|
70
|
+
console.log(JSON.stringify({}))
|
|
68
71
|
}
|
|
69
72
|
} catch (e) {
|
|
70
73
|
// Fail silently, but ensure we don't output invalid JSON if we crashed mid-stream
|
|
@@ -55,20 +55,18 @@ async function main() {
|
|
|
55
55
|
const context = result.context_text || ''
|
|
56
56
|
|
|
57
57
|
if (context) {
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// Log to stderr for visibility (BeforeAgent doesn't support systemMessage)
|
|
59
|
+
console.error(`\x1b[36m[Memory] Injecting ${context.length} chars of context\x1b[0m`)
|
|
60
|
+
|
|
61
61
|
console.log(JSON.stringify({
|
|
62
|
-
decision: "allow",
|
|
63
|
-
systemMessage: context,
|
|
64
62
|
hookSpecificOutput: {
|
|
65
63
|
hookEventName: "BeforeAgent",
|
|
66
64
|
additionalContext: context
|
|
67
65
|
}
|
|
68
66
|
}))
|
|
69
67
|
} else {
|
|
70
|
-
// No memories to surface -
|
|
71
|
-
console.log(JSON.stringify({
|
|
68
|
+
// No memories to surface - output empty JSON (implicit allow)
|
|
69
|
+
console.log(JSON.stringify({}))
|
|
72
70
|
}
|
|
73
71
|
} catch {
|
|
74
72
|
// Fail safe
|
package/package.json
CHANGED
package/src/core/curator.ts
CHANGED
|
@@ -788,6 +788,7 @@ This session has ended. Please curate the memories from this conversation accord
|
|
|
788
788
|
sessionId: string,
|
|
789
789
|
triggerType: CurationTrigger = "session_end",
|
|
790
790
|
cwd?: string,
|
|
791
|
+
apiKey?: string,
|
|
791
792
|
): Promise<CurationResult> {
|
|
792
793
|
const systemPrompt = this.buildCurationPrompt(triggerType);
|
|
793
794
|
const userMessage =
|
|
@@ -825,6 +826,7 @@ This session has ended. Please curate the memories from this conversation accord
|
|
|
825
826
|
...process.env,
|
|
826
827
|
MEMORY_CURATOR_ACTIVE: "1", // Prevent recursive hook triggering
|
|
827
828
|
GEMINI_SYSTEM_MD: tempPromptPath, // Inject our curation prompt
|
|
829
|
+
...(apiKey ? { GEMINI_API_KEY: apiKey } : {}),
|
|
828
830
|
},
|
|
829
831
|
stdout: "pipe",
|
|
830
832
|
stderr: "pipe",
|
package/src/core/manager.ts
CHANGED
|
@@ -405,6 +405,7 @@ Please process these memories according to your management procedure. Use the ex
|
|
|
405
405
|
sessionNumber: number,
|
|
406
406
|
result: CurationResult,
|
|
407
407
|
storagePaths?: StoragePaths,
|
|
408
|
+
apiKey?: string,
|
|
408
409
|
): Promise<ManagementResult> {
|
|
409
410
|
// Skip if disabled via config or env var
|
|
410
411
|
if (!this._config.enabled || process.env.MEMORY_MANAGER_DISABLED === "1") {
|
|
@@ -564,6 +565,7 @@ Use these tools to read existing memories, write updates, and manage the memory
|
|
|
564
565
|
...process.env,
|
|
565
566
|
MEMORY_CURATOR_ACTIVE: "1", // Prevent recursive hook triggering
|
|
566
567
|
GEMINI_SYSTEM_MD: tempPromptPath, // Inject our management prompt
|
|
568
|
+
...(apiKey ? { GEMINI_API_KEY: apiKey } : {}),
|
|
567
569
|
},
|
|
568
570
|
stdout: "pipe",
|
|
569
571
|
stderr: "pipe",
|
package/src/server/index.ts
CHANGED
|
@@ -62,6 +62,7 @@ interface CheckpointRequest {
|
|
|
62
62
|
cwd?: string
|
|
63
63
|
cli_type?: 'claude-code' | 'gemini-cli'
|
|
64
64
|
project_path?: string
|
|
65
|
+
gemini_api_key?: string
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -244,7 +245,8 @@ export async function createServer(config: ServerConfig = {}) {
|
|
|
244
245
|
result = await curator.curateWithGeminiCLI(
|
|
245
246
|
body.claude_session_id,
|
|
246
247
|
body.trigger,
|
|
247
|
-
body.cwd // Run from original project directory
|
|
248
|
+
body.cwd, // Run from original project directory
|
|
249
|
+
body.gemini_api_key
|
|
248
250
|
)
|
|
249
251
|
} else {
|
|
250
252
|
// Default: Use Claude Code (session resume or transcript parsing)
|
|
@@ -306,7 +308,8 @@ export async function createServer(config: ServerConfig = {}) {
|
|
|
306
308
|
body.project_id,
|
|
307
309
|
sessionNumber,
|
|
308
310
|
result,
|
|
309
|
-
storagePaths
|
|
311
|
+
storagePaths,
|
|
312
|
+
body.gemini_api_key
|
|
310
313
|
)
|
|
311
314
|
} else {
|
|
312
315
|
// Use Claude Agent SDK mode - more reliable than CLI
|