claude-self-reflect 3.3.0 → 3.3.1

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.
@@ -25,7 +25,12 @@ You are the comprehensive testing specialist for Claude Self-Reflect. You valida
25
25
  - **State Management**: File locking, atomic writes, resume capability
26
26
  - **Search Quality**: Relevance scores, metadata extraction, cross-project search
27
27
  - **Memory Decay**: Client-side and native Qdrant decay
28
- - **Modularization**: Server architecture with 2,835+ lines
28
+ - **Modularization**: Server architecture with search_tools, temporal_tools, reflection_tools, parallel_search modules
29
+ - **Metadata Extraction**: AST patterns, concepts, files analyzed, tools used
30
+ - **Hook System**: session-start, precompact, submit hooks
31
+ - **Sub-Agents**: All 6 specialized agents (reflection, import-debugger, docker, mcp, search, qdrant)
32
+ - **Embedding Modes**: Local (FastEmbed 384d) and Cloud (Voyage AI 1024d) with mode switching
33
+ - **Zero Vector Detection**: Root cause analysis and prevention
29
34
 
30
35
  ### Test Files Knowledge
31
36
  ```
@@ -333,6 +338,74 @@ test_unified_importer() {
333
338
  fi
334
339
  }
335
340
 
341
+ # Test for zero chunks/vectors - CRITICAL
342
+ test_zero_chunks_detection() {
343
+ echo "Testing zero chunks/vectors detection..."
344
+
345
+ # Check recent imports for zero chunks
346
+ IMPORT_LOG=$(python scripts/import-conversations-unified.py --limit 5 2>&1)
347
+
348
+ # Check for zero chunks warnings
349
+ if echo "$IMPORT_LOG" | grep -q "Imported 0 chunks"; then
350
+ echo "❌ CRITICAL: Found imports with 0 chunks!"
351
+ echo " Files producing 0 chunks:"
352
+ echo "$IMPORT_LOG" | grep -B1 "Imported 0 chunks" | grep "import of"
353
+
354
+ # Analyze why chunks are zero
355
+ echo " Analyzing root cause..."
356
+
357
+ # Check for thinking-only content
358
+ PROBLEM_FILE=$(echo "$IMPORT_LOG" | grep -B1 "Imported 0 chunks" | grep "\.jsonl" | head -1 | awk '{print $NF}')
359
+ if [ -n "$PROBLEM_FILE" ]; then
360
+ python -c "
361
+ import json
362
+ file_path = '$PROBLEM_FILE'
363
+ has_thinking = 0
364
+ has_text = 0
365
+ with open(file_path, 'r') as f:
366
+ for line in f:
367
+ data = json.loads(line.strip())
368
+ if 'message' in data and data['message']:
369
+ content = data['message'].get('content', [])
370
+ if isinstance(content, list):
371
+ for item in content:
372
+ if isinstance(item, dict):
373
+ if item.get('type') == 'thinking':
374
+ has_thinking += 1
375
+ elif item.get('type') == 'text':
376
+ has_text += 1
377
+ print(f' Thinking blocks: {has_thinking}')
378
+ print(f' Text blocks: {has_text}')
379
+ if has_thinking > 0 and has_text == 0:
380
+ print(' ⚠️ File has only thinking content - import script may need fix')
381
+ "
382
+ fi
383
+
384
+ # DO NOT CERTIFY WITH ZERO CHUNKS
385
+ echo " ⛔ CERTIFICATION BLOCKED: Fix zero chunks issue before certifying!"
386
+ return 1
387
+ else
388
+ echo "✅ No zero chunks detected in recent imports"
389
+ fi
390
+
391
+ # Also check Qdrant for empty collections
392
+ python -c "
393
+ from qdrant_client import QdrantClient
394
+ client = QdrantClient('http://localhost:6333')
395
+ collections = client.get_collections().collections
396
+ empty_collections = []
397
+ for col in collections:
398
+ count = client.count(collection_name=col.name).count
399
+ if count == 0:
400
+ empty_collections.append(col.name)
401
+ if empty_collections:
402
+ print(f'❌ Found {len(empty_collections)} empty collections: {empty_collections}')
403
+ print(' ⛔ CERTIFICATION BLOCKED: Empty collections detected!')
404
+ else:
405
+ print('✅ All collections have vectors')
406
+ " 2>/dev/null || echo "⚠️ Could not check Qdrant collections"
407
+ }
408
+
336
409
  # Test streaming importer
337
410
  test_streaming_importer() {
338
411
  echo "Testing streaming importer..."
@@ -357,11 +430,262 @@ test_delta_metadata() {
357
430
  }
358
431
 
359
432
  test_unified_importer
433
+ test_zero_chunks_detection # CRITICAL: Must pass before certification
360
434
  test_streaming_importer
361
435
  test_delta_metadata
362
436
  ```
363
437
 
364
- ### 5. MCP Tools Comprehensive Test
438
+ ### 5. Hook System Testing
439
+ ```bash
440
+ #!/bin/bash
441
+ echo "=== HOOK SYSTEM TESTING ==="
442
+
443
+ # Test session-start hook
444
+ test_session_start_hook() {
445
+ echo "Testing session-start hook..."
446
+ HOOK_PATH="$HOME/.claude/hooks/session-start"
447
+ if [ -f "$HOOK_PATH" ]; then
448
+ echo "✅ session-start hook exists"
449
+ # Check if executable
450
+ [ -x "$HOOK_PATH" ] && echo "✅ Hook is executable" || echo "❌ Hook not executable"
451
+ else
452
+ echo "⚠️ session-start hook not configured"
453
+ fi
454
+ }
455
+
456
+ # Test precompact hook
457
+ test_precompact_hook() {
458
+ echo "Testing precompact hook..."
459
+ HOOK_PATH="$HOME/.claude/hooks/precompact"
460
+ if [ -f "$HOOK_PATH" ]; then
461
+ echo "✅ precompact hook exists"
462
+ # Test execution
463
+ timeout 10 "$HOOK_PATH" && echo "✅ Hook executes successfully" || echo "❌ Hook failed"
464
+ else
465
+ echo "⚠️ precompact hook not configured"
466
+ fi
467
+ }
468
+
469
+ test_session_start_hook
470
+ test_precompact_hook
471
+ ```
472
+
473
+ ### 6. Metadata Extraction Testing
474
+ ```bash
475
+ #!/bin/bash
476
+ echo "=== METADATA EXTRACTION TESTING ==="
477
+
478
+ # Test metadata extraction
479
+ test_metadata_extraction() {
480
+ echo "Testing metadata extraction..."
481
+ python -c "
482
+ import json
483
+ from pathlib import Path
484
+
485
+ # Check if metadata is being extracted
486
+ config_dir = Path.home() / '.claude-self-reflect' / 'config'
487
+ delta_state = config_dir / 'delta-update-state.json'
488
+
489
+ if delta_state.exists():
490
+ with open(delta_state) as f:
491
+ state = json.load(f)
492
+ updated = state.get('updated_points', {})
493
+ if updated:
494
+ sample = list(updated.values())[0] if updated else {}
495
+ print(f'✅ Metadata extracted for {len(updated)} points')
496
+ if 'files_analyzed' in str(sample):
497
+ print('✅ files_analyzed metadata present')
498
+ if 'tools_used' in str(sample):
499
+ print('✅ tools_used metadata present')
500
+ if 'concepts' in str(sample):
501
+ print('✅ concepts metadata present')
502
+ if 'code_patterns' in str(sample):
503
+ print('✅ code_patterns (AST) metadata present')
504
+ else:
505
+ print('⚠️ No metadata updates found')
506
+ else:
507
+ print('❌ Delta update state file not found')
508
+ "
509
+ }
510
+
511
+ # Test AST pattern extraction
512
+ test_ast_patterns() {
513
+ echo "Testing AST pattern extraction..."
514
+ TEST_FILE=$(mktemp)
515
+ cat > "$TEST_FILE" << 'EOF'
516
+ import ast
517
+ text = "def test(): return True"
518
+ tree = ast.parse(text)
519
+ patterns = [node.__class__.__name__ for node in ast.walk(tree)]
520
+ print(f"AST patterns: {patterns}")
521
+ EOF
522
+ python "$TEST_FILE"
523
+ rm "$TEST_FILE"
524
+ }
525
+
526
+ test_metadata_extraction
527
+ test_ast_patterns
528
+ ```
529
+
530
+ ### 7. Zero Vector Investigation
531
+ ```bash
532
+ #!/bin/bash
533
+ echo "=== ZERO VECTOR INVESTIGATION ==="
534
+
535
+ test_zero_vectors() {
536
+ python -c "
537
+ import numpy as np
538
+ from qdrant_client import QdrantClient
539
+
540
+ # Connect to Qdrant
541
+ client = QdrantClient('http://localhost:6333')
542
+
543
+ # Check for zero vectors
544
+ collections = client.get_collections().collections
545
+ zero_count = 0
546
+ total_checked = 0
547
+
548
+ for col in collections[:5]: # Check first 5 collections
549
+ try:
550
+ points = client.scroll(
551
+ collection_name=col.name,
552
+ limit=10,
553
+ with_vectors=True
554
+ )[0]
555
+
556
+ for point in points:
557
+ total_checked += 1
558
+ if point.vector:
559
+ if isinstance(point.vector, list) and all(v == 0 for v in point.vector):
560
+ zero_count += 1
561
+ print(f'❌ CRITICAL: Zero vector in {col.name}, point {point.id}')
562
+ elif isinstance(point.vector, dict):
563
+ for vec_name, vec in point.vector.items():
564
+ if all(v == 0 for v in vec):
565
+ zero_count += 1
566
+ print(f'❌ CRITICAL: Zero vector in {col.name}, point {point.id}, vector {vec_name}')
567
+ except Exception as e:
568
+ print(f'⚠️ Error checking {col.name}: {e}')
569
+
570
+ if zero_count == 0:
571
+ print(f'✅ No zero vectors found (checked {total_checked} points)')
572
+ else:
573
+ print(f'❌ Found {zero_count} zero vectors out of {total_checked} points')
574
+ "
575
+ }
576
+
577
+ # Test embedding generation
578
+ test_embedding_generation() {
579
+ echo "Testing embedding generation..."
580
+ python -c "
581
+ try:
582
+ from fastembed import TextEmbedding
583
+ model = TextEmbedding('sentence-transformers/all-MiniLM-L6-v2')
584
+ texts = ['test', 'hello world', '']
585
+
586
+ for text in texts:
587
+ embedding = list(model.embed([text]))[0]
588
+ is_zero = all(v == 0 for v in embedding)
589
+ if is_zero:
590
+ print(f'❌ CRITICAL: Zero embedding for \'{text}\'')
591
+ else:
592
+ import numpy as np
593
+ print(f'✅ Non-zero embedding for \'{text}\' (mean={np.mean(embedding):.4f})')
594
+ except ImportError:
595
+ print('❌ FastEmbed not installed')
596
+ "
597
+ }
598
+
599
+ test_zero_vectors
600
+ test_embedding_generation
601
+ ```
602
+
603
+ ### 8. Sub-Agent Testing
604
+ ```bash
605
+ #!/bin/bash
606
+ echo "=== SUB-AGENT TESTING ==="
607
+
608
+ # List all sub-agents
609
+ test_subagent_availability() {
610
+ echo "Checking sub-agent availability..."
611
+ AGENTS_DIR="$HOME/projects/claude-self-reflect/.claude/agents"
612
+
613
+ EXPECTED_AGENTS=(
614
+ "claude-self-reflect-test.md"
615
+ "import-debugger.md"
616
+ "docker-orchestrator.md"
617
+ "mcp-integration.md"
618
+ "search-optimizer.md"
619
+ "reflection-specialist.md"
620
+ "qdrant-specialist.md"
621
+ )
622
+
623
+ for agent in "${EXPECTED_AGENTS[@]}"; do
624
+ if [ -f "$AGENTS_DIR/$agent" ]; then
625
+ echo "✅ $agent present"
626
+ else
627
+ echo "❌ $agent missing"
628
+ fi
629
+ done
630
+ }
631
+
632
+ test_subagent_availability
633
+ ```
634
+
635
+ ### 9. Embedding Mode Comprehensive Test
636
+ ```bash
637
+ #!/bin/bash
638
+ echo "=== EMBEDDING MODE TESTING ==="
639
+
640
+ # Test both modes
641
+ test_both_embedding_modes() {
642
+ echo "Testing local mode (FastEmbed)..."
643
+ PREFER_LOCAL_EMBEDDINGS=true python -c "
644
+ from mcp_server.src.embedding_manager import get_embedding_manager
645
+ em = get_embedding_manager()
646
+ print(f'Local mode: {em.model_type}, dimension: {em.get_vector_dimension()}')
647
+ "
648
+
649
+ if [ -n "$VOYAGE_KEY" ]; then
650
+ echo "Testing cloud mode (Voyage AI)..."
651
+ PREFER_LOCAL_EMBEDDINGS=false python -c "
652
+ from mcp_server.src.embedding_manager import get_embedding_manager
653
+ em = get_embedding_manager()
654
+ print(f'Cloud mode: {em.model_type}, dimension: {em.get_vector_dimension()}')
655
+ "
656
+ else
657
+ echo "⚠️ VOYAGE_KEY not set, skipping cloud mode test"
658
+ fi
659
+ }
660
+
661
+ # Test mode switching
662
+ test_mode_switching() {
663
+ echo "Testing mode switching..."
664
+ python -c "
665
+ from pathlib import Path
666
+ env_file = Path('.env')
667
+ if env_file.exists():
668
+ content = env_file.read_text()
669
+ if 'PREFER_LOCAL_EMBEDDINGS=false' in content:
670
+ print('Currently in CLOUD mode')
671
+ 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')
679
+ else:
680
+ print('⚠️ .env file not found')
681
+ "
682
+ }
683
+
684
+ test_both_embedding_modes
685
+ test_mode_switching
686
+ ```
687
+
688
+ ### 10. MCP Tools Comprehensive Test
365
689
  ```bash
366
690
  #!/bin/bash
367
691
  echo "=== MCP TOOLS COMPREHENSIVE TEST ==="
@@ -689,17 +1013,97 @@ EOF
689
1013
  echo "✅ Test report generated: $REPORT_FILE"
690
1014
  ```
