An open source design system that's fully customizable and agent ready
Prompt Purity Vibe Test
Status: implemented (harness); iterating on variants
Related: ../cli-discovery-test/PLAN.md (blueprint), ../src/universal-eval.ts (reused detectors), packages/cli/src/commands/agent-docs.mjs (the prompt under test)
1. The question
Agents are already decent at using Astryx — but on hard tasks they veer into raw
CSS / Tailwind / inline styles / hardcoded values instead of Astryx components +
xstyle/tokens. We want to change the injected init prompt so the agent
self-verifies its output and catches itself before finishing.
Does adding a post-generation self-check to the
astryx initprompt make agents reliably (a) not leave raw CSS/Tailwind in the final file, and (b) when they do start to veer, catch and correct it — measured from the actual run trajectory?
2. What varies (independent variable)
The text that astryx init --features agents splices between <!-- ASTRYX:START -->
markers, generated by generateCompressedIndex() in
packages/cli/src/commands/agent-docs.mjs. We do not edit that source during
experimentation. Instead each condition = a real astryx init AGENTS.md + one
variant self-check block spliced inside the markers (variants/*.md,
conditions.json). Only the injected prompt varies; environment, prompts, and model
are held constant (Checker Protocol §2). The winning variant is baked into
generateCompressedIndex() only at the end.
3. What we measure (dependent variables)
Per run, from the purity timeline — the ordered snapshots of the output .tsx
captured live during the run (run-purity.ts via fs.watch + a poll fallback),
classified in purity-eval.ts:
neverVeered— no non-Astryx styling marker ever appeared. (best)caught— a marker appeared at some step but the final file is clean. (the self-check working: veered, then caught)veeredUncaught— a marker is still present at the end. (the bad outcome to minimize)finalPurity— 0–100 graded score of the final file.
Veer markers (see purity-eval.ts, tunable in one place): className=,
style={{…}}, .css import / @apply, Tailwind utility classes, hardcoded
#hex/rgb() colors (hard markers → drive the binary "veered"); hardcoded
px/rem, styled raw elements (soft markers → affect the score only).
Secondary signals: ranAstryxSelfCheck (did it run astryx search/component/docs
to verify — from the logging shim), and a transcript scan for "caught-in-reasoning"
(proposed CSS then reconsidered before writing).
4. Harness
setup-purity.mjs— builds one isolated project percondition × prompt × repunder an out-of-workspace sandbox (os.tmpdir()/astryx-purity/<expId>by default;--outto override). Bare base =@astryxdesign/core+ theme symlinked, a StyleX compiler plugin listed inpackage.jsonso the CLI detects thestylexstyling system (the Astryx path), a loggingastryxshim, then realastryx init+ the variant splice. Writestasks/<id>.json+purity-config-<expId>.json.run-purity.ts— runner. Shells out to thecursor-agentCLI headless (--print --output-format stream-json --model claude-opus-4-8-max-fast --force --trust --workspace <sandbox project>), snapshots the.tsxon every change, persists the streamed events totranscript.jsonl, records runtime facts torun.json. Bounded concurrency (--concurrency, default 3) + per-run timeout so it never starves interactive Cursor usage.purity-eval.ts— veer-marker detectors + timeline classifier (also reusesevaluate()from../src/universal-evalfor a supplementary graded score).purity-aggregate.ts— per-condition Wilson 95% CI rates + comparison vs control; writespurity-summary-<expId>.json.run-purity.mjs— one-command orchestrator (setup → run → aggregate); the unit/loopwould drive.smoke-test.ts— no-LLM verification of the classifier + setup wiring.
5. Isolation (never interferes with parallel Cursor work)
- All runtime artifacts live under an out-of-workspace sandbox (temp dir /
worktree), never in the open repo, so file-watchers, other Cursor agents, and
git statusare untouched. - Each agent runs with
cwd= its sandbox project andsettingSources: []; repo packages are only read via symlink.fs.watchwatches only the sandbox. - Uses the
cursor-agentCLI scoped to the sandbox via--workspace; bounded concurrency + per-run timeout keep interactive Cursor usage responsive. No separate API key needed — it uses your existingcursor-agentlogin.
6. Procedure
One prerequisite for LIVE runs (the no-LLM smoke test and --dry-run need nothing):
the cursor-agent CLI must be logged in.
cursor-agent status # should say "Logged in as ..."; if not: cursor-agent login
# no-LLM harness check (zero model calls) — always safe to run
npx tsx prompt-purity-test/smoke-test.ts
# one-shot: setup -> run -> aggregate (pilot default: dd-1, tc-6; A vs B; K=3)
node prompt-purity-test/run-purity.mjs --conditions A-control,B-selfcheck --prompts dd-1,tc-6 --reps 3
# or step by step
node prompt-purity-test/setup-purity.mjs --exp <id> --conditions A-control,B-selfcheck --prompts dd-1,tc-6 --reps 3
npx tsx prompt-purity-test/run-purity.ts --experiment <id> --concurrency 3
npx tsx prompt-purity-test/purity-aggregate.ts --experiment <id>
7. Decision rule
A variant wins when its veeredUncaught rate is significantly below control
(its upper Wilson bound clears control's lower bound) and/or caught | veered and
mean finalPurity are significantly higher, holding across the curated hard prompts
at K ≥ 5. Then bake it into generateCompressedIndex().
8. Checker Protocol compliance
- §2 only the SUT varies — one bare base, single-variant splice, identical prompts/env/model.
- §3 never leak the answer —
expectedComponentsis eval-only, never in the task prompt. - §4 representative environment — realistic "installed @astryxdesign/core" project.
- §5 context-free agents — fresh SDK agent per run,
settingSources: [], K independent reps.
9. Autonomous iteration (/loop)
Once the prereqs are in place, the whole search runs itself. In a live Cursor agent session:
/loop follow internal/vibe-tests/prompt-purity-test/ITERATE.md
Dynamic (self-paced) mode: it runs one iteration now, then wakes when each harness run
finishes (event-gated on the orchestrator's completion line) and runs the next. Per tick
it authors ONE new challenger variant aimed at the last run's failure mode, compares
control vs champion vs challenger cheaply (K=3 on dd-1,tc-6), promotes the best, then
confirms a leader at K>=5 on the full curated set. It is fully autonomous with NO
iteration cap — it stops only on a confirmed winner (then bakes the wording into
generateCompressedIndex() and updates the CLI test — Phase 4) or a genuine plateau.
Cross-tick memory lives in "$TMPDIR/astryx-purity/_loop/iterations-log.json"; all runs
stay in the tmpdir sandbox, so your parallel Cursor work is never touched. See
ITERATE.md for the full per-tick procedure and stop conditions.