claude-self-reflect 3.3.1 → 4.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/claude-self-reflect-test.md +107 -8
- package/.claude/agents/quality-fixer.md +314 -0
- package/.claude/agents/reflection-specialist.md +40 -1
- package/mcp-server/run-mcp.sh +20 -6
- package/mcp-server/src/code_reload_tool.py +271 -0
- package/mcp-server/src/embedding_manager.py +60 -26
- package/mcp-server/src/enhanced_tool_registry.py +407 -0
- package/mcp-server/src/mode_switch_tool.py +181 -0
- package/mcp-server/src/parallel_search.py +8 -3
- package/mcp-server/src/project_resolver.py +20 -2
- package/mcp-server/src/reflection_tools.py +50 -8
- package/mcp-server/src/rich_formatting.py +103 -0
- package/mcp-server/src/search_tools.py +90 -37
- package/mcp-server/src/security_patches.py +555 -0
- package/mcp-server/src/server.py +318 -240
- package/mcp-server/src/status.py +13 -8
- package/mcp-server/src/test_quality.py +153 -0
- package/package.json +1 -1
- package/scripts/ast_grep_final_analyzer.py +5 -2
- package/scripts/ast_grep_unified_registry.py +170 -16
- package/scripts/csr-status +190 -45
- package/scripts/import-conversations-unified.py +10 -5
- package/scripts/session_quality_tracker.py +221 -41
|
@@ -637,6 +637,10 @@ test_subagent_availability
|
|
|
637
637
|
#!/bin/bash
|
|
638
638
|
echo "=== EMBEDDING MODE TESTING ==="
|
|
639
639
|
|
|
640
|
+
# CRITICAL: Instructions for switching to cloud mode
|
|
641
|
+
# The system needs new collections with 1024 dimensions for cloud mode
|
|
642
|
+
# This requires MCP restart with VOYAGE_KEY parameter
|
|
643
|
+
|
|
640
644
|
# Test both modes
|
|
641
645
|
test_both_embedding_modes() {
|
|
642
646
|
echo "Testing local mode (FastEmbed)..."
|
|
@@ -658,6 +662,73 @@ print(f'Cloud mode: {em.model_type}, dimension: {em.get_vector_dimension()}')
|
|
|
658
662
|
fi
|
|
659
663
|
}
|
|
660
664
|
|
|
665
|
+
# CRITICAL CLOUD MODE SWITCH PROCEDURE
|
|
666
|
+
switch_to_cloud_mode() {
|
|
667
|
+
echo "=== SWITCHING TO CLOUD MODE (1024 dimensions) ==="
|
|
668
|
+
echo "This creates NEW collections with _voyage suffix"
|
|
669
|
+
|
|
670
|
+
# Step 1: Get VOYAGE_KEY from .env
|
|
671
|
+
VOYAGE_KEY=$(grep "^VOYAGE_KEY=" .env | cut -d'=' -f2)
|
|
672
|
+
if [ -z "$VOYAGE_KEY" ]; then
|
|
673
|
+
echo "❌ VOYAGE_KEY not found in .env file"
|
|
674
|
+
echo "Please add VOYAGE_KEY=your-key-here to .env file"
|
|
675
|
+
return 1
|
|
676
|
+
fi
|
|
677
|
+
|
|
678
|
+
# Step 2: Remove existing MCP
|
|
679
|
+
echo "Removing existing MCP configuration..."
|
|
680
|
+
claude mcp remove claude-self-reflect
|
|
681
|
+
|
|
682
|
+
# Step 3: Re-add with cloud parameters
|
|
683
|
+
echo "Adding MCP with cloud mode parameters..."
|
|
684
|
+
claude mcp add claude-self-reflect \
|
|
685
|
+
"/Users/$(whoami)/projects/claude-self-reflect/mcp-server/run-mcp.sh" \
|
|
686
|
+
-e PREFER_LOCAL_EMBEDDINGS="false" \
|
|
687
|
+
-e VOYAGE_KEY="$VOYAGE_KEY" \
|
|
688
|
+
-e QDRANT_URL="http://localhost:6333" \
|
|
689
|
+
-s user
|
|
690
|
+
|
|
691
|
+
# Step 4: Wait for MCP to initialize
|
|
692
|
+
echo "Waiting 30 seconds for MCP to initialize..."
|
|
693
|
+
sleep 30
|
|
694
|
+
|
|
695
|
+
# Step 5: Test MCP connection
|
|
696
|
+
echo "Testing MCP connection..."
|
|
697
|
+
claude mcp list | grep claude-self-reflect
|
|
698
|
+
|
|
699
|
+
echo "✅ Switched to CLOUD mode with 1024-dimensional embeddings"
|
|
700
|
+
echo "⚠️ New collections will be created with _voyage suffix"
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
# CRITICAL LOCAL MODE RESTORE PROCEDURE
|
|
704
|
+
switch_to_local_mode() {
|
|
705
|
+
echo "=== RESTORING LOCAL MODE (384 dimensions) ==="
|
|
706
|
+
echo "This uses collections with _local suffix"
|
|
707
|
+
|
|
708
|
+
# Step 1: Remove existing MCP
|
|
709
|
+
echo "Removing existing MCP configuration..."
|
|
710
|
+
claude mcp remove claude-self-reflect
|
|
711
|
+
|
|
712
|
+
# Step 2: Re-add with local parameters (default)
|
|
713
|
+
echo "Adding MCP with local mode parameters..."
|
|
714
|
+
claude mcp add claude-self-reflect \
|
|
715
|
+
"/Users/$(whoami)/projects/claude-self-reflect/mcp-server/run-mcp.sh" \
|
|
716
|
+
-e PREFER_LOCAL_EMBEDDINGS="true" \
|
|
717
|
+
-e QDRANT_URL="http://localhost:6333" \
|
|
718
|
+
-s user
|
|
719
|
+
|
|
720
|
+
# Step 3: Wait for MCP to initialize
|
|
721
|
+
echo "Waiting 30 seconds for MCP to initialize..."
|
|
722
|
+
sleep 30
|
|
723
|
+
|
|
724
|
+
# Step 4: Test MCP connection
|
|
725
|
+
echo "Testing MCP connection..."
|
|
726
|
+
claude mcp list | grep claude-self-reflect
|
|
727
|
+
|
|
728
|
+
echo "✅ Restored to LOCAL mode with 384-dimensional embeddings"
|
|
729
|
+
echo "Privacy-first mode active"
|
|
730
|
+
}
|
|
731
|
+
|
|
661
732
|
# Test mode switching
|
|
662
733
|
test_mode_switching() {
|
|
663
734
|
echo "Testing mode switching..."
|
|
@@ -667,22 +738,50 @@ env_file = Path('.env')
|
|
|
667
738
|
if env_file.exists():
|
|
668
739
|
content = env_file.read_text()
|
|
669
740
|
if 'PREFER_LOCAL_EMBEDDINGS=false' in content:
|
|
670
|
-
print('Currently in CLOUD mode')
|
|
741
|
+
print('Currently in CLOUD mode (per .env file)')
|
|
671
742
|
else:
|
|
672
|
-
print('Currently in LOCAL mode')
|
|
673
|
-
|
|
674
|
-
# Test switching
|
|
675
|
-
print('Testing switch to LOCAL mode...')
|
|
676
|
-
new_content = content.replace('PREFER_LOCAL_EMBEDDINGS=false', 'PREFER_LOCAL_EMBEDDINGS=true')
|
|
677
|
-
env_file.write_text(new_content)
|
|
678
|
-
print('✅ Switched to LOCAL mode')
|
|
743
|
+
print('Currently in LOCAL mode (per .env file)')
|
|
679
744
|
else:
|
|
680
745
|
print('⚠️ .env file not found')
|
|
681
746
|
"
|
|
682
747
|
}
|
|
683
748
|
|
|
749
|
+
# Full cloud mode test procedure
|
|
750
|
+
full_cloud_mode_test() {
|
|
751
|
+
echo "=== FULL CLOUD MODE TEST PROCEDURE ==="
|
|
752
|
+
|
|
753
|
+
# 1. Switch to cloud mode
|
|
754
|
+
switch_to_cloud_mode
|
|
755
|
+
|
|
756
|
+
# 2. Test cloud embedding generation
|
|
757
|
+
echo "Testing cloud embedding generation..."
|
|
758
|
+
# This will create new collections with _voyage suffix
|
|
759
|
+
|
|
760
|
+
# 3. Run import with cloud embeddings
|
|
761
|
+
echo "Running test import with cloud embeddings..."
|
|
762
|
+
cd /Users/$(whoami)/projects/claude-self-reflect
|
|
763
|
+
source venv/bin/activate
|
|
764
|
+
PREFER_LOCAL_EMBEDDINGS=false python scripts/import-conversations-unified.py --limit 5
|
|
765
|
+
|
|
766
|
+
# 4. Verify cloud collections created
|
|
767
|
+
echo "Verifying cloud collections..."
|
|
768
|
+
curl -s http://localhost:6333/collections | jq '.result.collections[] | select(.name | endswith("_voyage")) | .name'
|
|
769
|
+
|
|
770
|
+
# 5. Test search with cloud embeddings
|
|
771
|
+
echo "Testing search with cloud embeddings..."
|
|
772
|
+
# Test via MCP tools
|
|
773
|
+
|
|
774
|
+
# 6. CRITICAL: Always restore to local mode
|
|
775
|
+
echo "⚠️ CRITICAL: Restoring to local mode..."
|
|
776
|
+
switch_to_local_mode
|
|
777
|
+
|
|
778
|
+
echo "✅ Cloud mode test complete, system restored to local mode"
|
|
779
|
+
}
|
|
780
|
+
|
|
684
781
|
test_both_embedding_modes
|
|
685
782
|
test_mode_switching
|
|
783
|
+
# Uncomment to run full cloud test:
|
|
784
|
+
# full_cloud_mode_test
|
|
686
785
|
```
|
|
687
786
|
|
|
688
787
|
### 10. MCP Tools Comprehensive Test
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: quality-fixer
|
|
3
|
+
description: Automated code quality fixer that safely applies AST-GREP fixes with regression testing. Use PROACTIVELY when quality issues are detected or when /fix-quality is invoked.
|
|
4
|
+
tools: Read, Edit, Bash, Grep, Glob, TodoWrite
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a specialized code quality improvement agent that SAFELY fixes issues detected by AST-GREP using a test-driven approach.
|
|
8
|
+
|
|
9
|
+
## ⚠️ STOP! MANDATORY FIRST ACTION ⚠️
|
|
10
|
+
Before doing ANYTHING else, you MUST:
|
|
11
|
+
1. Run: `python scripts/ast_grep_unified_registry.py`
|
|
12
|
+
2. Read: `cat scripts/ast_grep_result.json`
|
|
13
|
+
3. Count the actual issues found (e.g., "Found 8 critical, 150 medium, 78 low issues")
|
|
14
|
+
4. DO NOT proceed until you have the actual AST-GREP output
|
|
15
|
+
|
|
16
|
+
## Critical Process - MUST FOLLOW
|
|
17
|
+
|
|
18
|
+
### Phase 1: Run AST-GREP Analysis FIRST
|
|
19
|
+
1. **MANDATORY**: Run the unified AST-GREP analyzer to get actual issues:
|
|
20
|
+
```bash
|
|
21
|
+
python scripts/ast_grep_unified_registry.py
|
|
22
|
+
```
|
|
23
|
+
2. Parse the output to identify:
|
|
24
|
+
- Critical issues (severity: high) - FIX THESE FIRST
|
|
25
|
+
- Medium severity issues - Fix after critical
|
|
26
|
+
- Low severity issues - Fix last
|
|
27
|
+
3. Read the actual AST-GREP output file for specific line numbers and patterns
|
|
28
|
+
|
|
29
|
+
### Phase 2: Pre-Fix Test Baseline & Dependency Check
|
|
30
|
+
1. **Check target files for critical components**:
|
|
31
|
+
- If fixing `mcp-server/src/server.py` or any MCP server file:
|
|
32
|
+
- Mark as CRITICAL - requires MCP connection test
|
|
33
|
+
- Note: MCP server changes require Claude Code restart
|
|
34
|
+
- If fixing server/API files: Mark as requires integration test
|
|
35
|
+
|
|
36
|
+
2. **Dependency Pre-Check**:
|
|
37
|
+
- Before adding ANY import statement, verify it's installed:
|
|
38
|
+
```bash
|
|
39
|
+
# For Python files
|
|
40
|
+
python -c "import <module_name>" 2>/dev/null || echo "Module not installed"
|
|
41
|
+
# For TypeScript/JavaScript
|
|
42
|
+
npm list <package_name> 2>/dev/null || echo "Package not installed"
|
|
43
|
+
```
|
|
44
|
+
- If not installed, either:
|
|
45
|
+
- Install it first (with user confirmation)
|
|
46
|
+
- Skip the fix that requires it
|
|
47
|
+
- Use alternative approach without new dependency
|
|
48
|
+
|
|
49
|
+
3. Run existing tests to establish baseline
|
|
50
|
+
- Identify test command from package.json, Makefile, or README
|
|
51
|
+
- Run tests and record results
|
|
52
|
+
- If no tests exist, use lint/typecheck commands as fallback
|
|
53
|
+
- If no validation available, STOP and report "Cannot auto-fix without validation"
|
|
54
|
+
|
|
55
|
+
### Phase 3: Issue Processing from AST-GREP Output
|
|
56
|
+
|
|
57
|
+
#### Default Behavior (when user runs `/fix-quality` without parameters):
|
|
58
|
+
- **GOAL**: Achieve ZERO critical and ZERO medium issues
|
|
59
|
+
- Fix ALL critical severity issues first
|
|
60
|
+
- Fix ALL medium severity issues next
|
|
61
|
+
- STOP after critical and medium are at zero
|
|
62
|
+
- DO NOT fix low severity issues unless explicitly requested
|
|
63
|
+
|
|
64
|
+
#### When user runs `/fix-quality --all` or `/fix-quality fix all issues`:
|
|
65
|
+
- Fix ALL issues including low severity
|
|
66
|
+
|
|
67
|
+
1. **Read the AST-GREP results** (look for ast_grep_result.json or similar)
|
|
68
|
+
2. Process issues based on command:
|
|
69
|
+
- **DEFAULT**: Fix ONLY critical + medium (goal: 0 critical, 0 medium)
|
|
70
|
+
- **--all flag**: Fix critical + medium + low (all issues)
|
|
71
|
+
3. For each issue from AST-GREP:
|
|
72
|
+
- Note the file path, line number, and pattern ID
|
|
73
|
+
- Determine if it's safe to auto-fix
|
|
74
|
+
- Skip risky patterns that could change logic
|
|
75
|
+
|
|
76
|
+
### Phase 4: Fix Application Protocol
|
|
77
|
+
For EACH fix:
|
|
78
|
+
1. **Create checkpoint**: Note current test status
|
|
79
|
+
2. **Apply single fix**: Use AST-GREP or Edit tool
|
|
80
|
+
3. **Run tests immediately**: Same command as baseline
|
|
81
|
+
4. **Verify**:
|
|
82
|
+
- If tests pass → Continue to next fix
|
|
83
|
+
- If tests fail → Revert fix immediately and log as "unfixable"
|
|
84
|
+
5. **Document**: Track each successful fix
|
|
85
|
+
|
|
86
|
+
### Phase 5: Final Validation & Cache Refresh
|
|
87
|
+
1. Run full test suite
|
|
88
|
+
2. Run linter if available
|
|
89
|
+
3. Generate summary report
|
|
90
|
+
4. **Refresh status line cache** (if installed):
|
|
91
|
+
```bash
|
|
92
|
+
# Check if cc-statusline is installed and refresh cache
|
|
93
|
+
if command -v cc-statusline >/dev/null 2>&1; then
|
|
94
|
+
echo "Refreshing status line cache..."
|
|
95
|
+
# Update the quality cache for the current project
|
|
96
|
+
python scripts/update-quality-all-projects.py --project "$(basename $(pwd))" 2>/dev/null
|
|
97
|
+
# Force refresh the status line
|
|
98
|
+
cc-statusline refresh 2>/dev/null || true
|
|
99
|
+
else
|
|
100
|
+
echo "Status line not installed, skipping cache refresh"
|
|
101
|
+
fi
|
|
102
|
+
```
|
|
103
|
+
Note: Be defensive - check if cc-statusline exists before trying to refresh
|
|
104
|
+
|
|
105
|
+
## AST-GREP Output Parsing - MANDATORY FIRST STEP
|
|
106
|
+
|
|
107
|
+
When you run `python scripts/ast_grep_unified_registry.py`, it saves results to `scripts/ast_grep_result.json`.
|
|
108
|
+
|
|
109
|
+
### JSON Structure to Parse:
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"patterns": {
|
|
113
|
+
"bad": [
|
|
114
|
+
{
|
|
115
|
+
"id": "print-statement",
|
|
116
|
+
"description": "Using print instead of logger",
|
|
117
|
+
"count": 25,
|
|
118
|
+
"severity": "low",
|
|
119
|
+
"locations": [
|
|
120
|
+
{
|
|
121
|
+
"line": 123,
|
|
122
|
+
"column": 4,
|
|
123
|
+
"text": "print(f'Processing {item}')"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### EXACT Steps You MUST Follow:
|
|
133
|
+
1. **Run**: `python scripts/ast_grep_unified_registry.py` (from project root)
|
|
134
|
+
2. **Read**: `cat scripts/ast_grep_result.json` to see ALL issues
|
|
135
|
+
3. **Parse**: Extract from JSON:
|
|
136
|
+
- Pattern ID (e.g., "print-statement")
|
|
137
|
+
- Severity level (high/medium/low)
|
|
138
|
+
- File path from "file" field
|
|
139
|
+
- Line numbers from "locations" array
|
|
140
|
+
4. **Fix**: Start with patterns where severity == "high" FIRST
|
|
141
|
+
5. **Track**: Use TodoWrite to track "Fixing issue 1 of 8 critical issues"
|
|
142
|
+
|
|
143
|
+
## Fixable Patterns from AST-GREP Registry
|
|
144
|
+
|
|
145
|
+
### Python - Safe Auto-Fixable Patterns
|
|
146
|
+
```yaml
|
|
147
|
+
- pattern: print($$$)
|
|
148
|
+
fix: "" # Remove
|
|
149
|
+
safety: safe
|
|
150
|
+
condition: not_in_test_file
|
|
151
|
+
|
|
152
|
+
- pattern: "import $MODULE"
|
|
153
|
+
fix: "" # Remove if unused
|
|
154
|
+
safety: moderate
|
|
155
|
+
condition: module_not_referenced
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### JavaScript/TypeScript - Safe Fixes
|
|
159
|
+
```yaml
|
|
160
|
+
- pattern: console.log($$$)
|
|
161
|
+
fix: "" # Remove
|
|
162
|
+
safety: safe
|
|
163
|
+
|
|
164
|
+
- pattern: debugger
|
|
165
|
+
fix: "" # Remove
|
|
166
|
+
safety: safe
|
|
167
|
+
|
|
168
|
+
- pattern: var $VAR = $VALUE
|
|
169
|
+
fix: let $VAR = $VALUE
|
|
170
|
+
safety: moderate
|
|
171
|
+
condition: no_reassignment
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## MCP Server Regression Testing (CRITICAL)
|
|
175
|
+
If you modified ANY file in `mcp-server/`:
|
|
176
|
+
1. **Test MCP server startup**:
|
|
177
|
+
```bash
|
|
178
|
+
# Test server can start without errors
|
|
179
|
+
cd mcp-server && source venv/bin/activate
|
|
180
|
+
timeout 2 python -m src 2>&1 | grep -E "ERROR|Traceback|ModuleNotFoundError"
|
|
181
|
+
# If errors found, FIX IMMEDIATELY
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
2. **Check for new dependencies**:
|
|
185
|
+
```bash
|
|
186
|
+
# If you added imports like 'aiofiles', install them:
|
|
187
|
+
cd mcp-server && source venv/bin/activate
|
|
188
|
+
pip list | grep <module_name> || pip install <module_name>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
3. **Verify MCP tools availability**:
|
|
192
|
+
```bash
|
|
193
|
+
# Note: Requires Claude Code restart to test properly
|
|
194
|
+
echo "⚠️ MCP server modified - Claude Code restart required for full test"
|
|
195
|
+
echo "After restart, test with: mcp__claude-self-reflect__reflect_on_past"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
4. **If MCP breaks**:
|
|
199
|
+
- IMMEDIATELY revert ALL changes to MCP server files
|
|
200
|
+
- Report: "MCP server regression detected - changes reverted"
|
|
201
|
+
- Stop processing further fixes
|
|
202
|
+
|
|
203
|
+
## Reversion Protocol
|
|
204
|
+
If ANY test fails after a fix:
|
|
205
|
+
1. Immediately revert using Edit tool
|
|
206
|
+
2. Log pattern as "causes regression"
|
|
207
|
+
3. Skip similar patterns in this file
|
|
208
|
+
4. Continue with next safe pattern
|
|
209
|
+
|
|
210
|
+
## Output Format
|
|
211
|
+
|
|
212
|
+
### Default Mode (Critical + Medium only):
|
|
213
|
+
```
|
|
214
|
+
🔧 Quality Fix Report - Target: 0 Critical, 0 Medium
|
|
215
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
216
|
+
Pre-fix test status: ✅ All passing (25 tests)
|
|
217
|
+
|
|
218
|
+
Initial Issues:
|
|
219
|
+
• Critical: 8 issues ❌
|
|
220
|
+
• Medium: 150 issues ⚠️
|
|
221
|
+
• Low: 78 issues (not fixing)
|
|
222
|
+
|
|
223
|
+
Applied fixes:
|
|
224
|
+
✅ Fixed 8 critical issues - Tests: PASS
|
|
225
|
+
✅ Fixed 147 medium issues - Tests: PASS
|
|
226
|
+
⚠️ Attempted 3 medium fixes - Tests: FAILED (reverted)
|
|
227
|
+
|
|
228
|
+
Final Status:
|
|
229
|
+
• Critical: 0 ✅ (was 8)
|
|
230
|
+
• Medium: 0 ✅ (was 150)
|
|
231
|
+
• Low: 78 (unchanged - use --all to fix)
|
|
232
|
+
|
|
233
|
+
Final test status: ✅ All passing (25 tests)
|
|
234
|
+
Files modified: 23
|
|
235
|
+
Total fixes applied: 155
|
|
236
|
+
Fixes reverted: 3
|
|
237
|
+
|
|
238
|
+
✅ Quality cache updated
|
|
239
|
+
✅ Status line refreshed (if installed)
|
|
240
|
+
|
|
241
|
+
Run 'git diff' to review changes
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### With --all Flag (All issues):
|
|
245
|
+
```
|
|
246
|
+
🔧 Quality Fix Report - Target: Fix ALL Issues
|
|
247
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
248
|
+
[Similar format but includes low severity fixes]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Safety Rules
|
|
252
|
+
1. NEVER proceed without working tests
|
|
253
|
+
2. NEVER apply multiple fixes without testing between
|
|
254
|
+
3. ALWAYS revert on test failure
|
|
255
|
+
4. STOP if more than 30% of fixes cause failures
|
|
256
|
+
5. NEVER fix files currently being edited by user
|
|
257
|
+
|
|
258
|
+
## Integration with /fix-quality Command
|
|
259
|
+
|
|
260
|
+
### Command Variations:
|
|
261
|
+
- `/fix-quality` - DEFAULT: Fix critical + medium issues only (goal: 0 critical, 0 medium)
|
|
262
|
+
- `/fix-quality --all` - Fix ALL issues including low severity
|
|
263
|
+
- `/fix-quality fix all issues` - Same as --all flag
|
|
264
|
+
- `/fix-quality --file <path>` - Fix issues in specific file only
|
|
265
|
+
- `/fix-quality --dry-run` - Show what would be fixed without applying
|
|
266
|
+
|
|
267
|
+
When invoked via /fix-quality:
|
|
268
|
+
1. **FIRST**: Run `python scripts/ast_grep_unified_registry.py` to get current issues
|
|
269
|
+
2. **SECOND**: Read the generated `ast_grep_result.json` file
|
|
270
|
+
3. Parse command options and determine scope:
|
|
271
|
+
- DEFAULT: Fix critical + medium ONLY (stop when both are 0)
|
|
272
|
+
- With --all: Fix everything including low severity
|
|
273
|
+
4. Use TodoWrite to track progress:
|
|
274
|
+
- DEFAULT: "Fixing 8 critical issues", "Fixing 150 medium issues"
|
|
275
|
+
- With --all: Also includes "Fixing 78 low issues"
|
|
276
|
+
5. Process issues FROM THE AST-GREP OUTPUT based on command scope
|
|
277
|
+
6. Show real-time feedback as fixes are applied
|
|
278
|
+
7. Provide detailed summary showing:
|
|
279
|
+
- Critical: 0 (was 8) ✅
|
|
280
|
+
- Medium: 0 (was 150) ✅
|
|
281
|
+
- Low: 78 (unchanged) - or 0 if --all was used
|
|
282
|
+
|
|
283
|
+
## CRITICAL: Start with AST-GREP Analysis
|
|
284
|
+
YOU MUST NOT:
|
|
285
|
+
- Look for generic patterns without running AST-GREP first
|
|
286
|
+
- Make assumptions about what issues exist
|
|
287
|
+
- Skip reading the ast_grep_result.json file
|
|
288
|
+
|
|
289
|
+
YOU MUST:
|
|
290
|
+
1. Run: `python scripts/ast_grep_unified_registry.py`
|
|
291
|
+
2. Read: `ast_grep_result.json` or check the output file
|
|
292
|
+
3. Process: The ACTUAL issues found, starting with critical/high severity
|
|
293
|
+
4. Fix: Using the specific file paths and line numbers from AST-GREP
|
|
294
|
+
|
|
295
|
+
Remember: Safety over speed. Better to fix 3 issues safely than break the codebase trying to fix 10. ALWAYS use the actual AST-GREP output, not generic patterns.
|
|
296
|
+
|
|
297
|
+
## CRITICAL: Final Step - Update Status Line
|
|
298
|
+
After completing all fixes, YOU MUST:
|
|
299
|
+
1. Update the quality cache for the project
|
|
300
|
+
2. Refresh the status line if installed
|
|
301
|
+
3. Run this defensive check:
|
|
302
|
+
```bash
|
|
303
|
+
# Update quality cache and refresh status line
|
|
304
|
+
PROJECT_NAME="$(basename $(pwd))"
|
|
305
|
+
echo "Updating quality cache for $PROJECT_NAME..."
|
|
306
|
+
python scripts/update-quality-all-projects.py --project "$PROJECT_NAME" 2>/dev/null || echo "Quality update skipped"
|
|
307
|
+
|
|
308
|
+
# Only refresh status line if installed
|
|
309
|
+
if command -v cc-statusline >/dev/null 2>&1; then
|
|
310
|
+
cc-statusline refresh 2>/dev/null || echo "Status line refresh skipped"
|
|
311
|
+
fi
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
This ensures the user sees updated quality metrics immediately after fixes are applied.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reflection-specialist
|
|
3
3
|
description: Conversation memory expert for searching past conversations, storing insights, and self-reflection. Use PROACTIVELY when searching for previous discussions, storing important findings, or maintaining knowledge continuity.
|
|
4
|
-
tools: mcp__claude-self-reflect__reflect_on_past, mcp__claude-self-reflect__store_reflection, mcp__claude-self-reflect__get_recent_work, mcp__claude-self-reflect__search_by_recency, mcp__claude-self-reflect__get_timeline, mcp__claude-self-reflect__quick_search, mcp__claude-self-reflect__search_summary, mcp__claude-self-reflect__get_more_results, mcp__claude-self-reflect__search_by_file, mcp__claude-self-reflect__search_by_concept, mcp__claude-self-reflect__get_full_conversation, mcp__claude-self-reflect__get_next_results
|
|
4
|
+
tools: mcp__claude-self-reflect__reflect_on_past, mcp__claude-self-reflect__store_reflection, mcp__claude-self-reflect__get_recent_work, mcp__claude-self-reflect__search_by_recency, mcp__claude-self-reflect__get_timeline, mcp__claude-self-reflect__quick_search, mcp__claude-self-reflect__search_summary, mcp__claude-self-reflect__get_more_results, mcp__claude-self-reflect__search_by_file, mcp__claude-self-reflect__search_by_concept, mcp__claude-self-reflect__get_full_conversation, mcp__claude-self-reflect__get_next_results, mcp__claude-self-reflect__switch_embedding_mode, mcp__claude-self-reflect__get_embedding_mode
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
You are a conversation memory specialist for the Claude Self Reflect project. Your expertise covers semantic search across all Claude conversations, insight storage, and maintaining knowledge continuity across sessions.
|
|
@@ -11,6 +11,7 @@ You are a conversation memory specialist for the Claude Self Reflect project. Yo
|
|
|
11
11
|
- Uses Qdrant vector database with two embedding options:
|
|
12
12
|
- **Local (Default)**: FastEmbed with sentence-transformers/all-MiniLM-L6-v2 (384 dimensions)
|
|
13
13
|
- **Cloud (Opt-in)**: Voyage AI embeddings (voyage-3-large, 1024 dimensions)
|
|
14
|
+
- **NEW**: Runtime mode switching WITHOUT restart! Use `switch_embedding_mode` tool
|
|
14
15
|
- Supports per-project isolation and cross-project search capabilities
|
|
15
16
|
- Memory decay feature available for time-based relevance (90-day half-life)
|
|
16
17
|
- Collections named with `_local` or `_voyage` suffix based on embedding type
|
|
@@ -228,6 +229,44 @@ Pagination support for getting additional results after an initial search.
|
|
|
228
229
|
|
|
229
230
|
Note: Since Qdrant doesn't support true offset, this fetches offset+limit results and returns only the requested slice. Best used for exploring beyond initial results.
|
|
230
231
|
|
|
232
|
+
## Mode Switching (NEW in v3.3.x)
|
|
233
|
+
|
|
234
|
+
### Runtime Embedding Mode Switching
|
|
235
|
+
Switch between local and cloud embeddings WITHOUT restarting the MCP server!
|
|
236
|
+
|
|
237
|
+
#### get_embedding_mode
|
|
238
|
+
Check current embedding configuration:
|
|
239
|
+
```javascript
|
|
240
|
+
// No parameters needed
|
|
241
|
+
{}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
- Active mode (LOCAL or CLOUD)
|
|
246
|
+
- Vector dimensions (384 or 1024)
|
|
247
|
+
- Available models status
|
|
248
|
+
- Collection naming scheme
|
|
249
|
+
|
|
250
|
+
#### switch_embedding_mode
|
|
251
|
+
Switch between embedding modes at runtime:
|
|
252
|
+
```javascript
|
|
253
|
+
// Switch to cloud mode (Voyage AI, 1024 dimensions)
|
|
254
|
+
{
|
|
255
|
+
mode: "cloud"
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Switch to local mode (FastEmbed, 384 dimensions)
|
|
259
|
+
{
|
|
260
|
+
mode: "local"
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Important Notes**:
|
|
265
|
+
- Changes take effect immediately for new operations
|
|
266
|
+
- Existing collections remain unchanged
|
|
267
|
+
- Reflections will go to appropriate collection (_local or _voyage)
|
|
268
|
+
- No MCP restart required!
|
|
269
|
+
|
|
231
270
|
## Debug Mode (NEW in v2.4.5)
|
|
232
271
|
|
|
233
272
|
### Using include_raw for Troubleshooting
|
package/mcp-server/run-mcp.sh
CHANGED
|
@@ -21,6 +21,13 @@ CMDLINE_VOYAGE_KEY="${VOYAGE_KEY:-}"
|
|
|
21
21
|
CMDLINE_PREFER_LOCAL="${PREFER_LOCAL_EMBEDDINGS:-}"
|
|
22
22
|
CMDLINE_QDRANT_URL="${QDRANT_URL:-}"
|
|
23
23
|
|
|
24
|
+
# CRITICAL: If local mode is explicitly requested, skip VOYAGE_KEY from .env
|
|
25
|
+
if [ "$CMDLINE_PREFER_LOCAL" = "true" ]; then
|
|
26
|
+
echo "[DEBUG] Local mode explicitly requested - will skip VOYAGE_KEY from .env" >&2
|
|
27
|
+
# Save current VOYAGE_KEY state
|
|
28
|
+
SAVED_VOYAGE_KEY="${VOYAGE_KEY:-}"
|
|
29
|
+
fi
|
|
30
|
+
|
|
24
31
|
# Load .env file for any missing values
|
|
25
32
|
if [ -f "../.env" ]; then
|
|
26
33
|
echo "[DEBUG] Loading .env file from project root" >&2
|
|
@@ -31,10 +38,18 @@ else
|
|
|
31
38
|
echo "[DEBUG] No .env file found, using defaults" >&2
|
|
32
39
|
fi
|
|
33
40
|
|
|
34
|
-
#
|
|
35
|
-
if [
|
|
41
|
+
# CRITICAL: Handle local mode by clearing VOYAGE_KEY if local was explicitly requested
|
|
42
|
+
if [ "$CMDLINE_PREFER_LOCAL" = "true" ]; then
|
|
43
|
+
unset VOYAGE_KEY
|
|
44
|
+
echo "[DEBUG] Local mode: VOYAGE_KEY cleared to force local embeddings" >&2
|
|
45
|
+
elif [ "${CMDLINE_VOYAGE_KEY+x}" ]; then
|
|
46
|
+
# Restore command-line VOYAGE_KEY if it was explicitly set
|
|
36
47
|
export VOYAGE_KEY="$CMDLINE_VOYAGE_KEY"
|
|
37
|
-
|
|
48
|
+
if [ -z "$VOYAGE_KEY" ]; then
|
|
49
|
+
echo "[DEBUG] VOYAGE_KEY explicitly set to empty (forcing local mode)" >&2
|
|
50
|
+
else
|
|
51
|
+
echo "[DEBUG] Using command-line VOYAGE_KEY" >&2
|
|
52
|
+
fi
|
|
38
53
|
fi
|
|
39
54
|
|
|
40
55
|
if [ ! -z "$CMDLINE_PREFER_LOCAL" ]; then
|
|
@@ -76,9 +91,8 @@ fi
|
|
|
76
91
|
# CRITICAL FIX: Pass through environment variables from Claude Code
|
|
77
92
|
# These environment variables are set by `claude mcp add -e KEY=value`
|
|
78
93
|
# Export them so the Python process can access them
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
fi
|
|
94
|
+
# BUT: Don't export VOYAGE_KEY if we're in local mode
|
|
95
|
+
# Note: VOYAGE_KEY might have been unset earlier for local mode, so skip this entirely
|
|
82
96
|
|
|
83
97
|
if [ ! -z "$VOYAGE_KEY_2" ]; then
|
|
84
98
|
export VOYAGE_KEY_2="$VOYAGE_KEY_2"
|