Commit graph

7374 commits

Author SHA1 Message Date
Mohamed Ashraf
d22d74e112 fix: include codeflash.toml in config resolution depth comparison
When both package.json and codeflash.toml exist in the directory tree,
parse_config_file() only compared package.json against pyproject.toml.
Java projects use codeflash.toml, which was never checked — so any
package.json in a parent directory would always win, setting the wrong
module_root and project_root.

Now we find the closest toml config (pyproject.toml or codeflash.toml)
and compare its depth against package.json, so a closer codeflash.toml
correctly takes priority.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 02:25:37 +00:00
claude[bot]
13fcb048a4
Merge pull request #1826 from codeflash-ai/codeflash/optimize-pr1199-2026-03-13T01.03.06
️ Speed up method `TestGenRequest.to_payload` by 20% in PR #1199 (`omni-java`)
2026-03-13 01:58:50 +00:00
claude[bot]
e1081d4365
Merge pull request #1825 from codeflash-ai/codeflash/optimize-pr1199-2026-03-13T00.56.31
️ Speed up method `OptimizeRequest.to_payload` by 33% in PR #1199 (`omni-java`)
2026-03-13 01:58:37 +00:00
codeflash-ai[bot]
10a6ecb363
Optimize _prompt_custom_directory
The optimization moved the `inquirer.Path` question construction out of the while-loop and added `@lru_cache(maxsize=1)` to `_get_theme()`, eliminating repeated imports and instantiations of `CodeflashTheme` on every prompt iteration. The profiler shows `_get_theme()` was called 1247 times in the original, each time re-importing `init_config` (~2.2% overhead) and constructing a new theme object (~97.8% overhead, 323 µs per call). Moving the question object outside the loop avoids ~13 µs of reconstruction per iteration, and caching the theme cuts 1246 redundant constructions, yielding a 363% speedup with no functional trade-offs.
2026-03-13 01:44:32 +00:00
claude[bot]
ee6749fbfb style: auto-fix ruff formatting in schemas.py 2026-03-13 01:04:35 +00:00
codeflash-ai[bot]
900de505b4
Optimize TestGenRequest.to_payload
The optimization hoists `platform.python_version()` out of the per-call loop by caching it at module import time as `_PLATFORM_PYTHON_VERSION`, eliminating a 500+ns system call on every invocation when the language is not Python. The original code imported `platform` and called `platform.python_version()` inside `to_payload`, incurring repeated overhead even though the value never changes within a process. Line profiler shows the `import platform` statement itself consumed 6.6% of runtime, and the conditional evaluation another 7%. The payload dict construction was also reordered to compute `python_version` upfront, reducing incremental dict updates. This yields a 20% speedup (1.97ms → 1.64ms) with no correctness trade-offs.
2026-03-13 01:03:10 +00:00
codeflash-ai[bot]
588a3a94d6
Optimize OptimizeRequest.to_payload
The optimization hoists `import platform` to module-level (eliminating repeated import overhead on every call) and caches `self.language_info` in a local variable `lang`, cutting repeated attribute lookups from ~11 to ~3 per invocation. The single-dict construction merges what were previously separate assignments for `language_version` and `python_version` into the initial literal, reducing interpreter overhead for dict operations. Line profiler shows the original import cost ~381 ns per call and each `self.language_info.*` access ~150–300 ns; batching these accesses yields the observed 32% runtime improvement with no functional changes.
2026-03-13 00:56:35 +00:00
claude[bot]
9022f9ee43 fix: set original_pass=False when Java comparator scope is exception
When scope_str == "exception", the original code threw an exception and
should not be marked as passed. Consistent with the Python fallback path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 00:25:12 +00:00
Mohamed Ashraf
fa9d32f1c4 Merge branch 'main' into omni-java
Resolve 7 merge conflicts from main's modular refactoring + JS improvements:

