claude-self-reflect 5.0.7 → 6.0.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.
- package/.claude/agents/open-source-maintainer.md +1 -1
- package/.claude/agents/reflection-specialist.md +2 -2
- package/Dockerfile.async-importer +6 -4
- package/Dockerfile.importer +6 -6
- package/Dockerfile.safe-watcher +8 -8
- package/Dockerfile.streaming-importer +8 -1
- package/Dockerfile.watcher +8 -16
- package/docker-compose.yaml +12 -6
- package/installer/.claude/agents/README.md +138 -0
- package/package.json +5 -26
- package/src/__init__.py +0 -0
- package/src/cli/__init__.py +0 -0
- package/src/runtime/__init__.py +0 -0
- package/src/runtime/import-latest.py +124 -0
- package/{scripts → src/runtime}/precompact-hook.sh +1 -1
- package/src/runtime/streaming-importer.py +995 -0
- package/{scripts → src/runtime}/watcher-loop.sh +1 -1
- package/.claude/agents/claude-self-reflect-test.md +0 -1274
- package/.claude/agents/reflect-tester.md +0 -300
- package/scripts/add-timestamp-indexes.py +0 -134
- package/scripts/ast_grep_final_analyzer.py +0 -338
- package/scripts/ast_grep_unified_registry.py +0 -710
- package/scripts/check-collections.py +0 -29
- package/scripts/debug-august-parsing.py +0 -80
- package/scripts/debug-import-single.py +0 -91
- package/scripts/debug-project-resolver.py +0 -82
- package/scripts/debug-temporal-tools.py +0 -135
- package/scripts/import-conversations-enhanced.py +0 -672
- package/scripts/migrate-to-unified-state.py +0 -426
- package/scripts/session_quality_tracker.py +0 -671
- package/scripts/update_patterns.py +0 -334
- /package/{scripts → src}/importer/__init__.py +0 -0
- /package/{scripts → src}/importer/__main__.py +0 -0
- /package/{scripts → src}/importer/core/__init__.py +0 -0
- /package/{scripts → src}/importer/core/config.py +0 -0
- /package/{scripts → src}/importer/core/exceptions.py +0 -0
- /package/{scripts → src}/importer/core/models.py +0 -0
- /package/{scripts → src}/importer/embeddings/__init__.py +0 -0
- /package/{scripts → src}/importer/embeddings/base.py +0 -0
- /package/{scripts → src}/importer/embeddings/fastembed_provider.py +0 -0
- /package/{scripts → src}/importer/embeddings/validator.py +0 -0
- /package/{scripts → src}/importer/embeddings/voyage_provider.py +0 -0
- /package/{scripts → src}/importer/main.py +0 -0
- /package/{scripts → src}/importer/processors/__init__.py +0 -0
- /package/{scripts → src}/importer/processors/ast_extractor.py +0 -0
- /package/{scripts → src}/importer/processors/chunker.py +0 -0
- /package/{scripts → src}/importer/processors/concept_extractor.py +0 -0
- /package/{scripts → src}/importer/processors/conversation_parser.py +0 -0
- /package/{scripts → src}/importer/processors/tool_extractor.py +0 -0
- /package/{scripts → src}/importer/state/__init__.py +0 -0
- /package/{scripts → src}/importer/state/state_manager.py +0 -0
- /package/{scripts → src}/importer/storage/__init__.py +0 -0
- /package/{scripts → src}/importer/storage/qdrant_storage.py +0 -0
- /package/{scripts → src}/importer/utils/__init__.py +0 -0
- /package/{scripts → src}/importer/utils/logger.py +0 -0
- /package/{scripts → src}/importer/utils/project_normalizer.py +0 -0
- /package/{scripts → src/runtime}/delta-metadata-update-safe.py +0 -0
- /package/{scripts → src/runtime}/delta-metadata-update.py +0 -0
- /package/{scripts → src/runtime}/doctor.py +0 -0
- /package/{scripts → src/runtime}/embedding_service.py +0 -0
- /package/{scripts → src/runtime}/force-metadata-recovery.py +0 -0
- /package/{scripts → src/runtime}/import-conversations-unified.py +0 -0
- /package/{scripts → src/runtime}/import_strategies.py +0 -0
- /package/{scripts → src/runtime}/message_processors.py +0 -0
- /package/{scripts → src/runtime}/metadata_extractor.py +0 -0
- /package/{scripts → src/runtime}/streaming-watcher.py +0 -0
- /package/{scripts → src/runtime}/unified_state_manager.py +0 -0
- /package/{scripts → src/runtime}/utils.py +0 -0
|
@@ -726,12 +726,12 @@ source .venv/bin/activate # or source venv/bin/activate
|
|
|
726
726
|
|
|
727
727
|
# For local embeddings (default)
|
|
728
728
|
export PREFER_LOCAL_EMBEDDINGS=true
|
|
729
|
-
python
|
|
729
|
+
python src/runtime/import-conversations-unified.py
|
|
730
730
|
|
|
731
731
|
# For cloud embeddings (Voyage AI)
|
|
732
732
|
export PREFER_LOCAL_EMBEDDINGS=false
|
|
733
733
|
export VOYAGE_KEY=your-voyage-api-key
|
|
734
|
-
python
|
|
734
|
+
python src/runtime/import-conversations-unified.py
|
|
735
735
|
```
|
|
736
736
|
|
|
737
737
|
### Import Troubleshooting
|
|
@@ -25,12 +25,14 @@ COPY scripts/requirements.txt /app/
|
|
|
25
25
|
# Install Python dependencies
|
|
26
26
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
27
27
|
|
|
28
|
-
# Copy
|
|
29
|
-
COPY
|
|
28
|
+
# Copy source code
|
|
29
|
+
COPY src/ /app/src/
|
|
30
|
+
COPY shared/ /app/shared/
|
|
30
31
|
|
|
31
|
-
# Set environment variables for memory management
|
|
32
|
+
# Set environment variables for memory management and Python path
|
|
32
33
|
ENV MALLOC_ARENA_MAX=2
|
|
33
34
|
ENV PYTHONUNBUFFERED=1
|
|
35
|
+
ENV PYTHONPATH=/app
|
|
34
36
|
|
|
35
37
|
# Run the streaming importer
|
|
36
|
-
CMD ["python", "/
|
|
38
|
+
CMD ["python", "/app/src/runtime/streaming-importer.py"]
|
package/Dockerfile.importer
CHANGED
|
@@ -24,13 +24,13 @@ RUN pip install --no-cache-dir \
|
|
|
24
24
|
voyageai==0.3.4 \
|
|
25
25
|
tenacity==9.1.2
|
|
26
26
|
|
|
27
|
-
# Copy
|
|
28
|
-
# This ensures
|
|
29
|
-
COPY
|
|
27
|
+
# Copy src and shared modules into the image for npm package compatibility
|
|
28
|
+
# This ensures code is available even without volume mounts
|
|
29
|
+
COPY src/ /app/src/
|
|
30
|
+
COPY shared/ /app/shared/
|
|
30
31
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
RUN ln -s /app/scripts /scripts
|
|
32
|
+
# Set PYTHONPATH for proper module imports
|
|
33
|
+
ENV PYTHONPATH=/app
|
|
34
34
|
|
|
35
35
|
# Note: Volume mounts in docker-compose.yaml will override these files in local development
|
|
36
36
|
# This provides compatibility for both local development and global npm installs
|
package/Dockerfile.safe-watcher
CHANGED
|
@@ -40,15 +40,15 @@ RUN mkdir -p /root/.cache/fastembed && \
|
|
|
40
40
|
# Set working directory
|
|
41
41
|
WORKDIR /app
|
|
42
42
|
|
|
43
|
-
# Copy
|
|
44
|
-
COPY
|
|
43
|
+
# Copy source code
|
|
44
|
+
COPY src/ /app/src/
|
|
45
|
+
COPY shared/ /app/shared/
|
|
45
46
|
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
RUN ln -s /app/scripts /scripts
|
|
47
|
+
# Set PYTHONPATH for proper imports
|
|
48
|
+
ENV PYTHONPATH=/app
|
|
49
49
|
|
|
50
|
-
# Make
|
|
51
|
-
RUN chmod +x /app/
|
|
50
|
+
# Make scripts executable
|
|
51
|
+
RUN chmod +x /app/src/runtime/*.sh /app/src/runtime/*.py
|
|
52
52
|
|
|
53
53
|
# Create config directory
|
|
54
54
|
RUN mkdir -p /config
|
|
@@ -58,4 +58,4 @@ ENV PYTHONUNBUFFERED=1
|
|
|
58
58
|
ENV MALLOC_ARENA_MAX=2
|
|
59
59
|
|
|
60
60
|
# Run the watcher loop
|
|
61
|
-
CMD ["/app/
|
|
61
|
+
CMD ["/app/src/runtime/watcher-loop.sh"]
|
|
@@ -47,8 +47,15 @@ RUN useradd -m -u 1000 importer
|
|
|
47
47
|
# Set working directory
|
|
48
48
|
WORKDIR /app
|
|
49
49
|
|
|
50
|
+
# Copy source code
|
|
51
|
+
COPY src/ /app/src/
|
|
52
|
+
COPY shared/ /app/shared/
|
|
53
|
+
|
|
54
|
+
# Set PYTHONPATH for proper imports
|
|
55
|
+
ENV PYTHONPATH=/app
|
|
56
|
+
|
|
50
57
|
# Note: Running as root for now due to fastembed cache permissions
|
|
51
58
|
# TODO: Fix cache permissions to run as non-root user
|
|
52
59
|
|
|
53
60
|
# Default command
|
|
54
|
-
CMD ["python", "/
|
|
61
|
+
CMD ["python", "/app/src/runtime/streaming-importer.py"]
|
package/Dockerfile.watcher
CHANGED
|
@@ -32,26 +32,18 @@ RUN mkdir -p /home/watcher/.cache && \
|
|
|
32
32
|
FASTEMBED_CACHE_PATH=/home/watcher/.cache/fastembed python -c "from fastembed import TextEmbedding; import os; os.environ['FASTEMBED_CACHE_PATH']='/home/watcher/.cache/fastembed'; TextEmbedding('sentence-transformers/all-MiniLM-L6-v2')" && \
|
|
33
33
|
chown -R watcher:watcher /home/watcher/.cache
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
COPY scripts/import-conversations-unified.py /scripts/
|
|
40
|
-
COPY scripts/import-watcher.py /scripts/
|
|
41
|
-
COPY scripts/streaming-importer.py /scripts/
|
|
42
|
-
COPY scripts/utils.py /scripts/
|
|
43
|
-
COPY scripts/trigger-import.py /scripts/
|
|
44
|
-
|
|
45
|
-
# Copy MCP server directory for utils
|
|
46
|
-
COPY mcp-server/src/utils.py /mcp-server/src/utils.py
|
|
35
|
+
# Copy source code
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
COPY src/ /app/src/
|
|
38
|
+
COPY shared/ /app/shared/
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
# Set PYTHONPATH for proper imports
|
|
41
|
+
ENV PYTHONPATH=/app
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
WORKDIR /app
|
|
43
|
+
RUN chmod +x /app/src/runtime/*.sh /app/src/runtime/*.py
|
|
52
44
|
|
|
53
45
|
# Switch to non-root user
|
|
54
46
|
USER watcher
|
|
55
47
|
|
|
56
48
|
# Default command - use streaming importer for low memory usage
|
|
57
|
-
CMD ["python", "/
|
|
49
|
+
CMD ["python", "/app/src/runtime/streaming-importer.py"]
|
package/docker-compose.yaml
CHANGED
|
@@ -40,7 +40,8 @@ services:
|
|
|
40
40
|
volumes:
|
|
41
41
|
- ${CLAUDE_LOGS_PATH:-~/.claude/projects}:/logs:ro
|
|
42
42
|
- ${CONFIG_PATH:-~/.claude-self-reflect/config}:/config
|
|
43
|
-
- ./
|
|
43
|
+
- ./src:/app/src:ro
|
|
44
|
+
- ./shared:/app/shared:ro
|
|
44
45
|
environment:
|
|
45
46
|
- QDRANT_URL=http://qdrant:6333
|
|
46
47
|
- STATE_FILE=/config/imported-files.json
|
|
@@ -53,9 +54,10 @@ services:
|
|
|
53
54
|
- BATCH_SIZE=${BATCH_SIZE:-50}
|
|
54
55
|
- CHUNK_SIZE=${CHUNK_SIZE:-10}
|
|
55
56
|
- PYTHONUNBUFFERED=1
|
|
57
|
+
- PYTHONPATH=/app
|
|
56
58
|
restart: "no"
|
|
57
59
|
profiles: ["import"]
|
|
58
|
-
command: python /
|
|
60
|
+
command: python /app/src/runtime/import-conversations-unified.py
|
|
59
61
|
|
|
60
62
|
# Continuous watcher service (optional) - DEPRECATED, use streaming-importer
|
|
61
63
|
watcher:
|
|
@@ -69,7 +71,8 @@ services:
|
|
|
69
71
|
volumes:
|
|
70
72
|
- ${CLAUDE_LOGS_PATH:-~/.claude/projects}:/logs:ro
|
|
71
73
|
- ${CONFIG_PATH:-~/.claude-self-reflect/config}:/config
|
|
72
|
-
- ./
|
|
74
|
+
- ./src:/app/src:ro
|
|
75
|
+
- ./shared:/app/shared:ro
|
|
73
76
|
- /tmp:/tmp
|
|
74
77
|
environment:
|
|
75
78
|
- QDRANT_URL=http://qdrant:6333
|
|
@@ -100,7 +103,8 @@ services:
|
|
|
100
103
|
volumes:
|
|
101
104
|
- ${CLAUDE_LOGS_PATH:-~/.claude/projects}:/logs:ro
|
|
102
105
|
- ${CONFIG_PATH:-~/.claude-self-reflect/config}:/config
|
|
103
|
-
- ./
|
|
106
|
+
- ./src:/app/src:ro
|
|
107
|
+
- ./shared:/app/shared:ro
|
|
104
108
|
environment:
|
|
105
109
|
- QDRANT_URL=http://qdrant:6333
|
|
106
110
|
- STATE_FILE=/config/streaming-state.json # FIXED: Use streaming-specific state file
|
|
@@ -140,7 +144,8 @@ services:
|
|
|
140
144
|
volumes:
|
|
141
145
|
- ${CLAUDE_LOGS_PATH:-~/.claude/projects}:/logs:ro
|
|
142
146
|
- ${CONFIG_PATH:-~/.claude-self-reflect/config}:/config
|
|
143
|
-
- ./
|
|
147
|
+
- ./src:/app/src:ro
|
|
148
|
+
- ./shared:/app/shared:ro
|
|
144
149
|
environment:
|
|
145
150
|
- QDRANT_URL=http://qdrant:6333
|
|
146
151
|
- STATE_FILE=/config/imported-files.json
|
|
@@ -176,7 +181,8 @@ services:
|
|
|
176
181
|
volumes:
|
|
177
182
|
- ${CLAUDE_LOGS_PATH:-~/.claude/projects}:/logs:ro
|
|
178
183
|
- ${CONFIG_PATH:-~/.claude-self-reflect/config}:/config
|
|
179
|
-
- ./
|
|
184
|
+
- ./src:/app/src:ro
|
|
185
|
+
- ./shared:/app/shared:ro
|
|
180
186
|
environment:
|
|
181
187
|
- QDRANT_URL=http://qdrant:6333
|
|
182
188
|
- STATE_FILE=/config/csr-watcher.json
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Claude Self Reflect - Specialized Agents
|
|
2
|
+
|
|
3
|
+
This directory contains specialized sub-agents that Claude will proactively use when working on different aspects of the Claude Self Reflect system. Each agent has focused expertise and will automatically activate when their domain is encountered.
|
|
4
|
+
|
|
5
|
+
## Available Agents
|
|
6
|
+
|
|
7
|
+
### 🔧 Core System Agents
|
|
8
|
+
|
|
9
|
+
1. **[qdrant-specialist](./qdrant-specialist.md)** - Vector database expert
|
|
10
|
+
- Collection management and health monitoring
|
|
11
|
+
- Search optimization and troubleshooting
|
|
12
|
+
- Embedding configuration and dimension issues
|
|
13
|
+
- Performance tuning for Qdrant
|
|
14
|
+
|
|
15
|
+
2. **[import-debugger](./import-debugger.md)** - Import pipeline specialist
|
|
16
|
+
- JSONL processing and parsing issues
|
|
17
|
+
- Conversation chunking optimization
|
|
18
|
+
- Batch processing and memory management
|
|
19
|
+
- State tracking and error recovery
|
|
20
|
+
|
|
21
|
+
3. **[docker-orchestrator](./docker-orchestrator.md)** - Container management expert
|
|
22
|
+
- Multi-container orchestration
|
|
23
|
+
- Service health monitoring
|
|
24
|
+
- Resource optimization
|
|
25
|
+
- Networking and volume management
|
|
26
|
+
|
|
27
|
+
4. **[mcp-integration](./mcp-integration.md)** - MCP server developer
|
|
28
|
+
- Claude Desktop integration
|
|
29
|
+
- Tool implementation and schemas
|
|
30
|
+
- TypeScript development
|
|
31
|
+
- Connection debugging
|
|
32
|
+
|
|
33
|
+
5. **[search-optimizer](./search-optimizer.md)** - Search quality expert
|
|
34
|
+
- Semantic search tuning
|
|
35
|
+
- Embedding model comparison
|
|
36
|
+
- Similarity threshold optimization
|
|
37
|
+
- A/B testing methodologies
|
|
38
|
+
|
|
39
|
+
### 🌟 Open Source Development Agents
|
|
40
|
+
|
|
41
|
+
6. **[open-source-maintainer](./open-source-maintainer.md)** - Project governance expert
|
|
42
|
+
- Release management and versioning
|
|
43
|
+
- Community building and engagement
|
|
44
|
+
- Issue and PR triage
|
|
45
|
+
- Contributor recognition
|
|
46
|
+
|
|
47
|
+
7. **[documentation-writer](./documentation-writer.md)** - Technical documentation specialist
|
|
48
|
+
- API documentation and references
|
|
49
|
+
- Tutorial and guide creation
|
|
50
|
+
- Architecture documentation
|
|
51
|
+
- Example code development
|
|
52
|
+
|
|
53
|
+
8. **[performance-tuner](./performance-tuner.md)** - Performance optimization specialist
|
|
54
|
+
- Search latency optimization
|
|
55
|
+
- Memory usage reduction
|
|
56
|
+
- Scalability improvements
|
|
57
|
+
- Benchmark creation and monitoring
|
|
58
|
+
|
|
59
|
+
## How Agents Work
|
|
60
|
+
|
|
61
|
+
### Automatic Activation
|
|
62
|
+
|
|
63
|
+
Claude automatically engages the appropriate agent based on context. For example:
|
|
64
|
+
|
|
65
|
+
- Mentioning "search returns irrelevant results" → `search-optimizer`
|
|
66
|
+
- Discussing "import showing 0 messages" → `import-debugger`
|
|
67
|
+
- Working on "release v1.2.0" → `open-source-maintainer`
|
|
68
|
+
- Asking about "Qdrant collection errors" → `qdrant-specialist`
|
|
69
|
+
|
|
70
|
+
### Agent Capabilities
|
|
71
|
+
|
|
72
|
+
Each agent has:
|
|
73
|
+
- **Focused expertise** in their domain
|
|
74
|
+
- **Specific tool permissions** for their tasks
|
|
75
|
+
- **Contextual knowledge** about the project
|
|
76
|
+
- **Best practices** for their area
|
|
77
|
+
|
|
78
|
+
### Working with Multiple Agents
|
|
79
|
+
|
|
80
|
+
Agents can collaborate on complex issues:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
User: "Search is slow and returning poor results after import"
|
|
84
|
+
→ import-debugger checks data quality
|
|
85
|
+
→ qdrant-specialist optimizes collection settings
|
|
86
|
+
→ search-optimizer tunes similarity thresholds
|
|
87
|
+
→ performance-tuner profiles the entire pipeline
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Creating New Agents
|
|
91
|
+
|
|
92
|
+
To add a new specialized agent:
|
|
93
|
+
|
|
94
|
+
1. Create a new `.md` file in this directory
|
|
95
|
+
2. Use the following template:
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
---
|
|
99
|
+
name: agent-name
|
|
100
|
+
description: Brief description for proactive activation
|
|
101
|
+
tools: Read, Write, Edit, Bash, Grep, Glob, LS, WebFetch
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
You are a [role] for the Claude Self Reflect project. Your expertise covers [domains].
|
|
105
|
+
|
|
106
|
+
## Project Context
|
|
107
|
+
[Specific project knowledge relevant to this agent]
|
|
108
|
+
|
|
109
|
+
## Key Responsibilities
|
|
110
|
+
[Numbered list of main tasks]
|
|
111
|
+
|
|
112
|
+
## Essential Commands/Patterns
|
|
113
|
+
[Code blocks with common operations]
|
|
114
|
+
|
|
115
|
+
## Best Practices
|
|
116
|
+
[Domain-specific guidelines]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
3. Update this README with the new agent
|
|
120
|
+
4. Test the agent activation with relevant prompts
|
|
121
|
+
|
|
122
|
+
## Agent Development Guidelines
|
|
123
|
+
|
|
124
|
+
- **Be specific**: Agents should have clear, focused roles
|
|
125
|
+
- **Include examples**: Provide code snippets and commands
|
|
126
|
+
- **Stay current**: Update agents as the project evolves
|
|
127
|
+
- **Cross-reference**: Mention when to use other agents
|
|
128
|
+
- **Be helpful**: Include troubleshooting sections
|
|
129
|
+
|
|
130
|
+
## Maintenance
|
|
131
|
+
|
|
132
|
+
Agents should be reviewed and updated:
|
|
133
|
+
- When new features are added
|
|
134
|
+
- When common issues emerge
|
|
135
|
+
- When best practices change
|
|
136
|
+
- During major version updates
|
|
137
|
+
|
|
138
|
+
Remember: These agents are here to help contributors work more effectively on the Claude Self Reflect project. They embody the project's expertise and best practices.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-self-reflect",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Give Claude perfect memory of all your conversations - Installation wizard for Python MCP server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
@@ -34,41 +34,20 @@
|
|
|
34
34
|
"claude-self-reflect": "installer/cli.js"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
|
-
"installer
|
|
37
|
+
"installer/**/*.js",
|
|
38
38
|
"scripts/auto-migrate.cjs",
|
|
39
39
|
"scripts/migrate-to-unified-state.py",
|
|
40
|
-
"scripts/unified_state_manager.py",
|
|
41
40
|
"scripts/csr-status",
|
|
42
|
-
"scripts/session_quality_tracker.py",
|
|
43
|
-
"scripts/ast_grep_final_analyzer.py",
|
|
44
|
-
"scripts/ast_grep_unified_registry.py",
|
|
45
|
-
"scripts/update_patterns.py",
|
|
46
41
|
"mcp-server/src/**/*.py",
|
|
47
42
|
"mcp-server/pyproject.toml",
|
|
48
43
|
"mcp-server/run-mcp.sh",
|
|
49
44
|
"mcp-server/run-mcp-clean.sh",
|
|
50
45
|
"mcp-server/run-mcp-docker.sh",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"scripts/add-timestamp-indexes.py",
|
|
54
|
-
"scripts/debug-*.py",
|
|
55
|
-
"scripts/check-collections.py",
|
|
56
|
-
"scripts/status.py",
|
|
57
|
-
"scripts/utils.py",
|
|
58
|
-
"scripts/importer/**/*.py",
|
|
59
|
-
"scripts/delta-metadata-update.py",
|
|
60
|
-
"scripts/delta-metadata-update-safe.py",
|
|
61
|
-
"scripts/force-metadata-recovery.py",
|
|
62
|
-
"scripts/precompact-hook.sh",
|
|
63
|
-
"scripts/watcher-loop.sh",
|
|
64
|
-
"scripts/import-latest.py",
|
|
65
|
-
"scripts/metadata_extractor.py",
|
|
66
|
-
"scripts/message_processors.py",
|
|
67
|
-
"scripts/import_strategies.py",
|
|
68
|
-
"scripts/embedding_service.py",
|
|
69
|
-
"scripts/doctor.py",
|
|
46
|
+
"src/**/*.py",
|
|
47
|
+
"src/**/*.sh",
|
|
70
48
|
"shared/**/*.py",
|
|
71
49
|
".claude/agents/*.md",
|
|
50
|
+
"!.claude/agents/*test*.md",
|
|
72
51
|
"config/qdrant-config.yaml",
|
|
73
52
|
"docker-compose.yaml",
|
|
74
53
|
"Dockerfile.*",
|
package/src/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Quick import script for current project's latest conversations.
|
|
4
|
+
Designed for PreCompact hook integration - targets <10 second imports.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
import subprocess
|
|
11
|
+
from datetime import datetime, timedelta
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import logging
|
|
14
|
+
|
|
15
|
+
# Configuration
|
|
16
|
+
LOGS_DIR = os.getenv("LOGS_DIR", os.path.expanduser("~/.claude/projects"))
|
|
17
|
+
STATE_FILE = os.getenv("STATE_FILE", os.path.expanduser("~/.claude-self-reflect-state.json"))
|
|
18
|
+
HOURS_BACK = int(os.getenv("IMPORT_HOURS_BACK", "2")) # Only import last 2 hours by default
|
|
19
|
+
|
|
20
|
+
# Set up logging
|
|
21
|
+
logging.basicConfig(
|
|
22
|
+
level=logging.INFO,
|
|
23
|
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
|
24
|
+
)
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
def load_state():
|
|
28
|
+
"""Load import state from file."""
|
|
29
|
+
if os.path.exists(STATE_FILE):
|
|
30
|
+
try:
|
|
31
|
+
with open(STATE_FILE, 'r') as f:
|
|
32
|
+
return json.load(f)
|
|
33
|
+
except:
|
|
34
|
+
return {}
|
|
35
|
+
return {}
|
|
36
|
+
|
|
37
|
+
def save_state(state):
|
|
38
|
+
"""Save import state to file."""
|
|
39
|
+
os.makedirs(os.path.dirname(STATE_FILE), exist_ok=True)
|
|
40
|
+
with open(STATE_FILE, 'w') as f:
|
|
41
|
+
json.dump(state, f, indent=2)
|
|
42
|
+
|
|
43
|
+
def get_project_from_cwd():
|
|
44
|
+
"""Detect project from current working directory."""
|
|
45
|
+
cwd = os.getcwd()
|
|
46
|
+
# Convert path to project name format used in logs
|
|
47
|
+
# Claude logs use format: -Users-username-path-to-project
|
|
48
|
+
project_name = cwd.replace('/', '-')
|
|
49
|
+
# Keep the leading dash as that's how Claude stores it
|
|
50
|
+
if not project_name.startswith('-'):
|
|
51
|
+
project_name = '-' + project_name
|
|
52
|
+
return project_name
|
|
53
|
+
|
|
54
|
+
def get_recent_files(project_path: Path, hours_back: int):
|
|
55
|
+
"""Get JSONL files modified in the last N hours."""
|
|
56
|
+
cutoff_time = datetime.now() - timedelta(hours=hours_back)
|
|
57
|
+
recent_files = []
|
|
58
|
+
|
|
59
|
+
for jsonl_file in project_path.glob("*.jsonl"):
|
|
60
|
+
mtime = datetime.fromtimestamp(jsonl_file.stat().st_mtime)
|
|
61
|
+
if mtime > cutoff_time:
|
|
62
|
+
recent_files.append(jsonl_file)
|
|
63
|
+
|
|
64
|
+
return sorted(recent_files, key=lambda f: f.stat().st_mtime, reverse=True)
|
|
65
|
+
|
|
66
|
+
def main():
|
|
67
|
+
"""Main quick import function."""
|
|
68
|
+
start_time = datetime.now()
|
|
69
|
+
|
|
70
|
+
# Detect current project
|
|
71
|
+
project_name = get_project_from_cwd()
|
|
72
|
+
project_path = Path(LOGS_DIR) / project_name
|
|
73
|
+
|
|
74
|
+
if not project_path.exists():
|
|
75
|
+
logger.warning(f"Project logs not found: {project_path}")
|
|
76
|
+
logger.info("Make sure you're in a project directory with Claude conversations.")
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
logger.info(f"Quick importing latest conversations for: {project_name}")
|
|
80
|
+
|
|
81
|
+
# Get recent files
|
|
82
|
+
recent_files = get_recent_files(project_path, HOURS_BACK)
|
|
83
|
+
logger.info(f"Found {len(recent_files)} files modified in last {HOURS_BACK} hours")
|
|
84
|
+
|
|
85
|
+
if not recent_files:
|
|
86
|
+
logger.info("No recent conversations to import")
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
# For now, just call the unified importer with the specific project
|
|
90
|
+
# This is a temporary solution until we implement incremental imports
|
|
91
|
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
92
|
+
unified_script = os.path.join(script_dir, "import-conversations-unified.py")
|
|
93
|
+
|
|
94
|
+
# Set environment to only process this project
|
|
95
|
+
env = os.environ.copy()
|
|
96
|
+
env['LOGS_DIR'] = str(project_path.parent)
|
|
97
|
+
env['IMPORT_PROJECT'] = project_name
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
# Run the unified importer for just this project
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
[sys.executable, unified_script],
|
|
103
|
+
env=env,
|
|
104
|
+
capture_output=True,
|
|
105
|
+
text=True,
|
|
106
|
+
timeout=60 # 60 second timeout
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if result.returncode == 0:
|
|
110
|
+
logger.info("Quick import completed successfully")
|
|
111
|
+
else:
|
|
112
|
+
logger.error(f"Import failed: {result.stderr}")
|
|
113
|
+
|
|
114
|
+
except subprocess.TimeoutExpired:
|
|
115
|
+
logger.warning("Import timed out after 60 seconds")
|
|
116
|
+
except Exception as e:
|
|
117
|
+
logger.error(f"Error during import: {e}")
|
|
118
|
+
|
|
119
|
+
# Report timing
|
|
120
|
+
elapsed = (datetime.now() - start_time).total_seconds()
|
|
121
|
+
logger.info(f"Quick import completed in {elapsed:.1f} seconds")
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|
|
@@ -23,7 +23,7 @@ fi
|
|
|
23
23
|
echo "Updating conversation memory..." >&2
|
|
24
24
|
timeout $IMPORT_TIMEOUT bash -c "
|
|
25
25
|
source '$VENV_PATH/bin/activate' 2>/dev/null
|
|
26
|
-
python '$CLAUDE_REFLECT_DIR/
|
|
26
|
+
python '$CLAUDE_REFLECT_DIR/src/runtime/import-latest.py' 2>&1 | \
|
|
27
27
|
grep -E '(Quick import completed|Imported|Warning)' >&2
|
|
28
28
|
" || {
|
|
29
29
|
echo "Quick import timed out after ${IMPORT_TIMEOUT}s" >&2
|