claude-self-reflect 2.4.15 → 2.5.2

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.
@@ -79,13 +79,22 @@ def should_import_file(file_path, state):
79
79
  file_mtime = os.path.getmtime(file_path)
80
80
 
81
81
  if str_path in state["imported_files"]:
82
- last_imported = state["imported_files"][str_path].get("last_imported", 0)
83
- last_modified = state["imported_files"][str_path].get("last_modified", 0)
82
+ file_state = state["imported_files"][str_path]
84
83
 
85
- # Skip if file hasn't been modified since last import
86
- if file_mtime <= last_modified and last_imported > 0:
87
- logger.info(f"Skipping unchanged file: {file_path.name}")
88
- return False
84
+ # Handle both old string format and new dict format
85
+ if isinstance(file_state, str):
86
+ # Old format (just timestamp string) - treat as needs reimport
87
+ logger.info(f"Found old format state for {file_path.name}, will reimport")
88
+ return True
89
+ else:
90
+ # New format with dictionary
91
+ last_imported = file_state.get("last_imported", 0)
92
+ last_modified = file_state.get("last_modified", 0)
93
+
94
+ # Skip if file hasn't been modified since last import
95
+ if file_mtime <= last_modified and last_imported > 0:
96
+ logger.info(f"Skipping unchanged file: {file_path.name}")
97
+ return False
89
98
 
90
99
  return True
91
100
 
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Enhanced watcher that runs import periodically and supports manual triggers."""
3
-
4
- import time
5
- import subprocess
6
- import os
7
- import sys
8
- from datetime import datetime
9
- from pathlib import Path
10
-
11
- WATCH_INTERVAL = int(os.getenv('WATCH_INTERVAL', '60'))
12
- SIGNAL_FILE = Path("/tmp/claude-self-reflect-import-current")
13
- CHECK_INTERVAL = 1 # Check for signal file every second
14
-
15
- print(f"[Watcher] Starting enhanced import watcher with {WATCH_INTERVAL}s interval", flush=True)
16
- print(f"[Watcher] Monitoring signal file: {SIGNAL_FILE}", flush=True)
17
-
18
- last_import = 0
19
-
20
- while True:
21
- current_time = time.time()
22
-
23
- # Check for manual trigger signal
24
- if SIGNAL_FILE.exists():
25
- print(f"[Watcher] Signal detected! Running immediate import...", flush=True)
26
- try:
27
- # Read conversation ID if provided
28
- conversation_id = None
29
- try:
30
- conversation_id = SIGNAL_FILE.read_text().strip()
31
- except:
32
- pass
33
-
34
- # Remove signal file to prevent re-triggering
35
- SIGNAL_FILE.unlink()
36
-
37
- # Run import with special flag for current conversation only
38
- cmd = [sys.executable, "/scripts/import-conversations-unified.py"]
39
- if conversation_id:
40
- cmd.extend(["--conversation-id", conversation_id])
41
- else:
42
- # Import only today's conversations for manual trigger
43
- cmd.extend(["--days", "1"])
44
-
45
- # Write progress indicator
46
- progress_file = Path("/tmp/claude-self-reflect-import-progress")
47
- progress_file.write_text("🔄 Starting import...")
48
-
49
- print(f"[Watcher] Running command: {' '.join(cmd)}", flush=True)
50
- result = subprocess.run(cmd, capture_output=True, text=True)
51
-
52
- if result.returncode == 0:
53
- print(f"[Watcher] Manual import completed successfully", flush=True)
54
- # Create completion signal
55
- Path("/tmp/claude-self-reflect-import-complete").touch()
56
- else:
57
- print(f"[Watcher] Manual import failed with code {result.returncode}", flush=True)
58
- if result.stderr:
59
- print(f"[Watcher] Error: {result.stderr}", flush=True)
60
-
61
- last_import = current_time
62
-
63
- except Exception as e:
64
- print(f"[Watcher] Error during manual import: {e}", flush=True)
65
-
66
- # Regular scheduled import
67
- elif current_time - last_import >= WATCH_INTERVAL:
68
- try:
69
- print(f"[Watcher] Running scheduled import at {datetime.now().isoformat()}", flush=True)
70
- result = subprocess.run([
71
- sys.executable,
72
- "/scripts/import-conversations-unified.py"
73
- ], capture_output=True, text=True)
74
-
75
- if result.returncode == 0:
76
- print(f"[Watcher] Scheduled import completed successfully", flush=True)
77
- else:
78
- print(f"[Watcher] Scheduled import failed with code {result.returncode}", flush=True)
79
- if result.stderr:
80
- print(f"[Watcher] Error: {result.stderr}", flush=True)
81
-
82
- last_import = current_time
83
-
84
- except Exception as e:
85
- print(f"[Watcher] Error during scheduled import: {e}", flush=True)
86
-
87
- # Short sleep to check for signals frequently
88
- time.sleep(CHECK_INTERVAL)