← Catalog

pi-ghwebhook

Universal GitHub Webhook event bus and wake-up engine for Pi coding agent

Extension

Install

Install with PiG

pig install npm:pi-ghwebhook

Install with Pi

pi install npm:pi-ghwebhook
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./dist/index.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.5.0 (README.md). PiG does not review it.

pi-ghwebhook

Universal GitHub Webhook event bus and wake-up driver for the Pi coding agent

npm version Node.js TypeScript Pi Package GitHub License

English | 中文

Overview

pi-ghwebhook eliminates manual polling and terminal switching after pushing code or creating pull requests. By hosting an in-process loopback server connected to GitHub CLI's gh webhook forward reverse tunnel, it receives real-time GitHub Webhook events, evaluates GitHub Actions Workflow-style trigger rules, and wakes up the Pi Agent via pi.sendUserMessage() to close the loop.

Key Architecture

  • 100% GitHub Actions Workflow Specification: Uses official on and jobs syntax. Zero invented intermediate concepts.
  • JSON Schema Autocompletion: Includes an official schema ($schema) for instant editor IntelliSense and validation.
  • Zero Public Exposure: Uses gh webhook forward --events=* local reverse tunnels. No public server, ngrok, or exposed port required.
  • Dynamic Port Allocation: Binds to 127.0.0.1:0. The OS kernel dynamically assigns an unused port, eliminating port contention across concurrent sessions.
  • Table-Driven Dispatch: O(1) event routing with strict complexity constraints (CCN <= 15, CogC <= 15).
  • Workspace Detection: Probes .pi/ghwebhook.json on session_start. If absent, sleeps silently with zero resource consumption.
  • Clean Teardown: Hooks into session_shutdown and process exit to terminate child processes and servers idempotently.

Installation

Install into your Pi coding agent:

pi install npm:pi-ghwebhook

Or install from GitHub:

pi install git:github.com/xifan2333/pi-ghwebhook

To test locally in an active session:

pi -e /path/to/pi-ghwebhook

Commands & Status Bar

pi-ghwebhook integrates directly into the Pi TUI status bar and provides dedicated commands:

Status Bar

  • Connected: ● ghwk: <repo> (<branch>)
  • Stopped: ○ ghwk: stopped
  • Unconfigured: Cleared from status bar (zero visual noise)

Commands

  • /ghwk.status: Display active connection status, repository, branch, port, and jobs.
  • /ghwk.start: Manually start the local receiver and GitHub forwarder.
  • /ghwk.stop: Manually pause the webhook forwarder and release local port.
  • /ghwk.restart: Reload configuration and restart the forwarder.

Configuration (.pi/ghwebhook.json)

Place .pi/ghwebhook.json in the root of any repository. Point $schema to the hosted JSON Schema for auto-completion in VS Code, Cursor, and other editors:

{
  "$schema": "https://raw.githubusercontent.com/xifan2333/pi-ghwebhook/main/schemas/ghwebhook.schema.json",
  "name": "CI & Review Automation",
  "on": {
    "workflow_run": {
      "workflows": ["CI"],
      "types": ["completed"],
      "branches": ["@current"]
    },
    "pull_request_review": {
      "types": ["submitted"],
      "branches": ["@current"]
    },
    "issues": {
      "types": ["opened"]
    },
    "push": {
      "branches": ["main"]
    }
  },
  "jobs": {
    "ci-failure": {
      "if": "github.event.workflow_run.conclusion == 'failure'",
      "prompt": "CI run failed on branch {{ branch }}.\n\nRun URL: {{ run_url }}\nCommit: {{ head_sha }}\n\nPlease run `gh run view {{ run_id }} --log-failed` to diagnose the error and prepare a fix.",
      "deliverAs": "followUp"
    },
    "ci-success": {
      "if": "github.event.workflow_run.conclusion == 'success'",
      "prompt": "Remote CI has passed on branch {{ branch }}.\n\nRun URL: {{ run_url }}\n\nPlease check PR checks status and verify if it is ready to merge.",
      "deliverAs": "followUp"
    },
    "review-bot": {
      "if": "github.event.review.user.type == 'Bot'",
      "prompt": "Received review comments from {{ sender }}:\n\nState: {{ review_state }}\nDetails:\n{{ review_body }}\n\nPlease evaluate these comments critically: triage true issues to fix, and refute false positives.",
      "deliverAs": "steer"
    },
    "new-issue": {
      "prompt": "New issue opened #{{ issue_number }}: {{ issue_title }}\n\n{{ issue_body }}"
    },
    "push-main": {
      "prompt": "New commit pushed to main: {{ head_sha }} - {{ commit_message }}"
    }
  }
}

Configuration Fields

  • name: Optional workflow name.
  • repo: GitHub repository (owner/repo). Defaults to "auto" (resolved from git remote get-url origin).
  • secret: Optional webhook HMAC SHA-256 verification secret.
  • on: GitHub Actions event triggers specification:
    • <event_name>: Event name (e.g. workflow_run, pull_request, push, issues).
    • types: Activity types filtering payload.action (e.g. ["completed"], ["opened"]).
    • branches: Branches filter supporting @current and globs (e.g. ["@current", "main", "feat/*"]).
    • workflows: Workflow names filter (e.g. ["CI"]).
  • jobs: Map of jobs to execute:
    • if: Conditional expression (e.g. github.event.workflow_run.conclusion == 'failure').
    • prompt: Prompt template sent to Pi Agent.
    • deliverAs: Pi message delivery mode: "followUp" (default) or "steer".

Template Variables

  • {{ branch }}: Current head branch.
  • {{ head_sha }}: Commit SHA.
  • {{ commit_message }}: Head commit message.
  • {{ repo }} / {{ repo_url }}: Repository name and URL.
  • {{ run_id }} / {{ run_url }} / {{ workflow }} / {{ conclusion }}: Workflow run metadata.
  • {{ pr_number }} / {{ pr_title }} / {{ pr_url }}: Pull request details.
  • {{ issue_number }} / {{ issue_title }} / {{ issue_url }} / {{ issue_body }}: Issue details.
  • {{ sender }} / {{ sender_type }}: Triggering actor.
  • {{ review_state }} / {{ review_body }} / {{ review_url }}: Review details.
  • {{ comment_body }} / {{ comment_url }}: Comment details.

Development & Quality Gates

mise run check         # Run all quality gates (tsc, oxlint, prettier, lizard, jscpd, typos)
mise run check:plan    # Preview execution plan
mise run check:changed # Check only staged/modified files (< 50ms)
mise run fix           # Auto-format and fix lint/package issues
mise run test          # Run test suite

License

MIT © 2026 xifan