Skip to content
hunar2006Public

About

Local-first review cockpit for AI-generated diffs — deterministic triage, provenance, and verification.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Sift

CI License: Apache-2.0

Sift is a local-first review cockpit for AI-generated diffs. It ranks every hunk by risk, folds mechanical churn — renames, lockfiles, generated files — out of your way, and puts the code that actually needs a human first. You review entirely by keyboard, with a durable local decision history and undo/redo. Your diff never leaves your machine.

When an agent writes half your pull request, the bottleneck moves to review. Sift is where you catch the risky change before it lands — no cloud, no account, no diff leaving your laptop.

Sift demo

Sift workbench

Install

Sift is installed from source. You need Git and Node.js 22.13 or newer.

git clone https://github.com/hunar2006/sift.git
cd sift
corepack enable
pnpm install --frozen-lockfile
pnpm build
npm i -g ./packages/cli

The last line puts the sift command on your PATH, so it works in any repository. To skip it, run pnpm sift <command> from this checkout instead.

First run

sift demo

That reviews a sample repository, so you can see the workbench before pointing it at your own code. Then, inside a repo you want to review, sift doctor reports what Sift found, and sift setup wires hooks, the gate, and your editor — undo it any time with sift setup --remove.

60-second tour

  • sift — review current changes.
  • sift last — review the latest commit.
  • sift --watch — refresh as it changes.
  • j / k / a / x — move and decide.
  • sift tui — review in a terminal.
  • sift demo — try it without a repo.

Screenshots

Workbench Focus mode
Dark workbench Focus mode
Graphite and Assay
Graphite and Assay comparison
Light workbench Completion Timeline
Light workbench Completion Timeline
Queue close-up Inspector close-up
Queue Inspector
Diff search Static report
Diff search Static report
The hallmark Flagged checkpoint
Verified hallmark stamped over the focus card Flagged review checkpoint

Regenerate the complete set with pnpm shots.

Daily workflow

Run sift doctor once to check the local tools Sift relies on, then sift setup to configure hooks, editor, reasons, and coverage. During normal work, keep sift --watch open, decide with a/x/R, and use sift brief when a flag needs a fix.

How we test Sift

Sift grades AI-written code, so the engine is graded too: a six-repo corpus (pnpm eval), hard invariants (including independent mechanical honesty), and a property fuzzer (pnpm fuzz). pnpm health additionally blocks unused code, circular imports, lint/type failures, and oversized initial JavaScript; pnpm test:soak repeats the full suite ten times. Run pnpm preflight for the complete release-readiness scorecard before shipping. Numbers and recommendations live in docs/EVAL.md. Scoring weights stay frozen unless an invariant/spec bug is proven.

Live mode and the fix loop

Start a local review companion for the working tree, or for Git's index:

sift --watch
# or
sift --staged --watch

Sift watches changes, re-runs the same review after a short debounce, and streams hunk deltas into the open browser. Existing decisions never change. A modified hunk gets a new ID and returns unreviewed, marked fresh; untouched approvals remain approved. The New (n) header button filters fresh hunks, and opening or deciding one clears its fresh marker.

flag in Sift → sift brief | clip (or MCP) → agent fixes → fresh hunks return in watch mode

Use sift brief for flagged hunks, or sift brief --unreviewed-high for unreviewed high-risk work. It includes the reviewer note, primary reasons, and a patch capped at 120 lines per hunk.

What it does

  • Digest: factual, deterministic headlines and details for every hunk.
  • Triage: logic, tests, config, dependencies, docs, mechanical, generated, and binary categories.
  • Risk: inspectable deterministic reasons plus optional user rules.
  • Structure: formatting detection, rename-pattern groups, definitions, references, and reading-order hints.
  • Coverage: LCOV and Cobertura artifacts that you generated yourself.
  • Provenance: Claude Code hook logs and compatible open JSONL records.
  • State: approved, flagged, and unreviewed decisions stored locally under .sift/.
  • Word diff: changed words are tinted within paired added/removed lines without disturbing monospace alignment.
  • Search: Ctrl/Cmd+F finds literal text across paths, digests, and all diff lines.

Risk signals

