code2logic 1.0.0__tar.gz → 1.0.1__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 (58) hide show
  1. {code2logic-1.0.0 → code2logic-1.0.1}/.gitignore +3 -0
  2. {code2logic-1.0.0 → code2logic-1.0.1}/CHANGELOG.md +10 -0
  3. {code2logic-1.0.0 → code2logic-1.0.1}/PKG-INFO +41 -1
  4. {code2logic-1.0.0 → code2logic-1.0.1}/README.md +38 -0
  5. code2logic-1.0.1/code2logic/__init__.py +265 -0
  6. code2logic-1.0.1/code2logic/__main__.py +12 -0
  7. code2logic-1.0.1/code2logic/adaptive.py +620 -0
  8. code2logic-1.0.1/code2logic/base.py +69 -0
  9. code2logic-1.0.1/code2logic/benchmark.py +449 -0
  10. code2logic-1.0.1/code2logic/chunked_reproduction.py +444 -0
  11. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/cli.py +149 -8
  12. code2logic-1.0.1/code2logic/code_review.py +272 -0
  13. code2logic-1.0.1/code2logic/config.py +240 -0
  14. code2logic-1.0.1/code2logic/file_formats.py +352 -0
  15. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/generators.py +27 -5
  16. code2logic-1.0.1/code2logic/intent.py +561 -0
  17. code2logic-1.0.1/code2logic/llm_clients.py +272 -0
  18. code2logic-1.0.1/code2logic/logicml.py +370 -0
  19. code2logic-1.0.1/code2logic/markdown_format.py +365 -0
  20. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/mcp_server.py +3 -1
  21. code2logic-1.0.1/code2logic/metrics.py +597 -0
  22. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/models.py +7 -0
  23. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/parsers.py +25 -2
  24. code2logic-1.0.1/code2logic/project_reproducer.py +386 -0
  25. code2logic-1.0.1/code2logic/prompts.py +150 -0
  26. code2logic-1.0.1/code2logic/refactor.py +388 -0
  27. code2logic-1.0.1/code2logic/reproduction.py +440 -0
  28. code2logic-1.0.1/code2logic/universal.py +1067 -0
  29. {code2logic-1.0.0 → code2logic-1.0.1}/pyproject.toml +3 -1
  30. {code2logic-1.0.0 → code2logic-1.0.1}/tests/conftest.py +127 -47
  31. code2logic-1.0.1/tests/samples/sample_algorithms.py +251 -0
  32. code2logic-1.0.1/tests/samples/sample_api.py +138 -0
  33. code2logic-1.0.1/tests/samples/sample_async.py +210 -0
  34. code2logic-1.0.1/tests/samples/sample_class.py +96 -0
  35. code2logic-1.0.1/tests/samples/sample_dataclasses.py +82 -0
  36. code2logic-1.0.1/tests/samples/sample_functions.py +123 -0
  37. code2logic-1.0.1/tests/samples/sample_go.go +119 -0
  38. code2logic-1.0.1/tests/samples/sample_javascript.js +167 -0
  39. code2logic-1.0.1/tests/samples/sample_rust.rs +209 -0
  40. code2logic-1.0.1/tests/samples/sample_sql.sql +93 -0
  41. code2logic-1.0.1/tests/samples/sample_sql_dsl.py +231 -0
  42. code2logic-1.0.1/tests/samples/sample_typescript.ts +141 -0
  43. code2logic-1.0.1/tests/test_analyzer.py +246 -0
  44. code2logic-1.0.1/tests/test_format_specifics.py +260 -0
  45. {code2logic-1.0.0 → code2logic-1.0.1}/tests/test_intent.py +113 -105
  46. code2logic-1.0.1/tests/test_reproduction.py +288 -0
  47. code2logic-1.0.0/code2logic/__init__.py +0 -88
  48. code2logic-1.0.0/code2logic/intent.py +0 -246
  49. code2logic-1.0.0/tests/test_analyzer.py +0 -277
  50. {code2logic-1.0.0 → code2logic-1.0.1}/LICENSE +0 -0
  51. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/analyzer.py +0 -0
  52. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/dependency.py +0 -0
  53. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/gherkin.py +0 -0
  54. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/llm.py +0 -0
  55. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/py.typed +0 -0
  56. {code2logic-1.0.0 → code2logic-1.0.1}/code2logic/similarity.py +0 -0
  57. {code2logic-1.0.0 → code2logic-1.0.1}/tests/__init__.py +0 -0
  58. {code2logic-1.0.0 → code2logic-1.0.1}/tests/test_generators.py +0 -0
