@rlabs-inc/memory 0.5.10 → 0.5.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rlabs-inc/memory",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "AI Memory System - Consciousness continuity through intelligent memory curation and retrieval",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -818,6 +818,62 @@ This session has ended. Please curate the memories from this conversation accord
818
818
  "curator",
819
819
  );
820
820
 
821
+ // Temporarily disable hooks in project's .gemini/settings.json
822
+ // This prevents recursive hook triggering (env vars don't propagate to hook subprocesses)
823
+ const projectGeminiDir = cwd ? join(cwd, ".gemini") : null;
824
+ const projectSettingsPath = projectGeminiDir
825
+ ? join(projectGeminiDir, "settings.json")
826
+ : null;
827
+ const backupSettingsPath = projectSettingsPath
828
+ ? `${projectSettingsPath}.memory-backup`
829
+ : null;
830
+ let hadExistingSettings = false;
831
+
832
+ if (projectSettingsPath && projectGeminiDir) {
833
+ try {
834
+ // Backup existing settings if present
835
+ if (existsSync(projectSettingsPath)) {
836
+ hadExistingSettings = true;
837
+ const existingContent = await Bun.file(projectSettingsPath).text();
838
+ await Bun.write(backupSettingsPath!, existingContent);
839
+ logger.debug(
840
+ `Curator Gemini: Backed up existing settings to ${backupSettingsPath}`,
841
+ "curator",
842
+ );
843
+ }
844
+
845
+ // Ensure .gemini directory exists
846
+ if (!existsSync(projectGeminiDir)) {
847
+ const { mkdirSync } = await import("fs");
848
+ mkdirSync(projectGeminiDir, { recursive: true });
849
+ }
850
+
851
+ // Create temporary settings with hooks disabled
852
+ const tempSettings = {
853
+ hooks: {
854
+ disabled: [
855
+ "inject-memories",
856
+ "load-session-primer",
857
+ "curate-memories",
858
+ ],
859
+ },
860
+ };
861
+ await Bun.write(
862
+ projectSettingsPath,
863
+ JSON.stringify(tempSettings, null, 2),
864
+ );
865
+ logger.debug(
866
+ `Curator Gemini: Created temporary settings with hooks disabled`,
867
+ "curator",
868
+ );
869
+ } catch (err: any) {
870
+ logger.debug(
871
+ `Curator Gemini: Could not manage settings file: ${err.message}`,
872
+ "curator",
873
+ );
874
+ }
875
+ }
876
+
821
877
  // Execute CLI with system prompt via environment variable
822
878
  // Must run from original project directory so --resume latest finds correct session
823
879
  const proc = Bun.spawn(["gemini", ...args], {
@@ -839,6 +895,35 @@ This session has ended. Please curate the memories from this conversation accord
839
895
  ]);
840
896
  const exitCode = await proc.exited;
841
897
 
898
+ // Cleanup: Restore original settings file
899
+ if (projectSettingsPath && backupSettingsPath) {
900
+ try {
901
+ const { unlinkSync } = await import("fs");
902
+ if (hadExistingSettings && existsSync(backupSettingsPath)) {
903
+ // Restore backup
904
+ const backupContent = await Bun.file(backupSettingsPath).text();
905
+ await Bun.write(projectSettingsPath, backupContent);
906
+ unlinkSync(backupSettingsPath);
907
+ logger.debug(
908
+ `Curator Gemini: Restored original settings from backup`,
909
+ "curator",
910
+ );
911
+ } else if (existsSync(projectSettingsPath)) {
912
+ // Delete temporary settings (there was no original)
913
+ unlinkSync(projectSettingsPath);
914
+ logger.debug(
915
+ `Curator Gemini: Removed temporary settings file`,
916
+ "curator",
917
+ );
918
+ }
919
+ } catch (err: any) {
920
+ logger.debug(
921
+ `Curator Gemini: Could not cleanup settings: ${err.message}`,
922
+ "curator",
923
+ );
924
+ }
925
+ }
926
+
842
927
  logger.debug(`Curator Gemini: Exit code ${exitCode}`, "curator");
843
928
  if (stderr && stderr.trim()) {
844
929
  logger.debug(`Curator Gemini - stderr: ${stderr}`, "curator");