- aiservice.py: combine multi-language metadata (omni-java) with main's structure
- cmd_init.py: adopt main's modular split (init_config, init_auth, github_workflow) + add Java import
- code_replacer.py: main's clean early-return style + omni-java's non-Python single-block fallback
- version.py, test_support_dispatch.py, test_javascript_test_runner.py: take main's versions
- uv.lock: regenerated

Port Java into main's modular structure:
- Fix init_java.py lazy imports to point to new modules (init_config, init_auth, github_workflow)
- Add Java workflow support to github_workflow.py (detection, template, customization)
- Fix broken Java imports (function_optimizer, line_profiler) after main's module moves

Add safety tests for merge-critical functions:
- test_add_language_metadata.py: 10 tests covering per-language payload correctness
- test_code_replacer_matching.py: 8 tests covering fallback chain

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 00:15:19 +00:00
mashraf-222
d7ab5a9816
Merge pull request #1818 from codeflash-ai/fix/java-init-flow
fix: complete Java init flow (enum, detection, config)
2026-03-12 06:32:24 +02:00
Mohamed Ashraf
068c1a73d0 test: add unit tests for detect_project_language
Cover all detection paths: Java (pom.xml, build.gradle, build.gradle.kts),
TypeScript, JavaScript, Python, empty directory fallback, and priority
resolution when multiple build system markers coexist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 04:01:49 +00:00
Mohamed Ashraf
cc5b562574 fix: write language field to codeflash.toml for Java projects
configure_java_project() wrote module-root and tests-root but not
language. Downstream, process_pyproject_config() checks
config.get("language") == "java" to set is_java_project, so without
this field the pipeline couldn't identify the project as Java.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 03:22:59 +00:00
Mohamed Ashraf
21142a5d97 fix: add Java project detection to detect_project_language
The function only checked for Python and JS/TS markers. Java projects
(with pom.xml or build.gradle) always fell through to the PYTHON default.
Added Java detection before TypeScript check since build tool files are
definitive markers, mirroring setup/detector.py logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 03:22:45 +00:00
Mohamed Ashraf
8f8d4340d1 fix: add JAVA member to ProjectLanguage enum
The enum only had PYTHON, JAVASCRIPT, TYPESCRIPT but cmd_init.py
references ProjectLanguage.JAVA, causing an AttributeError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 03:22:25 +00:00
mashraf-222
d75ccd0141
Merge pull request #1817 from codeflash-ai/feat/mvn-central-runtime-resolution
feat: resolve codeflash-runtime from Maven Central
2026-03-12 04:15:19 +02:00
Mohamed Ashraf
66e8060d2c refactor: remove dev build fallback from runtime resolution chain
The dev build fallback (codeflash-java-runtime/target/) in
_ensure_codeflash_runtime() was dead code for production users
since that directory only exists in source checkouts. The resolution
chain is now:

1. ~/.m2 cache (instant)
2. Maven Central (primary)
3. GitHub Releases download (production fallback)

_find_runtime_jar() is kept for build_jacoco_agent_arg() and
generate_jacoco_report() which need to locate the JAR by path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 00:05:35 +00:00
Mohamed Ashraf
7f7ce7de91 feat: add GitHub Releases fallback for codeflash-runtime JAR
Adds a download_from_github_releases() fallback between Maven Central
and the dev-build-only local path. This gives pip users a working
fallback when Maven Central is unreachable. Downloads to ~/.cache/codeflash/
and caches for subsequent runs.

Resolution chain is now:
1. ~/.m2 cache (instant)
2. Maven Central (primary)
3. GitHub Releases download (production fallback)
4. Dev build directory (development only)