@@ -1,3 +1,6 @@
1
+ examples/reproduction/*
2
+ examples/output/*
3
+ bdd_output/*
1
4
  .idea
2
5
  # Byte-compiled / optimized / DLL files
3
6
  __pycache__/
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.1] - 2026-01-03
11
+
12
+ ### Changed
13
+ - Improved benchmark robustness and artifact hygiene in example scripts.
14
+ - Added packaging tools to development extras.
15
+
16
+ ### Fixed
17
+ - Cleaned and hardened benchmark output generation (atomic writes, cleanup of generated artifacts).
18
+ - Improved error reporting in benchmarking and function reproduction examples.
19
+
10
20
  ### Added
11
21
  - Initial release of code2logic
12
22
  - Multi-language code analysis support (Python, JavaScript, Java, C/C++)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code2logic
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Convert source code to logical representation for LLM analysis
5
5
  Project-URL: Homepage, https://github.com/softreck/code2logic
6
6
  Project-URL: Documentation, https://code2logic.readthedocs.io
@@ -30,11 +30,13 @@ Classifier: Typing :: Typed
30
30
  Requires-Python: >=3.9
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: black>=23.0; extra == 'dev'
33
+ Requires-Dist: build>=1.0.0; extra == 'dev'
33
34
  Requires-Dist: mypy>=1.0; extra == 'dev'
34
35
  Requires-Dist: pre-commit>=3.0; extra == 'dev'
35
36
  Requires-Dist: pytest-cov>=4.0; extra == 'dev'
36
37
  Requires-Dist: pytest>=7.0; extra == 'dev'
37
38
  Requires-Dist: ruff>=0.1.0; extra == 'dev'
39
+ Requires-Dist: twine>=4.0.0; extra == 'dev'
38
40
  Provides-Extra: docs
39
41
  Requires-Dist: mkdocs-material>=9.0; extra == 'docs'
40
42
  Requires-Dist: mkdocs>=1.5; extra == 'docs'
@@ -306,6 +308,39 @@ black code2logic
306
308
 
307
309
  Compact format is ~10-15x smaller than Markdown.
308
310
 
311
+ ## 🔬 Code Reproduction Benchmarks
312
+
313
+ Code2Logic can reproduce code from specifications using LLMs. Benchmark results:
314
+
315
+ ### Format Comparison (Token Efficiency)
316
+
317
+ | Format | Score | Token Efficiency | Spec Tokens | Runs OK |
318
+ |--------|-------|------------------|-------------|---------|
319
+ | **YAML** | **71.1%** | 42.1 | **366** | 66.7% |
320
+ | **Markdown** | 65.6% | **48.7** | 385 | **100%** |
321
+ | JSON | 61.9% | 23.7 | 605 | 66.7% |
322
+ | Gherkin | 51.3% | 19.1 | 411 | 66.7% |
323
+
324
+ ### Key Findings
325
+
326
+ - **YAML is best for score** - 71.1% reproduction accuracy
327
+ - **Markdown is best for token efficiency** - 48.7 score/1000 tokens
328
+ - **YAML uses 39.6% fewer tokens than JSON** with 9.2% higher score
329
+ - **Markdown has 100% runs OK** - generated code always executes
330
+
331
+ ### Run Benchmarks
332
+
333
+ ```bash
334
+ # Token-aware benchmark
335
+ python examples/11_token_benchmark.py --folder tests/samples/
336
+
337
+ # Async multi-format benchmark
338
+ python examples/09_async_benchmark.py --folder tests/samples/
339
+
340
+ # Function-level reproduction
341
+ python examples/10_function_reproduction.py --multi-lang
342
+ ```
343
+
309
344
  ## 🤝 Contributing
310
345
 
311
346
  Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
@@ -314,6 +349,11 @@ Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
314
349
 
315
350
  MIT License - see [LICENSE](LICENSE) for details.
316
351
 
352
+ ## 📚 Documentation
353
+
354
+ - [API Documentation](DOCS.md) - Complete API reference
355
+ - [Refactoring Plan](TODO.md) - Development roadmap
356
+
317
357
  ## 🔗 Links
318
358
 
319
359
  - [Documentation](https://code2logic.readthedocs.io)
@@ -240,6 +240,39 @@ black code2logic
240
240
 
241
241
  Compact format is ~10-15x smaller than Markdown.
242
242
 
243
+ ## 🔬 Code Reproduction Benchmarks
244
+
245
+ Code2Logic can reproduce code from specifications using LLMs. Benchmark results:
246
+
247
+ ### Format Comparison (Token Efficiency)
248
+
249
+ | Format | Score | Token Efficiency | Spec Tokens | Runs OK |
250
+ |--------|-------|------------------|-------------|---------|
251
+ | **YAML** | **71.1%** | 42.1 | **366** | 66.7% |
252
+ | **Markdown** | 65.6% | **48.7** | 385 | **100%** |
253
+ | JSON | 61.9% | 23.7 | 605 | 66.7% |
254
+ | Gherkin | 51.3% | 19.1 | 411 | 66.7% |
255
+
256
+ ### Key Findings
257
+
258
+ - **YAML is best for score** - 71.1% reproduction accuracy
259
+ - **Markdown is best for token efficiency** - 48.7 score/1000 tokens
260
+ - **YAML uses 39.6% fewer tokens than JSON** with 9.2% higher score
261
+ - **Markdown has 100% runs OK** - generated code always executes
262
+
263
+ ### Run Benchmarks
264
+
265
+ ```bash
266
+ # Token-aware benchmark
267
+ python examples/11_token_benchmark.py --folder tests/samples/
268
+
269
+ # Async multi-format benchmark
270
+ python examples/09_async_benchmark.py --folder tests/samples/
271
+
272
+ # Function-level reproduction
273
+ python examples/10_function_reproduction.py --multi-lang
274
+ ```
275
+
243
276
  ## 🤝 Contributing
244
277
 
245
278
  Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
@@ -248,6 +281,11 @@ Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
248
281
 
249
282
  MIT License - see [LICENSE](LICENSE) for details.
250
283
 
284
+ ## 📚 Documentation
285
+
286
+ - [API Documentation](DOCS.md) - Complete API reference
287
+ - [Refactoring Plan](TODO.md) - Development roadmap
288
+
251
289
  ## 🔗 Links
252
290
 
253
291
  - [Documentation](https://code2logic.readthedocs.io)
@@ -0,0 +1,265 @@
1
+ """
2
+ Code2Logic - Convert source code to logical representation for LLM analysis.
3
+
4
+ A Python library that analyzes codebases and generates compact, LLM-friendly
5
+ representations with semantic understanding using NLP and AST parsing.
6
+
7
+ Features:
8
+ - Multi-language support (Python, JavaScript, TypeScript, Java, Go, Rust, etc.)
9
+ - Tree-sitter AST parsing for 99% accuracy
10
+ - NetworkX dependency graph analysis with PageRank
11
+ - Rapidfuzz similarity detection for duplicate functions
12
+ - NLP-powered intent extraction from function names and docstrings
13
+
14
+ Example:
15
+ >>> from code2logic import analyze_project, MarkdownGenerator
16
+ >>> project = analyze_project("/path/to/project")
17
+ >>> output = MarkdownGenerator().generate(project)
18
+ >>> print(output)
19
+ """
20
+
21
+ __version__ = "1.0.1"
22
+ __author__ = "Softreck"
23
+ __email__ = "info@softreck.dev"
24
+ __license__ = "MIT"
25
+
26
+ from .analyzer import (
27
+ ProjectAnalyzer,
28
+ analyze_project,
29
+ )
30
+ from .models import (
31
+ FunctionInfo,
32
+ ClassInfo,
33
+ TypeInfo,
34
+ ModuleInfo,
35
+ DependencyNode,
36
+ ProjectInfo,
37
+ )
38
+ from .generators import (
39
+ MarkdownGenerator,
40
+ CompactGenerator,
41
+ JSONGenerator,
42
+ YAMLGenerator,
43
+ CSVGenerator,
44
+ )
45
+ from .gherkin import (
46
+ GherkinGenerator,
47
+ StepDefinitionGenerator,
48
+ CucumberYAMLGenerator,
49
+ csv_to_gherkin,
50
+ gherkin_to_test_data,
51
+ )
52
+ from .intent import EnhancedIntentGenerator
53
+ from .parsers import TreeSitterParser, UniversalParser
54
+ from .dependency import DependencyAnalyzer
55
+ from .similarity import SimilarityDetector
56
+ from .config import Config, load_env, get_api_key, get_model
57
+ from .llm_clients import (
58
+ BaseLLMClient,
59
+ OpenRouterClient,
60
+ OllamaLocalClient,
61
+ LiteLLMClient,
62
+ get_client,
63
+ )
64
+ from .reproduction import (
65
+ generate_file_gherkin,
66
+ compare_code,
67
+ extract_code_block,
68
+ CodeReproducer,
69
+ )
70
+ from .code_review import (
71
+ analyze_code_quality,
72
+ check_security_issues,
73
+ check_performance_issues,
74
+ CodeReviewer,
75
+ )
76
+ from .benchmark import (
77
+ ReproductionBenchmark,
78
+ run_benchmark,
79
+ FormatResult,
80
+ BenchmarkResult,
81
+ )
82
+ from .file_formats import (
83
+ generate_file_csv,
84
+ generate_file_json,
85
+ generate_file_yaml,
86
+ )
87
+ from .adaptive import (
88
+ AdaptiveReproducer,
89
+ AdaptiveResult,
90
+ get_llm_capabilities,
91
+ LLM_CAPABILITIES,
92
+ )
93
+ from .universal import (
94
+ UniversalReproducer,
95
+ UniversalParser,
96
+ CodeGenerator,
97
+ CodeLogic,
98
+ CodeElement,
99
+ Language,
100
+ ElementType,
101
+ reproduce_file,
102
+ )
103
+ from .project_reproducer import (
104
+ ProjectReproducer,
105
+ ProjectResult,
106
+ FileResult,
107
+ reproduce_project,
108
+ )
109
+ from .refactor import (
110
+ find_duplicates,
111
+ analyze_quality,
112
+ suggest_refactoring,
113
+ compare_codebases,
114
+ quick_analyze,
115
+ RefactoringReport,
116
+ DuplicateGroup,
117
+ )
118
+ from .metrics import (
119
+ ReproductionMetrics,
120
+ ReproductionResult,
121
+ TextMetrics,
122
+ StructuralMetrics,
123
+ SemanticMetrics,
124
+ FormatMetrics,
125
+ analyze_reproduction,
126
+ compare_formats,
127
+ )
128
+ from .base import (
129
+ VerboseMixin,
130
+ BaseParser,
131
+ BaseGenerator,
132
+ )
133
+ from .markdown_format import (
134
+ MarkdownHybridGenerator,
135
+ MarkdownSpec,
136
+ generate_markdown_hybrid,
137
+ )
138
+ from .logicml import (
139
+ LogicMLGenerator,
140
+ LogicMLSpec,
141
+ generate_logicml,
142
+ )
143
+ from .prompts import (
144
+ FORMAT_HINTS,
145
+ get_reproduction_prompt,
146
+ get_review_prompt,
147
+ get_fix_prompt,
148
+ )
149
+ from .chunked_reproduction import (
150
+ ChunkedReproducer,
151
+ ChunkedResult,
152
+ ChunkedSpec,
153
+ Chunk,
154
+ chunk_spec,
155
+ auto_chunk_reproduce,
156
+ get_llm_limit,
157
+ )
158
+
159
+ __all__ = [
160
+ # Version
161
+ "__version__",
162
+ # Main API
163
+ "analyze_project",
164
+ "ProjectAnalyzer",
165
+ # Models
166
+ "FunctionInfo",
167
+ "ClassInfo",
168
+ "TypeInfo",
169
+ "ModuleInfo",
170
+ "DependencyNode",
171
+ "ProjectInfo",
172
+ # Generators
173
+ "MarkdownGenerator",
174
+ "CompactGenerator",
175
+ "JSONGenerator",
176
+ "YAMLGenerator",
177
+ "CSVGenerator",
178
+ # Gherkin/BDD
179
+ "GherkinGenerator",
180
+ "StepDefinitionGenerator",
181
+ "CucumberYAMLGenerator",
182
+ "csv_to_gherkin",
183
+ "gherkin_to_test_data",
184
+ # Components
185
+ "EnhancedIntentGenerator",
186
+ "TreeSitterParser",
187
+ "UniversalParser",
188
+ "DependencyAnalyzer",
189
+ "SimilarityDetector",
190
+ # Configuration
191
+ "Config",
192
+ "load_env",
193
+ "get_api_key",
194
+ "get_model",
195
+ # LLM Clients
196
+ "BaseLLMClient",
197
+ "OpenRouterClient",
198
+ "OllamaLocalClient",
199
+ "LiteLLMClient",
200
+ "get_client",
201
+ # Reproduction
202
+ "generate_file_gherkin",
203
+ "compare_code",
204
+ "extract_code_block",
205
+ "CodeReproducer",
206
+ # Code Review
207
+ "analyze_code_quality",
208
+ "check_security_issues",
209
+ "check_performance_issues",
210
+ "CodeReviewer",
211
+ # Benchmark
212
+ "ReproductionBenchmark",
213
+ "run_benchmark",
214
+ "FormatResult",
215
+ "BenchmarkResult",
216
+ # File Formats
217
+ "generate_file_csv",
218
+ "generate_file_json",
219
+ "generate_file_yaml",
220
+ # Adaptive
221
+ "AdaptiveReproducer",
222
+ "AdaptiveResult",
223
+ "get_llm_capabilities",
224
+ "LLM_CAPABILITIES",
225
+ # Universal
226
+ "UniversalReproducer",
227
+ "UniversalParser",
228
+ "CodeGenerator",
229
+ "CodeLogic",
230
+ "CodeElement",
231
+ "Language",
232
+ "ElementType",
233
+ "reproduce_file",
234
+ # Project
235
+ "ProjectReproducer",
236
+ "ProjectResult",
237
+ "FileResult",
238
+ "reproduce_project",
239
+ # Refactoring
240
+ "find_duplicates",
241
+ "analyze_quality",
242
+ "suggest_refactoring",
243
+ "compare_codebases",
244
+ "quick_analyze",
245
+ "RefactoringReport",
246
+ "DuplicateGroup",
247
+ # Metrics
248
+ "ReproductionMetrics",
249
+ "ReproductionResult",
250
+ "TextMetrics",
251
+ "StructuralMetrics",
252
+ "SemanticMetrics",
253
+ "FormatMetrics",
254
+ "analyze_reproduction",
255
+ "compare_formats",
256
+ # Base
257
+ "VerboseMixin",
258
+ "BaseParser",
259
+ "BaseGenerator",
260
+ # Markdown Format
261
+ "MarkdownHybridGenerator",
262
+ "MarkdownSpec",
263
+ "generate_markdown_hybrid",
264
+ "generate_file_markdown",
265
+ ]
@@ -0,0 +1,12 @@
1
+ """
2
+ Allow running code2logic as a module: python -m code2logic
3
+
4
+ Usage:
5
+ python -m code2logic /path/to/project
6
+ python -m code2logic /path/to/project -f gherkin -o tests.feature
7
+ """
8
+
9
+ from .cli import main
10
+
11
+ if __name__ == '__main__':
12
+ main()