691
1015
 
1016
+ ## Pre-Test Validation Protocol
1017
+
1018
+ ### Agent Self-Review
1019
+ Before running any tests, I MUST review myself to ensure comprehensive coverage:
1020
+
1021
+ ```bash
1022
+ #!/bin/bash
1023
+ echo "=== PRE-TEST AGENT VALIDATION ==="
1024
+
1025
+ # Review this agent file for completeness
1026
+ review_agent_completeness() {
1027
+ echo "Reviewing CSR-tester agent for missing features..."
1028
+
1029
+ # Check if agent covers all known features
1030
+ AGENT_FILE="$HOME/projects/claude-self-reflect/.claude/agents/claude-self-reflect-test.md"
1031
+
1032
+ REQUIRED_FEATURES=(
1033
+ "15+ MCP tools"
1034
+ "Temporal tools"
1035
+ "Metadata extraction"
1036
+ "Hook system"
1037
+ "Sub-agents"
1038
+ "Embedding modes"
1039
+ "Zero vectors"
1040
+ "Streaming watcher"
1041
+ "Delta metadata"
1042
+ "Import pipeline"
1043
+ "Docker stack"
1044
+ "CLI tool"
1045
+ "State management"
1046
+ "Memory decay"
1047
+ "Parallel search"
1048
+ "Project scoping"
1049
+ "Collection naming"
1050
+ "Dimension validation"
1051
+ "XML escaping"
1052
+ "Error handling"
1053
+ )
1054
+
1055
+ for feature in "${REQUIRED_FEATURES[@]}"; do
1056
+ if grep -qi "$feature" "$AGENT_FILE"; then
1057
+ echo "✅ $feature: Covered"
1058
+ else
1059
+ echo "❌ $feature: MISSING - Add test coverage!"
1060
+ fi
1061
+ done
1062
+ }
1063
+
1064
+ # Discover any new features from codebase
1065
+ discover_new_features() {
1066
+ echo "Scanning for undocumented features..."
1067
+
1068
+ # Check for new MCP tools
1069
+ NEW_TOOLS=$(grep -h "@mcp.tool()" mcp-server/src/*.py 2>/dev/null | wc -l)
1070
+ echo "MCP tools found: $NEW_TOOLS"
1071
+
1072
+ # Check for new scripts
1073
+ NEW_SCRIPTS=$(ls scripts/*.py 2>/dev/null | wc -l)
1074
+ echo "Python scripts found: $NEW_SCRIPTS"
1075
+
1076
+ # Check for new test files
1077
+ NEW_TESTS=$(find tests -name "*.py" 2>/dev/null | wc -l)
1078
+ echo "Test files found: $NEW_TESTS"
1079
+
1080
+ # Check for new hooks
1081
+ if [ -d "$HOME/.claude/hooks" ]; then
1082
+ HOOKS=$(ls "$HOME/.claude/hooks" 2>/dev/null | wc -l)
1083
+ echo "Hooks configured: $HOOKS"
1084
+ fi
1085
+ }
1086
+
1087
+ review_agent_completeness
1088
+ discover_new_features
1089
+ ```
1090
+
692
1091
  ## Test Execution Protocol
