Skip to content

Commit fa9d32f

Browse files
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>
2 parents d7ab5a9 + 4b8effa commit fa9d32f

89 files changed

Lines changed: 6006 additions & 6061 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/architecture.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ When adding, moving, or deleting source files, update this doc to match.
66
codeflash/
77
├── main.py # CLI entry point
88
├── cli_cmds/ # Command handling, console output (Rich)
9+
│ ├── cmd_init.py # Init orchestrator + Python-specific setup
10+
│ ├── init_config.py # Config types, validation, writing, shared UI helpers
11+
│ ├── init_auth.py # API key management + GitHub app installation
12+
│ ├── github_workflow.py # GitHub Actions workflow generation
13+
│ ├── init_javascript.py # JavaScript/TypeScript project initialization
14+
│ └── oauth_handler.py # OAuth PKCE flow for CodeFlash authentication
915
├── discovery/ # Find optimizable functions
1016
├── optimization/ # Generate optimized code via AI
11-
│ ├── optimizer.py # Main optimization orchestration
12-
│ └── function_optimizer.py # Per-function optimization logic
17+
│ └── optimizer.py # Main optimization orchestration
1318
├── verification/ # Run deterministic tests (pytest plugin)
1419
├── benchmarking/ # Performance measurement
1520
├── github/ # PR creation
@@ -20,12 +25,16 @@ codeflash/
2025
│ ├── base.py # LanguageSupport protocol and shared data types
2126
│ ├── registry.py # Language registration and lookup by extension/enum
2227
│ ├── current.py # Current language singleton (set_current_language / current_language_support)
28+
│ ├── function_optimizer.py # FunctionOptimizer base class for per-function optimization
2329
│ ├── code_replacer.py # Language-agnostic code replacement
2430
│ ├── python/
2531
│ │ ├── support.py # PythonSupport (LanguageSupport implementation)
2632
│ │ ├── function_optimizer.py # PythonFunctionOptimizer subclass
2733
│ │ ├── optimizer.py # Python module preparation & AST resolution
28-
│ │ └── normalizer.py # Python code normalization for deduplication
34+
│ │ ├── normalizer.py # Python code normalization for deduplication
35+
│ │ ├── test_runner.py # Test subprocess execution for Python
36+
│ │ ├── instrument_codeflash_capture.py # Instrument __init__ with capture decorators
37+
│ │ └── parse_line_profile_test_output.py # Parse line profiler output
2938
│ └── javascript/
3039
│ ├── support.py # JavaScriptSupport (LanguageSupport implementation)
3140
│ ├── function_optimizer.py # JavaScriptFunctionOptimizer subclass
@@ -46,9 +55,9 @@ codeflash/
4655

4756
| Task | Start here |
4857
|------|------------|
49-
| CLI arguments & commands | `cli_cmds/cli.py` |
58+
| CLI arguments & commands | `cli_cmds/cli.py` (parsing), `main.py` (subcommand dispatch) |
5059
| Optimization orchestration | `optimization/optimizer.py``run()` |
51-
| Per-function optimization | `optimization/function_optimizer.py` (base), `languages/python/function_optimizer.py`, `languages/javascript/function_optimizer.py` |
60+
| Per-function optimization | `languages/function_optimizer.py` (base), `languages/python/function_optimizer.py`, `languages/javascript/function_optimizer.py` |
5261
| Function discovery | `discovery/functions_to_optimize.py` |
5362
| Context extraction | `languages/<lang>/context/code_context_extractor.py` |
5463
| Test execution | `languages/<lang>/support.py` (`run_behavioral_tests`, etc.), `verification/pytest_plugin.py` |

.github/workflows/claude.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,20 @@ jobs:
198198
199199
For each PR:
200200
- If CI passes and the PR is mergeable → merge with `--squash --delete-branch`
201-
- Close the PR as stale if ANY of these apply:
201+
- If CI is failing:
202+
1. Check out the PR branch and inspect the failing tests
203+
2. Attempt to fix the failures (the optimization may have broken tests or introduced issues)
204+
3. If fixed: commit, push, and leave a comment explaining what was fixed
205+
4. If unfixable: close with `gh pr close <number> --comment "Closing: CI checks are failing — <describe the specific failures and why they can't be auto-fixed>." --delete-branch`
206+
- Close the PR (without attempting fixes) if ANY of these apply:
202207
- Older than 7 days
203208
- Has merge conflicts (mergeable state is "CONFLICTING")
204-
- CI is failing
205209
- The optimized function no longer exists in the target file (check the diff)
206-
Close with: `gh pr close <number> --comment "Closing stale optimization PR." --delete-branch`
210+
Close with: `gh pr close <number> --comment "<reason>" --delete-branch`
211+
where <reason> explains WHY the PR is being closed. Examples:
212+
- "Closing: PR is older than 7 days without being merged."
213+
- "Closing: merge conflicts with the target branch."
214+
- "Closing: the optimized function no longer exists in the target file."
207215
</step>
208216
209217
<verification>

.github/workflows/codeflash-optimize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
- name: ⚡️Codeflash Optimization
4040
id: optimize_code
4141
run: |
42-
uv run codeflash --benchmark
42+
uv run codeflash --benchmark --testgen-review

code_to_optimize/js/code_to_optimize_js/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code_to_optimize/js/code_to_optimize_js_cjs/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code_to_optimize/js/code_to_optimize_js_esm/package-lock.json

Lines changed: 7 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code_to_optimize/js/code_to_optimize_mocha/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code_to_optimize/js/code_to_optimize_mocha/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
},
99
"devDependencies": {
1010
"codeflash": "file:../../../packages/codeflash",
11-
"mocha": "^10.7.0"
11+
"mocha": "^10.8.2"
1212
}
1313
}

code_to_optimize/js/code_to_optimize_ts/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)