Commit graph

6179 commits

Author SHA1 Message Date
Saurabh Misra
addbaad370
Merge branch 'main' into fix/class-method-import-syntax 2026-01-30 16:36:03 -08:00
Saurabh Misra
09e6a1710f Address review: add validation for edge cases in import generation
- Add _is_valid_js_identifier() to check for reserved words (module, exports, prototype, etc.)
- Only use class import pattern for single-dot names where class name is valid identifier
- Fall back to module import for:
  - Multiple dots (e.g., Constructor.prototype.method)
  - Reserved words (e.g., module.exports)
- Add comprehensive tests for edge cases
2026-01-31 00:35:10 +00:00
Saurabh Misra
b2fb58eba6 Fix invalid JavaScript import syntax for class methods
When generating test imports for class methods like `Validator.validateRequest`,
the previous code produced invalid JavaScript:
  const { Validator.validateRequest } = require('../middlewares/Validator');

This is invalid because dots are not allowed in destructuring patterns.

The fix:
- Add _generate_import_statement() function to detect class methods (names with dots)
- For class methods: generate `const ClassName = require('...')`
- For simple functions: keep destructuring `const { funcName } = require('...')`
- Update prompt templates to use {import_statement} placeholder

Includes unit tests for the new import generation logic.
2026-01-31 00:35:10 +00:00
HeshamHM28
795c157d12
Fix Line Profiler query (#2338)
# Pull Request Checklist

## Description
- [ ] **Description of PR**: Clear and concise description of what this
PR accomplishes
- [ ] **Breaking Changes**: Document any breaking changes (if
applicable)
- [ ] **Related Issues**: Link to any related issues or tickets

## Testing
- [ ] **Test cases Attached**: All relevant test cases have been
added/updated
- [ ] **Manual Testing**: Manual testing completed for the changes

## Monitoring & Debugging
- [ ] **Logging in place**: Appropriate logging has been added for
debugging user issues
- [ ] **Sentry will be able to catch errors**: Error handling ensures
Sentry can capture and report errors
- [ ] **Avoid Dev based/Prisma logging**: No development-only or
Prisma-specific logging in production code

## Configuration
- [ ] **Env variables newly added**: Any new environment variables are
documented in .env.example file or mentioned in description
---

## Additional Notes
<!-- Add any additional context, screenshots, or notes for reviewers
here -->
2026-01-31 00:04:29 +00:00
Saurabh Misra
289827e5cb
Merge pull request #2337 from codeflash-ai/fix/improve-typescript-validation-error-messages
fix: improve TypeScript/JavaScript validation error messages
2026-01-30 16:03:02 -08:00
Saurabh Misra
d255a29203
Update django/aiservice/aiservice/validators/javascript_validator.py
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-01-30 16:00:05 -08:00
Saurabh Misra
8800614d1c Add unit tests for TypeScript/JavaScript validator error reporting
Tests for:
- Error location reporting with line numbers and code snippets
- Markdown code block parsing with various scenarios
- Multiple code blocks with mixed valid/invalid content
- Real-world TypeScript patterns (async, try-catch, template literals)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:53:26 +00:00
Saurabh Misra
07ae9db684 fix: improve TypeScript/JavaScript validation error messages
Add better error diagnostics for TypeScript/JavaScript syntax validation:

- Add line numbers and code snippets to error messages
- Log warnings when markdown parsing finds no code blocks
- Show the actual problematic code in error logs
- Help debug "Invalid syntax" errors by showing exact location

This helps diagnose issues where the API rejects code that tree-sitter
parses correctly on the client side by providing more context in the
error messages and logs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:47:39 +00:00
Aseem Saxena
f6ec336246
Merge pull request #2320 from codeflash-ai/ranker-multidim-scoring
Multi dimensional scoring and structured json parsing for ranker
2026-01-30 15:00:33 -08:00
aseembits93
af2935f4f2 0-index finally 2026-01-30 14:42:28 -08:00
Kevin Turcios
c1a25b33e5
Merge branch 'main' into ranker-multidim-scoring 2026-01-30 22:16:08 +00:00
mohammed ahmed
391702c986
Merge pull request #2336 from codeflash-ai/fix/js-ts-validator
[FIX] Correctly handle markdown code for validating js/ts
2026-01-30 20:29:17 +02:00
ali
99a7a32b32
safer caching 2026-01-30 19:52:18 +02:00
ali
879aa93967
fix validating js/ts code with markdown syntax 2026-01-30 19:44:31 +02:00
Kevin Turcios
0f5d578d37
Merge branch 'main' into ranker-multidim-scoring 2026-01-29 22:45:18 +00:00
HeshamHM28
c24f350719
Fix Prevent log code for paid org in the optimization feature "AI service " (#2325)
Fixes Cf-1038
2026-01-29 19:28:30 +00:00
Kevin Turcios
04197195e8
Store instrumented performance tests in feature logging (#2330)
## Summary
- Add `instrumented_perf_test` field to `OptimizationFeatures` model
- Update `log_features` function to accept and store performance
instrumented tests

---------

Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2026-01-29 03:09:47 -05:00
aseembits93
f1b6fbf737 adding back the instructions 2026-01-28 16:13:28 -08:00
aseembits93
7386dd20b5 1-indexed ranking everywhere 2026-01-28 16:02:24 -08:00
aseembits93
71d397753d Merge remote-tracking branch 'origin/main' into ranker-multidim-scoring 2026-01-28 15:36:30 -08:00
aseembits93
215e6ad390 fixed merge issues 2026-01-28 15:33:11 -08:00
Saurabh Misra
8f7657da0d
Merge pull request #2247 from codeflash-ai/multi-language
codeflash-omni
2026-01-28 14:25:32 -08:00
ali
c19d9f4450
fix unit tests 2026-01-28 23:20:48 +02:00
ali
f0480fac39
use treesitter for validating js & ts code syntax 2026-01-28 23:15:30 +02:00
ali
db3f269b37
linting and formatting 2026-01-28 22:41:27 +02:00
ali
ec97ebd4e7
more cleanup 2026-01-28 22:23:54 +02:00
ali
31091350c9
cleanup 2026-01-28 22:19:40 +02:00
ali
dcac02b3f2
abstraction 2026-01-28 21:53:51 +02:00
ali
373d4c6574
Merge branch 'main' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-28 20:47:57 +02:00
mashraf-222
d9a8aa8811
enhance LLM response view & adding ranker details in observability (#2326)
<img width="1755" height="1017" alt="image"
src="https://github.com/user-attachments/assets/9d398362-48b0-45b3-82a7-acf1174f1684"
/>
<img width="1901" height="1043" alt="image"
src="https://github.com/user-attachments/assets/a3ea7ef4-4b62-4f72-874e-80b28d513b8d"
/>

---------

Co-authored-by: Codeflash Bot <bot@codeflash.ai>
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
2026-01-28 13:20:00 -05:00
HeshamHM28
f909642ce1
feat: Add Line Profiler visualization to webapp (#2268)
## Summary
Adds a line-by-line performance profiler visualization to the webapp,
allowing users to compare execution times between original and optimized
code.

  ## Changes

  ### New Line Profiler View
- **`LineProfilerView.tsx`**: Side-by-side comparison component showing:
    - Line-by-line execution times with heat map visualization
    - Syntax highlighting using `prism-react-renderer`
    - Collapsible function blocks
    - Light/dark mode support
    - Heat legend (cold → hot based on % time)

- **`lineProfilerParser.ts`**: Parser utilities for line profiler data:
- `parseLineProfilerResults()` - parses markdown table output from
Python's line_profiler
- `formatTime()` - converts timer units to human-readable format (ns,
µs, ms, s)
    - `getHeatLevel()` - determines heat coloring based on % time

- **`/review-optimizations/[traceId]/profiler/page.tsx`**: New route for
the profiler view

  ### API Changes
- **`create-pr.ts`**: Adds "📊 Performance Profile" link to PR
description when profiler data exists
- **`github-app.ts`**: Removes line profiler data from metadata when PR
is closed/merged
- **`create-staging.ts`**, **`suggest-pr-changes.ts`**: Handle line
profiler data in staging
- **`staging-storage-strategy.ts`**: Interface updates for line profiler
fields

  ### Webapp Integration
- **`page.tsx`**: Added "Performance Profile" button (only visible when
profiler data exists)
- **`action.ts`**: Sends line profiler data when creating PR from webapp
  Fixes CF-1018
  


https://codeflash-ai.slack.com/files/U08MSR1UN6L/F0A9YVDJY75/screen_recording_2026-01-21_at_10.03.18___pm.mov
https://github.com/HeshamHM28/my-best-repo/pull/21

linked to https://github.com/codeflash-ai/codeflash/pull/1139

---------

Co-authored-by: Aseem Saxena <aseem.bits@gmail.com>
2026-01-28 08:36:54 -08:00
Kevin Turcios
5ab169076c
Merge branch 'main' into multi-language 2026-01-28 08:19:52 -05:00
Kevin Turcios
8a66c78220
refactor: consolidate CST utilities and simplify add_missing_imports (#2324)
## Summary
- Consolidate shared CST utilities into `aiservice/common/cst_utils.py`
- Simplify `add_missing_imports` by removing redundant abstractions
- Require CST modules instead of strings in postprocessing pipeline
2026-01-28 08:05:45 -05:00
ali
d7e7125220
Merge branch 'multi-language' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-28 13:41:55 +02:00
ali
557fb11939
remove jest globals check (client handles it now) 2026-01-28 13:41:06 +02:00
misrasaurabh1
b0a1d6c09f Remove instrumentation of js tests from aiservice and into client 2026-01-27 16:10:35 -08:00
ali
39de6a3bce
Merge branch 'multi-language' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-27 23:30:11 +02:00
ali
72cb589948
some instrumentation fixes 2026-01-27 23:30:03 +02:00
Aseem Saxena
7f8ce66c6a multi dimensional scoring and structured json parsing for ranker 2026-01-27 12:24:16 -08:00
mohammed ahmed
0c9cc6afe4
Merge branch 'main' into multi-language 2026-01-27 19:44:57 +02:00
snyk-io[bot]
f7f3e7f0bd
[Snyk] Security upgrade diff from 8.0.2 to 8.0.3 (#2305)
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)

### Snyk has created this PR to fix 1 vulnerabilities in the npm
dependencies of this project.

#### Snyk changed the following file(s):

- `js/VSC-Extension/package.json`




#### Vulnerabilities that will be fixed with an upgrade:

|  | Issue | Score | 

:-------------------------:|:-------------------------|:-------------------------
![medium
severity](https://res.cloudinary.com/snyk/image/upload/w_20,h_20/v1561977819/icon/m.png
'medium severity') | Regular Expression Denial of Service (ReDoS)
<br/>[SNYK-JS-DIFF-14917201](https://snyk.io/vuln/SNYK-JS-DIFF-14917201)
| &nbsp;&nbsp;**708**&nbsp;&nbsp;




---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - Max score is 1000. Note that the real score may have changed since
the PR was raised.
> - This PR was automatically created by Snyk using the credentials of a
real user.

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open fix PRs._

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI1YmZkM2I3OC1iNmQ1LTRmNTYtODBhNC1iZDg4YmMzMTA4NDAiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjViZmQzYjc4LWI2ZDUtNGY1Ni04MGE0LWJkODhiYzMxMDg0MCJ9fQ=="
width="0" height="0"/>
🧐 [View latest project
report](https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source&#x3D;github-cloud-app&amp;utm_medium&#x3D;referral&amp;page&#x3D;fix-pr)
📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=github-cloud-app&utm_content=fix-pr-template)
🛠 [Adjust project
settings](https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source&#x3D;github-cloud-app&amp;utm_medium&#x3D;referral&amp;page&#x3D;fix-pr/settings)
📚 [Read about Snyk's upgrade
logic](https://docs.snyk.io/scan-with-snyk/snyk-open-source/manage-vulnerabilities/upgrade-package-versions-to-fix-vulnerabilities?utm_source=github-cloud-app&utm_content=fix-pr-template)

---

**Learn how to fix vulnerabilities with free interactive lessons:**

🦉 [Regular Expression Denial of Service
(ReDoS)](https://learn.snyk.io/lesson/redos/?loc&#x3D;fix-pr)

[//]: #
'snyk:metadata:{"breakingChangeRiskLevel":null,"FF_showPullRequestBreakingChanges":false,"FF_showPullRequestBreakingChangesWebSearch":false,"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"diff","from":"8.0.2","to":"8.0.3"}],"env":"prod","issuesToFix":["SNYK-JS-DIFF-14917201"],"prId":"5bfd3b78-b6d5-4f56-80a4-bd88bc310840","prPublicId":"5bfd3b78-b6d5-4f56-80a4-bd88bc310840","packageManager":"npm","priorityScoreList":[708],"projectPublicId":"9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233","projectUrl":"https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source=github-cloud-app&utm_medium=referral&page=fix-pr","prType":"fix","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":["updated-fix-title","priorityScore"],"type":"auto","upgrade":["SNYK-JS-DIFF-14917201"],"vulns":["SNYK-JS-DIFF-14917201"],"patch":[],"isBreakingChange":false,"remediationStrategy":"vuln"}'

Co-authored-by: snyk-io[bot] <141718529+snyk-io[bot]@users.noreply.github.com>
2026-01-27 17:37:39 +05:30
Sarthak Agarwal
ccdebe5782
fix for cf-api route issue and process exit (#2315) 2026-01-27 17:35:48 +05:30
Kevin Turcios
1b2105e6d3
Merge branch 'main' into multi-language 2026-01-27 01:25:52 -05:00
Kevin Turcios
3fabea495f fix: install uv in fix-formatting workflow
The ty-check hook requires uv to be available. Add astral-sh/setup-uv
step before running prek.
2026-01-27 01:25:19 -05:00
Kevin Turcios
bf3890fdbf fix: use interactive mode for Claude @mentions
Remove prompt parameter from claude-mention job so Claude runs in
interactive mode and naturally receives @mention context. Move prek
formatting instructions to CLAUDE.md where Claude reads them for any
request.
2026-01-27 01:24:07 -05:00
Kevin Turcios
d26871b355
Merge branch 'main' into multi-language 2026-01-27 01:18:25 -05:00
Kevin Turcios
d80321da9f one more cc debug 2026-01-27 01:17:48 -05:00
Kevin Turcios
35e5e37f7e
Merge branch 'main' into multi-language 2026-01-27 01:08:17 -05:00
Kevin Turcios
a741523b1f debug
- Add standalone fix-formatting.yml workflow for `/fix-formatting` command
- Uses prek's native --from-ref to only format changed files
- Properly handles prek exit codes and reports errors
- Enable show_full_output in claude-mention job for debugging
2026-01-27 01:07:55 -05:00
Kevin Turcios
646a480769
Merge branch 'main' into multi-language 2026-01-27 00:57:23 -05:00