项目文件夹

文件
reformedot 8a0c981082 feat: self-update CLI, release workflow, and fetch-use routing
- Add --version, --doctor, --setup, --update[-y] commands in run.py;
  logic lives in admin.py (install-mode detection, GitHub-releases cache
  with 24h TTL, dirty-worktree guard, interactive Chrome-attach flow).
- Print a once-per-day startup banner telling agents to run
  `browser-harness --update -y` when a newer release is available.
- Rename project to browser-harness in pyproject.toml so PyPI installs
  (uv tool install browser-harness) work via the public package name.
- Add .github/workflows/release.yml: on v* tag push, verify the tag
  matches pyproject.toml, uv build, and publish to PyPI via trusted
  publishing.
- Wire helpers.http_get through fetch_use.fetch_sync(...).text when
  BROWSER_USE_API_KEY is set; falls back to the original urllib path
  otherwise, preserving the existing str return contract.
- Document the new commands and the agent's self-update duty in
  SKILL.md and install.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 12:49:07 -07:00

68 行
1.6 KiB
Python

import 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)
"""
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 sys.stdin.isatty():
sys.exit(
"browser-harness reads Python from stdin. Use:\n"
" browser-harness <<'PY'\n"
" print(page_info())\n"
" PY"
)
print_update_banner()
ensure_daemon()
exec(sys.stdin.read())
if __name__ == "__main__":
main()