Skip to content

diegomarino/gh-delta

v0.12.1MIT

Decision guide for observing GitHub PR and issue deltas with gh-delta.

gh-delta

npm version CI

gh-delta is a deterministic, one-shot GitHub pull-request and issue detector for schedulers, scripts, and agent loops. It compares a current observation to a local snapshot, emits deltas, and leaves the next action to its caller. It is not a dashboard, inbox, bot, or scheduler.

A common one-minute PR loop lets the terminal history scroll naturally through the baseline, PR creation, CI starting, a failed job, a corrective push, green CI, and a final quiet tick that does not replay the change.

Contents

Try it live

Pick the most recently updated open PR with pending CI in a high-activity public repository, then poll only that PR once a minute:

REPO=NousResearch/hermes-agent
DEMO_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/gh-delta-live-demo"
WATCH_DIR="$DEMO_DIR/watch"
# Pick the most recently updated open PR with pending CI.
PR=$(gh search prs --repo "$REPO" --state open --checks pending \
  --sort updated --order desc --limit 1 \
  --json number --jq '.[0].number')

# Save the target locally once; watch add does not query GitHub.
# The loop reuses it to check one PR instead of scanning the whole repository.
npx gh-delta watch add "pr:$PR" \
  --repo "$REPO" \
  --watch-dir "$WATCH_DIR" \
  --until closed \
  --format text

# Check every 60 seconds; the first check establishes the baseline.
while true; do
  npx gh-delta \
    --repo "$REPO" \
    --monitor-id live-demo-60s \
    --state-dir "$DEMO_DIR" \
    --watch-dir "$WATCH_DIR" \
    --entities pr \
    --format text
  sleep 60
done
# Press Ctrl-C to stop.

The first tick is the baseline. Later ticks report changes to that one PR. Quiet ticks are normal. This demo still spends shared GraphQL quota.

gh-delta watch add pr:3 --until merged --watch-dir ./watch \
  --label thread=t-0004 --label package=F001-P05

Labels and watch sync: usage.

Install

Node 22+ and authenticated GitHub CLI access are required.

# npm binary
npm install --global gh-delta

# GitHub CLI extension
gh extension install diegomarino/gh-delta
gh delta --version

# agent skill (interactive)
npx skills add diegomarino/gh-delta --skill gh-delta

# or install globally for Codex without prompts, then verify
npx skills add diegomarino/gh-delta --skill gh-delta --agent codex --global --yes
npx skills list --global --agent codex

For a one-off run, use npx gh-delta. The skill is guidance only: it does not authorize GitHub mutations.

Quick start

In a GitHub checkout, create durable local monitor state and take a first tick:

gh-delta init
gh-delta --format compact

init writes a non-overwriting .gh-delta.json after a baseline. Later ticks reuse that identity. A first run exits 0; a changed run exits 10; exit 1 is retryable; exit 2 needs configuration or snapshot repair. JSON is always the default. Use --format compact for agents, text for logs, or template for per-delta lines.

The quick demo below shows the initial baseline followed by a later compact JSON report after GitHub state changes:

Output formats

The same observed change has four representations. Click any preview for the full-size generated output.

Agent contextStreaming consumers
compact: bounded summary and semantic changesndjson: one delta per line plus an end record
Full integration contractOperator log
json: complete fingerprints and optional detailtext: concise human-readable actions

Generated contract schemas are available offline through gh-delta schema --format compact|ndjson|json.

Quiet NDJSON ticks: --omit-end (usage).

What an agent usually does

ClassMeaningUsual agent response
new, first-seenNew or newly observed workInspect and queue the item; do not assume ownership.
ci-changedCI state changedGreen: inspect review/merge state. Failed: relay the failing check.
review-changed, review-requests-changedReview decision or audience changedNotify the right reviewer or return requested changes to the worker.
head-changed, base-changedCode or target base changedRe-check CI and reviews before trusting earlier approval.
merged, closed, reopenedLifecycle changedVerify it, then propose branch/work-queue follow-up.
new-comments, review-comments-added, unresolved-threads-addedNew discussion needs attentionRead the discussion before merge or dispatch. new-comments is conversation-only; review-comments-added is inline review replies.
became-mergeable, became-conflictingMergeability changedInspect protections/conflicts; never merge only because CI is green.
staleNo meaningful change for a periodSend one bounded reminder to the current owner/reviewer.
missing, presumed-deleted, reappearedObservation continuity changedCheck scope/permissions; only treat the terminal class as gone.
updated, relabeled, assignees-changedOther meaningful metadata changedReassess routing and inspect GitHub when the delta lacks enough detail.

The contract is canonical for class semantics, exit codes, schemas, snapshots, and every flag.

One agent pattern

Wait for a PR’s CI without polling from an LLM turn:

PR_NUMBER=42
gh-delta wait --repo owner/repo --monitor-id worker-42 \
  --state-dir "${XDG_STATE_HOME:-$HOME/.local/state}/gh-delta/snapshots" --entities pr --timeout 30m \
  --number "$PR_NUMBER" \
  --until-summary ciRollup=green,failed

On exit 10, inspect the JSON reason (until or already-satisfied) and the PR before proposing a next action. See the runnable, network-free agent worker example and the fan-out coordinator for one-fetch, many-worker operation.

Strict watch lists

gh-delta --repo owner/repo --monitor-id scheduled --entities pr \
  --state-dir ./state --watch-dir ./watch --watch-strict \
  --rate-limit-floor 100 --format ndjson

Also --entities issue and pr,issue. Usage.

Docs

Documentation map.

The official GitHub Action and Homebrew tap are external publication work; this repository ships only the safe local integration shapes until those artifacts exist.

License

MIT