Skip to content

Commit 7308afe

Browse files
Merge branch 'main' of github.com:codeflash-ai/codeflash
2 parents d307409 + 110e9b8 commit 7308afe

109 files changed

Lines changed: 4262 additions & 2256 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ codeflash/
2626
├── result/ # Result types and handling
2727
└── version.py # Version information
2828
```
29+
30+
## Key Entry Points
31+
32+
| Task | Start here |
33+
|------|------------|
34+
| CLI arguments & commands | `cli_cmds/cli.py` |
35+
| Optimization orchestration | `optimization/optimizer.py``run()` |
36+
| Per-function optimization | `optimization/function_optimizer.py` |
37+
| Function discovery | `discovery/functions_to_optimize.py` |
38+
| Context extraction | `context/code_context_extractor.py` |
39+
| Test execution | `verification/test_runner.py`, `verification/pytest_plugin.py` |
40+
| Performance ranking | `benchmarking/function_ranker.py` |
41+
| Domain types | `models/models.py`, `models/function_types.py` |
42+
| Result handling | `either.py` (`Result`, `Success`, `Failure`, `is_successful`) |

.claude/rules/code-style.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- **Line length**: 120 characters
44
- **Python**: 3.9+ syntax
5+
- **Package management**: Always use `uv`, never `pip`
56
- **Tooling**: Ruff for linting/formatting, mypy strict mode, prek for pre-commit checks
67
- **Comments**: Minimal - only explain "why", not "what"
78
- **Docstrings**: Do not add unless explicitly requested

.claude/rules/git.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Git Commits & Pull Requests
22

3+
- **Always create a new branch from `main` before starting any new work** — never commit directly to `main` or reuse an existing feature branch for unrelated changes
34
- Use conventional commit format: `fix:`, `feat:`, `refactor:`, `docs:`, `test:`, `chore:`
45
- Keep commits atomic - one logical change per commit
56
- Commit message body should be concise (1-2 sentences max)

.claude/rules/language-patterns.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
paths:
3+
- "codeflash/languages/**/*.py"
4+
---
5+
6+
# Language Support Patterns
7+
8+
- Current language is a module-level singleton in `languages/current.py` — use `set_current_language()` / `current_language()`, never pass language as a parameter through call chains
9+
- Use `get_language_support(identifier)` from `languages/registry.py` to get a `LanguageSupport` instance — never import language classes directly
10+
- New language support classes must use the `@register_language` decorator to register with the extension and language registries
11+
- `languages/__init__.py` uses `__getattr__` for lazy imports to avoid circular dependencies — follow this pattern when adding new exports
12+
- `is_javascript()` returns `True` for both JavaScript and TypeScript
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
paths:
3+
- "codeflash/optimization/**/*.py"
4+
- "codeflash/verification/**/*.py"
5+
- "codeflash/benchmarking/**/*.py"
6+
- "codeflash/context/**/*.py"
7+
---
8+
9+
# Optimization Pipeline Patterns
10+
11+
- All major operations return `Result[SuccessType, ErrorType]` — construct with `Success(value)` / `Failure(error)`, check with `is_successful()` before calling `unwrap()`
12+
- Code context has token limits (`OPTIMIZATION_CONTEXT_TOKEN_LIMIT`, `TESTGEN_CONTEXT_TOKEN_LIMIT` in `config_consts.py`) — exceeding them rejects the function
13+
- `read_writable_code` can span multiple files; `read_only_context_code` is reference-only
14+
- Code is serialized as markdown code blocks: ` ```language:filepath\ncode\n``` ` (see `CodeStringsMarkdown`)
15+
- Candidates form a forest (DAG): refinements/repairs reference `parent_id` on previous candidates
16+
- Test generation and optimization run concurrently — coordinate through `CandidateEvaluationContext`
17+
- Generated tests are instrumented with `codeflash_capture.py` to record return values and traces

.claude/rules/source-code.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ paths:
66
# Source Code Rules
77

88
- Use `libcst` for code modification/transformation to preserve formatting. `ast` is acceptable for read-only analysis and parsing.
9-
- NEVER use leading underscores for function names (e.g., `_helper`). Python has no true private functions. Always use public names.
10-
- Any new feature or bug fix that can be tested automatically must have test cases.
11-
- If changes affect existing test expectations, update the tests accordingly. Tests must always pass after changes.

.claude/rules/testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ paths:
1313
- Use `.as_posix()` when converting resolved paths to strings (normalizes to forward slashes).
1414
- Any new feature or bug fix that can be tested automatically must have test cases.
1515
- If changes affect existing test expectations, update the tests accordingly. Tests must always pass after changes.
16+
- The pytest plugin patches `time`, `random`, `uuid`, and `datetime` for deterministic test execution — never assume real randomness or real time in verification tests.
17+
- `conftest.py` uses an autouse fixture that calls `reset_current_language()` — tests always start with Python as the default language.

.claude/skills/fix-mypy.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Fix mypy errors
2+
3+
When modifying code, fix any mypy type errors in the files you changed:
4+
5+
```bash
6+
uv run mypy --non-interactive --config-file pyproject.toml <changed_files>
7+
```
8+
9+
- Fix type annotation issues: missing return types, incorrect types, Optional/None unions, import errors for type hints
10+
- Do NOT add `# type: ignore` comments — always fix the root cause
11+
- Do NOT fix type errors that require logic changes, complex generic type rework, or anything that could change runtime behavior
12+
- Files in `mypy_allowlist.txt` are checked in CI — ensure they remain error-free

.claude/skills/fix-prek.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Fix prek failures
2+
3+
When prek (pre-commit) checks fail:
4+
5+
1. Run `uv run prek run` to see failures (local, checks staged files)
6+
2. In CI, the equivalent is `uv run prek run --from-ref origin/main`
7+
3. prek runs ruff format, ruff check, and mypy on changed files
8+
4. Fix issues in order: formatting → lint → type errors
9+
5. Re-run `uv run prek run` to verify all checks pass

.codex/skills/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Managed by Tessl
2+
tessl:*

0 commit comments

Comments
 (0)