Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

4.2 KB
Raw Blame
# lefthook.yml - git hooks for ego-lite
#
# Enable hooks:
#   cd package/ego-browser && npm install
#
# lefthook is a package/ego-browser devDependency. npm install runs the
# prepare script, which installs hooks into the repository's .git/hooks.
#
# The git root is the repository root, while the JS package lives in
# package/ego-browser. Commands cd into that package when needed.
#
# pre-commit keeps the fast checks: it builds the SDK once, then runs the
# style check, repository tests, site-skill validation and plugin tests in
# parallel against that build (EGO_BROWSER_REUSE_BUILD). Dependency auditing
# runs in CI only. The real-browser E2E suite runs on pre-push, and its runner
# skips itself when the build, the suite and the ego lite CLI are unchanged
# since the last full pass (EGO_BROWSER_REAL_E2E_FORCE=1 reruns it).

pre-commit:
  jobs:
    - name: plugin-skill-sync
      # Refreshes the plugin's copy of the entry Skill before plugin-tests
      # checks it. It writes the index, so it runs before the parallel jobs.
      run: |
        git diff --cached --name-only | grep -q '^skills/ego-browser/' || exit 0
        node plugins/scripts/sync-skills.mjs ego --staged
    - group:
        parallel: true
        jobs:
          - name: branch-up-to-date
            run: |
              git fetch --quiet origin dev 2>/dev/null || { echo "⚠ skip branch-freshness check: cannot fetch origin/dev (offline?)"; exit 0; }
              if git merge-base --is-ancestor FETCH_HEAD HEAD; then
                exit 0
              fi
              echo "✗ Your branch is behind origin/dev — sync before committing:"
              echo "    git fetch origin dev && git rebase origin/dev   # or: git merge origin/dev"
              exit 1
          - name: build
            run: |
              git diff --cached --name-only --diff-filter=ACMR | grep -Eq '^(package/ego-browser/|skills/ego-browser/)' || exit 0
              cd package/ego-browser && npm run build
    - group:
        parallel: true
        jobs:
          - name: style-check
            run: |
              files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '^(package/ego-browser|plugins)/.*\.(ts|mjs|js|json|md)$' | grep -v '^skills/ego-browser/learnings/' || true)
              [ -z "$files" ] && exit 0
              package/ego-browser/node_modules/.bin/prettier --check $files
          - name: smoke-test
            env:
              EGO_BROWSER_REUSE_BUILD: "1"
            run: |
              git diff --cached --name-only --diff-filter=ACMR | grep -Eq '^(package/ego-browser/|skills/ego-browser/)' || exit 0
              cd package/ego-browser && npm test
          - name: site-skill-validation
            env:
              EGO_BROWSER_REUSE_BUILD: "1"
            run: |
              git diff --cached --name-only --diff-filter=ACMR | grep -Eq '^(package/ego-browser/(src/learning/|scripts/validate-site-skills\.ts)|skills/ego-browser/learnings/)' || exit 0
              cd package/ego-browser && npm run validate:site-skills
          - name: plugin-tests
            run: |
              git diff --cached --name-only --diff-filter=ACMR | grep -Eq '^(plugins/|skills/ego-browser/|package/ego-browser/skill-body/|\.agents/plugins/|\.claude-plugin/|\.cursor-plugin/)' || exit 0
              npm --prefix plugins/ego test

pre-push:
  jobs:
    - name: e2e-test
      run: |
        # Only the commits being pushed matter. branch-up-to-date keeps
        # origin/dev an ancestor of HEAD, so the merge-base diff lists them;
        # without origin/dev (offline, fresh clone) run the suite anyway.
        if git rev-parse --verify --quiet origin/dev >/dev/null; then
          git diff --name-only origin/dev...HEAD | grep -Eq '^(package/ego-browser/|skills/ego-browser/)' || exit 0
        fi
        cd package/ego-browser && npm run e2e

post-commit:
  jobs:
    - name: plugin-skill-index
      # `git commit <paths>` commits plugin-skill-sync's copy from a temporary
      # index, so the real index keeps the old copy. Point it back at HEAD.
      run: |
        copy=plugins/ego/skills/ego-browser
        if git diff --quiet HEAD -- "$copy" && ! git diff --cached --quiet -- "$copy"; then
          git reset -q -- "$copy"
        fi