-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject.toon
More file actions
1152 lines (1152 loc) · 67.7 KB
/
project.toon
File metadata and controls
1152 lines (1152 loc) · 67.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# code2logic | 152f 39758L | python:140/javascript:3/csharp:1/go:1/java:1/rust:1/sql:1/typescript:4
# Keys: M=modules, D=details, i=imports, c=classes, f=functions, m=methods
M[152]:
code2logic/__init__.py,392
code2logic/__main__.py,12
code2logic/adaptive.py,469
code2logic/analyzer.py,410
code2logic/base.py,49
code2logic/base_generator.py,5
code2logic/benchmark.py,349
code2logic/benchmarks/__init__.py,34
code2logic/benchmarks/common.py,327
code2logic/benchmarks/results.py,162
code2logic/benchmarks/runner.py,883
code2logic/chunked_reproduction.py,358
code2logic/cli.py,907
code2logic/code_review.py,205
code2logic/config.py,174
code2logic/core/__init__.py,21
code2logic/dependency.py,187
code2logic/errors.py,371
code2logic/file_formats.py,278
code2logic/formats/__init__.py,31
code2logic/function_logic.py,326
code2logic/generators.py,1787
code2logic/gherkin.py,764
code2logic/integrations/__init__.py,5
code2logic/intent.py,429
code2logic/llm.py,287
code2logic/llm/__init__.py,40
code2logic/llm_clients.py,209
code2logic/llm_profiler.py,490
code2logic/logicml.py,305
code2logic/markdown_format.py,265
code2logic/mcp_server.py,297
code2logic/metrics.py,479
code2logic/models.py,296
code2logic/parsers.py,2265
code2logic/project_reproducer.py,318
code2logic/prompts.py,120
code2logic/quality.py,212
code2logic/refactor.py,308
code2logic/reproducer.py,537
code2logic/reproduction.py,333
code2logic/schemas/__init__.py,25
code2logic/schemas/json_schema.py,206
code2logic/schemas/logicml_schema.py,184
code2logic/schemas/markdown_schema.py,118
code2logic/schemas/yaml_schema.py,167
code2logic/shared_utils.py,279
code2logic/similarity.py,201
code2logic/terminal.py,496
code2logic/tools/__init__.py,28
code2logic/toon_format.py,663
code2logic/universal.py,957
code2logic/utils.py,16
examples/01_quick_start.py,47
examples/02_refactoring.py,45
examples/03_reproduction.py,57
examples/04_project.py,55
examples/05_llm_integration.py,87
examples/06_metrics.py,85
examples/06_metrics_simple.py,0
examples/08_format_benchmark.py,90
examples/09_async_benchmark.py,60
examples/10_function_reproduction.py,51
examples/11_token_benchmark.py,69
examples/12_comprehensive_analysis.py,95
examples/12_comprehensive_analysis_simple.py,0
examples/13_project_benchmark.py,70
examples/14_repeatability_test.py,331
examples/15_unified_benchmark.py,143
examples/16_terminal_demo.py,178
examples/behavioral_benchmark.py,220
examples/benchmark_report.py,170
examples/benchmark_summary.py,100
examples/code2logic/sample_project/__init__.py,1
examples/code2logic/sample_project/api/client.py,15
examples/code2logic/sample_project/calculator.py,22
examples/code2logic/sample_project/models/user.py,9
examples/duplicate_detection.py,0
examples/token_efficiency.py,0
examples/windsurf_mcp_integration.py,0
logic2code/__init__.py,13
logic2code/__main__.py,8
logic2code/cli.py,152
logic2code/examples/01_quickstart.py,72
logic2code/examples/02_llm_enhanced.py,77
logic2code/generator.py,233
logic2code/renderers.py,297
logic2code/tests/__init__.py,1
logic2code/tests/test_basic.py,40
logic2test/__init__.py,14
logic2test/__main__.py,8
logic2test/cli.py,131
logic2test/examples/01_quickstart.py,62
logic2test/examples/02_custom_templates.py,92
logic2test/generator.py,328
logic2test/parsers.py,272
logic2test/templates.py,198
logic2test/tests/__init__.py,1
logic2test/tests/test_basic.py,31
lolm/__init__.py,103
lolm/__main__.py,10
lolm/cli.py,231
lolm/clients.py,274
lolm/config.py,271
lolm/examples/01_quickstart.py,60
lolm/examples/02_configuration.py,88
lolm/examples/03_code_generation.py,86
lolm/manager.py,412
lolm/provider.py,121
lolm/rotation.py,560
lolm/tests/__init__.py,1
lolm/tests/test_basic.py,51
raport/mermaid-init.js,29
scripts/configure_llm.py,360
tests/__init__.py,3
tests/conftest.py,314
tests/samples/sample_algorithms.py,184
tests/samples/sample_api.py,106
tests/samples/sample_async.py,163
tests/samples/sample_class.py,74
tests/samples/sample_csharp.cs,28
tests/samples/sample_dataclasses.py,68
tests/samples/sample_enum.py,78
tests/samples/sample_functions.py,89
tests/samples/sample_go.go,90
tests/samples/sample_java.java,43
tests/samples/sample_javascript.js,154
tests/samples/sample_javascript_advanced.js,111
tests/samples/sample_pydantic.py,62
tests/samples/sample_reexport/__init__.py,17
tests/samples/sample_reexport/exceptions.py,7
tests/samples/sample_reexport/models.py,21
tests/samples/sample_reexport/utils.py,8
tests/samples/sample_rust.rs,168
tests/samples/sample_sql.sql,73
tests/samples/sample_sql_dsl.py,177
tests/samples/sample_ts_reexport/index.ts,2
tests/samples/sample_ts_reexport/math.ts,6
tests/samples/sample_ts_reexport/types.ts,5
tests/samples/sample_typescript.ts,114
tests/test_analyzer.py,180
tests/test_e2e_projects.py,82
tests/test_error_handling.py,311
tests/test_formats.py,393
tests/test_generators.py,207
tests/test_intent.py,353
tests/test_llm_priority.py,44
tests/test_llm_profiler.py,416
tests/test_parser_integrity.py,361
tests/test_reproduction.py,208
tests/test_shared_utils.py,249
tests/test_yaml_compact.py,187
D:
code2logic/__init__.py:
i: adaptive.{AdaptiveReproducer,AdaptiveResult,LLM_CAPABILITIES,get_llm_capabilities},analyzer.{ProjectAnalyzer,analyze_project},base.{BaseGenerator,BaseParser,VerboseMixin},benchmark.BenchmarkResult
e: analyze_quality,reproduce_project
analyze_quality(target)
reproduce_project(source:str)
code2logic/adaptive.py:
i: dataclasses.dataclass,dotenv.load_dotenv,file_formats.{generate_file_csv,generate_file_json,generate_file_yaml},llm_clients.BaseLLMClient,pathlib.Path,typing.{Any,Dict,List}
e: LLM_CAPABILITIES,ChunkInfo,AdaptiveResult,AdaptiveReproducer,get_llm_capabilities
ChunkInfo: # Information about a code chunk.
AdaptiveResult: # Result of adaptive reproduction.
AdaptiveReproducer: __init__(2),_get_capabilities(0),select_format(2),should_chunk(1),chunk_content(2) # Adaptive code reproduction with LLM c...
get_llm_capabilities(model:str)->Dict[str, Any]
code2logic/analyzer.py:
i: logging,os,subprocess,sys,time,datetime,collections.defaultdict,pathlib.Path,typing.{Dict,List}
e: ProjectAnalyzer,analyze_project,get_library_status
ProjectAnalyzer: _language_from_shebang(1),__init__(6),_print_status(0),analyze(0),_scan_files(0) # Main class for analyzing software pro...
analyze_project(path:str;use_treesitter:bool=True;verbose:bool=False)->ProjectInfo
get_library_status()->Dict[str, bool]
code2logic/base.py:
i: logging
e: VerboseMixin,BaseParser,BaseGenerator
VerboseMixin: __init__(1),log(2),debug(1),info(1),warn(1) # Mixin providing verbose logging funct...
BaseParser: __init__(1),parse(2),parse_file(1) # Base class for code parsers.
BaseGenerator: __init__(1),generate(2) # Base class for output generators.
code2logic/base_generator.py:
i: models.ProjectInfo,typing.{Any,Protocol}
e: ProjectGenerator
ProjectGenerator: generate(1)
code2logic/benchmark.py:
i: json,time,datetime,dataclasses.{asdict,dataclass},dotenv.load_dotenv,pathlib.Path,typing.{Any,Dict,List}
e: FormatResult,BenchmarkResult,FORMAT_PROMPTS,ReproductionBenchmark,run_benchmark
FormatResult: # Result for a single format test.
BenchmarkResult: # Complete benchmark result.
ReproductionBenchmark: __init__(1),generate_spec(3),reproduce_with_format(3),run_single(2),run_all(2) # Benchmark reproduction quality across...
run_benchmark(files:List[str];output_dir:str='benchmark_results';provider:str=None;model:str=None)->Dict[str, Any]
code2logic/benchmarks/common.py:
i: json,datetime,function_logic.FunctionLogicGenerator,generators.{CSVGenerator,JSONGenerator,YAMLGenerator},gherkin.GherkinGenerator,logicml.LogicMLGenerator,markdown_format.MarkdownHybridGenerator,pathlib.Path
e: create_single_project,generate_spec,generate_spec_token,get_async_reproduction_prompt,get_token_reproduction_prompt,get_simple_reproduction_prompt
create_single_project(module_info;file_path:Path)->ProjectInfo
generate_spec(project:ProjectInfo;fmt:str)->str
_generate_token_json(project:ProjectInfo)->str
_generate_token_json_compact(project:ProjectInfo)->str
generate_spec_token(project:ProjectInfo;fmt:str)->str
get_async_reproduction_prompt(spec:str;fmt:str;file_name:str;with_tests:bool=False)->str
get_token_reproduction_prompt(spec:str;fmt:str;file_name:str;language:str='python')->str
get_simple_reproduction_prompt(spec:str;fmt:str;file_name:str)->str
code2logic/benchmarks/results.py:
i: json,datetime,dataclasses.{asdict,dataclass,field},pathlib.Path,typing.{Any,Dict,List,Optional}
e: FormatResult,FileResult,FunctionResult,BenchmarkResult,BenchmarkConfig
FormatResult: to_dict(0) # Result for a single format test.
FileResult: to_dict(0) # Result for single file reproduction.
FunctionResult: to_dict(0) # Result for single function reproduction.
BenchmarkResult: __post_init__(0),calculate_aggregates(0),to_dict(0),to_json(1),save(1) # Complete benchmark result.
BenchmarkConfig: to_dict(0) # Configuration for benchmark runs.
code2logic/benchmarks/runner.py:
i: difflib,re,sys,time,concurrent.futures.ThreadPoolExecutor,pathlib.Path,typing.{Any,Dict,List,Optional}
e: BenchmarkRunner,run_benchmark
BenchmarkRunner: __init__(2),_should_use_llm(0),_get_client(0),_template_generate_code(4),run_format_benchmark(4) # Unified benchmark runner for code2logic.
_test_python_syntax(code:str)->bool
_test_python_runs(code:str;timeout:int=5)->bool
_basic_syntax_ok(code:str;language:str)->bool
_count_structural_elements(code:str;language:str)->dict
_structural_score(original:str;generated:str;language:str)->float
_extract_code(response:str)->str
run_benchmark(source:str;benchmark_type:str='format';formats:List[str]=None;limit:Optional[int]=None;output:Optional[str]=None;verbose:bool=False)->BenchmarkResult
code2logic/chunked_reproduction.py:
i: re,dataclasses.dataclass,typing.{List,Optional},utils.estimate_tokens
e: LLM_CONTEXT_LIMITS,Chunk,ChunkedSpec,ChunkedResult,get_llm_limit,chunk_yaml_spec,chunk_gherkin_spec,chunk_markdown_spec
Chunk: # A chunk of specification for reproduc...
ChunkedSpec: # Chunked specification.
ChunkedResult: # Result of chunked reproduction.
ChunkedReproducer: __init__(3),reproduce(3),_extract_code(1) # Reproduce code from chunked specifica...
get_llm_limit(model_name:str)->int
chunk_yaml_spec(spec:str;max_tokens:int=2000)->List[Chunk]
chunk_gherkin_spec(spec:str;max_tokens:int=2000)->List[Chunk]
chunk_markdown_spec(spec:str;max_tokens:int=2000)->List[Chunk]
chunk_spec(spec:str;fmt:str;max_tokens:int=2000)->ChunkedSpec
get_chunk_prompt(chunk:Chunk;fmt:str;file_name:str;chunk_num:int;total_chunks:int)->str
merge_chunk_codes(codes:List[str];file_name:str)->str
auto_chunk_reproduce(spec:str;fmt:str;file_name:str;client;model_name:str='default')->ChunkedResult
code2logic/cli.py:
i: argparse,json,logging,os,signal,subprocess,sys,time,datetime,__version__
e: Colors,Logger,ensure_dependencies,main
Colors:
Logger: __init__(2),_elapsed(0),info(1),success(1),warning(1) # Enhanced logger for CLI output.
ensure_dependencies()
_get_env_file_path()->str
_read_text_file(path:str)->str
_write_text_file(path:str;content:str)->None
_set_env_var(var_name:str;value:str)->str
_unset_env_var(var_name:str)->str
_get_litellm_config_path()->str
_get_user_llm_config_path()->str
code2logic/code_review.py:
i: collections.defaultdict,typing.{Any,Dict,List}
e: SECURITY_PATTERNS,PERFORMANCE_PATTERNS,COMPLEXITY_HIGH,COMPLEXITY_MEDIUM,LINES_MAX,FILE_LINES_MAX,analyze_code_quality,check_security_issues
CodeReviewer: __init__(1),review(2),generate_report(2) # Automated code review with optional L...
analyze_code_quality(project)->Dict[str, List[Dict]]
check_security_issues(project)->Dict[str, List[Dict]]
check_performance_issues(project)->Dict[str, List[Dict]]
code2logic/config.py:
i: json,os,pathlib.Path,typing.{Any,Dict,Optional}
e: Config,load_env,get_api_key,get_model,SHELL_COMMANDS
Config: __init__(1),_load_env_file(1),_parse_env_file(1),_load_config_file(0),get_api_key(1) # Configuration manager for Code2Logic.
load_env()
get_api_key(provider:str)->Optional[str]
get_model(provider:str)->str
code2logic/dependency.py:
i: networkx,models.{DependencyNode,ModuleInfo},pathlib.Path,typing.{Dict,List}
e: NETWORKX_AVAILABLE,DependencyAnalyzer,is_networkx_available
DependencyAnalyzer: __init__(0),build_graph(1),analyze_metrics(0),get_entrypoints(0),get_hubs(0) # Analyzes dependency graphs using Netw...
is_networkx_available()->bool
code2logic/errors.py:
i: logging,dataclasses.{dataclass,field},enum.Enum,pathlib.Path,typing.{Any,Callable,Dict,List,Optional}
e: ErrorSeverity,ErrorType,AnalysisError,AnalysisResult,ErrorHandler,create_error_handler
ErrorSeverity: # Error severity levels.
ErrorType: # Types of errors that can occur during...
AnalysisError: to_dict(0) # Represents an error during analysis.
AnalysisResult: add_error(1),has_errors(0),summary(0) # Result of analysis with errors tracked.
ErrorHandler: __init__(4),reset(0),handle_error(5),_default_severity(1),_log_error(1) # Handles errors during analysis with c...
create_error_handler(mode:str='lenient';max_file_size_mb:float=10.0)->ErrorHandler
code2logic/file_formats.py:
i: json,pathlib.Path,typing.{Any,Dict}
e: generate_file_csv,generate_file_json,generate_file_yaml
generate_file_csv(file_path:Path)->str
generate_file_json(file_path:Path)->str
generate_file_yaml(file_path:Path)->str
_parse_file_elements(content:str)->Dict[str, Any]
code2logic/function_logic.py:
i: models.{FunctionInfo,ProjectInfo},shared_utils.{remove_self_from_params,truncate_docstring},toon_format.TOONGenerator,typing.{List,Tuple}
e: FunctionLogicGenerator
FunctionLogicGenerator: __init__(1),generate(2),generate_json(2),generate_yaml(2),generate_toon(6)
code2logic/generators.py:
i: json,collections.defaultdict,models.{ClassInfo,ConstantInfo,FieldInfo,FunctionInfo,ModuleInfo},pathlib.Path,typing.{List,Optional}
e: bytes_to_kb,MarkdownGenerator,CompactGenerator,JSONGenerator,YAMLGenerator,CSVGenerator
MarkdownGenerator: generate(2),_gen_tree(2),_print_tree(4),_gen_module(4),_gen_class(3) # Generates Markdown output for project...
CompactGenerator: generate(1) # Generates ultra-compact output for to...
JSONGenerator: generate(3),generate_from_module(2),_generate_nested(2),_field_to_dict(1),_generate_flat(2) # Generates JSON output for machine pro...
YAMLGenerator: generate(4),generate_schema(1),_generate_compact_schema(0),_generate_full_schema(0),_generate_hybrid_schema(0) # Generates YAML output for human-reada...
CSVGenerator: generate(2),_build_row(7),_build_function_row(7),_build_signature(1),_categorize(1) # Generates CSV output optimized for LL...
bytes_to_kb(bytes_value:int)->float
code2logic/gherkin.py:
i: re,collections.defaultdict,dataclasses.dataclass,models.{FunctionInfo,ProjectInfo},typing.{Any,Dict,List,Optional}
e: GherkinScenario,GherkinFeature,StepDefinition,GherkinGenerator,StepDefinitionGenerator,CucumberYAMLGenerator,csv_to_gherkin,gherkin_to_test_data
GherkinScenario: # Represents a single Gherkin scenario.
GherkinFeature: # Represents a Gherkin feature file.
StepDefinition: # Represents a step definition.
GherkinGenerator: __init__(1),generate(3),generate_test_scenarios(2),get_step_definitions(0),_extract_features(2) # Generates Gherkin feature files from...
StepDefinitionGenerator: generate_pytest_bdd(1),generate_behave(1),generate_cucumber_js(1),_step_to_func_name(1) # Generates step definition stubs from...
csv_to_gherkin(csv_content:str;language:str='en')->str
gherkin_to_test_data(gherkin_content:str)->Dict[str, Any]
code2logic/intent.py:
i: re,nltk,dataclasses.{dataclass,field},enum.{Enum,auto},typing.{Any,List,Optional,TYPE_CHECKING}
e: IntentType,Intent,EnhancedIntentGenerator,IntentAnalyzer
IntentType: # Types of user intents for code analysis.
Intent: # Represents a detected user intent.
EnhancedIntentGenerator: __init__(1),generate(2),_extract_from_docstring(1),_split_name(1),get_available_features(0) # Generator intencji z NLP - lemmatyzac...
IntentAnalyzer: __init__(0),_extract_keywords(1),_calculate_intent_confidence(2),_identify_target(2),_generate_description(2) # Analyzes user queries to detect inten...
code2logic/llm.py:
i: json,os,dataclasses.dataclass,importlib.util.find_spec,llm_clients.{LiteLLMClient,OllamaLocalClient,OpenRouterClient,get_client},typing.{Any,Optional}
e: LLMConfig,CodeAnalyzer,get_available_backends
LLMConfig: # Configuration for LLM backend.
CodeAnalyzer: __init__(4),is_available(0),suggest_refactoring(1),find_semantic_duplicates(1),generate_code(3) # LLM-powered code analysis for Code2Lo...
get_available_backends()->dict[str, bool]
code2logic/llm_clients.py:
i: json,os,lolm,typing.{Any,Optional}
e: get_priority_mode,get_effective_provider_priorities
_get_user_llm_config_path()->str
_load_user_llm_config()->dict[str, Any]
_get_priority_mode()->str
get_priority_mode()->str
_get_provider_priority_overrides()->dict[str, int]
_get_model_priority_rules()->dict[str, dict[str, int]]
_get_model_priority(model_string:str)->Optional[int]
_get_provider_model_string(provider:str)->str
code2logic/llm_profiler.py:
i: hashlib,json,time,datetime,dataclasses.{asdict,dataclass,field},difflib.SequenceMatcher,pathlib.Path,typing.Any
e: PROFILE_TEST_CASES,LLMProfile,ProfileTestResult,load_profiles,save_profile,get_profile,get_or_create_profile,LLMProfiler
LLMProfile: __post_init__(0) # Profile of LLM capabilities for code...
ProfileTestResult: # Result of a single profile test.
LLMProfiler: __init__(2),run_profile(1),_test_reproduction(2),_code_to_spec(1),_extract_code(1) # Profile LLM capabilities for code rep...
AdaptiveChunker: __init__(1),get_optimal_settings(0),chunk_spec(2),recommend_format(1),estimate_chunks_needed(1) # Adaptive chunking based on LLM profile.
_get_profiles_path()->Path
load_profiles()->dict[str, LLMProfile]
save_profile(profile:LLMProfile)->None
get_profile(provider:str;model:str)->Optional[LLMProfile]
get_or_create_profile(provider:str;model:str)->LLMProfile
_create_default_profile(provider:str;model:str)->LLMProfile
profile_llm(client;quick:bool=False)->LLMProfile
get_adaptive_chunker(provider:str;model:str)->AdaptiveChunker
code2logic/logicml.py:
i: dataclasses.dataclass,models.{ClassInfo,FunctionInfo,ModuleInfo,ProjectInfo},pathlib.Path,typing.{Dict,List,Optional,Set}
e: LogicMLSpec,LogicMLGenerator,generate_logicml,LOGICML_EXAMPLE
LogicMLSpec: # LogicML specification output.
LogicMLGenerator: __init__(1),generate(3),_generate_module(3),_generate_imports(1),_generate_class(3) # Generates LogicML format - optimized...
generate_logicml(project:ProjectInfo;detail:str='standard')->str
code2logic/markdown_format.py:
i: dataclasses.dataclass,generators.YAMLGenerator,gherkin.GherkinGenerator,models.ProjectInfo,pathlib.Path,typing.{Dict,List}
e: MarkdownSpec,MarkdownHybridGenerator,generate_markdown_hybrid,generate_file_markdown
MarkdownSpec: # Markdown specification for a project.
MarkdownHybridGenerator: __init__(1),generate(2),_generate_header(1),_generate_tree(1),_generate_imports(1) # Generates optimized Markdown hybrid f...
generate_markdown_hybrid(project:ProjectInfo;detail:str='full')->str
generate_file_markdown(file_path:str)->str
code2logic/mcp_server.py:
i: json,sys,__version__
e: handle_request,call_tool,run_server
handle_request(request:dict)->dict
call_tool(tool_name:str;arguments:dict)->str
run_server()
code2logic/metrics.py:
i: difflib,logging,re,collections.Counter,dataclasses.{asdict,dataclass,field},typing.{Any,Dict,List}
e: TextMetrics,StructuralMetrics,SemanticMetrics,FormatMetrics,ReproductionResult,ReproductionMetrics,analyze_reproduction,compare_formats
TextMetrics: # Text-level similarity metrics.
StructuralMetrics: # Structural code metrics.
SemanticMetrics: # Semantic preservation metrics.
FormatMetrics: # Format-specific efficiency metrics.
ReproductionResult: to_dict(0),to_report(0) # Complete reproduction analysis result.
analyze_reproduction(original:str;generated:str;spec:str='';format_name:str='';verbose:bool=False)->ReproductionResult
compare_formats(original:str;results:Dict[str;Tuple[str;str]];verbose:bool=False)->Dict[str, Any]
code2logic/models.py:
i: dataclasses.{dataclass,field},typing.{Dict,List,Optional}
e: FunctionInfo,ClassInfo,TypeInfo,ModuleInfo,DependencyNode,ProjectInfo,ConstantInfo,FieldInfo
FunctionInfo: # Information about a function or method.
ClassInfo: # Information about a class or interface.
TypeInfo: # Information about a type alias, inter...
ModuleInfo: # Information about a source file/module.
DependencyNode: # Node in the dependency graph with met...
code2logic/parsers.py:
i: ast,re,textwrap,intent.EnhancedIntentGenerator,models.{AttributeInfo,ClassInfo,ConstantInfo,FieldInfo},typing.{List,Optional}
e: TREE_SITTER_AVAILABLE,TreeSitterParser,UniversalParser,is_tree_sitter_available
_PyFunctionBodyAnalyzer: __init__(0),_add_call(1),_add_raise(1),visit_Call(1),visit_Raise(1)
TreeSitterParser: __init__(0),_init_parsers(0),is_available(1),get_supported_languages(0),parse(3) # Parser using Tree-sitter for high-acc...
UniversalParser: __init__(0),parse(3),_parse_python(2),_extract_ast_enum(1),_extract_ast_function(1) # Fallback parser using Python AST and...
_normalize_import_path(import_path:str)->str
_clean_imports(imports:List[str])->List[str]
_combine_import_name(module_name:str;identifier:str)->str
_truncate_constant_value(value_text:str;limit:int=400)->str
_py_expr_to_dotted_name(expr)->str
_analyze_python_function_node(func_node)
is_tree_sitter_available()->bool
code2logic/project_reproducer.py:
i: json,datetime,concurrent.futures.{ThreadPoolExecutor,as_completed},dataclasses.{asdict,dataclass,field},pathlib.Path,typing.{Dict,List}
e: SUPPORTED_EXTENSIONS,FileResult,ProjectResult,ProjectReproducer,reproduce_project
FileResult: # Result for a single file reproduction.
ProjectResult: # Result for project reproduction.
ProjectReproducer: __init__(4),_get_client(0),find_source_files(3),reproduce_file(2),reproduce_project(3) # Multi-file project reproduction system.
reproduce_project(project_path:str;output_dir:str=None;target_lang:str=None;parallel:bool=False;use_llm:bool=True)->ProjectResult
code2logic/prompts.py:
i: typing.Dict
e: FORMAT_HINTS,get_reproduction_prompt,get_review_prompt,get_fix_prompt
get_reproduction_prompt(spec:str;fmt:str;file_name:str;language:str='python';max_spec_length:int=5000)->str
get_review_prompt(code:str;spec:str;fmt:str)->str
get_fix_prompt(code:str;issues:list;spec:str)->str
code2logic/quality.py:
i: dataclasses.{dataclass,field},models.{ModuleInfo,ProjectInfo},typing.{Any,Dict,List}
e: QualityIssue,QualityReport,QualityAnalyzer,analyze_quality,get_quality_summary
QualityIssue: # Represents a code quality issue.
QualityReport: to_dict(0) # Complete quality analysis report.
QualityAnalyzer: __init__(1),analyze(1),analyze_modules(1),_analyze_module(2),_check_function(3) # Analyzes code quality and generates r...
analyze_quality(project:ProjectInfo;thresholds:Dict[str;int]=None)->QualityReport
get_quality_summary(report:QualityReport)->str
code2logic/refactor.py:
i: analyzer.analyze_project,code_review.{analyze_code_quality,check_security_issues},dataclasses.{asdict,dataclass,field},llm_clients.BaseLLMClient,typing.{Any,Dict,List}
e: DuplicateGroup,RefactoringSuggestion,RefactoringReport,find_duplicates,analyze_quality,suggest_refactoring,compare_codebases,quick_analyze
DuplicateGroup: # Group of duplicate functions.
RefactoringSuggestion: # Single refactoring suggestion.
RefactoringReport: to_dict(0),to_markdown(0) # Complete refactoring analysis report.
find_duplicates(project_path:str;threshold:float=0.8)->List[DuplicateGroup]
analyze_quality(project_path:str;include_security:bool=True;include_performance:bool=True)->RefactoringReport
suggest_refactoring(project_path:str;use_llm:bool=False;client:BaseLLMClient=None)->RefactoringReport
compare_codebases(project1:str;project2:str)->Dict[str, Any]
quick_analyze(project_path:str)->Dict[str, Any]
code2logic/reproducer.py:
i: json,re,dataclasses.{dataclass,field},enum.Enum,pathlib.Path,typing.{Any,Dict,List,Optional}
e: ReproductionStatus,FileValidation,ReproductionResult,SpecReproducer,SpecValidator,reproduce_project,validate_files
ReproductionStatus: # Status of file reproduction.
FileValidation: score(0),to_dict(0) # Validation result for a single file.
ReproductionResult: success_rate(0),average_score(0),summary(0) # Result of reproduction process.
SpecReproducer: __init__(1),reproduce_from_yaml(3),reproduce_from_json(3),_reproduce(3),_generate_file(2) # Reproduces code structure from logic...
SpecValidator: __init__(0),validate(3),_validate_file(2),_check_python_syntax(2) # Validates generated files against log...
_safe_load_yaml_file(path:str)->Any
reproduce_project(spec_path:str;output_dir:str;filter_paths:Optional[List[str]]=None;validate:bool=True;verbose:bool=True)->ReproductionResult
validate_files(spec_path:str;generated_dir:str;filter_paths:Optional[List[str]]=None)->List[FileValidation]
code2logic/reproduction.py:
i: difflib,re,datetime,llm_clients.{BaseLLMClient,get_client},pathlib.Path,typing.{Any,Dict,List}
e: generate_file_gherkin,compare_code,extract_code_block,CodeReproducer
CodeReproducer: __init__(2),reproduce_file(2),generate_from_gherkin(2),_save_results(2),_generate_report(1) # Code reproduction workflow using LLM.
generate_file_gherkin(file_path:Path)->str
compare_code(original:str;generated:str)->Dict[str, Any]
extract_code_block(text:str;language:str='python')->str
code2logic/schemas/json_schema.py:
i: json,dataclasses.{dataclass,field},typing.{Any,Dict,List,Optional,Tuple}
e: JSONMethodSchema,JSONClassSchema,JSONFunctionSchema,JSONModuleSchema,JSONSchema,validate_json,parse_json_spec
JSONMethodSchema: # Schema for JSON method definition.
JSONClassSchema: # Schema for JSON class definition.
JSONFunctionSchema: # Schema for JSON function definition.
JSONModuleSchema: # Schema for JSON module definition.
JSONSchema: # Complete JSON specification schema.
validate_json(spec:str)->Tuple[bool, List[str]]
_validate_json_module(module:Dict;index:int)->List[str]
_validate_json_class(cls:Dict;prefix:str)->List[str]
parse_json_spec(spec:str)->Optional[JSONSchema]
code2logic/schemas/logicml_schema.py:
i: re,dataclasses.{dataclass,field},typing.{Any,Dict,List,Optional,Tuple}
e: LogicMLMethod,LogicMLClass,LogicMLModule,LogicMLSchema,validate_logicml,parse_logicml_header,extract_logicml_signature
LogicMLMethod: # Schema for LogicML method.
LogicMLClass: # Schema for LogicML class.
LogicMLModule: # Schema for LogicML module.
LogicMLSchema: # Complete LogicML specification schema.
validate_logicml(spec:str)->Tuple[bool, List[str]]
parse_logicml_header(line:str)->Optional[Dict[str, Any]]
extract_logicml_signature(sig_line:str)->Dict[str, Any]
code2logic/schemas/markdown_schema.py:
i: re,dataclasses.{dataclass,field},typing.{Any,Dict,List,Tuple}
e: MarkdownMethod,MarkdownClass,MarkdownModule,MarkdownSchema,validate_markdown,extract_markdown_sections
MarkdownMethod: # Schema for Markdown method.
MarkdownClass: # Schema for Markdown class.
MarkdownModule: # Schema for Markdown module.
MarkdownSchema: # Complete Markdown specification schema.
validate_markdown(spec:str)->Tuple[bool, List[str]]
extract_markdown_sections(spec:str)->Dict[str, Any]
code2logic/schemas/yaml_schema.py:
i: dataclasses.{dataclass,field},typing.{Any,Dict,List,Tuple}
e: MethodSchema,ClassSchema,FunctionSchema,ModuleSchema,YAMLSchema,validate_yaml
MethodSchema: # Schema for method definition.
ClassSchema: # Schema for class definition.
FunctionSchema: # Schema for function definition.
ModuleSchema: # Schema for module definition.
YAMLSchema: # Complete YAML specification schema.
validate_yaml(spec:str)->Tuple[bool, List[str]]
_validate_module(module:Dict;index:int)->List[str]
_validate_class(cls:Dict;prefix:str)->List[str]
code2logic/shared_utils.py:
i: hashlib,re,typing.{Dict,List,Optional,Set}
e: compact_imports,deduplicate_imports,TYPE_ABBREVIATIONS,abbreviate_type,expand_type,build_signature,remove_self_from_params,CATEGORY_PATTERNS
compact_imports(imports:List[str];max_items:int=10)->List[str]
deduplicate_imports(imports:List[str])->List[str]
abbreviate_type(type_str:str)->str
expand_type(abbrev:str)->str
build_signature(params:List[str];return_type:Optional[str]=None;include_self:bool=False;abbreviate:bool=False;max_params:int=6)->str
remove_self_from_params(params:List[str])->List[str]
categorize_function(name:str)->str
extract_domain(path:str)->str
code2logic/similarity.py:
i: logging,time,collections.defaultdict,models.ModuleInfo,rapidfuzz.{fuzz,process},typing.{Dict,List}
e: RAPIDFUZZ_AVAILABLE,SimilarityDetector,is_rapidfuzz_available,get_refactoring_suggestions
SimilarityDetector: __init__(1),find_similar_functions(1),find_duplicate_signatures(1),_build_signature(3) # Detects similar functions using fuzzy...
is_rapidfuzz_available()->bool
get_refactoring_suggestions(similar_functions:Dict[str;List[str]])->List[Dict[str, any]]
code2logic/terminal.py:
i: os,re,sys,typing.{Any,List,Literal,Optional}
e: COLORS,ShellRenderer,get_renderer,set_renderer,RenderAPI
ShellRenderer: __init__(2),_supports_colors(0),enable_log(0),get_log(0),clear_log(0) # Renders colorized markdown output in...
RenderAPI: heading(2),code(2),codeblock(2),markdown(1),success(1) # Convenience API for terminal rendering.
get_renderer(use_colors:bool=True;verbose:bool=True)->ShellRenderer
set_renderer(renderer:ShellRenderer)->None
code2logic/toon_format.py:
i: re,models.{ClassInfo,FunctionInfo,ModuleInfo,ProjectInfo,TypeInfo},shared_utils.compact_imports,typing.{Any,Dict,List}
e: TOONGenerator,TOONParser,generate_toon,parse_toon
TOONGenerator: __init__(2),_short_lang(1),_compress_module_path(2),generate(3),generate_hybrid(5) # Generates TOON format output from Pro...
TOONParser: __init__(0),parse(1),_parse_value(1) # Parse TOON format back to Python dict.
generate_toon(project:ProjectInfo;detail:str='standard';use_tabs:bool=False)->str
parse_toon(content:str)->Dict[str, Any]
code2logic/universal.py:
i: hashlib,json,re,dataclasses.{asdict,dataclass,field},enum.Enum,pathlib.Path,typing.{Any,Dict}
e: ElementType,Language,Parameter,CodeElement,CodeLogic,UniversalParser,CodeGenerator,UniversalReproducer
ElementType: # Types of code elements.
Language: # Supported languages.
Parameter: # Function/method parameter.
CodeElement: # Universal representation of a code el...
CodeLogic: to_dict(0),_element_to_dict(1),to_compact(0),_element_to_compact(2) # Universal code logic representation f...
reproduce_file(source_path:str;target_lang:str=None;output_dir:str=None;use_llm:bool=True)->Dict[str, Any]
code2logic/utils.py:
i: shutil,pathlib.Path
e: estimate_tokens,write_text_atomic,cleanup_generated_root
estimate_tokens(text:str)->int
write_text_atomic(path:Path;content:str)->None
cleanup_generated_root(generated_root:Path;allowed_dirs:set[str])->None
examples/01_quick_start.py:
i: sys,code2logic.{CSVGenerator,GherkinGenerator,analyze_project,quick_analyze},pathlib.Path
e: main
main()
examples/02_refactoring.py:
i: sys,code2logic.{analyze_quality,find_duplicates,suggest_refactoring},pathlib.Path
e: main
main()
examples/03_reproduction.py:
i: sys,argparse,code2logic.{UniversalReproducer,generate_file_gherkin,reproduce_file},dotenv.load_dotenv,pathlib.Path
e: main
main()
examples/04_project.py:
i: sys,argparse,code2logic.{compare_codebases,reproduce_project},dotenv.load_dotenv,pathlib.Path
e: main
main()
examples/05_llm_integration.py:
i: sys,argparse,os,code2logic.{LLM_CAPABILITIES,OllamaLocalClient,OpenRouterClient,get_client,suggest_refactoring},dotenv.load_dotenv,pathlib.Path
e: main
main()
examples/06_metrics.py:
i: sys,argparse,code2logic.{ReproductionMetrics,generate_file_gherkin,get_client},code2logic.reproduction.extract_code_block,dotenv.load_dotenv,pathlib.Path
e: analyze_file,main
analyze_file(source_path:str;verbose:bool=False;no_llm:bool=False)
_template_generate(spec:str)->str
main()
examples/08_format_benchmark.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: print_format_comparison,print_per_file_results,main
print_format_comparison(result)
print_per_file_results(result)
main()
examples/09_async_benchmark.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: print_results,main
print_results(result)
main()
examples/10_function_reproduction.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: print_results,main
print_results(result)
main()
examples/11_token_benchmark.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: print_token_efficiency,main
print_token_efficiency(result)
main()
examples/12_comprehensive_analysis.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: ALL_FORMATS,print_comprehensive_analysis,main
print_comprehensive_analysis(result)
main()
examples/13_project_benchmark.py:
i: argparse,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner},dotenv.load_dotenv,pathlib.Path
e: print_project_results,main
print_project_results(result)
main()
examples/14_repeatability_test.py:
i: argparse,difflib,json,sys,time,datetime,dataclasses.{dataclass,field},pathlib.Path,typing.Dict
e: RunResult,RepeatabilityResult,generate_spec,get_reproduction_prompt,calculate_similarity,get_diff,test_syntax,run_repeatability_test
RunResult: # Result of a single generation run.
RepeatabilityResult: # Repeatability analysis for a format.
_template_generate(spec:str;fmt:str;file_name:str)->str
generate_spec(project:ProjectInfo;fmt:str)->str
get_reproduction_prompt(spec:str;fmt:str;file_name:str)->str
calculate_similarity(code1:str;code2:str)->float
get_diff(code1:str;code2:str;label1:str='Run 1';label2:str='Run 2')->List[str]
test_syntax(code:str)->bool
run_repeatability_test(file_path:str;formats:List[str];num_runs:int=3;verbose:bool=False;no_llm:bool=False)->Dict[str, RepeatabilityResult]
print_repeatability_summary(results:Dict[str;RepeatabilityResult])
examples/15_unified_benchmark.py:
i: argparse,os,sys,code2logic.benchmarks.{BenchmarkConfig,BenchmarkRunner,run_benchmark},code2logic.llm_clients.get_client,dotenv.load_dotenv,pathlib.Path
e: print_format_results,print_function_results,print_project_results,main
print_format_results(result)
print_function_results(result)
print_project_results(result)
main()
examples/16_terminal_demo.py:
i: argparse,sys,code2logic.terminal.{ShellRenderer,get_renderer,render,set_renderer},pathlib.Path
e: demo_headings,demo_codeblocks,demo_status_messages,demo_progress,demo_tasks,demo_key_value,demo_tables,demo_markdown
demo_headings()
demo_codeblocks()
demo_status_messages()
demo_progress()
demo_tasks()
demo_key_value()
demo_tables()
demo_markdown()
examples/behavioral_benchmark.py:
i: json,os,tempfile,dataclasses.{asdict,dataclass},importlib.util,pathlib.Path,typing.{Any,Callable,Dict}
e: CaseResult,FunctionBehaviorResult,main
CaseResult:
FunctionBehaviorResult:
_load_module_from_path(path:Path;module_name:str)->Any
_exec_function_from_code(code:str;function_name:str)->Callable[..., Any]
_values_equal(got:Any;expected:Any)->bool
_run_case(label:str;fn:Callable[Any;Any];expected:Any)->CaseResult
_looks_like_template_stub(code:str)->bool
_cases_for(function_name:str)->List[Tuple[str, Callable[[], Tuple[Tuple[Any, ...], Dict[str, Any]]]]]
_apply_env_hook(kwargs:Dict[str;Any])->Dict[str, Any]
main()->None
examples/benchmark_report.py:
i: json,os,shlex,datetime,dataclasses.dataclass,pathlib.Path,typing.{Any,Dict,List,Optional}
e: Artifact,main
Artifact:
_load_json(path:Path)->Optional[Dict[str, Any]]
_sizeof(path:Path)->int
_fmt_bytes(n:int)->str
_token_estimate_bytes(n:int)->int
_calc_function_summary(d:Dict[str;Any])->Tuple[int, float, float]
_calc_file_summary(d:Dict[str;Any])->Tuple[int, float, float, float]
_read_commands(commands_path:Path)->List[str]
main()->None
examples/benchmark_summary.py:
i: json,os,sys
e: main
_fmt_bytes(n:int)->str
_token_estimate_bytes(n:int)->int
_artifact_row(label:str;path:str)->str
main()
examples/code2logic/sample_project/api/client.py:
i: dataclasses.dataclass
e: Response,APIClient
Response: # Very small HTTP-like response placeho...
APIClient: get(1),post(2) # Example client with async methods.
examples/code2logic/sample_project/calculator.py:
e: Calculator,factorial
Calculator: add(2),divide(2) # A tiny calculator used for Code2Logic...
factorial(n:int)->int
examples/code2logic/sample_project/models/user.py:
i: dataclasses.dataclass
e: User
User: # Simple user model.
logic2code/cli.py:
i: argparse,sys,generator.{CodeGenerator,GenerationResult,GeneratorConfig},pathlib.Path
e: main
main()
logic2code/examples/01_quickstart.py:
i: sys,logic2code.{CodeGenerator,GeneratorConfig},pathlib.Path
e: example_basic_generation,example_with_config,example_stubs_only,example_single_module
example_basic_generation()
example_with_config()
example_stubs_only()
example_single_module()
logic2code/examples/02_llm_enhanced.py:
i: sys,logic2code.{CodeGenerator,GeneratorConfig},pathlib.Path
e: example_llm_generation,example_hybrid_generation,example_compare_outputs
example_llm_generation()
example_hybrid_generation()
example_compare_outputs()
logic2code/generator.py:
i: re,sys,dataclasses.{dataclass,field},logic2test.parsers.LogicParser,pathlib.Path,typing.{Dict,List,Optional,Union}
e: GeneratorConfig,GenerationResult,CodeGenerator
GeneratorConfig: # Configuration for code generation.
GenerationResult: # Result of code generation.
CodeGenerator: __init__(2),project(0),generate(2),generate_module(1),generate_class(2) # Main code generator class.
logic2code/renderers.py:
i: re,abc.{ABC,abstractmethod},dataclasses.{dataclass,field},typing.{Any,Dict,List,Optional,Set}
e: RenderConfig,BaseRenderer,PythonRenderer
RenderConfig: # Configuration for code rendering.
BaseRenderer: __init__(1),render_module(1),render_class(1),render_function(1) # Abstract base class for language-spec...
PythonRenderer: render_module(1),_collect_imports(1),_render_constant(1),render_class(1),_render_field(1) # Python code renderer.
logic2code/tests/test_basic.py:
i: pytest
e: test_import_logic2code,test_import_generator,test_config_defaults,test_generator_config_custom,test_generator_config_llm
test_import_logic2code()
test_import_generator()
test_config_defaults()
test_generator_config_custom()
test_generator_config_llm()
logic2test/cli.py:
i: argparse,sys,generator.{GenerationResult,GeneratorConfig,TestGenerator},pathlib.Path
e: main
main()
logic2test/examples/01_quickstart.py:
i: sys,logic2test.{GeneratorConfig,TestGenerator},pathlib.Path
e: example_basic_generation,example_with_config,example_generate_all_types
example_basic_generation()
example_with_config()
example_generate_all_types()
logic2test/examples/02_custom_templates.py:
i: sys,logic2test.parsers.{ClassSpec,FunctionSpec},logic2test.templates.TestTemplate,pathlib.Path
e: example_function_test,example_class_test,example_dataclass_test,example_async_function_test
example_function_test()
example_class_test()
example_dataclass_test()
example_async_function_test()
logic2test/generator.py:
i: re,dataclasses.{dataclass,field},parsers.{LogicParser,ProjectSpec},pathlib.Path,typing.{Dict,List,Optional,Union}
e: GeneratorConfig,GenerationResult,TestGenerator
GeneratorConfig: # Configuration for test generation.
GenerationResult: # Result of test generation.
TestGenerator: __init__(2),project(0),generate_unit_tests(2),_generate_module_tests(1),_generate_class_tests(1) # Main test generator class.
logic2test/parsers.py:
i: re,dataclasses.{dataclass,field},pathlib.Path,typing.{Any,Dict,List,Optional,Union}
e: FunctionSpec,ClassSpec,ModuleSpec,ProjectSpec,LogicParser
FunctionSpec: # Specification of a function/method ex...
ClassSpec: # Specification of a class extracted fr...
ModuleSpec: # Specification of a module extracted f...
ProjectSpec: # Full project specification from logic...
LogicParser: __init__(1),parse(0),_detect_and_parse_format(0),_parse_yaml(0),_parse_yaml_simple(0) # Parser for Code2Logic output formats.
logic2test/templates.py:
i: dataclasses.dataclass,typing.{List,Optional}
e: TestTemplate
TestTemplate: render_test_file_header(2),render_function_test(6),render_class_test(5),render_dataclass_test(2) # Template for generating test code.
logic2test/tests/test_basic.py:
i: pytest
e: test_import_logic2test,test_import_generator,test_config_defaults,test_generator_config_custom
test_import_logic2test()
test_import_generator()
test_config_defaults()
test_generator_config_custom()
lolm/cli.py:
i: argparse,os,sys,config,pathlib.Path
e: cmd_status,cmd_set_provider,cmd_set_model,cmd_key_set,cmd_key_show,cmd_models,cmd_test,cmd_config_show
cmd_status(args)->int
cmd_set_provider(args)->int
cmd_set_model(args)->int
cmd_key_set(args)->int
cmd_key_show(args)->int
cmd_models(args)->int
cmd_test(args)->int
cmd_config_show(args)->int
lolm/clients.py:
i: os,time,config.{DEFAULT_MODELS,RECOMMENDED_MODELS,get_provider_model,load_env_file},provider.{BaseLLMClient,LLMModelInfo},typing.{List,Optional}
e: LLMRateLimitError,OpenRouterClient,OllamaClient,LiteLLMClient,GroqClient,TogetherClient
LLMRateLimitError: __init__(5),__str__(0) # Exception raised when a rate limit is...
OpenRouterClient: __init__(2),generate(3),is_available(0),list_recommended_models(0) # OpenRouter API client for cloud LLM a...
OllamaClient: __init__(2),generate(3),is_available(0),list_models(0),list_recommended_models(0) # Ollama client for local LLM inference.
LiteLLMClient: __init__(1),generate(3),is_available(0) # LiteLLM client for universal LLM access.
GroqClient: __init__(2),generate(3),is_available(0) # Groq API client for fast inference.
lolm/config.py:
i: json,os,dataclasses.{dataclass,field},getv.EnvStore,pathlib.Path,typing.{Any,Dict,List,Optional}
e: RECOMMENDED_MODELS,DEFAULT_MODELS,DEFAULT_PROVIDER_PRIORITIES,LLMConfig,get_config_dir,get_config_path,load_config,save_config
LLMConfig: to_dict(0),from_dict(1) # LLM configuration container.
get_config_dir()->Path
get_config_path()->Path
load_config()->LLMConfig
save_config(config:LLMConfig)->None
load_env_file(search_paths:Optional[List[Path]]=None)->None
load_litellm_config(search_paths:Optional[List[Path]]=None)->Dict[str, Any]
save_litellm_config(config:Dict[str;Any];path:Optional[Path]=None)->None
get_provider_model(provider:str)->str
lolm/examples/01_quickstart.py:
i: lolm.{LLMManager,get_client}
e: example_simple_client,example_specific_provider,example_manager,example_fallback
example_simple_client()
example_specific_provider()
example_manager()
example_fallback()
lolm/examples/02_configuration.py:
i: os,lolm,pathlib.Path
e: show_defaults,show_recommended_models,show_current_config,example_modify_config,show_environment_config
show_defaults()
show_recommended_models()
show_current_config()
example_modify_config()
show_environment_config()
lolm/examples/03_code_generation.py:
i: lolm.{LLMManager,get_client}
e: SYSTEM_PROMPT,generate_function,generate_class,explain_code,review_code
generate_function(description:str)->str
generate_class(description:str)->str
explain_code(code:str)->str
review_code(code:str)->str
lolm/manager.py:
i: os,config,typing.{Dict,List,Optional}
e: ProviderInfo,LLMManager,get_client,list_available_providers
ProviderInfo: __init__(5) # Information about a configured provider.
LLMManager: __init__(2),is_available(0),is_ready(0),primary_provider(0),providers(0) # LLM Manager with multi-provider support.
get_client(provider:str=None;model:str=None)->BaseLLMClient
list_available_providers()->List[str]
lolm/provider.py:
i: abc.{ABC,abstractmethod},dataclasses.{dataclass,field},enum.Enum,typing.{Any,Dict,List,Literal,Optional}
e: LLMProviderStatus,GenerateOptions,LLMResponse,LLMModelInfo,BaseLLMClient,LLMProvider
LLMProviderStatus: # Provider availability status.
GenerateOptions: to_messages(0) # Options for LLM generation.
LLMResponse: # Response from LLM generation.
LLMModelInfo: # Information about an available model.
BaseLLMClient: generate(3),is_available(0),chat(2) # Abstract base class for synchronous L...
lolm/rotation.py:
i: time,threading,datetime,dataclasses.{dataclass,field},datetime.timedelta,enum.Enum,typing.{Any,Callable,Dict}
e: ProviderState,RateLimitType,RateLimitInfo,ProviderHealth,RotationQueue,parse_rate_limit_headers,is_rate_limit_error,LLMRotationManager
ProviderState: # Provider availability state.
RateLimitType: # Type of rate limit encountered.
RateLimitInfo: get_wait_seconds(0) # Information about a rate limit event.
ProviderHealth: success_rate(0),is_available(0),record_success(1),record_failure(3),_adjust_priority(0) # Health metrics for a provider.
RotationQueue: __init__(3),add_provider(2),remove_provider(1),set_priority(2),get_priority_order(0) # Priority queue for LLM provider rotat...
parse_rate_limit_headers(headers:Dict[str;str])->Optional[RateLimitInfo]
is_rate_limit_error(status_code:int=None;error_message:str=None)->bool
create_rotation_manager(providers:Dict[str;Tuple[Any;int]]=None;verbose:bool=False)->LLMRotationManager
lolm/tests/test_basic.py:
i: pytest
e: test_import_lolm,test_import_config,test_import_clients,test_config_defaults,test_manager_init,test_recommended_models
test_import_lolm()
test_import_config()
test_import_clients()
test_config_defaults()
test_manager_init()
test_recommended_models()
raport/mermaid-init.js:
i: https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs
e: renderMermaid,convertMermaidCodeBlocks
convertMermaidCodeBlocks()
renderMermaid()
scripts/configure_llm.py:
i: sys,os,json,time,datetime,pathlib.Path,typing.{Any,Dict,List,Optional}
e: CONFIG_DIR,CONFIG_FILE,log,check_ollama,check_litellm,check_env_keys,categorize_models,get_recommended_models
log(msg:str;level:str='info')
check_ollama()->Dict[str, Any]
check_litellm()->Dict[str, Any]
check_env_keys()->Dict[str, bool]
categorize_models(models:List[Dict])->Dict[str, List[Dict]]
get_recommended_models(models:List[Dict])->Dict[str, str]
test_model(model:str;timeout:int=30)->Dict[str, Any]
save_config(config:Dict[str;Any])
tests/conftest.py:
i: pytest,tempfile,code2logic.models.{ClassInfo,FunctionInfo,ModuleInfo,ProjectInfo},pathlib.Path,typing.{Any,Dict}
e: sample_python_code,sample_javascript_code,sample_java_code,temp_project_dir,sample_project,sample_module,sample_project_model,mock_llm_config
sample_python_code()->str
sample_javascript_code()->str
sample_java_code()->str
temp_project_dir()
sample_project(temp_project_dir;sample_python_code)
sample_module()
sample_project_model()
mock_llm_config()
tests/samples/sample_algorithms.py:
i: functools.lru_cache,typing.{Generator,List,Optional,Tuple,TypeVar}
e: T,binary_search,quicksort,merge_sort,fibonacci,fibonacci_generator,is_prime,sieve_of_eratosthenes
binary_search(arr:List[int];target:int)->int
quicksort(arr:List[int])->List[int]
merge_sort(arr:List[int])->List[int]
_merge(left:List[int];right:List[int])->List[int]
fibonacci(n:int)->int
fibonacci_generator(limit:int)->Generator[int, None, None]
is_prime(n:int)->bool
sieve_of_eratosthenes(limit:int)->List[int]
tests/samples/sample_api.py:
i: datetime,json,dataclasses.{dataclass,field},typing.{Any,Dict,List,Optional}
e: APIResponse,User,APIError,UserAPI,fetch_user_async,create_user_async,handle_api_error
APIResponse: # Standard API response structure.
User: # User model for API.
APIError: __init__(2) # Custom API error.
UserAPI: __init__(0),create_user(3),get_user(1),update_user(1),delete_user(1) # User management API.
fetch_user_async(api:UserAPI;user_id:int)->APIResponse
create_user_async(api:UserAPI;username:str;email:str)->APIResponse
handle_api_error(func)
tests/samples/sample_async.py:
i: asyncio,datetime,contextlib.asynccontextmanager,dataclasses.{dataclass,field},typing.{Any,Dict,List,Optional,TypeVar}
e: T,Task,TaskResult,AsyncTaskQueue,AsyncCache,async_timer,fetch_with_retry,parallel_map
Task: # Async task with status tracking.
TaskResult: # Result of task execution.
AsyncTaskQueue: __init__(1),add_task(1),get_task(1),process_task(2),process_all(1) # Async task queue with concurrency con...
AsyncCache: __init__(1),get(1),set(2),delete(1),clear(0) # Simple async cache with TTL.
async_timer(name:str='operation')
fetch_with_retry(url:str;max_retries:int=3;delay:float=1.0)->Dict[str, Any]
parallel_map(items:List[T];handler;max_concurrent:int=5)->List[Any]
race()->Any
timeout_wrapper(coro;timeout_seconds:float;default=None)
tests/samples/sample_class.py:
i: typing.{Any,Dict,List,Optional}
e: Calculator
Calculator: __init__(1),add(2),subtract(2),multiply(2),divide(2) # Simple calculator with history.
tests/samples/sample_csharp.cs:
i: System,System.Linq,System.Collections.Generic
e: IHasId,User
IHasId:
User:
FilterActive(IEnumerable<User> users)->List<User>
FindById(IEnumerable<User> users;string id)->User
tests/samples/sample_dataclasses.py:
i: datetime,dataclasses.{dataclass,field},typing.{Dict,List,Optional}
e: User,Product,Order,Address
User: # Represents a user in the system.
Product: # Represents a product in the catalog.
Order: # Represents a customer order.
Address: # Represents a shipping address.
tests/samples/sample_enum.py:
i: enum.{Enum,IntEnum,auto},typing.List
e: Status,Priority,Color,HttpStatus,TaskType
Status: # Status enumeration with auto values.
Priority: # Priority levels as integers.
Color: from_hex(1) # Color enumeration with string values.
HttpStatus: is_success(0),is_error(0) # HTTP status codes.
TaskType: get_timeout(0),get_allowed_statuses(0) # Task type enumeration.
tests/samples/sample_functions.py:
i: json,os,typing.{Any,Dict,List,Optional}
e: calculate_total,filter_by_status,merge_configs,validate_email,load_json_file,get_env_or_default,chunk_list,format_currency
calculate_total(items:List[int];tax_rate:float=0.1)->float
filter_by_status(records:List[Dict];status:str)->List[Dict]
merge_configs(base:Dict[str;Any];override:Dict[str;Any])->Dict[str, Any]
validate_email(email:str)->bool
load_json_file(path:str)->Optional[Dict]
get_env_or_default(key:str;default:str='')->str
chunk_list(items:List[Any];chunk_size:int)->List[List[Any]]
format_currency(amount:int;currency:str='USD')->str
tests/samples/sample_go.go:
i: errors
e: User,Product,Order,OrderItem,UserService,Repository,NewUserService,GetUser
User:
Product:
Order:
OrderItem:
UserService:
NewUserService()
GetUser(id int)->(*User, error)
CreateUser(name;email string)->(*User, error)
CalculateTotal(items []OrderItem;taxRate float64)->int64
FilterProducts(products []Product;predicate func(Product)->bool
FormatPrice(cents int64;currency string)->string
tests/samples/sample_java.java:
i: java.util.{ArrayList,Collections,Comparator,List,Objects}
e: SampleJava,Identifiable,Status,User
SampleJava:
Identifiable:
User:
getId()->String
filterActive(List<User> users)->List<User>
sortByName(List<User> users)->List<User>
tests/samples/sample_javascript.js:
e: fetchData,deepClone,filterBy,calculateTotal,User,debounce,Product
User: constructor(3),getDisplayName(0),deactivate(0)
Product: constructor(3),addTags(0),isInStock(0),formatPrice(0)
calculateTotal(items)
filterBy(arr;predicate)
fetchData(url)
debounce(func;wait)
deepClone(obj)
tests/samples/sample_javascript_advanced.js:
i: fs,path,events
e: outerFunction,walk,getArg,validate,formatOutput,shouldIgnore,processItem,FileProcessor
FileProcessor: constructor(1),analyze(1),fromConfig(1),getResults(0)
getArg(name;def)
processItem(item)
validate(input)
fetchResource(url;options)
shouldIgnore(filePath)
formatOutput(data;indent)
walk(dir;onFile)
findFiles(dir;extensions)
tests/samples/sample_pydantic.py:
i: datetime,enum.Enum,pydantic.{BaseModel,Field,field_validator},typing.{List,Optional}
e: TaskStatus,Task,TaskQueue,Project
TaskStatus: # Task status enumeration.
Task: name_not_empty(1) # Task model with Pydantic features.
TaskQueue: add_task(1),get_pending(0),get_by_status(1) # Task queue container.
Project: total_tasks(0) # Project model with nested models.
tests/samples/sample_reexport/exceptions.py:
e: ValidationError,ProcessingError
ValidationError: # Validation error.
ProcessingError: # Processing error.
tests/samples/sample_reexport/models.py:
i: dataclasses.dataclass,typing.{List,Optional}
e: User,Order,Product
User: # User model.
Order: # Order model.
Product: # Product model.
tests/samples/sample_reexport/utils.py:
i: typing.{Any,Dict}
e: process_data,validate_input
process_data(data:Dict[str;Any])->Dict[str, Any]
validate_input(data:Dict[str;Any])->bool
tests/samples/sample_rust.rs:
i: std::collections::HashMap,std::fmt
e: User,Product,Order,OrderItem,Repository,OrderStatus,AppError,Entity