From 3c835d7591b6c3ad79c207eca406cfaac98a8901 Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 13 Feb 2026 04:48:55 -0500 Subject: [PATCH 1/2] Fix package.json config overriding closer pyproject.toml in monorepos In parse_config_file(), package.json was always checked first by walking up from CWD. In monorepos with both a root package.json and a nested pyproject.toml with [tool.codeflash], the JS config would win and set pytest_cmd to "jest", causing Python function optimization to crash with FileNotFoundError: 'jest'. Now both config files are located first, and the one closer to CWD is preferred, so a pyproject.toml in the working directory takes precedence over a parent-directory package.json. --- codeflash/code_utils/config_parser.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/codeflash/code_utils/config_parser.py b/codeflash/code_utils/config_parser.py index 1d6a75f2a..b2f0c4258 100644 --- a/codeflash/code_utils/config_parser.py +++ b/codeflash/code_utils/config_parser.py @@ -88,9 +88,23 @@ def find_conftest_files(test_paths: list[Path]) -> list[Path]: def parse_config_file( config_file_path: Path | None = None, override_formatter_check: bool = False ) -> tuple[dict[str, Any], Path]: - # First try package.json for JS/TS projects package_json_path = find_package_json(config_file_path) + pyproject_toml_path = find_closest_config_file("pyproject.toml") if config_file_path is None else None + + # When both config files exist, prefer the one closer to CWD. + # This prevents a parent-directory package.json (e.g., monorepo root) + # from overriding a closer pyproject.toml with [tool.codeflash]. + use_package_json = False if package_json_path: + if pyproject_toml_path is None: + use_package_json = True + else: + # Compare depth: more path parts = closer to CWD = more specific + package_json_depth = len(package_json_path.parent.parts) + pyproject_toml_depth = len(pyproject_toml_path.parent.parts) + use_package_json = package_json_depth >= pyproject_toml_depth + + if use_package_json: result = parse_package_json_config(package_json_path) if result is not None: config, path = result From 2e7ad77dc57dcce92472ae92edd5126aa05b8c94 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 09:54:35 +0000 Subject: [PATCH 2/2] fix: resolve mypy arg-type error for package_json_path --- codeflash/code_utils/config_parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/codeflash/code_utils/config_parser.py b/codeflash/code_utils/config_parser.py index b2f0c4258..d6839d82f 100644 --- a/codeflash/code_utils/config_parser.py +++ b/codeflash/code_utils/config_parser.py @@ -105,6 +105,7 @@ def parse_config_file( use_package_json = package_json_depth >= pyproject_toml_depth if use_package_json: + assert package_json_path is not None result = parse_package_json_config(package_json_path) if result is not None: config, path = result