Directive comments are machine-read behavior changes, not bulk-approvable prose. Sift flags compiler, linter, coverage, formatter, and declaration-tooling suppressions (for example @ts-ignore, # noqa, and //go:build) as the primary LINT_SUPPRESSED signal whether they are added or removed, so they remain in the attention queue with the matched directive shown as evidence.

Commands

Command Purpose
sift [range] Analyze the worktree or a ref/range and start the loopback UI.
sift last [n] Review HEAD~n..HEAD (default: 1).
sift --staged Analyze staged changes.
sift --watch Keep the default worktree review live; it also works with --staged, not a ref range or PR.
sift pr [number, URL, or owner/repo#number] Analyze a GitHub PR diff through gh.
sift brief [--flagged|--unreviewed-high] [-o file] Produce an agent-ready review handoff.
sift report [--md|--json|--html] [-o file] Emit a report and append a stats snapshot; --html is one self-contained static file.
sift print [--json] Print compact terminal triage without starting the server.
sift stats [--json] Print review debt, progress, flags, and line-match coverage.
sift check [--max-debt pct] Personal pre-push aid; not a team performance metric.
sift doctor [--json] Check local Sift prerequisites and print exact recovery commands.
sift setup [--remove] Interactively configure the daily review workflow, or remove its setup-owned changes.
sift demo [--dir path] Generate the demo repository and launch Sift.
sift rules lint / sift rules list Validate and display the effective ruleset.
sift init Write commented .sift/config.json and .sift/rules.yml starters if absent.
sift mcp Serve read-only review context over stdio MCP tools.
sift tui [range] Full-screen terminal review cockpit (Ink); same pipeline and state.json as the web UI.
sift hooks install [--project] Install the Claude Code PostToolUse capture hook.
pnpm shots / pnpm perf / pnpm pack-check / pnpm eval / pnpm fuzz Reproduce visual evidence, check the pipeline budget, verify an installed tarball, run the corpus eval, or property-fuzz the parser/pipeline.

Pull requests

Run sift pr to choose an open pull request, or pass its number, URL, or owner/repo#number. Use sift report --pr 123 --md for a PR report. Sift never posts; any gh pr comment command is yours to run.

Terminal cockpit (sift tui)

Browser-averse path that shares the decision-core, digests, and .sift/state.json with the web UI.

SIFT TUI FRAME · 34 hunks · 11 groups · debt 100%
[attention] High-risk logic (5)
[attention] Medium risk (15)
…
-- src/auth/session.ts · high 100 · Adds `rotateSessionRefresh()` (+7 lines)
footer: n of m · j/k move · a approve · x flag · u unreview · z undo · Shift+Z redo · R revert · q quit

Keys: j/k hunk · g/G first/last · n/p next/prev unreviewed attention · a approve · x flag (1–4 quick reasons, i note) · u unreview · z undo · Shift+Z redo · A group · space expand patch · o editor · R snapshot-backed file revert · ? help · q quit (prints sift print summary). Prefer a terminal ≥100×28; 80×24 still works with truncation. Use --watch for live refreshes and --print-frame for CI smoke.

Cockpit keys

Key Action
j Next hunk
k Previous hunk
g First hunk
G Last hunk
n Next unreviewed attention hunk
p Previous unreviewed attention hunk
a Approve current hunk
x Flag current hunk
u Mark current hunk unreviewed
z Undo latest decision
Shift+Z Redo latest decision
? Open shortcuts
R Revert current file
Ctrl/Cmd+K Open command palette
Ctrl/Cmd+F Search diff text
J Next file
K Previous file
i Focus note
f Enter focus mode
F Show flagged only
e Open current hunk in editor
r Refresh review
Space Collapse current hunk
o Toggle split diff
t Open timeline
T Cycle theme
s Cycle sort mode
/ Focus filter
[ Collapse all groups
] Expand all groups
Esc Close overlay

In focus mode the action row is [a] Approve [x] Flag [j] Skip [z] Undo [R] Revert [e] Open in editor; Esc returns to the workbench. The New (n) header button filters fresh hunks.

Change digests and the summary stack

Every hunk carries a factual digest computed deterministically in core. Understanding arrives in a labeled stack:

  • auto: deterministic digest (headline and details), always present.
  • agent: when provenance matches, the Intent block shows what was asked and the agent reasoning excerpt.
  • AI: with --ai, an optional second headline line labeled AI · <provider>.

Sift describes, never judges. It informs the decision; you make it.

Flag reasons and editor jump

Quick-flag reasons default to Needs tests, Security concern, Doesn't match intent, and Unnecessary change. Override them in .sift/config.json:

{ "flagReasons": ["Needs tests", "Perf risk", "Out of scope"] }

Set a known editor ID or a safe argument template in that same file:

{ "editor": "code" }
{ "editor": "subl %f:%l" }

Sift resolves the selected hunk server-side and launches only the configured editor (or detected code/cursor) through execFile with an argument array. It never opens a shell or executes anything from the reviewed repository.

Rules, coverage, provenance, and MCP

Rules load from ~/.sift/rules.yml and then <repo>/.sift/rules.yml, with repo rules winning. See docs/RULES.md.

Sift never executes repository tests, scripts, or configs. It only parses LCOV and Cobertura artifacts you already produced; pass --coverage <path> when autodetection is not right.

sift hooks install merges a Claude Code PostToolUse hook into settings and writes compact provenance metadata to ~/.sift/provenance.jsonl. On Windows, the default settings file is %USERPROFILE%\.claude\settings.json; use sift hooks install --project for repo-local settings. See docs/PROVENANCE.md.

sift mcp serves read-only stdio tools and refreshes mid-session when the worktree fingerprint changes, so the flag→agent→fix loop works without restarting the server. It has no write tools and accepts only IDs/enums as inputs. See docs/MCP.md.

Optional AI

--ai, --ai=cross, --ai=same, --ai=both, --ai=anthropic, or --ai=openai adds annotation-only summaries for high and medium risk hunks. Secret-like hunks are excluded from provider payloads. AI output never changes score, category, order, grouping, or status.

Security and privacy

  • Offline-first by default; no telemetry or analytics.
  • Sift never runs reviewed repository code.
  • Git access is read-only except an explicitly confirmed file revert. Revert is limited to WORKTREE/STAGED, snapshots the current bytes in Git first, and never stages, commits, pushes, or bulk-reverts.
  • The web server binds 127.0.0.1 only.
  • Web and grammar assets are bundled from disk; nothing is fetched at runtime.
  • Network is limited to localhost and explicit --ai provider calls.

Help

See docs/TROUBLESHOOTING.md for command-first fixes for Git, gh, coverage, ports, watch mode, editors, Windows PATH, and bundled assets.

License

Apache-2.0. See LICENSE and NOTICE.

About

Local-first review cockpit for AI-generated diffs — deterministic triage, provenance, and verification.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages