Skip to content

Skill-as-markdown: polymorphic frontmatter field on MarkdownDef#5244

Draft
lukemelia wants to merge 3 commits into
mainfrom
cs-11545-skill-representation-markdowndef-polymorphic-frontmatter
Draft

Skill-as-markdown: polymorphic frontmatter field on MarkdownDef#5244
lukemelia wants to merge 3 commits into
mainfrom
cs-11545-skill-representation-markdowndef-polymorphic-frontmatter

Conversation

@lukemelia

Copy link
Copy Markdown
Contributor

Implements the realm representation for skills as markdown (CS-11545): a skill is not a distinct file type. Every .md stays a MarkdownDef; skill-ness is a polymorphic frontmatter field, not a SkillDef subclass.

Design + rationale: Linear CS-11545. De-risking spike: CS-11568.

What this does

  • MarkdownDef gains @field frontmatter = contains(FrontmatterField).
  • extractAttributes parses YAML frontmatter; a kind → FieldDef registry (kept above MarkdownDef) picks the concrete subclass — SkillField (name/description/commands) for kind: skill.
  • The concrete subclass is recorded via meta.fields.frontmatter.adoptsFrom and rehydrates as that type on read (field-level polymorphism).
  • Flat searchable kind/description are written to search_docsearchFiles({ filter: { eq: { kind: 'skill' } } }). (name isn't surfaced flat — it collides with the FileDef filename; it lives in frontmatter.name.)
  • Boxel discovers skills by frontmatter kind; Claude Code discovers them by the SKILL.md filename — independent, so one byte-for-byte file serves both.

Closes the spike's write-path gap

The FileDef write path was flat (buildFileResource emitted only top-level meta.adoptsFrom). extractAttributes now routes per-field meta via a global symbol; the file extractor lifts it into the resource's meta.fields (kept out of the flat search_doc) and buildFileResource threads it through. Additive — FileDefs that emit no field meta are unchanged.

Notable

  • CommandField extracted into its own module so SkillField reuses it without depending on the legacy Skill card (skill.gts re-exports for back-compat).
  • Adds yaml to @cardstack/base.

Validation

Draft: opened to let CI run the build / type-check / tests — these were not runnable locally (needs the full host test-services stack). The half the spike couldn't exercise live — whether meta.fields survives the index storage→read bridge — is what the round-trip test (markdown-skill-frontmatter-test.gts) is here to confirm under CI.

Not in this PR (remaining Phase B)

  • Host command-definition upload reading markdownDef.frontmatter.commands (spec §6).
  • migrate-skill command + chooser/search surfacing.

🤖 Generated with Claude Code

lukemelia and others added 3 commits June 15, 2026 19:16
Foundation for skill-as-markdown-frontmatter (CS-11545): every .md stays a
MarkdownDef and skill-ness is a polymorphic field, not a SkillDef subclass.

- Extract CommandField into its own module so SkillField can reuse it without
  depending on the legacy Skill card (skill.gts re-exports for back-compat).
- FrontmatterField (base) + SkillField (name/description/commands) subclass.
- frontmatter-kinds.ts: the kind -> FieldDef registry, kept above MarkdownDef.
- Add `yaml` dep to @cardstack/base for frontmatter parsing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… field

MarkdownDef now parses YAML frontmatter and, when `kind` maps to a known
frontmatter subclass (e.g. `kind: skill` -> SkillField), populates the nested
`frontmatter` field and records the concrete subclass so it rehydrates as that
type. Flat `kind`/`description` are also written for search.

Closes the FileDef write-path gap from the CS-11568 spike: extractAttributes
routes per-field meta via a global symbol; the file extractor lifts it into the
resource's `meta.fields` (keeping it out of the flat search_doc) and
buildFileResource threads it through. Additive — FileDefs that emit no field
meta are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Covers parseFrontmatter, MarkdownDef.extractAttributes (flat kind + nested
frontmatter + routed SkillField marker), the write->read round-trip rehydrating
frontmatter as SkillField with commands, and plain-markdown no-op.

Requires the host test-services stack / CI to run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   1h 34m 55s ⏱️
3 065 tests 2 976 ✅ 15 💤  1 ❌ 73 🔥
3 084 runs  2 922 ✅ 15 💤 74 ❌ 73 🔥

Results for commit e0c8611.

For more details on these errors, see this check.

Realm Server Test Results

    1 files      1 suites   10m 8s ⏱️
1 716 tests 1 709 ✅ 0 💤 7 ❌
1 809 runs  1 802 ✅ 0 💤 7 ❌

Results for commit e0c8611.

For more details on these errors, see this check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant