npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hunkdiff

v0.2.0

Published

Desktop-inspired terminal diff viewer for understanding agent-authored changesets.

Downloads

182

Readme

hunk

Hunk is a terminal diff viewer for reviewing agent-authored changesets with a desktop-style UI.

  • full-screen multi-file review stream
  • split, stacked, and responsive auto layouts
  • keyboard and mouse navigation
  • optional agent rationale beside annotated hunks
  • Git pager and difftool integration

Install

npm i -g hunkdiff

Requirements

  • Node.js 18+
  • Git for hunk diff, hunk show, hunk stash show, and pager integration

Quick start

Review your current working tree:

hunk diff

Review staged changes:

hunk diff --staged

Review a commit:

hunk show HEAD~1

Compare two files directly:

hunk diff before.ts after.ts

Open a patch from stdin:

git diff --no-color | hunk patch -

Feature comparison

| Capability | hunk | difftastic | delta | diff | | --- | --- | --- | --- | --- | | Dedicated interactive review UI | ✅ | ❌ | ❌ | ❌ | | Multi-file review stream with navigation sidebar | ✅ | ❌ | ❌ | ❌ | | Agent / AI rationale sidecar | ✅ | ❌ | ❌ | ❌ | | Split diffs | ✅ | ✅ | ✅ | ✅ | | Stacked diffs | ✅ | ✅ | ✅ | ✅ | | Auto responsive layouts | ✅ | ❌ | ❌ | ❌ | | Themes | ✅ | ❌ | ✅ | ❌ | | Syntax highlighting | ✅ | ✅ | ✅ | ❌ | | Syntax-aware / structural diffing | ❌ | ✅ | ❌ | ❌ | | Mouse support inside the diff viewer | ✅ | ❌ | ❌ | ❌ | | Runtime toggles for wrapping / line numbers / hunk metadata | ✅ | ❌ | ❌ | ❌ | | Pager-compatible mode | ✅ | ✅ | ✅ | ✅ |

Benchmarks

Quick local timing snapshot from one Linux machine on the same 120-line TypeScript file pair. Metric: time until a changed marker first became visible.

| Tool | Avg first-visible changed output | | --- | ---: | | diff | ~37 ms | | delta --paging=never | ~35 ms | | hunk diff | ~219 ms | | difft --display side-by-side | ~266 ms |

Takeaway:

  • diff and delta are fastest here because they print plain diff text and exit.
  • hunk spends more startup time on an interactive UI, syntax highlighting, navigation state, and optional agent context.
  • difftastic spends more startup time on structural diffing.

Common workflows

  • hunk — print CLI help
  • hunk diff — review working tree changes
  • hunk diff --staged / hunk diff --cached — review staged changes
  • hunk diff <ref> — review changes versus a branch, tag, or commit-ish
  • hunk diff <ref1>..<ref2> / hunk diff <ref1>...<ref2> — review Git ranges
  • hunk diff -- <pathspec...> — limit review to selected paths
  • hunk show [ref] — review the last commit or a specific ref
  • hunk stash show [ref] — review a stash entry
  • hunk patch [file|-] — review a patch file or stdin
  • hunk pager — act as a Git pager wrapper, opening Hunk for diff-like stdin and falling back to plain text paging otherwise
  • hunk difftool <left> <right> [path] — integrate with Git difftool

Interaction

  • 1 split view
  • 2 stacked view
  • 0 auto layout
  • t cycle themes
  • a toggle the agent panel
  • l toggle line numbers
  • w toggle line wrapping
  • m toggle hunk metadata
  • [ / ] move between hunks
  • space / b page forward and backward
  • / focus the file filter
  • tab cycle focus regions
  • q or Esc quit

Git integration

Use Hunk directly for full-screen review:

hunk diff
hunk diff --staged
hunk diff main...feature
hunk show
hunk stash show

Use Hunk as a pager for git diff and git show:

git config --global core.pager 'hunk patch -'

Or scope it just to diff/show:

git config --global pager.diff 'hunk patch -'
git config --global pager.show 'hunk patch -'

Use Hunk as a Git difftool:

git config --global diff.tool hunk
git config --global difftool.hunk.cmd 'hunk difftool "$LOCAL" "$REMOTE" "$MERGED"'

Configuration

Hunk reads layered TOML config with this precedence:

  1. built-in defaults
  2. global config: $XDG_CONFIG_HOME/hunk/config.toml or ~/.config/hunk/config.toml
  3. repo-local config: .hunk/config.toml
  4. command-specific sections like [diff], [show], [stash-show], [patch], [difftool]
  5. [pager] when Hunk is running in pager mode
  6. explicit CLI flags

Example:

theme = "midnight"
mode = "auto"
line_numbers = true
wrap_lines = false
hunk_headers = true
agent_notes = false

[pager]
mode = "stack"
line_numbers = false

[diff]
mode = "split"

Supported one-off CLI overrides:

  • --mode <auto|split|stack>
  • --theme <theme>
  • --line-numbers / --no-line-numbers
  • --wrap / --no-wrap
  • --hunk-headers / --no-hunk-headers
  • --agent-notes / --no-agent-notes

Agent context sidecar

Use --agent-context <file> to load a JSON sidecar and show agent rationale next to the diff.

The order of files in the sidecar is significant. Hunk uses that order for the sidebar and the main review stream so an agent can present a review narrative instead of raw patch order.

{
  "version": 1,
  "summary": "High-level change summary from the agent.",
  "files": [
    {
      "path": "src/core/loaders.ts",
      "summary": "Normalizes git and patch inputs into one changeset model.",
      "annotations": [
        {
          "newRange": [120, 156],
          "summary": "Adds the patch loader entrypoint.",
          "rationale": "Keeps all diff sources flowing through one normalized shape.",
          "tags": ["parser", "architecture"],
          "confidence": "high"
        }
      ]
    }
  ]
}

For local agent-driven review, keep a transient sidecar at .hunk/latest.json and load it with:

hunk diff --agent-context .hunk/latest.json

Development

Install dependencies:

bun install

Validate a change:

bun run typecheck
bun test
bun run test:tty-smoke

Build the npm runtime bundle used for publishing:

bun run build:npm
bun run check:pack

License

MIT