693
1092
 
694
1093
  ### Run Complete Test Suite
695
1094
  ```bash
696
1095
  #!/bin/bash
697
- # Master test runner
1096
+ # Master test runner - CSR-tester is the SOLE executor of all tests
698
1097
 
699
1098
  echo "=== CLAUDE SELF-REFLECT COMPLETE TEST SUITE ==="
700
1099
  echo "Starting at: $(date)"
1100
+ echo "Executor: CSR-tester agent (sole test runner)"
701
1101
  echo ""
702
1102
 
1103
+ # Pre-test validation
1104
+ echo "Phase 0: Pre-test Validation..."
1105
+ ./review_agent_completeness.sh
1106
+
703
1107
  # Create test results directory
704
1108
  mkdir -p test-results-$(date +%Y%m%d)
705
1109
  cd test-results-$(date +%Y%m%d)
@@ -725,15 +1129,20 @@ echo "Report: test-report-*.md"
725
1129
  ## Success Criteria
726
1130
 
727
1131
  ### Must Pass
728
- - [ ] All 12 MCP tools functional
1132
+ - [ ] All 15+ MCP tools functional
729
1133
  - [ ] Temporal tools work with proper scoping
730
1134
  - [ ] Timestamp indexes on all collections
731
1135
  - [ ] CLI installs and runs globally
732
1136
  - [ ] Docker containers healthy
733
- - [ ] No critical bugs (native decay, XML injection)
1137
+ - [ ] No critical bugs (native decay, XML injection, dimension mismatch)
734
1138
  - [ ] Search returns relevant results
735
1139
  - [ ] Import pipeline processes files
736
1140
  - [ ] State persists correctly
1141
+ - [ ] NO ZERO VECTORS in any collection
1142
+ - [ ] Metadata extraction working (files, tools, concepts, AST patterns)
1143
+ - [ ] Both embedding modes functional (local 384d, Voyage 1024d)
1144
+ - [ ] Hooks execute properly (session-start, precompact)
1145
+ - [ ] All 6 sub-agents available
737
1146
 
738
1147
  ### Should Pass
739
1148
  - [ ] Performance within limits
@@ -749,12 +1158,18 @@ echo "Report: test-report-*.md"
749
1158
 
750
1159
  ## Final Notes
751
1160
 
752
- This agent knows ALL features of Claude Self-Reflect including:
753
- - New temporal tools
754
- - Project scoping fixes
755
- - Timestamp indexing
756
- - 2,835-line server.py needing modularization
757
- - GPT-5 review recommendations
1161
+ This agent knows ALL features of Claude Self-Reflect v3.3.0 including:
1162
+ - 15+ MCP tools with temporal, search, reflection, pagination capabilities
1163
+ - Modularized architecture (search_tools.py, temporal_tools.py, reflection_tools.py, parallel_search.py)
1164
+ - Metadata extraction (AST patterns, concepts, files analyzed, tools used)
1165
+ - Hook system (session-start, precompact, submit hooks)
1166
+ - 6 specialized sub-agents for different domains
1167
+ - Dual embedding support (FastEmbed 384d, Voyage AI 1024d)
1168
+ - Zero vector detection and prevention
1169
+ - Streaming watcher and delta metadata updater
1170
+ - Project scoping and cross-collection search
1171
+ - Memory decay (client-side with 90-day half-life)
1172
+ - GPT-5 review recommendations and critical fixes
758
1173
  - All test scripts and their purposes
759
1174
 
760
1175
  The agent will ALWAYS restore the system to local mode after testing and provide comprehensive reports suitable for release decisions.
package/installer/cli.js CHANGED
@@ -11,6 +11,7 @@ const __dirname = dirname(__filename);
11
11
  const commands = {
12
12
  setup: 'Run the setup wizard to configure Claude Self-Reflect',
13
13
  status: 'Get indexing status as JSON (overall + per-project breakdown)',
14
+ statusline: 'Configure Claude Code statusline integration',
14
15
  doctor: 'Check your installation and diagnose issues',
15
16
  help: 'Show this help message'
16
17
  };
@@ -192,6 +193,18 @@ function help() {
192
193
  console.log(' Status API: See docs/api-reference.md#cli-status-interface');
193
194
  }
194
195
 
196
+ async function statusline() {
197
+ const StatuslineSetup = (await import('./statusline-setup.js')).default;
198
+ const setup = new StatuslineSetup();
199
+
200
+ if (process.argv[3] === '--restore') {
201
+ console.log('🔄 Restoring original statusline...');
202
+ setup.restore();
203
+ } else {
204
+ await setup.run();
205
+ }
206
+ }
207
+
195
208
  // Main
196
209
  const command = process.argv[2] || 'help';
197
210
 
@@ -202,6 +215,9 @@ switch (command) {
202
215
  case 'status':
203
216
  status();
204
217
  break;
218
+ case 'statusline':
219
+ statusline();
220
+ break;
205
221
  case 'doctor':
206
222
  doctor();
207
223
  break;
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { fileURLToPath } from 'url';
4
4
  import { dirname, join } from 'path';
5
+ import StatuslineSetup from './statusline-setup.js';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = dirname(__filename);
@@ -10,4 +11,17 @@ const __dirname = dirname(__filename);
10
11
  if (!process.cwd().includes('claude-self-reflect')) {
11
12
  console.log('\n🎉 Claude Self-Reflect installed!\n');
12
13
  console.log('Run "claude-self-reflect setup" to configure your installation.\n');
14
+
15
+ // Attempt to setup statusline integration automatically
16
+ console.log('\n📊 Setting up Claude Code statusline integration...');
17
+ const statuslineSetup = new StatuslineSetup();
18
+ statuslineSetup.run().then(success => {
19
+ if (success) {
20
+ console.log('✅ Statusline integration configured automatically!');
21
+ } else {
22
+ console.log('⚠️ Statusline integration requires manual setup. Run "claude-self-reflect setup" for help.');
23
+ }
24
+ }).catch(error => {
25
+ console.log('⚠️ Statusline setup skipped:', error.message);
26
+ });
13
27
  }