The GitHub Releases fallback will activate once a release tagged
'runtime-v1.0.0' is published with the JAR as an asset.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 23:56:46 +00:00
Mohamed Ashraf
6e8cf410f2 feat: resolve codeflash-runtime from Maven Central
Maven Central is now the primary resolution path for the codeflash-runtime
JAR. Falls back to local dev build install for development workflows.
Excludes the bundled JAR from the PyPI wheel to save ~15MB.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 23:12:26 +00:00
mashraf-222
f3e36fe409
Merge pull request #1816 from codeflash-ai/feat/maven-central-publishing-setup
Feat/maven central publishing setup
2026-03-12 00:57:22 +02:00
Aseem Saxena
4b8effa07b
Merge pull request #1661 from codeflash-ai/chore/docstring-updates
chore: add docstring to banner helper
2026-03-11 15:30:25 -07:00
Aseem Saxena
5dab68613c
Merge branch 'main' into chore/docstring-updates 2026-03-11 15:21:33 -07:00
Mohamed Ashraf
e2f2d946d9 fix: align ComparatorCorrectnessTest schema with Comparator and fix javadoc config
The test was creating SQLite tables with the old schema (iteration_id,
loop_index, return_value) but Comparator.readTestResults() now expects
test_module_path, test_class_name, and test_function_name columns.

Also configure javadoc plugin with doclint=none and failOnError=false
to prevent malformed HTML in comments from blocking the release build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 21:34:38 +00:00
Mohamed Ashraf
5150b4feed feat: add Maven Central publishing configuration
Add central-publishing-maven-plugin to the release profile and developer
ID for Sonatype namespace verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 21:02:48 +00:00
mohammed ahmed
dabd160a67
codeflash re-write
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
2026-03-11 22:34:56 +02:00
mohammed ahmed
d616501871
Merge pull request #1808 from codeflash-ai/fix/jest-runtime-config-for-external-tests
fix: use runtime Jest config for test files outside project root
2026-03-11 22:34:10 +02:00
ali
6a451ffe03
fix: re-discover function position after add_global_declarations shifts line numbers
When optimized JS/TS code introduces new global declarations (const, Set, etc.),
add_global_declarations inserts them into the original source, shifting the target
function's line numbers. The stale starting_line from function_to_optimize then
causes _replace_function_body to fail with "Could not find function X at line Y".

