Commit graph

7374 commits

Author SHA1 Message Date
aseembits93
596763d33a Merge remote-tracking branch 'origin/main' into feat/subagent-low-effort-defaults 2026-03-09 10:30:04 -07:00
Sarthak Agarwal
c7d4e5be64
Merge pull request #1798 from codeflash-ai/update_js_to_10.2
update JS package to 0.10.2
2026-03-09 02:32:44 +05:30
Sarthak Agarwal
aa63155610 update JS package to 0.10.2 2026-03-09 02:32:02 +05:30
claude[bot]
a29bca3372 style: fix EM102 f-string in exception in init_config.py 2026-03-07 18:30:17 +00:00
Sarthak Agarwal
222805730b
Merge pull request #1778 from codeflash-ai/fix/github_actions_init
[Fix] Github Actions init
2026-03-07 23:58:13 +05:30
Kevin Turcios
d9a329667e fix: resolve jest-runner inside scoped package subdirectories
The recursive search in loop-runner.js wasn't entering package
directories inside scoped namespaces (e.g. @jest/core), so it couldn't
find jest-runner nested at @jest/core/node_modules/jest-runner.
2026-03-07 12:26:52 -06:00
claude[bot]
123f06084d fix: resolve mypy type errors in newly added cli_cmds and base modules
- Fix get_suggestions() param type: str -> CommonSections (prevents silent no-match bugs)
- Fix generate_dynamic_workflow_content()/customize_codeflash_yaml_content() config param: tuple -> dict (runtime crash: dict-key access on a tuple)
- Fix get_dependency_installation_commands() return type: tuple[str,str] -> str (runtime crash: tuple passed to str.replace())
- Fix configure_pyproject_toml() else->elif isinstance(CLISetupInfo) for proper type narrowing
- Mark apologize_and_exit() as NoReturn to enable post-call type narrowing
- Remove unreachable return None statements in collect_setup_info()
- Refactor while-loop sentinels in collect_setup_info() to typed local vars
- Add missing type params to list/dict/tuple in LanguageSupport
- Add _get_theme() return type with TYPE_CHECKING import

Co-authored-by: Kevin Turcios <undefined@users.noreply.github.com>
2026-03-07 13:47:02 +00:00
Kevin Turcios
6ffe9bd51d fix: resolve mypy no-any-return errors in code_context_extractor
Wrap jedi Name.name comparisons with bool() since jedi's Name.name
property is typed as Any.
2026-03-07 08:38:00 -05:00
Kevin Turcios
1a0726729d bit 2026-03-07 08:29:50 -05:00
Kevin Turcios
9bc589dbbe Merge remote-tracking branch 'origin/fix-dependabot-vulns' into fix-dependabot-vulns 2026-03-07 08:27:11 -05:00
Kevin Turcios
9c7566a042 style: wrap long lines in github_workflow.py to meet line length limit 2026-03-07 08:25:22 -05:00
Kevin Turcios
2021ce9595
Merge pull request #1794 from codeflash-ai/codeflash/optimize-pr1789-2026-03-07T11.48.50
️ Speed up function `get_suggestions` by 17% in PR #1789 (`fix-dependabot-vulns`)
2026-03-07 13:24:26 +00:00
Kevin Turcios
5db42fa9ef
Merge pull request #1793 from codeflash-ai/codeflash/optimize-pr1789-2026-03-07T11.26.49
️ Speed up function `prompt_api_key` by 22% in PR #1789 (`fix-dependabot-vulns`)
2026-03-07 13:23:26 +00:00
Kevin Turcios
f43ee06859 refactor: restructure codebase for locality and faster CLI startup
Move files closer to their consumers:
- function_context.py merged into code_context_extractor.py
- FunctionOptimizer base class to languages/function_optimizer.py
- test_runner, instrument_codeflash_capture, parse_line_profile to languages/python/
- oauth_handler.py to cli_cmds/

Split cmd_init.py (1993 lines) into focused modules:
- init_config.py: config types, validation, writing, shared UI
- init_auth.py: API key management + GitHub app installation
- github_workflow.py: GitHub Actions workflow generation
- cmd_init.py: init orchestrator + Python setup (639 lines)

