Commit graph

7714 commits

Author SHA1 Message Date
mashraf-222
0849d153da
Merge pull request #1908 from codeflash-ai/codeflash/optimize-pr1906-2026-03-26T12.05.22
️ Speed up function `_extract_gradle_include_modules` by 22% in PR #1906 (`cf-java-zero-config-strategy`)
2026-03-26 15:46:16 +02:00
codeflash-ai[bot]
99c543ba25
Optimize _extract_gradle_include_modules
Pre-compiling the two regex patterns (`_RE_INCLUDE` and `_RE_QUOTED`) at module load time eliminates the per-call compilation overhead that `re.finditer` and `re.findall` incurred when given raw strings. Line profiler shows the inner loop's regex overhead dropped from ~3.4 ms to ~1.8 ms (47% reduction), and the outer loop regex from ~1.8 ms to ~1.1 ms (39% reduction), yielding a 21% overall speedup. The optimization is particularly effective in the realistic `_parse_gradle_settings_modules` caller, where the function may be invoked repeatedly across many project roots. No functional or behavioral changes; all tests pass with identical outputs.
2026-03-26 12:05:25 +00:00
HeshamHM28
3f85939e82 fix parse_java_project_config 2026-03-26 13:15:42 +02:00
HeshamHM28
fe17ad46df Fix multi-module config 2026-03-26 12:58:28 +02:00
claude[bot]
d5551a396c fix: resolve mypy type errors in maven_strategy.py (getroot() may return None) 2026-03-26 10:08:37 +00:00
claude[bot]
4102c69f40 style: auto-fix ruff-format line length in function_optimizer.py 2026-03-26 10:07:17 +00:00
HeshamHM28
ab0f914957 Class name regex fix (function_optimizer.py + instrumentation.py) 2026-03-26 12:00:26 +02:00
HeshamHM28
76fe0e13bc Class name regex fix (function_optimizer.py + instrumentation.py) 2026-03-26 12:00:21 +02:00
HeshamHM28
7151341026 remove left over files 2026-03-26 11:38:48 +02:00
HeshamHM28
0317d218de Fix imports 2026-03-26 11:04:50 +02:00
Ubuntu
c5b3687d52 refactor: remove zero-config logic from java-config-redesign branch
Zero-config Java support (auto-detection from build files, codeflash.toml
elimination) is handled separately in cf-java-zero-config-strategy. This
commit strips those changes, keeping only bug fixes:
- JFR parser, ReplayHelper, instrumentation, replay tests
- Multi-module test root resolution
- JUnit 4/5 test framework detection
- add_help=False for optimize subparser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 07:39:29 +00:00
Ubuntu
d2e99e2f51 feat: add JaCoCo deps, fix checkstyle skip properties, and add auto-config integration tests
Add JaCoCo runtime and CLI dependencies to Gradle build. Split Maven validation
skip properties into true/false groups so failOnViolation flags are set to false
instead of true. Add Gradle wrapper and integration tests for Java auto-config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 07:31:53 +00:00
claude[bot]
10f50b391c style: auto-fix ruff formatting in inject_validation_skip_properties 2026-03-26 06:45:00 +00:00
HeshamHM28
b67bf0b6a8 fix tests 2026-03-26 08:42:00 +02:00
HeshamHM28
0b700664a3 handle multi-module Java projects and disable checkstyle for generated tests 2026-03-26 08:40:23 +02:00
HeshamHM28
c21cf85aca Fix moduleRoot detecation 2026-03-26 08:34:42 +02:00
HeshamHM28
08edf66847 fix maven override the style validation 2026-03-26 08:29:54 +02:00
HeshamHM28
d49ac809e4 fix checkstyle validation 2026-03-26 08:19:05 +02:00
claude[bot]
dc20b7aee3 fix: use standard Maven paths as defaults when source dirs don't exist 2026-03-26 06:08:03 +00:00
claude[bot]
b0f949aa33 style: normalize f-string quotes in add_codeflash_dependency_multimodule 2026-03-26 06:06:12 +00:00
HeshamHM28
f65578db3f fix mutli module 2026-03-26 08:00:35 +02:00
HeshamHM28
ec1e4d3bc0 fall back to project root when Java module_root directory doesn't exist 2026-03-26 07:38:13 +02:00
HeshamHM28
e7d07d073f Auto config 2026-03-26 06:38:33 +02:00
Sarthak Agarwal
d5f82bb48b
Merge pull request #1897 from codeflash-ai/cf-fix-tsx-syntax-validation
fix: use file-aware parser in validate_syntax for TSX support
2026-03-26 04:23:18 +05:30
mohammed ahmed
5a81195384
Merge pull request #1889 from codeflash-ai/cf-worktree-subagent-fixes
fix: harden worktree creation and improve subagent mode support
2026-03-26 00:26:52 +02:00
mohammed ahmed
607200ab03
Merge pull request #1896 from codeflash-ai/cf-fix-formatter-temp-file-extension
fix: pass language to format_generated_code for correct temp file extension
2026-03-26 00:26:38 +02:00
ali
50c8a74d14
use result failure instead of exiting the process 2026-03-26 00:03:49 +02:00
mohammed ahmed
bd0e96f2c0
Merge pull request #1900 from codeflash-ai/cf-fix-monorepo-module-resolution
fix: add monorepo root node_modules to Jest moduleDirectories
2026-03-25 23:54:20 +02:00
claude[bot]
5d2c959f42 fix: remove unreachable non-str branch in _compile_ok
The function signature `source: str` guarantees str input, making
the isinstance guard and its else branch dead code (mypy unreachable error).

