项目文件夹

文件
Sarath S Menon 216a2c9653 feat(cli): add --reload flag to restart the daemon (#200)
* fix(js): don't double-wrap IIFEs that contain return

The substring check `"return " in expression` incorrectly matched
expressions that already contained an IIFE with an internal return,
causing double-wrapping and a silent None result. Guard with
`not expression.strip().startswith("(")` so pre-wrapped expressions
pass through unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(cli): add --reload flag to restart the daemon

Kills the running daemon so the next call picks up code changes,
replacing the manual pkill workflow after editing helpers.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 15:32:22 +05:30

71 行
1.9 KiB
Python

import os, sys
from admin import (
_version,
ensure_daemon,
list_cloud_profiles,
list_local_profiles,
print_update_banner,
restart_daemon,
run_doctor,
run_setup,
run_update,
start_remote_daemon,
stop_remote_daemon,
sync_local_profile,
)
from helpers import *
HELP = """Browser Harness
Read SKILL.md for the default workflow and examples.
Typical usage:
uv run bh <<'PY'
ensure_real_tab()
print(page_info())
PY
Helpers are pre-imported. The daemon auto-starts and connects to the running browser.
Commands:
browser-harness --version print the installed version
browser-harness --doctor diagnose install, daemon, and browser state
browser-harness --setup interactively attach to your running browser
browser-harness --update [-y] pull the latest version (agents: pass -y)
browser-harness --reload stop the daemon so next call picks up code changes
"""
def main():
args = sys.argv[1:]
if args and args[0] in {"-h", "--help"}:
print(HELP)
return
if args and args[0] == "--version":
print(_version() or "unknown")
return
if args and args[0] == "--doctor":
sys.exit(run_doctor())
if args and args[0] == "--setup":
sys.exit(run_setup())
if args and args[0] == "--update":
yes = any(a in {"-y", "--yes"} for a in args[1:])
sys.exit(run_update(yes=yes))
if args and args[0] == "--reload":
restart_daemon()
print("daemon stopped — will restart fresh on next call")
return
if args and args[0] == "--debug-clicks":
os.environ["BH_DEBUG_CLICKS"] = "1"
args = args[1:]
if not args or args[0] != "-c":
sys.exit("Usage: browser-harness -c \"print(page_info())\"")
print_update_banner()
ensure_daemon()
exec(args[1], globals())
if __name__ == "__main__":
main()