feat(js): add JavaScript function tracer with Babel instrumentation#2105
Merged
feat(js): add JavaScript function tracer with Babel instrumentation#2105
Conversation
Replaces source-level JavaScript function tracing with Babel AST transformation via babel-tracer-plugin.js and trace-runner.js. Adds replay test generation, Python-side tracer runner, and --language flag to the tracer CLI for explicit JS/TS routing.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue or discussion
Supersedes #1377 — reimplemented against current main after the original branch diverged too far to rebase (78 days, conflicts in 4+ files).
What changed
Adds function tracing for JavaScript/TypeScript projects, matching the existing Python tracer architecture.
How it works:
babel-tracer-plugin.js) instruments JS/TS functions at runtime by wrapping them with__codeflash_tracer__.wrap()calls — no source modification neededtracer.js) records function calls with nanosecond timing and serialized arguments to a SQLite databasereplay.js) reads the trace DB and generates Jest/Vitest test files that replay the captured callstracer_runner.py,replay_test.py) spawns the Node.js tracer subprocess and converts trace data into codeflash's test formatCLI integration:
codeflash trace --language javascriptroutes to the JS tracerDeferred:
parse.py→parse_test_output.pyconsolidation refactor from feat(js): add JavaScript function tracer with Babel instrumentation #1377 will be done in codeflash-agent (codeflash-ai/codeflash-agent#31)Test plan
test_javascript_tracer.pycovering trace parsing, replay test generation, and E2E tracingjs-tests.ymlCI workflowtest_javascript_instrumentation.pyto reflect that Babel handles instrumentation at runtime (no more source-levelinstrument_source())