socratic-analyzer 0.1.0__tar.gz

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 (25) hide show
  1. socratic_analyzer-0.1.0/LICENSE +21 -0
  2. socratic_analyzer-0.1.0/PKG-INFO +414 -0
  3. socratic_analyzer-0.1.0/README.md +371 -0
  4. socratic_analyzer-0.1.0/pyproject.toml +104 -0
  5. socratic_analyzer-0.1.0/setup.cfg +4 -0
  6. socratic_analyzer-0.1.0/src/socratic_analyzer/__init__.py +42 -0
  7. socratic_analyzer-0.1.0/src/socratic_analyzer/async_client.py +109 -0
  8. socratic_analyzer-0.1.0/src/socratic_analyzer/client.py +475 -0
  9. socratic_analyzer-0.1.0/src/socratic_analyzer/exceptions.py +55 -0
  10. socratic_analyzer-0.1.0/src/socratic_analyzer/models.py +193 -0
  11. socratic_analyzer-0.1.0/src/socratic_analyzer.egg-info/PKG-INFO +414 -0
  12. socratic_analyzer-0.1.0/src/socratic_analyzer.egg-info/SOURCES.txt +23 -0
  13. socratic_analyzer-0.1.0/src/socratic_analyzer.egg-info/dependency_links.txt +1 -0
  14. socratic_analyzer-0.1.0/src/socratic_analyzer.egg-info/requires.txt +22 -0
  15. socratic_analyzer-0.1.0/src/socratic_analyzer.egg-info/top_level.txt +1 -0
  16. socratic_analyzer-0.1.0/tests/test_analyzers.py +435 -0
  17. socratic_analyzer-0.1.0/tests/test_client.py +356 -0
  18. socratic_analyzer-0.1.0/tests/test_langchain_integration.py +181 -0
  19. socratic_analyzer-0.1.0/tests/test_models.py +358 -0
  20. socratic_analyzer-0.1.0/tests/test_openclaw_integration.py +209 -0
  21. socratic_analyzer-0.1.0/tests/test_patterns.py +152 -0
  22. socratic_analyzer-0.1.0/tests/test_performance.py +115 -0
  23. socratic_analyzer-0.1.0/tests/test_performance_benchmarks.py +222 -0
  24. socratic_analyzer-0.1.0/tests/test_quality_scorer.py +223 -0
  25. socratic_analyzer-0.1.0/tests/test_smells.py +185 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Socratic Analyzer Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,414 @@
