A post-prompt receipt for AI coding agents that compares the prompt you typed against the
git diffthe agent handed back—deterministically flagging every diff hunk as either Mentioned in your prompt or Not mentioned in your prompt, explaining the impact of unrequested edits, and generating a 1-click restore prompt.
When using modern AI coding agents (Claude Code, OpenCode, Cursor, Copilot, Codex), asking for a simple edit ("Change the submit button color to blue") often results in silent collateral damage (e.g., an email validation routine 15 lines above gets deleted).
DiffStory solves this with a verifiable deterministic + bounded LLM hybrid architecture:
- 100% Deterministic Token Matcher: A pure JavaScript token intersection engine compares your prompt against mutated lines in each hunk. It splits
camelCase, filters syntax/JSX boilerplate, and deterministically sorts unmentioned warning hunks to the top. Zero hallucinations in classification. - Bounded Live AI Receipt: Gemini (
gemini-3.5-flash-lite) is queried strictly for unmentioned hunks to generate a 1-sentence impact statement and a 1-click copyable restore prompt.
npm installCreate a .env file or export your Gemini API key:
cp .env.example .env
# Edit .env and supply your VITE_GEMINI_API_KEYnpm run devOpen http://localhost:3001 in your browser.
npm testRuns both the deterministic engine test suite and the live model integration test.
- Trigger & UI State:
src/App.jsx- Captures user prompt & unified diff.
- Instantly renders sorted receipt cards using the deterministic engine.
- Dispatches async Gemini requests for unmentioned hunks.
- Deterministic Token Engine:
src/lib/receiptEngine.js- Splits unified diff on
@@ -X,Y +A,B @@. - Isolates mutated lines (
+and-). - Computes intersection between prompt tokens and hunk tokens.
- Generates literal token receipts (e.g., "Your prompt mentions 'submit', 'button', 'color', 'blue'. Nothing in your prompt mentions 'email', 'includes', 'set', 'error'.").
- Splits unified diff on
- Bounded Live Model:
src/lib/liveModel.js- Queries Gemini with strict JSON schema:
{ impactSummary, restorePrompt }. - Never fakes or silently mocks output on failure.
- Queries Gemini with strict JSON schema:
MIT License — see LICENSE for details.