This affected ~666 function replacements in the Strapi optimization run, including
bytesToHumanReadable, isSelectable, getFileIconComponent, and many others.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 21:30:10 +02:00
mashraf-222
10a0e1417a
Merge pull request #1775 from codeflash-ai/feat/java-infra-improvements
feat: Java infrastructure — version centralization, pom.xml safety, JaCoCo bundling, Maven Central prep
2026-03-11 16:56:49 +02:00
Saurabh Misra
7f7591cf29
Merge pull request #1813 from codeflash-ai/fix/detect-deletion-only-diffs
fix: detect functions in deletion-only git diffs
2026-03-11 01:19:21 -04:00
Mohamed Ashraf
8bd170ca57 fix: apply 300s timeout for standalone JaCoCo coverage path
The standalone JaCoCo agent path was using a 60s minimum timeout
instead of 300s, causing behavioral tests to be killed before
completion. The JaCoCo agent adds instrumentation overhead regardless
of whether it runs via mvn verify or standalone -javaagent injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 01:16:52 +00:00
aseembits93
b5a01457d2 test: add unit tests for deletion-only git diff detection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:33:40 -07:00
aseembits93
12b7173388 revert: restore console.py to main branch version
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:13:42 -07:00
aseembits93
4f2a8ff0d8 fix: detect functions in deletion-only git diffs
When a commit only deletes lines (e.g., removing a docstring), get_git_diff
returned an empty add_line_no list, causing no functions to be discovered.
Fall back to hunk target start lines so the surrounding function is still
matched against the current file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:10:29 -07:00
Kevin Turcios
055103da46
Merge pull request #1789 from codeflash-ai/fix-dependabot-vulns
fix: upgrade dependencies to resolve Dependabot security alerts
2026-03-10 17:18:15 -06:00
Kevin Turcios
d77d14be09 chore: upgrade filelock, numpy, posthog, prek, smmap 2026-03-10 16:55:48 -06:00
Kevin Turcios
748094c7e0 Merge remote-tracking branch 'origin/main' into fix-dependabot-vulns 2026-03-10 16:54:29 -06:00
Kevin Turcios
15f8e6f7be
Merge pull request #1811 from codeflash-ai/fix/ci-review-fix-before-close
fix: attempt to fix failing CI on codeflash optimization PRs before closing
2026-03-10 16:48:32 -06:00
aseembits93
59c131a63e Merge remote-tracking branch 'origin/fix/subagent-diff-worktree-paths' into feat/subagent-native-diff-output 2026-03-10 15:47:30 -07:00
aseembits93
9e22a6616f feat: instruct subagent to apply optimized code directly via Edit tool for native diff
Instead of presenting the diff via AskUserQuestion with markdown preview,
the subagent now applies the code directly so the user sees Claude's native inline diff.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:46:15 -07:00
Kevin Turcios
3ba68c0288 fix: attempt to fix failing CI on codeflash optimization PRs before closing
Instead of immediately closing optimization PRs when CI fails, Claude
now checks out the branch, inspects failures, and attempts to fix them.
Only closes if unfixable, with a specific explanation of the failures.
2026-03-10 16:34:55 -06:00
Aseem Saxena
ffd39abf91
Merge pull request #1809 from codeflash-ai/chore/bump-version-0.20.2
chore: release v0.20.2
2026-03-10 13:38:48 -07:00
aseembits93
97260ce1da chore: bump version to 0.20.2
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:32:40 -07:00
ali
eeeb6eebf8
test: update Jest roots tests to verify runtime config behavior
Update TestJestRootsConfiguration to match the new runtime config
approach: verify no --roots/config when tests are inside the project
root, and verify runtime config creation when tests are outside it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:18:16 +02:00
claude[bot]
17c733f6b6 fix: correct runtime jest config bugs
- Add encoding="utf-8" to write_text (CLAUDE.md requirement)
- Fix return type to Path | None and return None on write failure with no base config
- Replace startswith path prefix check with Path.is_relative_to()

Co-authored-by: mohammed ahmed <undefined@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 14:39:31 +00:00
ali
ad0bc0876a
fix: use runtime Jest config for test files outside project root
Replace CLI `--roots` flags with a runtime wrapper config that extends
the base Jest config with additional `roots` and `testMatch` entries.
This fixes test discovery in monorepo setups where generated test files
live outside the project root, since Jest's `testMatch` patterns using
`<rootDir>` won't match external files and CLI `--roots` can be
overridden by config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:31:33 +02:00
aseembits93
6e720f013d fix: relativize worktree paths in subagent optimization output
The <file> and <optimized-code file="..."> XML tags in subagent mode
were showing absolute worktree paths instead of relative project paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:21:11 -07:00
Aseem Saxena
b3dc0339e0
Merge pull request #1685 from codeflash-ai/feat/subagent-low-effort-defaults
feat: set low effort and skip review/explanation in subagent mode
2026-03-09 13:49:41 -07:00
claude[bot]
dea671073e test: skip reporter junit xml test on Windows CI
Node.js subprocess pipe behavior causes the test to hang on Windows
(returncode=1 but stdout reader thread blocks beyond 10s timeout).

Co-authored-by: Aseem Saxena <aseembits93@users.noreply.github.com>
2026-03-09 19:10:57 +00:00
aseembits93
71cd3bcaab dont hardcode defaults 2026-03-09 11:53:38 -07:00
aseembits93
0d2ddab531 Merge remote-tracking branch 'origin/feat/subagent-review-optimization' into feat/subagent-low-effort-defaults 2026-03-09 11:31:28 -07:00
aseembits93
da4752373c merge conflict 2026-03-09 11:08:15 -07:00