The repo had nothing a visitor could run. Evaluating the library meant wiring a provider into your own app first, which is the wrong order — the behaviour has to be visible before anyone invests that. `examples/next` is a real job-posting form: prose fills it, follow-up instructions patch it. It runs with zero configuration because `complete` is caller-supplied, so the example ships a deterministic offline pattern matcher for the no-key case. That matcher is NOT a language model and the UI says so in plain words — it exists so the library's own contribution (merge intent, sanitizing, field discipline) is visible without a provider in the way. Set GROQ_API_KEY or OPENAI_API_KEY for real model behaviour. Verified end to end against the running example: - fill from one sentence -> 9 fields set, salary parsed as 130000-160000 - "make it principal" -> changed == ["seniority"], everything else survives - "set the posting id" -> postingId unchanged; it is aiExcluded - unknown target -> rejected before any model call Root package unaffected: 14/14 tests green. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
ai-forms — runnable example
A job-posting form you fill by describing it, then change by continuing to talk to it.
npm install
npm run dev # http://localhost:3000
No API key needed to try it. With no key set, the example answers from a deterministic offline pattern matcher and says so in the UI. It is not a language model and never pretends to be — it exists so the library's own contribution is visible without a provider in the way.
For real model behaviour, set either key and restart:
cp .env.example .env
# GROQ_API_KEY=... or OPENAI_API_KEY=...
What to try
- Press the suggested prompt to fill the empty form from one sentence.
- Then send "actually make it principal level".
Only seniority changes. Salary, skills, contact and start date all survive. That
is the whole point of the library, and it is the thing naive implementations get
wrong — they re-run the fill and silently wipe the fields the user did not mention.
Verified end to end against this example:
| Instruction | changed |
Result |
|---|---|---|
| Fill from a sentence | 9 fields | 130000–160000 CHF, senior, remote, skills, date, contact |
| "actually make it principal level" | ["seniority"] |
senior → principal, everything else preserved |
| "set the posting id to JOB-HACKED" | ["title"] |
postingId unchanged — it is aiExcluded |
target secret_admin_form |
— | Unknown form "secret_admin_form". |
How it is wired
| File | Role |
|---|---|
lib/form.ts |
The only declaration of what the form contains |
lib/complete.ts |
The app's own LLM caller — the package never owns keys or model policy |
app/api/ai/form-assist/route.ts |
One route serves every form; add a target, not an endpoint |
app/page.tsx |
Rendering. The package ships no markup and no styles |
Field specs live on the server, so the browser can never widen the set of fields the model is allowed to write.