Defer heavy imports (cmd_init, posthog, sentry) from module-level to
usage sites, reducing CLI startup from ~600ms to ~250ms. Replace
set_defaults(func=) with direct args.command dispatch in main().
2026-03-07 08:21:27 -05:00
codeflash-ai[bot]
2c4f31ba6e
Optimize get_suggestions
The hot function `get_valid_subdirs` replaced `os.walk(...)[1]` (which builds full directory trees) with `os.scandir`, iterating only immediate children and checking `entry.is_dir()` directly. The profiler shows 82% of runtime was in the cached `get_valid_subdirs` call; within that function, `os.walk` was materializing nested structures unnecessarily. Switching `ignore_subdirs` from a list to a set reduced membership tests from O(n) to O(1), and consolidating two `startswith` checks into a single tuple-argument call eliminated redundant method dispatch. Across 34 hits in `get_suggestions`, per-call latency dropped from ~23 µs to ~21.6 µs, yielding a 17% speedup with no correctness regressions.
2026-03-07 11:48:54 +00:00
claude[bot]
7188e587c5 style: auto-fix linting issues from prek 2026-03-07 11:28:55 +00:00
codeflash-ai[bot]
8fcc472eac
Optimize prompt_api_key
The optimization hoisted `Panel` and `Text` imports (from `rich.panel` and `rich.text`) to module scope and created a singleton `_THEME_SINGLETON = CodeflashTheme()` instead of instantiating it on each `inquirer.prompt` call. Line profiler shows that `prompt_api_key` spent ~22% of its runtime on these two imports plus ~11% on `CodeflashTheme().__init__` calls (which invokes `super().__init__()` to configure inquirer theme attributes). By importing once and reusing the theme instance, the optimized code eliminates repeated import overhead (from ~1.9ms down to ~0.0ms for imports) and theme construction overhead (from ~5ms to a one-time ~0.4ms initialization). This reduces the overall runtime from 21.4ms to 17.5ms (22% speedup) when `prompt_api_key` is invoked multiple times by the CLI, with no regressions in correctness or functionality.
2026-03-07 11:26:52 +00:00
claude[bot]
f8fc662e7d
Merge pull request #1790 from codeflash-ai/codeflash/optimize-pr1789-2026-03-07T09.56.25
️ Speed up function `parse_args` by 38% in PR #1789 (`fix-dependabot-vulns`)
2026-03-07 10:15:07 +00:00
claude[bot]
a32ffe4b3b fix: remove duplicate _build_parser definition and fix import order 2026-03-07 10:01:11 +00:00
codeflash-ai[bot]
fefae96d6c
Optimize parse_args
The optimization wraps parser construction in `@lru_cache(maxsize=1)` so that the 35+ `add_argument` calls (each costing ~7 µs per profiler data) execute once per process instead of on every invocation of `parse_args`. This cuts parse_args time from 581 ms to 32 ms because ArgumentParser construction dominates the original runtime. The cache is safe because the parser definition is static; parsing different sys.argv values reuses the cached parser object without rebuilding its internal action registry.
2026-03-07 09:56:29 +00:00
claude[bot]
64a236cdee style: auto-fix linting issues from prek
Co-authored-by: Kevin Turcios <undefined@users.noreply.github.com>
2026-03-07 09:46:38 +00:00
Kevin Turcios
7cd1a3e4e8 refactor: restructure codebase for locality and faster CLI startup
Move files closer to their consumers:
- function_context.py merged into code_context_extractor.py
- FunctionOptimizer base class to languages/function_optimizer.py
- test_runner, instrument_codeflash_capture, parse_line_profile to languages/python/
- oauth_handler.py to cli_cmds/

Split cmd_init.py (1993 lines) into focused modules:
- init_config.py: config types, validation, writing, shared UI
- init_auth.py: API key management + GitHub app installation
- github_workflow.py: GitHub Actions workflow generation
- cmd_init.py: init orchestrator + Python setup (639 lines)

Defer heavy imports (cmd_init, posthog, sentry) from module-level to
usage sites, reducing CLI startup from ~600ms to ~250ms. Replace
set_defaults(func=) with direct args.command dispatch in main().
2026-03-07 04:42:50 -05:00
Kevin Turcios
45fb07fad2 fix: upgrade dependencies to resolve Dependabot security alerts
Upgrade Python deps via uv sync --upgrade (werkzeug, filelock for py>=3.10,
and others). Run npm audit fix across JS test fixtures to patch minimatch
and rollup vulnerabilities.

Remaining unfixable:
- filelock <3.20.3 for py<3.10 (patched version requires py>=3.10)
- serialize-javascript in mocha ^10 (fix requires mocha 11 breaking change)
2026-03-07 03:48:38 -05:00
Kevin Turcios
5f3480e8a2
Merge pull request #1714 from codeflash-ai/testgen-review
feat: per-function test quality review and repair
2026-03-07 08:40:50 +00:00
Kevin Turcios
2fec18c65b fix: build full dotted name in _expr_name for module-qualified decorators/bases
_expr_name now recurses into ast.Attribute to produce the full dotted
path (e.g. "dataclasses.dataclass", "typing.NamedTuple"). Callers use
.endswith() so both bare and module-qualified forms are matched. Adds
test for typing.NamedTuple base class.
2026-03-07 03:32:25 -05:00
Kevin Turcios
2b8bef5f9c Update function_optimizer.py 2026-03-07 03:29:31 -05:00
Kevin Turcios
9fd5a3d93f fix: address PR review — recurse _expr_name for call-style decorators, guard empty-set superset
Add tests for remove_test_functions qualified name support and
module-qualified dataclass decorator handling.
2026-03-07 03:03:23 -05:00
Kevin Turcios
fc55aedee7 fix: address PR review — recurse _expr_name for call-style decorators, guard empty-set superset 2026-03-07 03:00:19 -05:00
Mohamed Ashraf
2a00f27818 fix: guard against None message in JUnit XML failure elements
testcase.result[0].message can be None when a JUnit XML failure/error
element has no message attribute. This caused an AttributeError crash
in parse_java_test_xml during benchmarking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 02:56:48 +00:00
Mohamed Ashraf
9870785469 fix: address PR review feedback
- Fix mypy error: assert coverage_xml_path is not None before
  generate_jacoco_report call (control flow guarantees it but mypy
  can't infer it)
- Remove unused _JAVA_RESOURCES_DIR constant from build_tools.py
- Make AgentDispatcher routing robust: check startsWith("config=") or
  contains(",config=") instead of bare substring match, preventing
  false positive on paths containing "config="
- Drop redundant exception arg from logger.exception call

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:27:17 +00:00
Mohamed Ashraf
dcf9edb21d chore: remove redundant pom.xml backup/restore logic
add_codeflash_dependency_to_pom() already handles errors internally —
it builds content in memory and only writes on success. The backup
mechanism was redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:17:31 +00:00
claude[bot]
193307b9f1 style: remove extra blank line in build_tools.py 2026-03-07 01:10:47 +00:00
Mohamed Ashraf
24ad61aa5c feat: shade JaCoCo into codeflash-runtime as one fat JAR
Merge JaCoCo agent and CLI into the runtime JAR instead of shipping 3
separate JARs. JaCoCo already self-shades its internals with a version
hash, so no relocation is needed.

- Add AgentDispatcher premain that routes to profiler (config=) or
  JaCoCo (destfile=) based on agent args
- Update shade plugin: Premain-Class → AgentDispatcher, add
  ServicesResourceTransformer and DontIncludeResourceTransformer
- Rewrite build_jacoco_agent_arg() and generate_jacoco_report() to use
  the runtime JAR instead of separate JaCoCo JARs
- Delete org.jacoco.agent-0.8.13-runtime.jar and
  org.jacoco.cli-0.8.13-nodeps.jar from resources/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:06:58 +00:00
Kevin Turcios
e33a7da615 Merge branch 'main' into testgen-review 2026-03-06 17:20:42 -05:00
Kevin Turcios
89faf1e2fd chore: use default testgen-review-turns in GHA 2026-03-06 17:05:01 -05:00
Kevin Turcios
c595a04426 fix: per-function revert granularity in testgen review/repair
Instead of reverting the entire test file when any function fails
after repair, remove only the failing test functions and keep passing
ones. Full revert is preserved when all functions in a file fail.
2026-03-06 15:43:23 -05:00
Kevin Turcios
8c974c9540 module level only 2026-03-06 15:43:22 -05:00
Aseem Saxena
d9f33fc8d9 feat: instruct Claude Code to review optimizations in subagent mode
The subagent action instructions now tell Claude Code to read the
original source, compare it against the optimized code, and check for
correctness and quality issues before presenting the result to the user.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 12:34:34 -08:00
Sarthak Agarwal
417623f930
Merge pull request #1780 from codeflash-ai/fix/normalizer
[Fix] Normalizer and expand its scope
2026-03-07 01:55:44 +05:30
Sarthak Agarwal
934a718ae3
Merge pull request #1784 from codeflash-ai/fix/failing_tests
fix failing unit tests with recent refactoring
2026-03-07 01:54:46 +05:30
Sarthak Agarwal
3367383824 fix failing unit tests with recent refactoring 2026-03-07 01:48:41 +05:30
claude[bot]
af628c94fa
Merge pull request #1779 from codeflash-ai/codeflash/optimize-pr1714-2026-03-06T15.35.25
️ Speed up method `InitDecorator.visit_ClassDef` by 19% in PR #1714 (`testgen-review`)
2026-03-06 16:05:06 +00:00
Sarthak Agarwal
353feab063 [Fix] Normalizer and expand its scope 2026-03-06 21:31:24 +05:30
claude[bot]
c0f2030494 style: remove docstring from _expr_name per project conventions
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 15:45:50 +00:00
codeflash-ai[bot]
b39946f922
Optimize InitDecorator.visit_ClassDef
The optimization precomputes AST nodes for the synthetic `__init__` (arguments and super-call body) once in `__init__` instead of rebuilding them for every class lacking an `__init__`, and extracts a `_expr_name` helper to replace duplicated isinstance chains when checking decorator/base names. Line profiler shows the `ast.arguments(...)` and `ast.Expr(...)` construction blocks dropped from ~80 µs total per synthetic-init case to near-zero by reusing prebuilt fragments, and the helper consolidates three 4–6 line isinstance sequences into single-call lookups. Runtime improved 18% (237 µs → 199 µs) with negligible per-test variance, and no correctness regressions across all edge cases (dataclasses, NamedTuples, existing decorators).
2026-03-06 15:35:29 +00:00
Kevin Turcios
0f6d7555b7 fix: address PR review — hoist pruning above loop, add warning on repair failure 2026-03-06 09:15:52 -05:00
Kevin Turcios
f93fb20305 fix: apply token-budget pruning to testgen review/repair source code
Replace the always-extract-function-only approach with progressive
fallback matching optimization/testgen: send the full module source
unless it exceeds OPTIMIZATION_CONTEXT_TOKEN_LIMIT (64k tokens), then
fall back to function-only extraction. Pass full module separately as
module_source_code for repair validation.
2026-03-06 08:13:41 -05:00
Kevin Turcios
43b4eb888e fix: revert repair endpoint to use full module source
The repair endpoint passes function_source_code as
source_code_being_tested to validate_request_data(), which requires
a parseable module. Only the review endpoint should use the extracted
function-only source.
2026-03-06 07:57:12 -05:00
Kevin Turcios
10ebf38409 fix: address PR review findings in testgen review/repair loop
- Revert repaired test files on disk before returning Failure when
  post-repair re-validation fails entirely
- Break out of repair cycle loop when all repair API calls fail
  instead of wasting cycles retrying
- Fix --testgen-review-turns help text to say default: 2 (matches
  MAX_TEST_REPAIR_CYCLES)
2026-03-06 07:54:43 -05:00
Kevin Turcios
f35898de2c add xml.etree.elementree 2026-03-06 07:33:20 -05:00