refactor(run): replace heredoc stdin with -c flag#188
Merged
sarath-menon merged 2 commits intomainfrom Apr 24, 2026
Merged
Conversation
Agents naturally write js() calls with top-level `return`, which is a syntax error in Runtime.evaluate. js() now detects `return ` and wraps the expression in an IIFE so both styles work without callers needing to know the CDP constraint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drops the <<'PY' heredoc pattern entirely. Agents now pass code via `browser-harness -c "..."`, which is simpler to construct programmatically and avoids heredoc quoting pitfalls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
<<'PY' ... PYheredoc pattern entirely — no backward compatibility shimbrowser-harness -c "code"is now the only invocation styletest_run.pywith two tests covering the-cflag (red → green via TDD)Test plan
test_c_flag_executes_code— code passed via-cruns and produces outputtest_c_flag_does_not_read_stdin— stdin is never touched when-cis useduv run pytest test_js.py test_run.py -v)🤖 Generated with Claude Code
Summary by cubic
Switches
browser-harnessto use a-cflag instead of heredoc stdin, making invocation simpler and more reliable. Also updateshelpers.js()to accept top‑levelreturnby auto‑wrapping the expression in an IIFE.Migration
browser-harness -c "print(page_info())". Heredoc stdin is no longer supported.Bug Fixes
helpers.js()auto-wraps expressions containingreturnin an IIFE, so bothdocument.titleandconst x = 1; return xwork without CDP syntax errors.Written for commit 0f20388. Summary will update on new commits.