Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
c737417
include concolic tests in arg even if not used
aseembits93 Jan 30, 2026
0bf3112
extra keyword args ignored
aseembits93 Jan 30, 2026
699dc30
extra keyword args ignored for staging
aseembits93 Jan 30, 2026
3a44a3e
Merge branch 'main' into fix-opt-review
aseembits93 Jan 31, 2026
9700b7e
Merge branch 'main' into fix-opt-review
aseembits93 Jan 31, 2026
77d9f4f
Merge branch 'main' into fix-opt-review
aseembits93 Jan 31, 2026
6dc3bc5
Merge branch 'main' into fix-opt-review
aseembits93 Feb 2, 2026
308a4e4
Add tests for project-inside-tests-folder fix
Saga4 Feb 3, 2026
a765b6d
Merge branch 'main' into fix/test-file-pattern-matching-parent-dirs
Saga4 Feb 3, 2026
4c56af3
Merge branch 'main' into fix-opt-review
KRRT7 Feb 4, 2026
09e3ba3
xml parsing fix and refactor to support directory
Saga4 Feb 4, 2026
86abf64
Merge pull request #1208 from codeflash-ai/fix-opt-review
KRRT7 Feb 4, 2026
390397e
fix: support monorepo hoisted dependencies in JS requirements check
mohammedahmed18 Feb 4, 2026
e42abb6
Merge branch 'main' into fix/jest_xml_parsing_and_refactor
Saga4 Feb 4, 2026
adc4832
style: auto-fix formatting issues
github-actions[bot] Feb 4, 2026
c15a781
Merge pull request #1375 from codeflash-ai/fix/jest_xml_parsing_and_r…
Saga4 Feb 4, 2026
db2fa8d
Merge branch 'main' into fix/js-requirements-monorepo-support
Saga4 Feb 4, 2026
54110a8
refactor: move test framework discovery to init_javascript
mohammedahmed18 Feb 4, 2026
8231c60
fix(ci): consolidate Claude review into single sticky comment
KRRT7 Feb 4, 2026
fe9f22b
docs: update pre-commit references to prek
KRRT7 Feb 4, 2026
7cf2e4e
feat(ci): add mypy checks to Claude PR review workflow
KRRT7 Feb 4, 2026
09aede2
Merge pull request #1380 from codeflash-ai/claude-improvements
KRRT7 Feb 4, 2026
e9aadb8
feat(ci): auto-merge codeflash optimization PRs when CI passes
KRRT7 Feb 4, 2026
31aba1e
Merge pull request #1381 from codeflash-ai/new-work
KRRT7 Feb 4, 2026
3904126
vitest dot notation for junit reporter
Saga4 Feb 4, 2026
d373d99
Merge branch 'main' into fix/js-requirements-monorepo-support
Saga4 Feb 4, 2026
0e5bf04
Merge pull request #1376 from codeflash-ai/fix/js-requirements-monore…
Saga4 Feb 4, 2026
27254b9
Merge branch 'main' into add_vitest_reporter_for_output_format
Saga4 Feb 4, 2026
6fc2c17
Merge pull request #1382 from codeflash-ai/add_vitest_reporter_for_ou…
Saga4 Feb 4, 2026
ad3555f
fix/test_globals
Saga4 Feb 4, 2026
0f23588
Merge branch 'main' into add_vitest_reporter_for_output_format
Saga4 Feb 4, 2026
2b66d15
feat: add PyArrow support to comparator
aseembits93 Feb 4, 2026
da1d243
fix: resolve mypy type errors for PyArrow comparisons
github-actions[bot] Feb 4, 2026
d015e1d
coverage vitest version compatibility fix and cov. report to original…
Saga4 Feb 4, 2026
aa7eed1
ts and js validation test
Saga4 Feb 4, 2026
6aa8796
style: auto-fix linting issues
github-actions[bot] Feb 4, 2026
0748874
adding more E2E tests for JS/TS
Saga4 Feb 4, 2026
280747f
integration tests for js/ts
Saga4 Feb 4, 2026
7d40855
add ts/js multiple tests
Saga4 Feb 4, 2026
6808e46
adding package.json update- we shouldnt upload package lock file for …
Saga4 Feb 4, 2026
07a0bdf
fix: resolve mypy type errors in models.py
github-actions[bot] Feb 4, 2026
1f127d1
xml relative path issue fix
Saga4 Feb 5, 2026
6355f92
feat: support glob patterns in ignore_paths configuration
mohammedahmed18 Feb 5, 2026
17916ef
fix on loop count
Saga4 Feb 5, 2026
00a6f4d
fix unit tests
Saga4 Feb 5, 2026
94922ed
style: auto-fix linting issues
github-actions[bot] Feb 5, 2026
d148f87
Merge pull request #1386 from codeflash-ai/add_vitest_reporter_for_ou…
Saga4 Feb 5, 2026
e0330ed
Merge branch 'main' into feat/ignore-paths-glob-patterns
Saga4 Feb 5, 2026
b741859
Merge pull request #1391 from codeflash-ai/feat/ignore-paths-glob-pat…
Saga4 Feb 5, 2026
ff7c0f9
version upgrade to 0.7.1
Saga4 Feb 5, 2026
0dc2b5f
Merge pull request #1396 from codeflash-ai/version_upgrade_to_0.7.1
Saga4 Feb 5, 2026
be5b4de
ESM config compatibility for vitest
Saga4 Feb 5, 2026
91454e2
fix: add verification step to CI Claude workflow to prevent hallucina…
KRRT7 Feb 6, 2026
ee5871d
feat: add modular Claude Code rules in .claude/rules/
KRRT7 Feb 6, 2026
308507c
cleanup
KRRT7 Feb 6, 2026
2847edc
feat: upgrade Claude GHA to Opus 4.6
KRRT7 Feb 6, 2026
3e4a2a8
Merge pull request #1399 from codeflash-ai/fix/claude-workflow-verifi…
KRRT7 Feb 6, 2026
0d0a9fb
Merge branch 'main' into fix/path_resolution_for_esm
KRRT7 Feb 6, 2026
c233a37
style: auto-fix linting issues
github-actions[bot] Feb 6, 2026
961cca5
fix for weakref
aseembits93 Feb 6, 2026
0e15c77
Merge branch 'main' into comparator-nn-module
aseembits93 Feb 6, 2026
648c447
style: add type annotation for superset_obj parameter
github-actions[bot] Feb 6, 2026
555a2f9
standalone tests
aseembits93 Feb 6, 2026
410aca7
fix loop count issue among subsequent tests
Saga4 Feb 9, 2026
c56b008
Merge branch 'main' into fix/test-file-pattern-matching-parent-dirs
Saga4 Feb 9, 2026
5926949
style: auto-fix linting issues
github-actions[bot] Feb 9, 2026
67b48be
Merge pull request #1334 from codeflash-ai/fix/test-file-pattern-matc…
Saga4 Feb 9, 2026
ae4df22
Merge branch 'main' into fix/path_resolution_for_esm
Saga4 Feb 9, 2026
cd1f353
Merge pull request #1397 from codeflash-ai/fix/path_resolution_for_esm
Saga4 Feb 9, 2026
476682c
fix: lower pytest-asyncio minimum version to 0.18.0
KRRT7 Feb 9, 2026
6428a22
Merge pull request #1424 from codeflash-ai/inference-fix
KRRT7 Feb 10, 2026
0b611c7
Install cli post cloning in npm
Saga4 Feb 10, 2026
1ad9c6a
Merge pull request #1438 from codeflash-ai/install_with_clone
Saga4 Feb 10, 2026
b8597b2
wrapped functions default export support
Saga4 Feb 10, 2026
fa56eb7
refactor
Saga4 Feb 10, 2026
b893220
Merge branch 'main' into install_with_clone
Saga4 Feb 10, 2026
78ce6e6
style: auto-fix linting issues
github-actions[bot] Feb 10, 2026
97531dc
Merge pull request #1441 from codeflash-ai/install_with_clone
Saga4 Feb 10, 2026
88d6e8b
Merge branch 'main' into comparator-nn-module
KRRT7 Feb 11, 2026
ce67f09
Merge pull request #1411 from codeflash-ai/comparator-nn-module
KRRT7 Feb 11, 2026
fb5ee23
Merge branch 'main' into pyarrow-comparator
KRRT7 Feb 11, 2026
dd0e83d
style: auto-fix linting issues
github-actions[bot] Feb 11, 2026
3dd19c6
Merge pull request #1387 from codeflash-ai/pyarrow-comparator
KRRT7 Feb 11, 2026
7d7a2a2
Merge commit '3dd19c62' into sync-main-batch-1
KRRT7 Feb 20, 2026
30fa101
chore: fix ruff check and format issues
KRRT7 Feb 20, 2026
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
28 changes: 28 additions & 0 deletions .claude/rules/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Architecture