1
+ Metadata-Version: 2.4
2
+ Name: socratic-analyzer
3
+ Version: 0.1.0
4
+ Summary: Production-grade code analysis package with LLM-powered insights
5
+ Author-email: Socratic Analyzer <info@socratic-analyzer.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Nireus79/Socratic-analyzer
8
+ Project-URL: Documentation, https://github.com/Nireus79/Socratic-analyzer/tree/main/docs
9
+ Project-URL: Repository, https://github.com/Nireus79/Socratic-analyzer.git
10
+ Project-URL: Issues, https://github.com/Nireus79/Socratic-analyzer/issues
11
+ Keywords: code-analysis,static-analysis,metrics,linting,quality,insights
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: socrates-nexus>=0.1.0
26
+ Provides-Extra: openclaw
27
+ Provides-Extra: langchain
28
+ Requires-Dist: langchain>=0.1.0; extra == "langchain"
29
+ Provides-Extra: llm
30
+ Requires-Dist: socrates-nexus>=0.1.0; extra == "llm"
31
+ Provides-Extra: all
32
+ Requires-Dist: langchain>=0.1.0; extra == "all"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
36
+ Requires-Dist: pytest-benchmark>=4.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
38
+ Requires-Dist: black>=23.0; extra == "dev"
39
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
40
+ Requires-Dist: mypy>=1.0; extra == "dev"
41
+ Requires-Dist: langchain>=0.1.0; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # Socratic Analyzer
45
+
46
+ Production-grade code analysis package with LLM-powered insights. Analyze Python code for issues, metrics, patterns, and get intelligent recommendations.
47
+
48
+ [![Python 3.9+](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/downloads/)
49
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
50
+ [![PyPI Status](https://img.shields.io/badge/PyPI-Coming%20Soon-blue.svg)](https://pypi.org/)
51
+
52
+ ## Overview
53
+
54
+ Socratic Analyzer provides automated code analysis with static analysis, complexity metrics, pattern detection, and LLM-powered recommendations. Perfect for code quality assurance, refactoring guidance, and architectural insights.
55
+
56
+ ### Key Features
57
+
58
+ - **Static Code Analysis** - Detect issues, violations, and code smells
59
+ - **Complexity Metrics** - Calculate cyclomatic complexity, maintainability index, and more
60
+ - **Pattern Detection** - Identify antipatterns, design patterns, and performance issues
61
+ - **Security Analysis** - Find potential security vulnerabilities
62
+ - **Documentation Analysis** - Check docstrings and type hints
63
+ - **Project-Wide Analysis** - Aggregate metrics across entire projects
64
+ - **Quality Scoring** - Get overall code quality score (0-100)
65
+ - **LLM Integration** - Get intelligent recommendations via Socrates Nexus
66
+ - **Multiple Formats** - Generate reports in text, JSON, and Markdown
67
+ - **Framework Integration** - Use as Openclaw skill or LangChain tool
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ # Basic installation
73
+ pip install socratic-analyzer
74
+
75
+ # With Openclaw support
76
+ pip install socratic-analyzer[openclaw]
77
+
78
+ # With LangChain support
79
+ pip install socratic-analyzer[langchain]
80
+
81
+ # With all features
82
+ pip install socratic-analyzer[all]
83
+
84
+ # Development
85
+ pip install socratic-analyzer[dev]
86
+ ```
87
+
88
+ ## Quick Start
89
+
90
+ ### Basic File Analysis
91
+
92
+ ```python
93
+ from socratic_analyzer import AnalyzerClient, AnalyzerConfig
94
+
95
+ # Create analyzer
96
+ analyzer = AnalyzerClient(AnalyzerConfig())
97
+
98
+ # Analyze a file
99
+ analysis = analyzer.analyze_file("mycode.py")
100
+
101
+ # Print results
102
+ print(f"Issues: {analysis.total_issues}")
103
+ print(f"Patterns detected: {len(analysis.patterns)}")
104
+
105
+ # Generate report
106
+ report = analyzer.generate_report(analysis, format="text")
107
+ print(report)
108
+ ```
109
+
110
+ ### Project Analysis
111
+
112
+ ```python
113
+ from socratic_analyzer import AnalyzerClient
114
+
115
+ analyzer = AnalyzerClient()
116
+
117
+ # Analyze entire project
118
+ project_analysis = analyzer.analyze_project("./src")
119
+
120
+ print(f"Files analyzed: {project_analysis.files_analyzed}")
121
+ print(f"Total issues: {project_analysis.total_issues}")
122
+ print(f"Quality score: {project_analysis.overall_score:.1f}/100")
123
+
124
+ # Get recommendations
125
+ for recommendation in project_analysis.recommendations:
126
+ print(f"- {recommendation}")
127
+ ```
128
+
129
+ ### LLM-Powered Analysis
130
+
131
+ ```python
132
+ from socratic_analyzer import AnalyzerClient
133
+ from socratic_analyzer.llm import LLMPoweredAnalyzer
134
+ from socrates_nexus import LLMClient
135
+
136
+ # Create components
137
+ analyzer = AnalyzerClient()
138
+ llm_client = LLMClient(provider="anthropic", model="claude-opus")
139
+
140
+ # Create LLM-powered analyzer
141
+ llm_analyzer = LLMPoweredAnalyzer(analyzer, llm_client)
142
+
143
+ # Get analysis with intelligent insights
144
+ result = llm_analyzer.analyze_with_insights("complex_module.py")
145
+ print(result["llm_insights"])
146
+ ```
147
+
148
+ ### Openclaw Integration
149
+
150
+ ```python
151
+ from socratic_analyzer.integrations.openclaw import AnalyzerSkill
152
+
153
+ # Use in Openclaw
154
+ skill = AnalyzerSkill(detailed=True)
155
+ result = skill.analyze("mycode.py")
156
+ ```
157
+
158
+ ### LangChain Integration
159
+
160
+ ```python
161
+ from socratic_analyzer.integrations.langchain import SocraticAnalyzerTool
162
+ from langchain.agents import AgentType, initialize_agent, Tool
163
+ from langchain.llms import OpenAI
164
+
165
+ # Create tool
166
+ analyzer_tool = SocraticAnalyzerTool()
167
+
168
+ # Use in LangChain agent
169
+ tools = [
170
+ Tool(
171
+ name="analyze_code",
172
+ func=analyzer_tool._run,
173
+ description="Analyze Python code for issues and patterns"
174
+ )
175
+ ]
176
+
177
+ agent = initialize_agent(
178
+ tools,
179
+ OpenAI(temperature=0),
180
+ agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
181
+ verbose=True
182
+ )
183
+ ```
184
+
185
+ ## Architecture
186
+
187
+ ### Core Components
188
+
189
+ **Analyzers** - Pluggable analysis strategies:
190
+ - StaticAnalyzer - Code issues and violations
191
+ - ComplexityAnalyzer - Cyclomatic complexity
192
+ - MetricsAnalyzer - Code metrics
193
+ - DocstringAnalyzer - Documentation quality
194
+ - TypeHintAnalyzer - Type hint completeness
195
+ - SecurityAnalyzer - Security issues
196
+
197
+ **Patterns** - Pattern detection:
198
+ - AntipatternDetector - Common antipatterns
199
+ - DesignPatternDetector - Design patterns
200
+ - PerformancePatternDetector - Performance issues
201
+
202
+ **Reports** - Output formats:
203
+ - TextReportFormatter
204
+ - JSONReportFormatter
205
+ - MarkdownReportFormatter
206
+
207
+ **Insights** - Intelligence generation:
208
+ - Scoring system (0-100 quality score)
209
+ - Recommendation generator
210
+ - LLM integration for intelligent insights
211
+
212
+ ## Configuration
213
+
214
+ ```python
215
+ from socratic_analyzer import AnalyzerConfig, AnalyzerClient
216
+
217
+ config = AnalyzerConfig(
218
+ # Analysis options
219
+ analyze_types=True, # Check type hints
220
+ analyze_docstrings=True, # Check documentation
221
+ analyze_security=True, # Check security issues
222
+ analyze_performance=True, # Check performance antipatterns
223
+
224
+ # Thresholds
225
+ max_complexity=10, # Max cyclomatic complexity
226
+ max_line_length=120, # Max line length
227
+ min_docstring_length=10, # Min docstring length
228
+
229
+ # Output
230
+ include_metrics=True,
231
+ include_patterns=True,
232
+ detailed_output=False,
233
+
234
+ # LLM Integration
235
+ use_llm=True,
236
+ llm_provider="anthropic",
237
+ llm_model="claude-opus",
238
+ )
239
+
240
+ analyzer = AnalyzerClient(config)
241
+ ```
242
+
243
+ ## Output Formats
244
+
245
+ ### Text Report
246
+
247
+ ```
248
+ === Analysis Report: example.py ===
249
+
250
+ FILE INFORMATION
251
+ Size: 2,048 bytes
252
+ Lines: 45
253
+
254
+ ISSUES (5 total)
255
+ CRITICAL: example.py:12 - Function 'process_data' is too complex (CC: 15)
256
+ Suggestion: Refactor into smaller functions
257
+
258
+ HIGH: example.py:25 - Unused variable 'temp_result'
259
+
260
+ MEDIUM: example.py:8 - Missing type hints
261
+
262
+ METRICS
263
+ Cyclomatic Complexity: 15 (threshold: 10)
264
+ Maintainability Index: 62.5
265
+
266
+ PATTERNS DETECTED
267
+ - Unused variable pattern
268
+ - Long function pattern
269
+ ```
270
+
271
+ ### JSON Report
272
+
273
+ ```json
274
+ {
275
+ "file_path": "example.py",
276
+ "total_issues": 5,
277
+ "critical_issues": 1,
278
+ "issues": [
279
+ {
280
+ "type": "complexity",
281
+ "severity": "critical",
282
+ "location": "example.py:12",
283
+ "message": "Function too complex",
284
+ "suggestion": "Refactor..."
285
+ }
286
+ ],
287
+ "metrics": [...],
288
+ "overall_score": 62.5
289
+ }
290
+ ```
291
+
292
+ ### Markdown Report
293
+
294
+ ```markdown
295
+ # Analysis Report: example.py
296
+
297
+ ## Summary
298
+ - **Files analyzed**: 1
299
+ - **Issues**: 5 (1 critical, 1 high, 3 medium)
300
+ - **Quality score**: 62.5/100
301
+
302
+ ## Critical Issues
303
+ 1. **Function 'process_data' too complex** (CC: 15)
304
+ - Location: `example.py:12`
305
+ - Suggestion: Refactor into smaller functions
306
+
307
+ ## Recommendations
308
+ - Fix critical issues immediately
309
+ - Address high-severity issues
310
+ ```
311
+
312
+ ## Examples
313
+
314
+ See the `examples/` directory for complete working examples:
315
+
316
+ - `01_basic_analysis.py` - Analyze a single file
317
+ - `02_pattern_detection.py` - Detect code patterns
318
+ - `03_scoring_analysis.py` - Get quality scores
319
+ - `04_project_analysis.py` - Analyze entire projects
320
+ - `05_openclaw_integration.py` - Use as Openclaw skill
321
+ - `06_langchain_integration.py` - Use in LangChain agents
322
+ - `07_llm_powered_analysis.py` - Get LLM insights
323
+
324
+ ## Testing
325
+
326
+ ```bash
327
+ # Run all tests
328
+ pytest
329
+
330
+ # Run with coverage
331
+ pytest --cov=src/socratic_analyzer
332
+
333
+ # Run specific test
334
+ pytest tests/test_models.py::TestAnalyzerConfig
335
+
336
+ # Run benchmarks
337
+ pytest tests/benchmarks/ -v
338
+ ```
339
+
340
+ ## API Reference
341
+
342
+ ### AnalyzerClient
343
+
344
+ Main interface for code analysis.
345
+
346
+ ```python
347
+ class AnalyzerClient:
348
+ def analyze_file(self, file_path: str) -> Analysis
349
+ def analyze_project(self, project_path: str) -> ProjectAnalysis
350
+ def generate_report(self, analysis, format: str) -> str
351
+ ```
352
+
353
+ ### Analysis Model
354
+
355
+ ```python
356
+ @dataclass
357
+ class Analysis:
358
+ file_path: str
359
+ file_size: int
360
+ language: str
361
+ issues: List[CodeIssue]
362
+ metrics: List[MetricResult]
363
+ patterns: List[str]
364
+ timestamp: datetime
365
+ ```
366
+
367
+ ### CodeIssue Model
368
+
369
+ ```python
370
+ @dataclass
371
+ class CodeIssue:
372
+ issue_type: str # "complexity", "style", "security", etc.
373
+ severity: str # "critical", "high", "medium", "low", "info"
374
+ location: str # "file.py:123"
375
+ message: str
376
+ suggestion: Optional[str]
377
+ ```
378
+
379
+ ## Performance
380
+
381
+ Based on benchmarks:
382
+
383
+ - **Single file** (1-5 KB): ~10-50ms
384
+ - **Medium file** (50 KB): ~100-200ms
385
+ - **Large file** (500 KB): ~500ms-1s
386
+ - **Batch operation**: 10-15ms per file
387
+
388
+ ## Integration with Socrates Ecosystem
389
+
390
+ Socratic Analyzer integrates seamlessly with:
391
+
392
+ - **Socrates Nexus** - Multi-provider LLM client for intelligent recommendations
393
+ - **Openclaw** - Available as reusable skill
394
+ - **LangChain** - Available as tool for agents
395
+
396
+ ## Contributing
397
+
398
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
399
+
400
+ ## License
401
+
402
+ MIT License - See [LICENSE](LICENSE) for details.
403
+
404
+ ## Support
405
+
406
+ - GitHub Issues: https://github.com/Nireus79/Socratic-analyzer/issues
407
+ - Documentation: https://github.com/Nireus79/Socratic-analyzer/tree/main/docs
408
+ - Email: info@socratic-analyzer.dev
409
+
410
+ ---
411
+
412
+ **Built with ❤️ as part of the Socrates ecosystem**
413
+
414
+ Made by [@Nireus79](https://github.com/Nireus79)