code2logic 1.0.5__tar.gz → 1.0.7__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 (92) hide show
  1. code2logic-1.0.7/PKG-INFO +674 -0
  2. {code2logic-1.0.5 → code2logic-1.0.7}/README.md +34 -15
  3. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/__init__.py +20 -6
  4. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/analyzer.py +17 -3
  5. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/benchmarks/results.py +6 -7
  6. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/benchmarks/runner.py +24 -4
  7. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/cli.py +144 -13
  8. code2logic-1.0.7/code2logic/generators.py +1987 -0
  9. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/logicml.py +21 -39
  10. code2logic-1.0.7/code2logic/models.py +337 -0
  11. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/parsers.py +545 -78
  12. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/project_reproducer.py +18 -3
  13. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/schemas/yaml_schema.py +62 -27
  14. code2logic-1.0.7/code2logic/shared_utils.py +414 -0
  15. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/toon_format.py +247 -13
  16. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/universal.py +9 -2
  17. {code2logic-1.0.5 → code2logic-1.0.7}/pyproject.toml +6 -4
  18. code2logic-1.0.7/tests/test_parser_integrity.py +307 -0
  19. code2logic-1.0.7/tests/test_shared_utils.py +325 -0
  20. code2logic-1.0.7/tests/test_yaml_compact.py +240 -0
  21. code2logic-1.0.5/PKG-INFO +0 -455
  22. code2logic-1.0.5/code2logic/generators.py +0 -1084
  23. code2logic-1.0.5/code2logic/models.py +0 -177
  24. {code2logic-1.0.5 → code2logic-1.0.7}/.gitignore +0 -0
  25. {code2logic-1.0.5 → code2logic-1.0.7}/CHANGELOG.md +0 -0
  26. {code2logic-1.0.5 → code2logic-1.0.7}/LICENSE +0 -0
  27. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/__main__.py +0 -0
  28. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/adaptive.py +0 -0
  29. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/base.py +0 -0
  30. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/benchmark.py +0 -0
  31. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/benchmarks/__init__.py +0 -0
  32. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/benchmarks/common.py +0 -0
  33. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/chunked_reproduction.py +0 -0
  34. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/code_review.py +0 -0
  35. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/config.py +0 -0
  36. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/core/__init__.py +0 -0
  37. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/dependency.py +0 -0
  38. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/errors.py +0 -0
  39. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/file_formats.py +0 -0
  40. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/formats/__init__.py +0 -0
  41. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/gherkin.py +0 -0
  42. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/integrations/__init__.py +0 -0
  43. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/intent.py +0 -0
  44. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/llm/__init__.py +0 -0
  45. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/llm.py +0 -0
  46. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/llm_clients.py +0 -0
  47. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/llm_profiler.py +0 -0
  48. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/markdown_format.py +0 -0
  49. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/mcp_server.py +0 -0
  50. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/metrics.py +0 -0
  51. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/prompts.py +0 -0
  52. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/py.typed +0 -0
  53. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/quality.py +0 -0
  54. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/refactor.py +0 -0
  55. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/reproducer.py +0 -0
  56. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/reproduction.py +0 -0
  57. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/schemas/__init__.py +0 -0
  58. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/schemas/json_schema.py +0 -0
  59. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/schemas/logicml_schema.py +0 -0
  60. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/schemas/markdown_schema.py +0 -0
  61. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/similarity.py +0 -0
  62. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/terminal.py +0 -0
  63. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/tools/__init__.py +0 -0
  64. {code2logic-1.0.5 → code2logic-1.0.7}/code2logic/utils.py +0 -0
  65. {code2logic-1.0.5 → code2logic-1.0.7}/tests/__init__.py +0 -0
  66. {code2logic-1.0.5 → code2logic-1.0.7}/tests/conftest.py +0 -0
  67. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_algorithms.py +0 -0
  68. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_api.py +0 -0
  69. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_async.py +0 -0
  70. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_class.py +0 -0
  71. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_dataclasses.py +0 -0
  72. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_enum.py +0 -0
  73. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_functions.py +0 -0
  74. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_go.go +0 -0
  75. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_javascript.js +0 -0
  76. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_pydantic.py +0 -0
  77. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_reexport/__init__.py +0 -0
  78. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_reexport/exceptions.py +0 -0
  79. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_reexport/models.py +0 -0
  80. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_reexport/utils.py +0 -0
  81. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_rust.rs +0 -0
  82. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_sql.sql +0 -0
  83. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_sql_dsl.py +0 -0
  84. {code2logic-1.0.5 → code2logic-1.0.7}/tests/samples/sample_typescript.ts +0 -0
  85. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_analyzer.py +0 -0
  86. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_error_handling.py +0 -0
  87. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_formats.py +0 -0
  88. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_generators.py +0 -0
  89. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_intent.py +0 -0
  90. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_llm_priority.py +0 -0
  91. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_llm_profiler.py +0 -0
  92. {code2logic-1.0.5 → code2logic-1.0.7}/tests/test_reproduction.py +0 -0