```
codeflash/
├── main.py # CLI entry point
├── cli_cmds/ # Command handling, console output (Rich)
├── discovery/ # Find optimizable functions
├── context/ # Extract code dependencies and imports
├── optimization/ # Generate optimized code via AI
│ ├── optimizer.py # Main optimization orchestration
│ └── function_optimizer.py # Per-function optimization logic
├── verification/ # Run deterministic tests (pytest plugin)
├── benchmarking/ # Performance measurement
├── github/ # PR creation
├── api/ # AI service communication
├── code_utils/ # Code parsing, git utilities
├── models/ # Pydantic models and types
├── languages/ # Multi-language support (Python, JavaScript/TypeScript)
├── setup/ # Config schema, auto-detection, first-run experience
├── picklepatch/ # Serialization/deserialization utilities
├── tracing/ # Function call tracing
├── tracer.py # Root-level tracer entry point for profiling
├── lsp/ # IDE integration (Language Server Protocol)
├── telemetry/ # Sentry, PostHog
├── either.py # Functional Result type for error handling
├── result/ # Result types and handling
└── version.py # Version information
```
9 changes: 9 additions & 0 deletions .claude/rules/code-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Code Style

- **Line length**: 120 characters
- **Python**: 3.9+ syntax
- **Tooling**: Ruff for linting/formatting, mypy strict mode, prek for pre-commit checks
- **Comments**: Minimal - only explain "why", not "what"
- **Docstrings**: Do not add unless explicitly requested
- **Naming**: NEVER use leading underscores (`_function_name`) - Python has no true private functions, use public names
- **Paths**: Always use absolute paths, handle encoding explicitly (UTF-8)
6 changes: 6 additions & 0 deletions .claude/rules/git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Git Commits & Pull Requests

