WORK-051
ID:WORK-051Status:in-progress

Editor Package Awareness

Priority:highComplexity:complexMilestone:v1.0.0Source:SPEC-001

Summary

The editor (packages/editor/) only sees core runes. It doesn't load community or official packages from refrakt.config.json, so package runes don't appear in the palette, fail to parse in preview, and can't be edited. This gap existed before the official packages breakout but is now critical — official @refrakt-md/* runes like hero, character, and api are invisible to the editor.

The SvelteKit plugin (packages/sveltekit/src/plugin.ts) and CLI inspect command already load packages via loadRunePackage() + mergePackages(). The editor needs the same treatment.

Acceptance Criteria

  • Editor loads packages from refrakt.config.json on startup using loadRunePackage() + mergePackages()
  • Package runes appear in the rune palette (/api/runes endpoint)
  • Package runes parse and render correctly in the preview panel
  • Rune palette groups package runes by package name (using RunePackage.displayName)
  • CHILD_RUNES set is derived from rune schemas rather than hardcoded
  • RUNE_CATEGORIES map uses package displayName for package runes instead of hardcoded categories
  • Package RuneConfig entries are included in the theme config sent to the client for preview rendering
  • Package postTransform hooks survive the server→client serialisation boundary

Approach

  1. Pass RefraktConfig (or config.packages) through to startEditor() via EditorOptions
  2. Call loadRunePackage() + mergePackages() in packages/editor/src/server.ts on startup
  3. Feed merged tags into Markdoc.transform() in packages/editor/src/preview.ts
  4. Feed merged rune metadata into the /api/runes response
  5. Feed merged RuneConfig entries into the themeConfig sent to the client
  6. Replace hardcoded CHILD_RUNES with schema-derived detection (runes with a parent tag are children)
  7. Replace hardcoded RUNE_CATEGORIES with dynamic grouping: core runes keep functional categories, package runes use RunePackage.displayName

References

History

  1. 59ded4a
    Content edited
  2. f262d7b
    source+SPEC-001
  3. 2637549
    milestonev0.9.0v1.0.0
  4. a129a9e
    milestone+v0.9.0
  5. a333007
    statusreadyin-progress
    • ☑ Editor loads packages from `refrakt.config.json` on startup using `loadRunePackage()` + `mergePackages()`
    • ☑ Package runes appear in the rune palette (`/api/runes` endpoint)
    • ☑ Package runes parse and render correctly in the preview panel
  6. 2f24c14
    Created (ready, high, complex, editor, packages)