Co-authored-by: mohammed ahmed <undefined@users.noreply.github.com>
2026-03-25 18:17:45 +00:00
ali
c9855e419b
fix: convert import statements inside function bodies to require() calls
AI-generated tests sometimes place `import X from 'Y'` inside jest.mock()
callbacks, describe() blocks, or other function bodies. This is invalid
JavaScript syntax (import must be top-level). Add a post-processing step
that converts indented import statements to equivalent require() calls.

Affects ~79/1026 Strapi log files showing "import/export cannot be used
outside of module code" SWC syntax errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 20:15:21 +02:00
mohammed ahmed
3346a052ff
Merge pull request #1905 from codeflash-ai/codeflash/optimize-pr1897-2026-03-25T18.07.00
️ Speed up function `_compile_ok` by 24,733% in PR #1897 (`cf-fix-tsx-syntax-validation`)
2026-03-25 20:12:54 +02:00
codeflash-ai[bot]
c82d8ecdd9
Optimize _compile_ok
Added a bounded cache (max 4096 entries) that stores boolean compile results keyed by source string, so repeated validation of identical code skips the expensive `compile()` call. The profiler shows `compile()` consumed ~99.6% of original runtime at ~226 µs per hit; cache hits now return in ~150–200 ns, yielding a 247× speedup when the same source is validated multiple times (common in workflows that re-validate unchanged snippets). Non-string inputs bypass the cache entirely to preserve original exception behavior, and the cache bound prevents unbounded memory growth in pipelines that see many unique sources.
2026-03-25 18:07:04 +00:00
claude[bot]
17d833b20e
Merge pull request #1902 from codeflash-ai/codeflash/optimize-pr1897-2026-03-25T17.23.56
️ Speed up method `PythonSupport.validate_syntax` by 573% in PR #1897 (`cf-fix-tsx-syntax-validation`)
2026-03-25 17:57:23 +00:00
claude[bot]
11c527537f
Merge pull request #1904 from codeflash-ai/codeflash/optimize-pr1902-2026-03-25T17.35.13
️ Speed up function `_compile_ok` by 134% in PR #1902 (`codeflash/optimize-pr1897-2026-03-25T17.23.56`)
2026-03-25 17:57:11 +00:00
Aseem Saxena
7dc862611e
Merge pull request #1893 from codeflash-ai/cf-auth-login-subcommand
feat: add `auth login` subcommand
2026-03-25 10:40:38 -07:00
codeflash-ai[bot]
c60c051dac
Optimize _compile_ok
Removing the `@lru_cache(maxsize=1024)` decorator eliminated per-call overhead from argument hashing and dictionary lookups that exceeded the benefit of caching, since `compile()` is already fast (~15-30 µs for typical inputs) and the function is called with mostly unique source strings in practice. The 134% speedup (26.9 ms → 11.5 ms) reflects that cache management cost dominated total runtime when processing diverse code snippets through the `validate_syntax` caller. Test results show consistent small wins across all cases, with the largest gains on short/invalid inputs where cache overhead was proportionally highest (e.g., null-byte test improved 23.9%). The single regression is the unhashable-input test (43.8% slower) because TypeError now originates from `compile()` rather than cache-key construction, but this is an edge case with negligible absolute impact.
2026-03-25 17:35:17 +00:00
claude[bot]
432d8118da fix: remove duplicate _compile_ok function definition 2026-03-25 17:26:44 +00:00
codeflash-ai[bot]
b608ed53a0
Optimize PythonSupport.validate_syntax
The optimized code extracts `compile()` into a standalone `_compile_ok` function decorated with `@lru_cache(maxsize=1024)`, enabling memoization of syntax validation results for identical source strings. This eliminates redundant AST parsing and compilation work when the same code snippet is validated multiple times, which profiler data shows was responsible for 99.3% of the original function's runtime. The test suite demonstrates a 572% overall speedup because many assertions validate repeated or similar snippets that now hit the cache, with individual test improvements ranging from 939% to 61109% on cases involving large or duplicate inputs. Memory overhead is bounded by the cache size, and correctness is preserved since `compile()` behavior remains unchanged.
2026-03-25 17:24:00 +00:00
ali
1a5216ed54
fix: add monorepo root node_modules to Jest moduleDirectories
In monorepo setups (e.g., Strapi), workspace packages are hoisted to the
root node_modules. When Jest runs from a subpackage, it can't resolve
these packages because its default moduleDirectories only includes the
local node_modules. This adds the monorepo root's node_modules to
moduleDirectories in the runtime Jest config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 19:05:20 +02:00
ali
0641930f25
fix: use cross-context type detection in V8 serializer self-test
The V8 serialization self-test used `instanceof Map` which fails in
Jest's sandboxed VM context where the Map class from v8.deserialize
differs from the test environment's Map class. This incorrectly
disabled V8 serialization, falling through to msgpack which often
also isn't resolvable in monorepo setups.