@@ -0,0 +1,674 @@
1
+ Metadata-Version: 2.4
2
+ Name: code2logic
3
+ Version: 1.0.7
4
+ Summary: Convert source code to logical representation for LLM analysis
5
+ Project-URL: Homepage, https://github.com/wronai/code2logic
6
+ Project-URL: Documentation, https://code2logic.readthedocs.io
7
+ Project-URL: Repository, https://github.com/wronai/code2logic.git
8
+ Project-URL: Issues, https://github.com/wronai/code2logic/issues
9
+ Project-URL: Changelog, https://github.com/wronai/code2logic/blob/main/CHANGELOG.md
10
+ Author-email: Softreck <info@softreck.dev>
11
+ Maintainer-email: Softreck <info@softreck.dev>
12
+ License: Apache License
13
+ Version 2.0, January 2004
14
+ http://www.apache.org/licenses/
15
+
16
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
17
+
18
+ 1. Definitions.
19
+
20
+ "License" shall mean the terms and conditions for use, reproduction,
21
+ and distribution as defined by Sections 1 through 9 of this document.
22
+
23
+ "Licensor" shall mean the copyright owner or entity authorized by
24
+ the copyright owner that is granting the License.
25
+
26
+ "Legal Entity" shall mean the union of the acting entity and all
27
+ other entities that control, are controlled by, or are under common
28
+ control with that entity. For the purposes of this definition,
29
+ "control" means (i) the power, direct or indirect, to cause the
30
+ direction or management of such entity, whether by contract or
31
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
32
+ outstanding shares, or (iii) beneficial ownership of such entity.
33
+
34
+ "You" (or "Your") shall mean an individual or Legal Entity
35
+ exercising permissions granted by this License.
36
+
37
+ "Source" form shall mean the preferred form for making modifications,
38
+ including but not limited to software source code, documentation
39
+ source, and configuration files.
40
+
41
+ "Object" form shall mean any form resulting from mechanical
42
+ transformation or translation of a Source form, including but
43
+ not limited to compiled object code, generated documentation,
44
+ and conversions to other media types.
45
+
46
+ "Work" shall mean the work of authorship, whether in Source or
47
+ Object form, made available under the License, as indicated by a
48
+ copyright notice that is included in or attached to the work
49
+ (an example is provided in the Appendix below).
50
+
51
+ "Derivative Works" shall mean any work, whether in Source or Object
52
+ form, that is based on (or derived from) the Work and for which the
53
+ editorial revisions, annotations, elaborations, or other modifications
54
+ represent, as a whole, an original work of authorship. For the purposes
55
+ of this License, Derivative Works shall not include works that remain
56
+ separable from, or merely link (or bind by name) to the interfaces of,
57
+ the Work and Derivative Works thereof.
58
+
59
+ "Contribution" shall mean any work of authorship, including
60
+ the original version of the Work and any modifications or additions
61
+ to that Work or Derivative Works thereof, that is intentionally
62
+ submitted to Licensor for inclusion in the Work by the copyright owner
63
+ or by an individual or Legal Entity authorized to submit on behalf of
64
+ the copyright owner. For the purposes of this definition, "submitted"
65
+ means any form of electronic, verbal, or written communication sent
66
+ to the Licensor or its representatives, including but not limited to
67
+ communication on electronic mailing lists, source code control systems,
68
+ and issue tracking systems that are managed by, or on behalf of, the
69
+ Licensor for the purpose of discussing and improving the Work, but
70
+ excluding communication that is conspicuously marked or otherwise
71
+ designated in writing by the copyright owner as "Not a Contribution."
72
+
73
+ "Contributor" shall mean Licensor and any individual or Legal Entity
74
+ on behalf of whom a Contribution has been received by Licensor and
75
+ subsequently incorporated within the Work.
76
+
77
+ 2. Grant of Copyright License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ copyright license to reproduce, prepare Derivative Works of,
81
+ publicly display, publicly perform, sublicense, and distribute the
82
+ Work and such Derivative Works in Source or Object form.
83
+
84
+ 3. Grant of Patent License. Subject to the terms and conditions of
85
+ this License, each Contributor hereby grants to You a perpetual,
86
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
87
+ (except as stated in this section) patent license to make, have made,
88
+ use, offer to sell, sell, import, and otherwise transfer the Work,
89
+ where such license applies only to those patent claims licensable
90
+ by such Contributor that are necessarily infringed by their
91
+ Contribution(s) alone or by combination of their Contribution(s)
92
+ with the Work to which such Contribution(s) was submitted. If You
93
+ institute patent litigation against any entity (including a
94
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
95
+ or a Contribution incorporated within the Work constitutes direct
96
+ or contributory patent infringement, then any patent licenses
97
+ granted to You under this License for that Work shall terminate
98
+ as of the date such litigation is filed.
99
+
100
+ 4. Redistribution. You may reproduce and distribute copies of the
101
+ Work or Derivative Works thereof in any medium, with or without
102
+ modifications, and in Source or Object form, provided that You
103
+ meet the following conditions:
104
+
105
+ (a) You must give any other recipients of the Work or
106
+ Derivative Works a copy of this License; and
107
+
108
+ (b) You must cause any modified files to carry prominent notices
109
+ stating that You changed the files; and
110
+
111
+ (c) You must retain, in the Source form of any Derivative Works
112
+ that You distribute, all copyright, patent, trademark, and
113
+ attribution notices from the Source form of the Work,
114
+ excluding those notices that do not pertain to any part of
115
+ the Derivative Works; and
116
+
117
+ (d) If the Work includes a "NOTICE" text file as part of its
118
+ distribution, then any Derivative Works that You distribute must
119
+ include a readable copy of the attribution notices contained
120
+ within such NOTICE file, excluding those notices that do not
121
+ pertain to any part of the Derivative Works, in at least one
122
+ of the following places: within a NOTICE text file distributed
123
+ as part of the Derivative Works; within the Source form or
124
+ documentation, if provided along with the Derivative Works; or,
125
+ within a display generated by the Derivative Works, if and
126
+ wherever such third-party notices normally appear. The contents
127
+ of the NOTICE file are for informational purposes only and
128
+ do not modify the License. You may add Your own attribution
129
+ notices within Derivative Works that You distribute, alongside
130
+ or as an addendum to the NOTICE text from the Work, provided
131
+ that such additional attribution notices cannot be construed
132
+ as modifying the License.
133
+
134
+ You may add Your own copyright statement to Your modifications and
135
+ may provide additional or different license terms and conditions
136
+ for use, reproduction, or distribution of Your modifications, or
137
+ for any such Derivative Works as a whole, provided Your use,
138
+ reproduction, and distribution of the Work otherwise complies with
139
+ the conditions stated in this License.
140
+
141
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
142
+ any Contribution intentionally submitted for inclusion in the Work
143
+ by You to the Licensor shall be under the terms and conditions of
144
+ this License, without any additional terms or conditions.
145
+ Notwithstanding the above, nothing herein shall supersede or modify
146
+ the terms of any separate license agreement you may have executed
147
+ with Licensor regarding such Contributions.
148
+
149
+ 6. Trademarks. This License does not grant permission to use the trade
150
+ names, trademarks, service marks, or product names of the Licensor,
151
+ except as required for reasonable and customary use in describing the
152
+ origin of the Work and reproducing the content of the NOTICE file.
153
+
154
+ 7. Disclaimer of Warranty. Unless required by applicable law or
155
+ agreed to in writing, Licensor provides the Work (and each
156
+ Contributor provides its Contributions) on an "AS IS" BASIS,
157
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
158
+ implied, including, without limitation, any warranties or conditions
159
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
160
+ PARTICULAR PURPOSE. You are solely responsible for determining the
161
+ appropriateness of using or redistributing the Work and assume any
162
+ risks associated with Your exercise of permissions under this License.
163
+
164
+ 8. Limitation of Liability. In no event and under no legal theory,
165
+ whether in tort (including negligence), contract, or otherwise,
166
+ unless required by applicable law (such as deliberate and grossly
167
+ negligent acts) or agreed to in writing, shall any Contributor be
168
+ liable to You for damages, including any direct, indirect, special,
169
+ incidental, or consequential damages of any character arising as a
170
+ result of this License or out of the use or inability to use the
171
+ Work (including but not limited to damages for loss of goodwill,
172
+ work stoppage, computer failure or malfunction, or any and all
173
+ other commercial damages or losses), even if such Contributor
174
+ has been advised of the possibility of such damages.
175
+
176
+ 9. Accepting Warranty or Additional Liability. While redistributing
177
+ the Work or Derivative Works thereof, You may choose to offer,
178
+ and charge a fee for, acceptance of support, warranty, indemnity,
179
+ or other liability obligations and/or rights consistent with this
180
+ License. However, in accepting such obligations, You may act only
181
+ on Your own behalf and on Your sole responsibility, not on behalf
182
+ of any other Contributor, and only if You agree to indemnify,
183
+ defend, and hold each Contributor harmless for any liability
184
+ incurred by, or claims asserted against, such Contributor by reason
185
+ of your accepting any such warranty or additional liability.
186
+
187
+ END OF TERMS AND CONDITIONS
188
+
189
+ APPENDIX: How to apply the Apache License to your work.
190
+
191
+ To apply the Apache License to your work, attach the following
192
+ boilerplate notice, with the fields enclosed by brackets "[]"
193
+ replaced with your own identifying information. (Don't include
194
+ the brackets!) The text should be enclosed in the appropriate
195
+ comment syntax for the file format. We also recommend that a
196
+ file or class name and description of purpose be included on the
197
+ same "printed page" as the copyright notice for easier
198
+ identification within third-party archives.
199
+
200
+ Copyright [yyyy] [name of copyright owner]
201
+
202
+ Licensed under the Apache License, Version 2.0 (the "License");
203
+ you may not use this file except in compliance with the License.
204
+ You may obtain a copy of the License at
205
+
206
+ http://www.apache.org/licenses/LICENSE-2.0
207
+
208
+ Unless required by applicable law or agreed to in writing, software
209
+ distributed under the License is distributed on an "AS IS" BASIS,
210
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
211
+ See the License for the specific language governing permissions and
212
+ limitations under the License.
213
+ License-File: LICENSE
214
+ Keywords: ast,code-analysis,code-understanding,dependency-graph,documentation,llm,nlp,static-analysis,tree-sitter
215
+ Classifier: Development Status :: 4 - Beta
216
+ Classifier: Environment :: Console
217
+ Classifier: Intended Audience :: Developers
218
+ Classifier: License :: OSI Approved :: Apache Software License
219
+ Classifier: Operating System :: OS Independent
220
+ Classifier: Programming Language :: Python :: 3
221
+ Classifier: Programming Language :: Python :: 3.9
222
+ Classifier: Programming Language :: Python :: 3.10
223
+ Classifier: Programming Language :: Python :: 3.11
224
+ Classifier: Programming Language :: Python :: 3.12
225
+ Classifier: Topic :: Software Development :: Documentation
226
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
227
+ Classifier: Topic :: Software Development :: Quality Assurance
228
+ Classifier: Topic :: Text Processing :: Linguistic
229
+ Classifier: Typing :: Typed
230
+ Requires-Python: >=3.9
231
+ Provides-Extra: dev
232
+ Requires-Dist: black>=23.0; extra == 'dev'
233
+ Requires-Dist: build>=1.0.0; extra == 'dev'
234
+ Requires-Dist: bumpver>=2023.1129; extra == 'dev'
235
+ Requires-Dist: mypy>=1.0; extra == 'dev'
236
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
237
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
238
+ Requires-Dist: pytest>=7.0; extra == 'dev'
239
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
240
+ Requires-Dist: twine>=4.0.0; extra == 'dev'
241
+ Provides-Extra: docs
242
+ Requires-Dist: mkdocs-material>=9.0; extra == 'docs'
243
+ Requires-Dist: mkdocs>=1.5; extra == 'docs'
244
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
245
+ Provides-Extra: full
246
+ Requires-Dist: networkx>=3.0; extra == 'full'
247
+ Requires-Dist: nltk>=3.8; extra == 'full'
248
+ Requires-Dist: pyyaml>=6.0; extra == 'full'
249
+ Requires-Dist: rapidfuzz>=3.0; extra == 'full'
250
+ Requires-Dist: tree-sitter-javascript>=0.21.0; extra == 'full'
251
+ Requires-Dist: tree-sitter-python>=0.21.0; extra == 'full'
252
+ Requires-Dist: tree-sitter-typescript>=0.21.0; extra == 'full'
253
+ Requires-Dist: tree-sitter>=0.21.0; extra == 'full'
254
+ Provides-Extra: graph
255
+ Requires-Dist: networkx>=3.0; extra == 'graph'
256
+ Provides-Extra: llm
257
+ Requires-Dist: httpx>=0.25.0; extra == 'llm'
258
+ Requires-Dist: litellm>=1.0.0; extra == 'llm'
259
+ Provides-Extra: nlp
260
+ Requires-Dist: nltk>=3.8; extra == 'nlp'
261
+ Provides-Extra: similarity
262
+ Requires-Dist: rapidfuzz>=3.0; extra == 'similarity'
263
+ Provides-Extra: treesitter
264
+ Requires-Dist: tree-sitter-javascript>=0.21.0; extra == 'treesitter'
265
+ Requires-Dist: tree-sitter-python>=0.21.0; extra == 'treesitter'
266
+ Requires-Dist: tree-sitter-typescript>=0.21.0; extra == 'treesitter'
267
+ Requires-Dist: tree-sitter>=0.21.0; extra == 'treesitter'
268
+ Description-Content-Type: text/markdown
269
+
270
+ # Code2Logic
271
+
272
+ [![PyPI version](https://badge.fury.io/py/code2logic.svg)](https://badge.fury.io/py/code2logic)
273
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
274
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-yellow.svg)](https://www.apache.org/licenses/LICENSE-2.0)
275
+
276
+ **Convert source code to logical representation for LLM analysis.**
277
+
278
+ Code2Logic analyzes codebases and generates compact, LLM-friendly representations with semantic understanding.
279
+ Perfect for feeding project context to AI assistants, building code documentation, or analyzing code structure.
280
+
281
+ ## ✨ Features
282
+
283
+ - 🌳 **Multi-language support** - Python, JavaScript, TypeScript, Java, Go, Rust, and more
284
+ - 🎯 **Tree-sitter AST parsing** - 99% accuracy with graceful fallback
285
+ - 📊 **NetworkX dependency graphs** - PageRank, hub detection, cycle analysis
286
+ - 🔍 **Rapidfuzz similarity** - Find duplicate and similar functions
287
+ - 🧠 **NLP intent extraction** - Human-readable function descriptions
288
+ - 📦 **Zero dependencies** - Core works without any external libs
289
+
290
+ ## 🚀 Installation
291
+
292
+ ### Basic (no dependencies)
293
+
294
+ ```bash
295
+ pip install code2logic
296
+ ```
297
+
298
+ ### Full (all features)
299
+
300
+ ```bash
301
+ pip install code2logic[full]
302
+ ```
303
+
304
+ ### Selective features
305
+
306
+ ```bash
307
+ pip install code2logic[treesitter] # High-accuracy AST parsing
308
+ pip install code2logic[graph] # Dependency analysis
309
+ pip install code2logic[similarity] # Similar function detection
310
+ pip install code2logic[nlp] # Enhanced intents
311
+ ```
312
+
313
+ ## 📖 Quick Start
314
+
315
+ ### Command Line
316
+
317
+ ```bash
318
+ # Standard Markdown output
319
+ code2logic /path/to/project
320
+
321
+ # Compact YAML (14% smaller, meta.legend transparency)
322
+ code2logic /path/to/project -f yaml --compact -o analysis-compact.yaml
323
+
324
+ # Ultra-compact TOON (71% smaller, single-letter keys)
325
+ code2logic /path/to/project -f toon --ultra-compact -o analysis-ultra.toon
326
+
327
+ # Generate schema alongside output
328
+ code2logic /path/to/project -f yaml --compact --with-schema
329
+
330
+ # With detailed analysis
331
+ code2logic /path/to/project -d detailed
332
+ ```
333
+
334
+ ### Python API
335
+
336
+ ```python
337
+ from code2logic import analyze_project, MarkdownGenerator
338
+
339
+ # Analyze a project
340
+ project = analyze_project("/path/to/project")
341
+
342
+ # Generate output
343
+ generator = MarkdownGenerator()
344
+ output = generator.generate(project, detail_level='standard')
345
+ print(output)
346
+
347
+ # Access analysis results
348
+ print(f"Files: {project.total_files}")
349
+ print(f"Lines: {project.total_lines}")
350
+ print(f"Languages: {project.languages}")
351
+
352
+ # Get hub modules (most important)
353
+ hubs = [p for p, n in project.dependency_metrics.items() if n.is_hub]
354
+ print(f"Key modules: {hubs}")
355
+ ```
356
+
357
+ ### Organized Imports
358
+
359
+ ```python
360
+ # Core analysis
361
+ from code2logic.core import ProjectInfo, ProjectAnalyzer, analyze_project
362
+
363
+ # Format generators
364
+ from code2logic.formats import (
365
+ YAMLGenerator, JSONGenerator, TOONGenerator,
366
+ LogicMLGenerator, GherkinGenerator
367
+ )
368
+
369
+ # LLM clients
370
+ from code2logic.llm import get_client, BaseLLMClient
371
+
372
+ # Development tools
373
+ from code2logic.tools import run_benchmark, CodeReviewer
374
+ ```
375
+
376
+ ## 📋 Output Formats
377
+
378
+ ### Markdown (default)
379
+
380
+ Human-readable documentation with:
381
+
382
+ - Project structure tree with hub markers (★)
383
+ - Dependency graphs with PageRank scores
384
+ - Classes with methods and intents
385
+ - Functions with signatures and descriptions
386
+
387
+ ### Compact
388
+
389
+ Ultra-compact format optimized for LLM context:
390
+
391
+ ```text
392
+ # myproject | 102f 31875L | typescript:79/python:23
393
+ ENTRY: index.ts main.py
394
+ HUBS: evolution-manager llm-orchestrator
395
+
396
+ [core/evolution]
397
+ evolution-manager.ts (3719L) C:EvolutionManager | F:createEvolutionManager
398
+ task-queue.ts (139L) C:TaskQueue,Task
399
+ ```
400
+
401
+ ### JSON
402
+
403
+ Machine-readable format for:
404
+
405
+ - RAG (Retrieval-Augmented Generation)
406
+ - Database storage
407
+ - Further analysis
408
+
409
+ ## 🔧 Configuration
410
+
411
+ ### Library Status
412
+
413
+ Check which features are available:
414
+
415
+ ```bash
416
+ code2logic --status
417
+ ```
418
+
419
+ ```text
420
+ Library Status:
421
+ tree_sitter: ✓
422
+ networkx: ✓
423
+ rapidfuzz: ✓
424
+ nltk: ✗
425
+ spacy: ✗
426
+ ```
427
+
428
+ ### LLM Configuration
429
+
430
+ Manage LLM providers, models, API keys, and routing priorities:
431
+
432
+ ```bash
433
+ code2logic llm status
434
+ code2logic llm set-provider auto
435
+ code2logic llm set-model openrouter nvidia/nemotron-3-nano-30b-a3b:free
436
+ code2logic llm key set openrouter <OPENROUTER_API_KEY>
437
+ code2logic llm priority set-provider openrouter 10
438
+ code2logic llm priority set-mode provider-first
439
+ code2logic llm priority set-llm-model nvidia/nemotron-3-nano-30b-a3b:free 5
440
+ code2logic llm priority set-llm-family nvidia/ 5
441
+ code2logic llm config list
442
+ ```
443
+
444
+ Notes:
445
+
446
+ - `code2logic llm set-provider auto` enables automatic fallback selection: providers are tried in priority order.
447
+ - API keys should be stored in `.env` (or environment variables), not in `litellm_config.yaml`.
448
+ - These commands write configuration files:
449
+ - `.env` in the current working directory
450
+ - `litellm_config.yaml` in the current working directory
451
+ - `~/.code2logic/llm_config.json` in your home directory
452
+
453
+ #### Priority modes
454
+
455
+ You can choose how automatic fallback ordering is computed:
456
+
457
+ - `provider-first`
458
+ providers are ordered by provider priority (defaults + overrides)
459
+ - `model-first`
460
+ providers are ordered by priority rules for the provider's configured model (exact/prefix)
461
+ - `mixed`
462
+ providers are ordered by the best (lowest) priority from either provider priority or model rules
463
+
464
+ Configure the mode:
465
+
466
+ ```bash
467
+ code2logic llm priority set-mode provider-first
468
+ code2logic llm priority set-mode model-first
469
+ code2logic llm priority set-mode mixed
470
+ ```
471
+
472
+ Model priority rules are stored in `~/.code2logic/llm_config.json`.
473
+
474
+ ### Python API (Library Status)
475
+
476
+ ```python
477
+ from code2logic import get_library_status
478
+
479
+ status = get_library_status()
480
+ # {'tree_sitter': True, 'networkx': True, ...}
481
+ ```
482
+
483
+ ## 📊 Analysis Features
484
+
485
+ ### Dependency Analysis
486
+
487
+ - **PageRank** - Identifies most important modules
488
+ - **Hub detection** - Central modules marked with ★
489
+ - **Cycle detection** - Find circular dependencies
490
+ - **Clustering** - Group related modules
491
+
492
+ ### Intent Generation
493
+
494
+ Functions get human-readable descriptions:
495
+
496
+ ```yaml
497
+ methods:
498
+ async findById(id:string) -> Promise<User> # retrieves user by id
499
+ async createUser(data:UserDTO) -> Promise<User> # creates user
500
+ validateEmail(email:string) -> boolean # validates email
501
+ ```
502
+
503
+ ### Similarity Detection
504
+
505
+ Find duplicate and similar functions:
506
+
507
+ ```yaml
508
+ Similar Functions:
509
+ core/auth.ts::validateToken:
510
+ - python/auth.py::validate_token (92%)
511
+ - services/jwt.ts::verifyToken (85%)
512
+ ```
513
+
514
+ ## 🏗️ Architecture
515
+
516
+ ```text
517
+ code2logic/
518
+ ├── analyzer.py # Main orchestrator
519
+ ├── parsers.py # Tree-sitter + fallback parser
520
+ ├── dependency.py # NetworkX dependency analysis
521
+ ├── similarity.py # Rapidfuzz similar detection
522
+ ├── intent.py # NLP intent generation
523
+ ├── generators.py # Output generators (MD/Compact/JSON)
524
+ ├── models.py # Data structures
525
+ └── cli.py # Command-line interface
526
+ ```
527
+
528
+ ## 🔌 Integration Examples
529
+
530
+ ### With Claude/ChatGPT
531
+
532
+ ```python
533
+ from code2logic import analyze_project, CompactGenerator
534
+
535
+ project = analyze_project("./my-project")
536
+ context = CompactGenerator().generate(project)
537
+
538
+ # Use in your LLM prompt
539
+ prompt = f"""
540
+ Analyze this codebase and suggest improvements:
541
+
542
+ {context}
543
+ """
544
+ ```
545
+
546
+ ### With RAG Systems
547
+
548
+ ```python
549
+ import json
550
+ from code2logic import analyze_project, JSONGenerator
551
+
552
+ project = analyze_project("./my-project")
553
+ data = json.loads(JSONGenerator().generate(project))
554
+
555
+ # Index in vector DB
556
+ for module in data['modules']:
557
+ for func in module['functions']:
558
+ embed_and_store(
559
+ text=f"{func['name']}: {func['intent']}",
560
+ metadata={'path': module['path'], 'type': 'function'}
561
+ )
562
+ ```
563
+
564
+ ## 🧪 Development
565
+
566
+ ### Setup
567
+
568
+ ```bash
569
+ git clone https://github.com/wronai/code2logic
570
+ cd code2logic
571
+ pip install -e ".[dev]"
572
+ pre-commit install
573
+ ```
574
+
575
+ ### Tests
576
+
577
+ ```bash
578
+ pytest
579
+ pytest --cov=code2logic --cov-report=html
580
+ ```
581
+
582
+ ### Type Checking
583
+
584
+ ```bash
585
+ mypy code2logic
586
+ ```
587
+
588
+ ### Linting
589
+
590
+ ```bash
591
+ ruff check code2logic
592
+ black code2logic
593
+ ```
594
+
595
+ ## 📈 Performance
596
+
597
+ | Codebase Size | Files | Lines | Time | Output Size |
598
+ | --- | --- | --- | --- | --- |
599
+ | Small | 10 | 1K | <1s | ~5KB |
600
+ | Medium | 100 | 30K | ~2s | ~50KB |
601
+ | Large | 500 | 150K | ~10s | ~200KB |
602
+
603
+ Compact format is ~10-15x smaller than Markdown.
604
+
605
+ ## 🔬 Code Reproduction Benchmarks
606
+
607
+ Code2Logic can reproduce code from specifications using LLMs. Benchmark results:
608
+
609
+ ### Format Comparison (Token Efficiency)
610
+
611
+ | Format | Score | Token Efficiency | Spec Tokens | Runs OK |
612
+ | --- | --- | --- | --- | --- |
613
+ | **YAML** | **71.1%** | 42.1 | **366** | 66.7% |
614
+ | **Markdown** | 65.6% | **48.7** | 385 | **100%** |
615
+ | JSON | 61.9% | 23.7 | 605 | 66.7% |
616
+ | Gherkin | 51.3% | 19.1 | 411 | 66.7% |
617
+
618
+ ### Key Findings
619
+
620
+ - **YAML is best for score** - 71.1% reproduction accuracy
621
+ - **Markdown is best for token efficiency** - 48.7 score/1000 tokens
622
+ - **YAML uses 39.6% fewer tokens than JSON** with 9.2% higher score
623
+ - **Markdown has 100% runs OK** - generated code always executes
624
+
625
+ ### Run Benchmarks
626
+
627
+ ```bash
628
+ # Token-aware benchmark
629
+ python examples/11_token_benchmark.py --folder tests/samples/ --no-llm
630
+
631
+ # Async multi-format benchmark
632
+ python examples/09_async_benchmark.py --folder tests/samples/ --no-llm
633
+
634
+ # Function-level reproduction
635
+ python examples/10_function_reproduction.py --file tests/samples/sample_functions.py --no-llm
636
+
637
+ python examples/15_unified_benchmark.py --folder tests/samples/ --no-llm
638
+
639
+ # Terminal markdown rendering demo
640
+ python examples/16_terminal_demo.py --folder tests/samples/
641
+ ```
642
+
643
+ ## 🤝 Contributing
644
+
645
+ Contributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
646
+
647
+ ## 📄 License
648
+
649
+ Apache 2 License - see [LICENSE](LICENSE) for details.
650
+
651
+ ## 📚 Documentation
652
+
653
+ - [00 - Docs Index](docs/00-index.md) - Documentation home (start here)
654
+ - [01 - Getting Started](docs/01-getting-started.md) - Install and first steps
655
+ - [02 - Configuration](docs/02-configuration.md) - API keys, environment setup
656
+ - [03 - CLI Reference](docs/03-cli-reference.md) - Command-line usage
657
+ - [04 - Python API](docs/04-python-api.md) - Programmatic usage
658
+ - [05 - Output Formats](docs/05-output-formats.md) - Format comparison and usage
659
+ - [06 - Format Specifications](docs/06-format-specifications.md) - Detailed format specs
660
+ - [07 - TOON Format](docs/07-toon.md) - Token-Oriented Object Notation
661
+ - [08 - LLM Integration](docs/08-llm-integration.md) - OpenRouter/Ollama/LiteLLM
662
+ - [09 - LLM Comparison](docs/09-llm-comparison-report.md) - Provider/model comparison
663
+ - [10 - Benchmarking](docs/10-benchmark.md) - Benchmark methodology and results
664
+ - [11 - Repeatability](docs/11-repeatability.md) - Repeatability testing
665
+ - [12 - Examples](docs/12-examples.md) - Usage workflows and examples
666
+ - [13 - Architecture](docs/13-architecture.md) - System design and components
667
+ - [14 - Format Analysis](docs/14-format-analysis.md) - Deeper format evaluation
668
+
669
+ ## 🔗 Links
670
+
671
+ - [Documentation](https://code2logic.readthedocs.io)
672
+ - [PyPI](https://pypi.org/project/code2logic/)
673
+ - [GitHub](https://github.com/wronai/code2logic)
674
+ - [Issues](https://github.com/wronai/code2logic/issues)