- Use conventional commit format: `fix:`, `feat:`, `refactor:`, `docs:`, `test:`, `chore:`
- Keep commits atomic - one logical change per commit
- Commit message body should be concise (1-2 sentences max)
- PR titles should also use conventional format
11 changes: 11 additions & 0 deletions .claude/rules/source-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
paths:
- "codeflash/**/*.py"
---

# Source Code Rules

- Use `libcst` for code modification/transformation to preserve formatting. `ast` is acceptable for read-only analysis and parsing.
- NEVER use leading underscores for function names (e.g., `_helper`). Python has no true private functions. Always use public names.
- Any new feature or bug fix that can be tested automatically must have test cases.
- If changes affect existing test expectations, update the tests accordingly. Tests must always pass after changes.
15 changes: 15 additions & 0 deletions .claude/rules/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
paths:
- "tests/**"
- "codeflash/**/*test*.py"
---

# Testing Conventions

- Code context extraction and replacement tests must always assert for full string equality, no substring matching.
- Use pytest's `tmp_path` fixture for temp directories (it's a `Path` object).
- Write temp files inside `tmp_path`, never use `NamedTemporaryFile` (causes Windows file contention).
- Always call `.resolve()` on Path objects to ensure absolute paths and resolve symlinks.
- Use `.as_posix()` when converting resolved paths to strings (normalizes to forward slashes).
- Any new feature or bug fix that can be tested automatically must have test cases.
- If changes affect existing test expectations, update the tests accordingly. Tests must always pass after changes.
71 changes: 61 additions & 10 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,34 @@ jobs:
PR NUMBER: ${{ github.event.pull_request.number }}
EVENT: ${{ github.event.action }}

## STEP 1: Run pre-commit checks and fix issues
## STEP 1: Run prek and mypy checks, fix issues

First, run `uv run prek run --from-ref origin/main` to check for linting/formatting issues on files changed in this PR.
First, run these checks on files changed in this PR:
1. `uv run prek run --from-ref origin/main` - linting/formatting issues
2. `uv run mypy <changed_files>` - type checking issues

