Fix setup reliability, add Xvfb headed mode, improve inline execution#12
Merged
Fix setup reliability, add Xvfb headed mode, improve inline execution#12
Conversation
Setup script: - Resolve skill dir from script location (works without CLAUDE_PROJECT_DIR) - Verify vendor wheel vs PyPI install and reinstall if needed - Install trafilatura alongside patchright in one pass - Add --system flag to all uv pip commands for non-venv environments - Fix __version__ attribute access for patchright version check Xvfb virtual display: - Add ensure_virtual_display() / stop_virtual_display() to proxy_wrapper - get_browser_config(headless=False) auto-starts Xvfb in web environments - Pass DISPLAY explicitly to Chrome via launch env for reliable detection - Graceful fallback to headless if Xvfb unavailable - Enables headed mode for better anti-bot evasion in headless environments Inline execution: - Auto-detect when code needs pre-configured browser/page vs manual setup - Auto-configured mode: provides browser, context, page, helpers, cleanup - Simple tasks like "await page.goto(...)" just work without boilerplate - Manual mode still available when code uses p.chromium.launch() - Fix multiline code indentation in all wrapper templates - Add stop_virtual_display() cleanup to all wrapper finally blocks https://claude.ai/code/session_011rNycMwFzJkx8UNqb5kGxh
Setup script now installs xvfb via apt-get during session startup (non-fatal if it fails). The Python ensure_virtual_display() also attempts apt-get install as a runtime fallback before giving up and falling back to headless mode. https://claude.ai/code/session_011rNycMwFzJkx8UNqb5kGxh
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
$CLAUDE_PROJECT_DIR— resolves skill directory from the script's own location viaBASH_SOURCE[0], which always works. Also verifies the installed patchright is actually from the vendor wheel (not PyPI) and reinstalls if needed, installs trafilatura alongside patchright, and adds--systemto alluv pipcalls for non-venv environments.get_browser_config(headless=False)now auto-starts an Xvfb virtual display in web/CI environments. This gives better anti-bot evasion since some detection systems fingerprint headless browsers. Xvfb is installed by the setup script and also attempted at runtime as a fallback. Gracefully degrades to headless if Xvfb is unavailable.run.pyexecutor now auto-detects when inline code referencespagewithout creating its own browser, and provides pre-configuredbrowser,context,page, plus all helper functions. Simple tasks become one-liners (await page.goto(...); print(await page.title())) with automatic setup and teardown.Changes
scripts/setup-session.sh--systemto alluv pipcallspatchright.__version__attribute checkskills/playwright-skill/lib/proxy_wrapper.pyensure_virtual_display()/stop_virtual_display()get_browser_config(headless=False)starts Xvfb + passes env to Chromexvfb_usedkey in config dictskills/playwright-skill/run.pypage.usage, provides full setup)p.chromium.launch)stop_virtual_display()cleanup to finally blocks--systemto uv pip fallback installerskills/playwright-skill/SKILL.mdskills/playwright-skill/lib/helpers.pyensure_virtual_display/stop_virtual_displayxvfb_usedto stubget_browser_config()Test plan
$CLAUDE_PROJECT_DIRget_browser_config()defaults to headless in web envget_browser_config(headless=False)starts Xvfb and Chrome connectsawait page.goto(...)works without boilerplatep.chromium.launch(...)still worksextract_markdown()in auto-configured modetake_screenshot()in auto-configured mode