claude-self-reflect 3.2.4 → 3.3.0

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.
Files changed (33) hide show
  1. package/.claude/agents/claude-self-reflect-test.md +595 -528
  2. package/.claude/agents/reflection-specialist.md +59 -3
  3. package/README.md +14 -5
  4. package/mcp-server/run-mcp.sh +49 -5
  5. package/mcp-server/src/app_context.py +64 -0
  6. package/mcp-server/src/config.py +57 -0
  7. package/mcp-server/src/connection_pool.py +286 -0
  8. package/mcp-server/src/decay_manager.py +106 -0
  9. package/mcp-server/src/embedding_manager.py +64 -40
  10. package/mcp-server/src/embeddings_old.py +141 -0
  11. package/mcp-server/src/models.py +64 -0
  12. package/mcp-server/src/parallel_search.py +371 -0
  13. package/mcp-server/src/project_resolver.py +5 -0
  14. package/mcp-server/src/reflection_tools.py +206 -0
  15. package/mcp-server/src/rich_formatting.py +196 -0
  16. package/mcp-server/src/search_tools.py +826 -0
  17. package/mcp-server/src/server.py +127 -1720
  18. package/mcp-server/src/temporal_design.py +132 -0
  19. package/mcp-server/src/temporal_tools.py +597 -0
  20. package/mcp-server/src/temporal_utils.py +384 -0
  21. package/mcp-server/src/utils.py +150 -67
  22. package/package.json +10 -1
  23. package/scripts/add-timestamp-indexes.py +134 -0
  24. package/scripts/check-collections.py +29 -0
  25. package/scripts/debug-august-parsing.py +76 -0
  26. package/scripts/debug-import-single.py +91 -0
  27. package/scripts/debug-project-resolver.py +82 -0
  28. package/scripts/debug-temporal-tools.py +135 -0
  29. package/scripts/delta-metadata-update.py +547 -0
  30. package/scripts/import-conversations-unified.py +53 -2
  31. package/scripts/precompact-hook.sh +33 -0
  32. package/scripts/streaming-watcher.py +1443 -0
  33. package/scripts/utils.py +39 -0
@@ -0,0 +1,132 @@
1
+ """
2
+ Temporal Query API Design for Claude Self Reflect
3
+ ==================================================
4
+
5
+ This document outlines the design for new temporal query capabilities.
6
+
7
+ ## New MCP Tools
8
+
9
+ ### 1. get_recent_work
10
+ Purpose: Answer "What did we work on last?" queries
11
+ Parameters:
12
+ - limit: int (default=10) - Number of recent conversations to return
13
+ - project: Optional[str] - Specific project or 'all' for cross-project
14
+ - include_reflections: bool (default=True) - Include stored reflections
15
+ - group_by: str (default='conversation') - Group by 'conversation', 'day', or 'session'
16
+
17
+ Returns:
18
+ - List of recent conversations/sessions with:
19
+ - timestamp (ISO format)
20
+ - relative_time (e.g., "2 hours ago", "yesterday")
21
+ - project_name
22
+ - summary (auto-generated from content)
23
+ - main_topics (extracted concepts)
24
+ - files_worked_on (if any)
25
+ - conversation_id
26
+
27
+ ### 2. search_by_recency
28
+ Purpose: Time-constrained semantic search ("docker issues last week")
29
+ Parameters:
30
+ - query: str - Semantic search query
31
+ - time_range: str - Natural language time ("last week", "yesterday", "past 3 days")
32
+ OR
33
+ - since: Optional[str] - ISO timestamp or relative time
34
+ - until: Optional[str] - ISO timestamp or relative time
35
+ - limit: int (default=10)
36
+ - min_score: float (default=0.3)
37
+ - project: Optional[str]
38
+
39
+ Returns:
40
+ - Search results filtered and sorted by time
41
+ - Each result includes relative_time for context
42
+
43
+ ### 3. get_timeline
44
+ Purpose: Show activity timeline for a project or across all projects
45
+ Parameters:
46
+ - time_range: str (default="last_week") - Natural language or specific range
47
+ - project: Optional[str] - Specific project or 'all'
48
+ - granularity: str (default='day') - 'hour', 'day', 'week', 'month'
49
+ - include_stats: bool (default=True) - Include activity statistics
50
+
51
+ Returns:
52
+ - Timeline with activity grouped by time period
53
+ - Statistics: messages_count, files_edited, concepts_discussed
54
+ - Activity heat map data
55
+ - Peak activity times
56
+
57
+ ## Natural Language Time Parsing
58
+
59
+ Supported formats:
60
+ - Relative: "today", "yesterday", "last week", "past 3 days", "this month"
61
+ - Specific: "January 2025", "last Monday", "2 days ago"
62
+ - Ranges: "last 7 days", "past month", "since yesterday"
63
+
64
+ Implementation using dateparser library or custom parser with:
65
+ - Timezone awareness (use user's timezone if available)
66
+ - Fuzzy matching for common phrases
67
+ - ISO 8601 fallback for precise queries
68
+
69
+ ## Timestamp Indexing Optimization
70
+
71
+ 1. Create Qdrant index on timestamp field for faster sorting
72
+ 2. Use server-side filtering for time ranges
73
+ 3. Implement caching for recent queries (5-minute TTL)
74
+ 4. Pre-compute relative times during import
75
+
76
+ ## Integration with Existing Tools
77
+
78
+ ### Enhanced reflect_on_past:
79
+ - Add optional `sort_by` parameter: 'relevance' (default) or 'recency'
80
+ - Add optional `since` parameter for time filtering
81
+ - Include relative_time in all results
82
+
83
+ ### Backward Compatibility:
84
+ - All existing tools continue to work unchanged
85
+ - New parameters are optional with sensible defaults
86
+ - Response format extensions are additive only
87
+
88
+ ## Performance Considerations
89
+
90
+ 1. Index timestamp field in all collections
91
+ 2. Use Qdrant's native date filtering when possible
92
+ 3. Implement result caching for common queries
93
+ 4. Limit default results to prevent overwhelming responses
94
+
95
+ ## Edge Cases to Handle
96
+
97
+ 1. Empty time periods (no conversations)
98
+ 2. Timezone differences between conversations
99
+ 3. Ambiguous time expressions ("last Friday" on a Monday vs Tuesday)
100
+ 4. Very old conversations (show year in relative time)
101
+ 5. Conversations spanning multiple days
102
+ 6. Deleted or moved conversations
103
+
104
+ ## Example Usage
105
+
106
+ ```python
107
+ # What did we work on last?
108
+ result = await get_recent_work(limit=5, group_by='session')
109
+
110
+ # When did we last discuss Docker?
111
+ result = await search_by_recency(
112
+ query="docker containers",
113
+ time_range="past month",
114
+ limit=5
115
+ )
116
+
117
+ # Show my activity this week
118
+ timeline = await get_timeline(
119
+ time_range="this week",
120
+ granularity="day",
121
+ include_stats=True
122
+ )
123
+ ```
124
+
125
+ ## Testing Strategy
126
+
127
+ 1. Unit tests for time parsing functions
128
+ 2. Integration tests with mock Qdrant data
129
+ 3. Edge case tests for timezone handling
130
+ 4. Performance tests with large datasets
131
+ 5. User acceptance tests with natural language queries
132
+ """