1919from plain2code_arguments import parse_arguments
2020from plain2code_console import console
2121from plain2code_state import CONFORMANCE_TESTS_DEFINITION_FILE_NAME , ConformanceTestsUtils , ExecutionState , RunState
22+ # from plain2code_utils import AMBIGUITY_CAUSES, RetryOnlyFilter
2223from plain2code_utils import RetryOnlyFilter
2324from system_config import system_config
2425
3334MAX_REFACTORING_ITERATIONS = 5
3435MAX_UNIT_TEST_RENDER_RETRIES = 2
3536
36- MAX_ISSUE_LENGTH = 15000 # Characters.
37+ MAX_ISSUE_LENGTH = 10000 # Characters.
3738
3839UNRECOVERABLE_ERROR_EXIT_CODES = [69 ]
3940TIMEOUT_ERROR_EXIT_CODE = 124
@@ -1041,6 +1042,41 @@ def render_functional_requirement( # noqa: C901
10411042 run_state .render_id ,
10421043 )
10431044
1045+ # fixed_implementation_code_diff = git_utils.get_fixed_implementation_code_diff(args.build_folder, frid)
1046+ # if fixed_implementation_code_diff is None:
1047+ # raise Exception(
1048+ # "Fixes to the implementation code found during conformance testing are not committed to git."
1049+ # )
1050+
1051+ # git_utils.checkout_commit_with_frid(args.build_folder, previous_frid)
1052+ # existing_files = file_utils.list_all_text_files(args.build_folder)
1053+ # existing_files_content = file_utils.get_existing_files_content(args.build_folder, existing_files)
1054+ # git_utils.checkout_previous_branch(args.build_folder)
1055+
1056+ # implementation_code_diff = git_utils.get_implementation_code_diff(args.build_folder, frid, previous_frid)
1057+
1058+ # rendering_analysis = codeplainAPI.analyze_rendering(
1059+ # frid,
1060+ # plain_source_tree,
1061+ # linked_resources,
1062+ # existing_files_content,
1063+ # implementation_code_diff,
1064+ # fixed_implementation_code_diff,
1065+ # run_state,
1066+ # )
1067+
1068+ # if rendering_analysis:
1069+ # # TODO: Before this output is exposed to the user, we should check the 'guidance' field using LLM in the same way as we do conflicting requirements.
1070+ # console.info(
1071+ # f"Specification ambiguity detected! {AMBIGUITY_CAUSES[rendering_analysis['cause']]} of the functional requirement {frid}."
1072+ # )
1073+ # console.info(rendering_analysis["guidance"])
1074+ # run_state.add_rendering_analysis_for_frid(frid, rendering_analysis)
1075+ # else:
1076+ # console.warning(
1077+ # f"During conformance testing, the implementation code of the functional requirement {frid} was fixed, but the cause of the issue was not identified."
1078+ # )
1079+
10441080 conformance_tests_utils .dump_conformance_tests_json (conformance_tests )
10451081 git_utils .add_all_files_and_commit (
10461082 args .conformance_tests_folder ,
@@ -1055,6 +1091,15 @@ def render_functional_requirement( # noqa: C901
10551091 None ,
10561092 run_state .render_id ,
10571093 )
1094+
1095+ # Copy build and conformance tests folders to output folders if specified
1096+ if args .copy_build :
1097+ file_utils .copy_folder_to_output (args .build_folder , args .build_dest )
1098+ if args .copy_conformance_tests :
1099+ file_utils .copy_folder_to_output (args .conformance_tests_folder , args .conformance_tests_dest )
1100+
1101+ codeplainAPI .finish_functional_requirement (frid , run_state )
1102+
10581103 return
10591104
10601105
@@ -1069,6 +1114,7 @@ def render(args, run_state: RunState): # noqa: C901
10691114 logging .getLogger ("langsmith" ).setLevel (logging .WARNING )
10701115 logging .getLogger ("git" ).setLevel (logging .WARNING )
10711116 logging .getLogger ("anthropic._base_client" ).setLevel (logging .DEBUG )
1117+ logging .getLogger ("services.langsmith.langsmith_service" ).setLevel (logging .INFO )
10721118
10731119 # Try to load logging configuration from YAML file
10741120 if os .path .exists (LOGGING_CONFIG_PATH ):
@@ -1123,7 +1169,7 @@ def render(args, run_state: RunState): # noqa: C901
11231169
11241170 console .info (f"Rendering { args .filename } to target code." )
11251171
1126- plain_source_tree = codeplainAPI .get_plain_source_tree (plain_source , loaded_templates )
1172+ plain_source_tree = codeplainAPI .get_plain_source_tree (plain_source , loaded_templates , run_state )
11271173
11281174 if args .render_range is not None :
11291175 args .render_range = get_render_range (args .render_range , plain_source_tree )
@@ -1146,6 +1192,17 @@ def render(args, run_state: RunState): # noqa: C901
11461192 )
11471193 frid = plain_spec .get_next_frid (plain_source_tree , frid )
11481194
1195+ # if args.verbose and len(run_state.frid_render_anaysis.items()) > 0:
1196+ # console.warning("\nWhile generating the code following ambiguities in the specs were identified:\n")
1197+ # for frid, render_analysis in run_state.frid_render_anaysis.items():
1198+ # specifications, _ = plain_spec.get_specifications_for_frid(plain_source_tree, frid)
1199+ # functional_requirement_text = specifications[plain_spec.FUNCTIONAL_REQUIREMENTS][-1]
1200+ # console.info("\n-------------------------------------")
1201+ # console.info(f"Functional requirement {frid}:")
1202+ # console.output(f"{functional_requirement_text}")
1203+ # console.info(f"Guidance: {render_analysis['guidance']}")
1204+ # console.info("-------------------------------------\n")
1205+
11491206 # Copy build and conformance tests folders to output folders if specified
11501207 if args .copy_build :
11511208 file_utils .copy_folder_to_output (args .build_folder , args .build_dest )
@@ -1225,10 +1282,6 @@ def exit_with_error(message, last_successful_frid=None, render_id=None):
12251282
12261283 codeplain_api = importlib .import_module (codeplain_api_module_name )
12271284
1228- if not args .api_key or args .api_key == "" :
1229- exit_with_error (
1230- "Error: API key is not provided. Please provide an API key using the --api-key flag or by setting the CLAUDE_API_KEY environment variable."
1231- )
12321285 run_state = RunState (replay_with = args .replay_with )
12331286 console .debug (f"Render ID: { run_state .render_id } " )
12341287
0 commit comments