Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions codeflash/setup/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,10 @@ def has_existing_config(project_root: Path) -> tuple[bool, str | None]:
toml_path = project_root / toml_filename
if toml_path.exists():
try:
with toml_path.open("rb") as f:
data = tomlkit.parse(f.read())
if "tool" in data and "codeflash" in data["tool"]:
with toml_path.open("r", encoding="utf8", errors="ignore") as f:
content = f.read()
# Quick string search before expensive parsing
if "codeflash" in content and "[tool" in content:
return True, toml_filename
except Exception:
pass
Expand All @@ -905,9 +906,10 @@ def has_existing_config(project_root: Path) -> tuple[bool, str | None]:
package_json_path = project_root / "package.json"
if package_json_path.exists():
try:
with package_json_path.open(encoding="utf8") as f:
data = json.load(f)
if "codeflash" in data:
with package_json_path.open("r", encoding="utf8", errors="ignore") as f:
content = f.read()
# Quick string search for codeflash key
if '"codeflash"' in content:
return True, "package.json"
except Exception:
pass
Expand Down
Loading