@promptsnap/sdk
v0.2.0
Published
Semantic snapshot testing for LLM apps — checkpoint() API.
Readme
@promptsnap/sdk
Semantic snapshot testing for LLM apps. Wrap any LLM call with checkpoint() to capture its output, commit the snapshot to your repo, and get a PR comment describing exactly what changed.
Install
npm add -D @promptsnap/sdk @promptsnap/cliQuick start
import { checkpoint } from '@promptsnap/sdk';
import OpenAI from 'openai';
const openai = new OpenAI();
export async function answerQuestion(question: string) {
return checkpoint('qa/answer', async () => {
const r = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: question }],
temperature: 0,
});
return r.choices[0]?.message?.content ?? '';
}, { input: { question } });
}Vitest — add one line to vitest.config.ts:
test: { setupFiles: ['@promptsnap/sdk/vitest'] }Jest — add to jest.config.ts:
setupFilesAfterEnv: ['@promptsnap/sdk/jest']Capture baselines
PROMPTSNAP_MODE=record npx vitest run
git add __llm_snapshots__ && git commit -m "chore: baselines"Exports
| Path | Contents |
|---|---|
| @promptsnap/sdk | checkpoint(), determinism helpers, runtime mode |
| @promptsnap/sdk/vitest | Vitest afterEach integration |
| @promptsnap/sdk/jest | Jest afterEach integration |
| @promptsnap/sdk/internal | Storage helpers (used by CLI) |