If there are any issues:
If there are prek issues:
- For SAFE auto-fixable issues (formatting, import sorting, trailing whitespace, etc.), run `uv run prek run --from-ref origin/main` again to auto-fix them
- For issues that prek cannot auto-fix, do NOT attempt to fix them manually — report them as remaining issues in your summary

If there are mypy issues:
- Fix type annotation issues (missing return types, Optional/None unions, import errors for type hints, incorrect types)
- Do NOT add `type: ignore` comments - always fix the root cause

After fixing issues:
- Stage the fixed files with `git add`
- Commit with message "style: auto-fix linting issues"
- Commit with message "style: auto-fix linting issues" or "fix: resolve mypy type errors" as appropriate
- Push the changes with `git push`

IMPORTANT - Verification after fixing:
- After committing fixes, run `uv run prek run --from-ref origin/main` ONE MORE TIME to verify all issues are resolved
- If errors remain, either fix them or report them honestly as unfixed in your summary
- NEVER claim issues are fixed without verifying. If you cannot fix an issue, say so

Do NOT attempt to fix:
- Type errors that require logic changes
- Complex refactoring suggestions
- Anything that could change behavior
- Type errors that require logic changes or refactoring
- Complex generic type issues
- Anything that could change runtime behavior

## STEP 2: Review the PR

Expand All @@ -85,7 +99,6 @@ jobs:
- Only create NEW inline comments for HIGH-PRIORITY issues found in changed files.
- Limit to 5-7 NEW comments maximum per review.
- Use CLAUDE.md for project-specific guidance.
- Use `gh pr comment` for summary-level feedback.
- Use `mcp__github_inline_comment__create_inline_comment` sparingly for critical code issues only.

## STEP 3: Coverage analysis
Expand Down Expand Up @@ -122,7 +135,45 @@ jobs:
- New implementations/files: Must have ≥75% test coverage
- Modified code: Changed lines should be exercised by existing or new tests
- No coverage regressions: Overall coverage should not decrease
claude_args: '--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh issue view:*),Bash(gh issue list:*),Bash(gh api:*),Bash(uv run prek *),Bash(uv run coverage *),Bash(uv run pytest *),Bash(git status*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git diff *),Bash(git checkout *),Read,Glob,Grep"'

## STEP 4: Post ONE consolidated summary comment

CRITICAL: You must post exactly ONE summary comment containing ALL results (pre-commit, review, coverage).
DO NOT post multiple separate comments. Use this format:

```
## PR Review Summary

### Prek Checks
[status and any fixes made]

### Code Review
[critical issues found, if any]

### Test Coverage
[coverage table and analysis]

---
*Last updated: <timestamp>*
```

To ensure only ONE comment exists:
1. Find existing claude[bot] comment: `gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "claude[bot]") | .id' | head -1`
2. If found, UPDATE it: `gh api --method PATCH repos/${{ github.repository }}/issues/comments/<ID> -f body="<content>"`
3. If not found, CREATE: `gh pr comment ${{ github.event.pull_request.number }} --body "<content>"`
4. Delete any OTHER claude[bot] comments to clean up duplicates: `gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "claude[bot]") | .id' | tail -n +2 | xargs -I {} gh api --method DELETE repos/${{ github.repository }}/issues/comments/{}`

## STEP 5: Merge pending codeflash optimization PRs

Check for open optimization PRs from codeflash and merge if CI passes:

1. List open PRs from codeflash bot:
`gh pr list --author "codeflash-ai[bot]" --state open --json number,title,headRefName`

2. For each optimization PR:
- Check if CI is passing: `gh pr checks <number>`
- If all checks pass, merge it: `gh pr merge <number> --squash --delete-branch`
claude_args: '--model claude-opus-4-6 --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh pr checks:*),Bash(gh pr merge:*),Bash(gh issue view:*),Bash(gh issue list:*),Bash(gh api:*),Bash(uv run prek *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(uv run pytest *),Bash(git status*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git diff *),Bash(git checkout *),Read,Glob,Grep,Edit"'
additional_permissions: |
actions: read
env:
Expand Down Expand Up @@ -194,7 +245,7 @@ jobs:
uses: anthropics/claude-code-action@v1
with:
use_foundry: "true"
claude_args: '--allowedTools "Read,Edit,Write,Glob,Grep,Bash(git status*),Bash(git diff*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git log*),Bash(git merge*),Bash(git fetch*),Bash(git checkout*),Bash(git branch*),Bash(uv run prek *),Bash(prek *),Bash(uv run ruff *),Bash(uv run pytest *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(gh pr comment*),Bash(gh pr view*),Bash(gh pr diff*),Bash(gh pr merge*),Bash(gh pr close*)"'
claude_args: '--model claude-opus-4-6 --allowedTools "Read,Edit,Write,Glob,Grep,Bash(git status*),Bash(git diff*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git log*),Bash(git merge*),Bash(git fetch*),Bash(git checkout*),Bash(git branch*),Bash(uv run prek *),Bash(prek *),Bash(uv run ruff *),Bash(uv run pytest *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(gh pr comment*),Bash(gh pr view*),Bash(gh pr diff*),Bash(gh pr merge*),Bash(gh pr close*)"'
additional_permissions: |
actions: read
env:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ WARP.MD
.mcp.json
.tessl/
tessl.json

# Claude Code - track shared rules, ignore local config
.claude/*
!.claude/rules/
**/node_modules/**
**/dist-nuitka/**
**/.npmrc
Expand Down
53 changes: 2 additions & 51 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,15 @@ uv run mypy codeflash/ # Type check
uv run ruff check codeflash/ # Lint
uv run ruff format codeflash/ # Format

# Pre-commit (run before committing)
uv run pre-commit run --all-files
# Linting (run before committing)
uv run prek run --from-ref origin/main

# Running the CLI
uv run codeflash --help
uv run codeflash init # Initialize in a project
uv run codeflash --all # Optimize entire codebase
```

## Architecture

```
codeflash/
├── main.py # CLI entry point
├── cli_cmds/ # Command handling, console output (Rich)
├── discovery/ # Find optimizable functions
├── context/ # Extract code dependencies and imports
├── optimization/ # Generate optimized code via AI
│ ├── optimizer.py # Main optimization orchestration
│ └── function_optimizer.py # Per-function optimization logic
├── verification/ # Run deterministic tests (pytest plugin)
├── benchmarking/ # Performance measurement
├── github/ # PR creation
├── api/ # AI service communication
├── code_utils/ # Code parsing, git utilities
├── models/ # Pydantic models and types
├── tracing/ # Function call tracing
├── lsp/ # IDE integration (Language Server Protocol)
├── telemetry/ # Sentry, PostHog
├── either.py # Functional Result type for error handling
└── result/ # Result types and handling
```

### Key Rules to follow

- Use libcst, not ast - For Python, always use `libcst` for code parsing/modification to preserve formatting.
- Code context extraction and replacement tests must always assert for full string equality, no substring matching.
- Any new feature or bug fix that can be tested automatically must have test cases.
- If changes affect existing test expectations, update the tests accordingly. Tests must always pass after changes.
- NEVER use leading underscores for function names (e.g., `_helper`). Python has no true private functions. Always use public names.

## Code Style

- **Line length**: 120 characters
- **Python**: 3.9+ syntax
- **Tooling**: Ruff for linting/formatting, mypy strict mode, pre-commit hooks
- **Comments**: Minimal - only explain "why", not "what"
- **Docstrings**: Do not add unless explicitly requested
- **Naming**: NEVER use leading underscores (`_function_name`) - Python has no true private functions, use public names
- **Paths**: Always use absolute paths, handle encoding explicitly (UTF-8)

## Git Commits & Pull Requests

- Use conventional commit format: `fix:`, `feat:`, `refactor:`, `docs:`, `test:`, `chore:`
- Keep commits atomic - one logical change per commit
- Commit message body should be concise (1-2 sentences max)
- PR titles should also use conventional format

<!-- Section below is auto-generated by `tessl install` - do not edit manually -->

# Agent Rules <!-- tessl-managed -->
Expand Down
4 changes: 2 additions & 2 deletions MULTI_LANGUAGE_ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class JavaScriptTransformer:

from pathlib import Path
from codeflash.languages.base import LanguageSupport, FunctionInfo, CodeContext
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer
from codeflash.languages.javascript.transformer import JavaScriptTransformer

class JavaScriptSupport(LanguageSupport):
Expand Down Expand Up @@ -523,7 +523,7 @@ class JavaScriptSupport(LanguageSupport):
# codeflash/languages/javascript/test_discovery.py

from pathlib import Path
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer

class JestTestDiscovery:
"""Static analysis-based test discovery for Jest."""
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ def get_optimization_review(
replay_tests: str,
calling_fn_details: str,
language: str = "python",
**_kwargs: Any,
) -> OptimizationReviewResult:
"""Compute the optimization review of current Pull Request.

Expand Down
1 change: 1 addition & 0 deletions codeflash/api/cfapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def create_staging(
optimization_review: str = "",
original_line_profiler: str | None = None,
optimized_line_profiler: str | None = None,
**_kwargs: Any, # ignores the language argument TODO Hesham: staging for all langs
) -> Response:
"""Create a staging pull request, targeting the specified branch. (usually 'staging').

Expand Down
14 changes: 5 additions & 9 deletions codeflash/cli_cmds/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from codeflash.cli_cmds.console import logger
from codeflash.cli_cmds.extension import install_vscode_extension
from codeflash.code_utils import env_utils
from codeflash.code_utils.code_utils import exit_with_message
from codeflash.code_utils.code_utils import exit_with_message, normalize_ignore_paths
from codeflash.code_utils.config_parser import parse_config_file
from codeflash.languages.test_framework import set_current_test_framework
from codeflash.lsp.helpers import is_LSP_enabled
Expand Down Expand Up @@ -296,16 +296,12 @@ def process_pyproject_config(args: Namespace) -> Namespace:

require_github_app_or_exit(owner, repo_name)

if hasattr(args, "ignore_paths") and args.ignore_paths is not None:
normalized_ignore_paths = []
for path in args.ignore_paths:
path_obj = Path(path)
if path_obj.exists():
normalized_ignore_paths.append(path_obj.resolve())
# Silently skip non-existent paths (e.g., .next, dist before build)
args.ignore_paths = normalized_ignore_paths
# Project root path is one level above the specified directory, because that's where the module can be imported from
args.module_root = Path(args.module_root).resolve()
if hasattr(args, "ignore_paths") and args.ignore_paths is not None:
# Normalize ignore paths, supporting both literal paths and glob patterns
# Use module_root as base path for resolving relative paths and patterns
args.ignore_paths = normalize_ignore_paths(args.ignore_paths, base_path=args.module_root)
# If module-root is "." then all imports are relatives to it.
# in this case, the ".." becomes outside project scope, causing issues with un-importable paths
args.project_root = project_root_from_module_root(args.module_root, pyproject_file_path)
Expand Down
26 changes: 26 additions & 0 deletions codeflash/cli_cmds/init_javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,32 @@ def determine_js_package_manager(project_root: Path) -> JsPackageManager:
return JsPackageManager.UNKNOWN


def find_node_modules_with_package(project_root: Path, package_name: str) -> Path | None:
"""Find node_modules directory containing a specific package.

Searches from project_root up to filesystem root for node_modules containing
the specified package. This supports monorepo setups where dependencies are
hoisted to the workspace root.

Args:
project_root: Starting directory for the search.
package_name: Name of the package to look for (e.g., "jest", "vitest").

Returns:
Path to the node_modules directory containing the package, or None if not found.

"""
current_dir = project_root.resolve()
while current_dir != current_dir.parent:
node_modules = current_dir / "node_modules"
if node_modules.exists():
package_path = node_modules / package_name
if package_path.exists():
return node_modules
current_dir = current_dir.parent
return None


def get_package_install_command(project_root: Path, package: str, dev: bool = True) -> list[str]:
"""Get the correct install command for the project's package manager.

Expand Down
2 changes: 1 addition & 1 deletion codeflash/code_utils/code_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ def _extract_calling_function_js(source_code: str, function_name: str, ref_line:

"""
try:
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

# Try TypeScript first, fall back to JavaScript
for lang in [TreeSitterLanguage.TYPESCRIPT, TreeSitterLanguage.TSX, TreeSitterLanguage.JAVASCRIPT]:
Expand Down
Loading
Loading