Replaced all `instanceof` checks in the serializer with
`Object.prototype.toString.call()` for cross-VM-context compatibility,
matching the pattern already used in the msgpack codepath.

Trace IDs: 003e1410, fe2ae122, fde51112 (153 affected logs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 18:47:38 +02:00
ali
8b7ebee5fa
fix: skip object literal methods during JS/TS function discovery
Shorthand method definitions inside object literals (e.g., `{ encrypt(data) {} }`)
were being discovered as optimizable functions. Since bare method syntax is only
valid inside class bodies or object literals, extracting them as standalone code
produced syntactically invalid JavaScript, failing context extraction.

Now skip method_definition nodes whose parent is an `object` node, matching
the existing skip for arrow functions in `pair` nodes.

Trace IDs: 04f07244, 01ac202f, 024a3d42, 04da127a (~274 affected logs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 18:44:08 +02:00
ali
9664307d59
fix: use file-aware parser in validate_syntax for TSX support
TypeScriptSupport.validate_syntax() always used the TYPESCRIPT parser,
which cannot parse JSX syntax. TSX files (.tsx) containing JSX were
incorrectly rejected as syntactically invalid, blocking optimization
of React components.

Added optional file_path parameter to validate_syntax across all
language support classes. When provided, the correct parser is selected
based on file extension (e.g., TSX parser for .tsx files).

Trace IDs: 00c25f79, 02697f98, fdfc6a8d (113 affected logs total)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 18:38:21 +02:00
ali
f95a06afe6
fix: pass language to format_generated_code for correct temp file extension
format_generated_code was called without the language parameter in
process_review(), defaulting to "python". This created temp files with
.py extension when formatting JS/TS code, causing prettier to fail.

Trace IDs: 11e9745d, 1578f081, 7e8abab2 (73 affected logs total)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 18:05:28 +02:00
claude[bot]
2857e84790 fix: remove invalid get_shell_rc_path patches from auth tests
Co-authored-by: Aseem Saxena <undefined@users.noreply.github.com>
2026-03-25 00:55:39 +00:00
aseembits93
ec8ad93110 login and status subcommand 2026-03-24 17:51:48 -07:00
Aseem Saxena
630dcfc126
Merge pull request #1894 from codeflash-ai/codeflash/optimize-auth_login-mn55wrey
️ Speed up function `auth_login` by 1,583%
2026-03-24 15:05:25 -07:00
codeflash-ai[bot]
7985f16000
Optimize auth_login
The optimization removed redundant operations that duplicated logic already inside `save_api_key_to_rc`. Previously, `auth_login` called `get_shell_rc_path()` (which performs `Path.home()` filesystem operations) and conditionally invoked `shell_rc_path.touch()` on Windows, then passed the result to `save_api_key_to_rc`. The optimized version calls `save_api_key_to_rc(api_key)` directly, because that function already internally calls `get_shell_rc_path()` and safely handles file creation via context managers. Line profiler shows `get_shell_rc_path()` dropped from ~1 ms to negligible per-call overhead, and `shell_rc_path.touch()` overhead was eliminated entirely. Runtime improved from 19 ms to 1.13 ms (1582% speedup) with no regressions across all test scenarios.
2026-03-24 22:04:24 +00:00
aseembits93
9ce18aca33 feat: add auth login subcommand for standalone OAuth authentication
Adds `codeflash auth login` CLI subcommand that performs the full OAuth
PKCE flow, prints the authentication URL, and saves the API key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 13:44:16 -07:00
Mohamed Ashraf
970c9f86da fix: use 3 package components for tracer instrumentation scope (TODO-39)
Changed detect_packages_from_source() from min(2, len) to min(3, len)
so com.aerospike.client.util produces prefix com.aerospike.client
instead of com.aerospike. This reduces instrumentation to the actual
source package instead of the entire organization namespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 16:50:40 +00:00
Mohamed Ashraf
12921447b9 fix: capture real line numbers in tracer and track dropped captures (TODO-34, TODO-38)
TODO-34: TracingClassVisitor hardcoded line number to 0 because ASM's
visitMethod() doesn't provide line info. Added a pre-scan pass in
TracingTransformer.instrumentClass() that collects first line numbers
via visitLineNumber() before the instrumentation pass.

TODO-38: Serialization timeouts/failures silently dropped captures with
no visibility. Added AtomicInteger droppedCaptures counter and included
it in flush() metadata output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 16:50:31 +00:00