WORK-413
Setting up your dashboard 0 entities found · 8/31 branches scanned
ID:WORK-413Status:done

AI write mode draws fixtures as few-shot exemplars

ai/src/modes/write.ts hardcodes an "Example structure" in its prompt. Replace it with the unified fixtures — drawing each rune's rich/canonical fixture (with its notes) as in-context few-shot exemplars. No training pipeline; retrieval into the prompt only.

Priority:mediumComplexity:moderateMilestone:v0.22.0Source:SPEC-102

Criteria completion

Criteria completion: 2 of 2 (100%) checked; history from Jun 12 to Jun 130%25%50%75%100%Jun 12Jun 13
Branches 2
History 3
  1. ef7d397
    • ☑ The write mode selects fixtures by `role` (rich/canonical) and includes them (+ `notes`) as few-shot examples instead of the hardcoded prompt example.
    • ☑ No fine-tuning / training pipeline is introduced.
    by bjornolofandersson
  2. 320213c
    Created (pending)by bjornolofandersson
  3. 09b3a2e
    Content editedby Claude
    plan: accept SPEC-102 and break it into work items (WORK-411–415)

Acceptance Criteria

  • The write mode selects fixtures by role (rich/canonical) and includes them (+ notes) as few-shot examples instead of the hardcoded prompt example.
  • No fine-tuning / training pipeline is introduced.

Dependencies

  • Requires WORK-411 (manifest) and WORK-412 (annotated corpus).

References

  • SPEC-102 · packages/ai/src/modes/write.ts.

Resolution

Completed: 2026-06-13

Branch: claude/work-413-ai-fixture-fewshot (stacked on the WORK-414 fixture work).

What was done

  • Extended packages/runes/scripts/generate-examples.mjs to also emit RUNE_FIXTURE_META (role + notes per fixture, only when explicitly set) alongside RUNE_EXAMPLES, parsing frontmatter with yaml. Exported RUNE_FIXTURE_META + RuneFixtureMeta from @refrakt-md/runes. (Fixtures aren't shipped in the published package, so the curation metadata is baked into the bundle at build time — runtime fixture reading wouldn't work for consumers.)
  • Rewrote packages/ai/src/modes/write.ts: new exemplarSection() selects fixtures whose frontmatter explicitly tags role: canonical|rich, renders each as a fenced Markdoc block prefixed by its notes, under a "## Example patterns" heading. The hardcoded fake-hero "Example structure" snippet is removed; the multi-file path keeps only the FILE-marker format skeleton and points at the exemplars. Exemplars appear in both single- and multi-file modes.
  • Tests in packages/ai/test/modes/write.test.ts assert role-based selection (includes section/card, excludes bare chart), notes surfacing (badge), fenced-block rendering, and that the old # Welcome stub is gone.

Selection decision

An explicit role is the opt-in signal — the parser leaves role undefined for bare fixtures, so only authored exemplars qualify. Today that's 11 curated core fixtures (annotate, badge, bar, card, deflist, drawer, gallery, juxtapose, progress, reveal, section); the set grows automatically as the corpus is annotated. This keeps the few-shot block lean and intentional rather than dumping all ~92 examples (the rune vocabulary already lists every rune's example via describeRune).

Notes

  • No training/fine-tuning — pure prompt-time retrieval (AC #2).
  • 208 tests pass across ai + cli; the examples drift test covers the new generated export.