code-finder 0.1.0__py3-none-any.whl
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.
- claude_context/__init__.py +33 -0
- claude_context/agentic_integration.py +309 -0
- claude_context/ast_chunker.py +646 -0
- claude_context/config.py +239 -0
- claude_context/context_manager.py +627 -0
- claude_context/embeddings.py +307 -0
- claude_context/embeddings_interface.py +226 -0
- claude_context/enhanced_ast_chunker.py +1129 -0
- claude_context/explorer.py +951 -0
- claude_context/explorer_with_context.py +1008 -0
- claude_context/indexer.py +893 -0
- claude_context/markdown_chunker.py +421 -0
- claude_context/mode_handler.py +1774 -0
- claude_context/query_metrics.py +164 -0
- claude_context/question_generator.py +800 -0
- claude_context/readme_extractor.py +485 -0
- claude_context/repository_adapter.py +399 -0
- claude_context/search.py +493 -0
- claude_context/skills/__init__.py +11 -0
- claude_context/skills/_cli_common.py +74 -0
- claude_context/skills/_index_manager.py +98 -0
- claude_context/skills/api_surface.py +219 -0
- claude_context/skills/evidence_retrieval.py +151 -0
- claude_context/skills/grounded_review.py +212 -0
- claude_context/synthesis/__init__.py +8 -0
- claude_context/synthesis/editor_agent.py +391 -0
- claude_context/synthesis/llm_synthesizer.py +153 -0
- claude_context/synthesis/logic_explainer.py +235 -0
- claude_context/synthesis/multi_review_pipeline.py +717 -0
- claude_context/synthesis/prompt_builder.py +439 -0
- claude_context/synthesis/providers.py +115 -0
- claude_context/synthesis/validators.py +458 -0
- code_finder-0.1.0.dist-info/METADATA +823 -0
- code_finder-0.1.0.dist-info/RECORD +37 -0
- code_finder-0.1.0.dist-info/WHEEL +5 -0
- code_finder-0.1.0.dist-info/entry_points.txt +4 -0
- code_finder-0.1.0.dist-info/top_level.txt +1 -0
claude_context/config.py
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Balanced Claude Context Configuration - Practical defaults with fail-fast principles
|
|
3
|
+
|
|
4
|
+
This version keeps useful file extensions while removing over-engineering
|
|
5
|
+
and silent fallbacks.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import List, Optional
|
|
12
|
+
from pymilvus import MilvusClient
|
|
13
|
+
|
|
14
|
+
# Clear, simple logging
|
|
15
|
+
logging.basicConfig(
|
|
16
|
+
level=logging.INFO,
|
|
17
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
18
|
+
)
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class ClaudeContextConfig:
|
|
24
|
+
"""Configuration for Claude Context - practical defaults, no speculation"""
|
|
25
|
+
|
|
26
|
+
# Database
|
|
27
|
+
db_path: str = "./data/milvus_vibe2doc.db"
|
|
28
|
+
collection_name: str = "code_chunks"
|
|
29
|
+
|
|
30
|
+
# Embeddings - start with fast, local model
|
|
31
|
+
# This is for DEVELOPMENT - easily upgradeable to better models:
|
|
32
|
+
# - "all-mpnet-base-v2" (better quality, 420MB)
|
|
33
|
+
# - "BAAI/bge-large-en-v1.5" (state-of-art, 1.3GB)
|
|
34
|
+
# - OpenAI API "text-embedding-3-large" (best, requires API key)
|
|
35
|
+
# - Voyage AI "voyage-code-2" (optimized for code, requires API key)
|
|
36
|
+
embedding_model: str = "all-MiniLM-L6-v2"
|
|
37
|
+
|
|
38
|
+
# Chunking - reasonable defaults based on experience
|
|
39
|
+
chunk_size: int = 1500
|
|
40
|
+
chunk_overlap: int = 200
|
|
41
|
+
|
|
42
|
+
# Search - simple for now
|
|
43
|
+
max_results: int = 10
|
|
44
|
+
|
|
45
|
+
# File patterns - comprehensive but practical
|
|
46
|
+
file_extensions: List[str] = field(default_factory=list)
|
|
47
|
+
ignore_patterns: List[str] = field(default_factory=list)
|
|
48
|
+
|
|
49
|
+
def __post_init__(self):
|
|
50
|
+
"""Initialize with practical defaults"""
|
|
51
|
+
|
|
52
|
+
# Include common programming languages and config files
|
|
53
|
+
# These are languages we're likely to encounter in real projects
|
|
54
|
+
if not self.file_extensions:
|
|
55
|
+
self.file_extensions = [
|
|
56
|
+
# Core languages (most common)
|
|
57
|
+
".py", # Python
|
|
58
|
+
".js", # JavaScript
|
|
59
|
+
".ts", # TypeScript
|
|
60
|
+
".jsx", # React
|
|
61
|
+
".tsx", # React TypeScript
|
|
62
|
+
|
|
63
|
+
# Other common languages
|
|
64
|
+
".java", # Java
|
|
65
|
+
".cpp", # C++
|
|
66
|
+
".c", # C
|
|
67
|
+
".h", # Headers
|
|
68
|
+
".hpp", # C++ headers
|
|
69
|
+
".go", # Go
|
|
70
|
+
".rs", # Rust
|
|
71
|
+
".rb", # Ruby
|
|
72
|
+
".php", # PHP
|
|
73
|
+
".cs", # C#
|
|
74
|
+
|
|
75
|
+
# Documentation
|
|
76
|
+
".md", # Markdown
|
|
77
|
+
".rst", # reStructuredText
|
|
78
|
+
".txt", # Plain text
|
|
79
|
+
|
|
80
|
+
# Configuration
|
|
81
|
+
".json", # JSON
|
|
82
|
+
".yaml", # YAML
|
|
83
|
+
".yml", # YAML
|
|
84
|
+
".toml", # TOML
|
|
85
|
+
".ini", # INI
|
|
86
|
+
".env", # Environment
|
|
87
|
+
".xml", # XML
|
|
88
|
+
|
|
89
|
+
# Web
|
|
90
|
+
".html", # HTML
|
|
91
|
+
".css", # CSS
|
|
92
|
+
|
|
93
|
+
# Shell/Scripts
|
|
94
|
+
".sh", # Shell
|
|
95
|
+
".bash", # Bash
|
|
96
|
+
".ps1", # PowerShell
|
|
97
|
+
".bat", # Batch
|
|
98
|
+
|
|
99
|
+
# Data/Query
|
|
100
|
+
".sql", # SQL
|
|
101
|
+
".graphql", # GraphQL
|
|
102
|
+
]
|
|
103
|
+
# Note: We can easily add more as needed, but these cover 99% of projects
|
|
104
|
+
|
|
105
|
+
# Only ignore things that definitely shouldn't be indexed
|
|
106
|
+
if not self.ignore_patterns:
|
|
107
|
+
self.ignore_patterns = [
|
|
108
|
+
# Version control
|
|
109
|
+
"**/.git/**",
|
|
110
|
+
|
|
111
|
+
# Dependencies (these are huge and not your code)
|
|
112
|
+
"**/node_modules/**",
|
|
113
|
+
"**/venv/**",
|
|
114
|
+
"**/venv_*/**",
|
|
115
|
+
"**/__pycache__/**",
|
|
116
|
+
|
|
117
|
+
# Build outputs
|
|
118
|
+
"**/dist/**",
|
|
119
|
+
"**/build/**",
|
|
120
|
+
|
|
121
|
+
# Generated/archived content
|
|
122
|
+
"**/archive/**",
|
|
123
|
+
"**/docs/generated/**",
|
|
124
|
+
"**/docs/planning/**",
|
|
125
|
+
"**/evaluation/results/**",
|
|
126
|
+
"**/.vibe2doc/**",
|
|
127
|
+
"**/vendor/**",
|
|
128
|
+
|
|
129
|
+
# OS files
|
|
130
|
+
"**/.DS_Store",
|
|
131
|
+
|
|
132
|
+
# Binary files
|
|
133
|
+
"**/*.pyc",
|
|
134
|
+
"**/*.pyo",
|
|
135
|
+
"**/*.so",
|
|
136
|
+
"**/*.dylib",
|
|
137
|
+
"**/*.dll",
|
|
138
|
+
"**/*.exe",
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
# Create data directory - FAIL if we can't
|
|
142
|
+
data_dir = Path(self.db_path).parent
|
|
143
|
+
try:
|
|
144
|
+
data_dir.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
logger.info(f"Data directory ready: {data_dir.absolute()}")
|
|
146
|
+
except Exception as e:
|
|
147
|
+
# FAIL FAST - if we can't create the data dir, something is wrong
|
|
148
|
+
raise RuntimeError(f"Cannot create data directory {data_dir}: {e}")
|
|
149
|
+
|
|
150
|
+
# Validate configuration - FAIL FAST on bad config
|
|
151
|
+
self._validate()
|
|
152
|
+
|
|
153
|
+
def _validate(self):
|
|
154
|
+
"""Validate configuration - fail fast on problems"""
|
|
155
|
+
if self.chunk_size <= 0:
|
|
156
|
+
raise ValueError(f"chunk_size must be positive, got {self.chunk_size}")
|
|
157
|
+
|
|
158
|
+
if self.chunk_overlap >= self.chunk_size:
|
|
159
|
+
raise ValueError(f"chunk_overlap ({self.chunk_overlap}) must be less than chunk_size ({self.chunk_size})")
|
|
160
|
+
|
|
161
|
+
if self.max_results <= 0:
|
|
162
|
+
raise ValueError(f"max_results must be positive, got {self.max_results}")
|
|
163
|
+
|
|
164
|
+
if not self.file_extensions:
|
|
165
|
+
raise ValueError("file_extensions cannot be empty")
|
|
166
|
+
|
|
167
|
+
logger.debug("Configuration validated")
|
|
168
|
+
|
|
169
|
+
def add_extension(self, ext: str):
|
|
170
|
+
"""Add a file extension at runtime if needed"""
|
|
171
|
+
if not ext.startswith('.'):
|
|
172
|
+
ext = f'.{ext}'
|
|
173
|
+
if ext not in self.file_extensions:
|
|
174
|
+
self.file_extensions.append(ext)
|
|
175
|
+
logger.info(f"Added file extension: {ext}")
|
|
176
|
+
|
|
177
|
+
def add_ignore_pattern(self, pattern: str):
|
|
178
|
+
"""Add an ignore pattern at runtime if needed"""
|
|
179
|
+
if pattern not in self.ignore_patterns:
|
|
180
|
+
self.ignore_patterns.append(pattern)
|
|
181
|
+
logger.info(f"Added ignore pattern: {pattern}")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class MilvusManager:
|
|
185
|
+
"""Simple Milvus client manager - fail fast, no silent errors"""
|
|
186
|
+
|
|
187
|
+
def __init__(self, config: ClaudeContextConfig):
|
|
188
|
+
"""Initialize manager - will fail fast if config is invalid"""
|
|
189
|
+
self.config = config
|
|
190
|
+
self.client: Optional[MilvusClient] = None
|
|
191
|
+
logger.info(f"MilvusManager initialized with: {config.db_path}")
|
|
192
|
+
|
|
193
|
+
def get_client(self) -> MilvusClient:
|
|
194
|
+
"""Get or create client - fails fast if connection fails"""
|
|
195
|
+
if not self.client:
|
|
196
|
+
logger.info(f"Creating Milvus client: {self.config.db_path}")
|
|
197
|
+
|
|
198
|
+
# No try/except - if this fails, we want to know
|
|
199
|
+
self.client = MilvusClient(self.config.db_path)
|
|
200
|
+
|
|
201
|
+
# Verify it works - fail fast if not
|
|
202
|
+
collections = self.client.list_collections()
|
|
203
|
+
logger.info(f"✅ Connected. Collections: {collections or 'none'}")
|
|
204
|
+
|
|
205
|
+
return self.client
|
|
206
|
+
|
|
207
|
+
def __enter__(self) -> MilvusClient:
|
|
208
|
+
"""Context manager entry"""
|
|
209
|
+
return self.get_client()
|
|
210
|
+
|
|
211
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
212
|
+
"""Context manager exit - don't hide exceptions"""
|
|
213
|
+
if exc_type:
|
|
214
|
+
logger.error(f"ERROR in MilvusManager: {exc_type.__name__}: {exc_val}")
|
|
215
|
+
# Don't suppress the exception
|
|
216
|
+
return False
|
|
217
|
+
logger.debug("MilvusManager context closed cleanly")
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# Example usage showing the balance
|
|
221
|
+
if __name__ == "__main__":
|
|
222
|
+
print("Testing balanced configuration...")
|
|
223
|
+
|
|
224
|
+
# Create config with good defaults
|
|
225
|
+
config = ClaudeContextConfig()
|
|
226
|
+
print(f"✅ Config created with {len(config.file_extensions)} useful extensions")
|
|
227
|
+
print(f" Covers: Python, JS/TS, Java, Go, Rust, Ruby, configs, docs, etc.")
|
|
228
|
+
|
|
229
|
+
# Show we can easily extend at runtime
|
|
230
|
+
config.add_extension(".vue") # Add Vue files when needed
|
|
231
|
+
config.add_extension("swift") # Add Swift when we encounter iOS code
|
|
232
|
+
|
|
233
|
+
# Test connection - will fail fast if problem
|
|
234
|
+
with MilvusManager(config) as client:
|
|
235
|
+
print("✅ Connected to Milvus")
|
|
236
|
+
collections = client.list_collections()
|
|
237
|
+
print(f" Collections: {collections or 'none'}")
|
|
238
|
+
|
|
239
|
+
print("\n✨ Balanced config: practical defaults + expandability + fail fast!")
|