Skip to content

feat: add tooling API to expose macro registry metadata#105

Merged
rohal12 merged 10 commits intomainfrom
feat/tooling-api-macro-registry
Mar 22, 2026
Merged

feat: add tooling API to expose macro registry metadata#105
rohal12 merged 10 commits intomainfrom
feat/tooling-api-macro-registry

Conversation

@rohal12
Copy link
Owner

@rohal12 rohal12 commented Mar 22, 2026

Summary

Closes #102.

  • Story.getMacroRegistry() — runtime API returning metadata for all registered macros (built-in + user-defined): name, block status, sub-macros, feature flags, source origin, and optional description/parameters
  • @rohal12/spindle/tooling — lightweight Node.js entry point for LSP servers and linters. Exports a metadata-only defineMacro() shim (no Preact dependency) that captures macro metadata, pre-loaded with builtin metadata from a build-time JSON snapshot. LSPs can evaluate user defineMacro() calls against this shim to auto-discover custom macros.
  • description and parameters fields on MacroDefinition — optional tooling hints for hover docs, completions, and parameter info
  • block: true added to 11 builtin macro configs — makes defineMacro() config the single source of truth for block status (previously some relied on hardcoded BLOCK_MACROS set)
  • Build-time macro-registry.json — generated by scripts/dump-macro-registry.ts, consumed by the tooling entry point

Test plan

  • 16 new tests in test/unit/macro-registry.test.ts — metadata storage, retrieval, source tracking, builtin verification
  • 3 new tests in test/unit/story-api.test.tsgetMacroRegistry() availability, builtin metadata, user source marking
  • 6 new tests in test/unit/tooling-entry.test.ts — contract tests and file existence checks
  • Full suite passes (916 tests), typecheck clean
  • npm run build produces dist/pkg/macro-registry.json with all builtin metadata

🤖 Generated with Claude Code

clem and others added 10 commits March 22, 2026 20:54
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Release preview: merging this PR will publish v0.34.0 (minor bump from v0.33.0)

@rohal12 rohal12 enabled auto-merge March 22, 2026 13:13
@github-actions
Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.45% 2440 / 3071
🔵 Statements 78.48% 2670 / 3402
🔵 Functions 71.31% 440 / 617
🔵 Branches 74.12% 1341 / 1809
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/define-macro.ts 98.3% 93.75% 100% 98.14% 123
src/registry.ts 100% 100% 100% 100%
src/story-api.ts 9.25% 0% 16.12% 9.8% 117-232, 245-323, 350-355, 367-402
src/components/macros/Button.tsx 100% 66.66% 100% 100%
src/components/macros/Cycle.tsx 73.33% 61.53% 66.66% 78.57% 11, 27-30
src/components/macros/Do.tsx 85.71% 100% 100% 85.71% 13
src/components/macros/For.tsx 91.11% 82.35% 100% 90.24% 28, 39, 42-44, 104-108
src/components/macros/If.tsx 93.75% 100% 100% 93.75% 37-41
src/components/macros/MacroLink.tsx 85.18% 69.23% 80% 85.18% 30, 80-82
src/components/macros/Nobr.tsx 100% 100% 100% 100%
src/components/macros/Repeat.tsx 13.04% 0% 0% 16.66% 14-47
src/components/macros/Span.tsx 50% 0% 0% 50% 7
src/components/macros/Type.tsx 86.2% 83.33% 83.33% 92.3% 27, 32-33, 39
src/components/macros/Widget.tsx 100% 100% 100% 100%
Generated in workflow #173 for commit 19f36ce by the Vitest Coverage Report Action

@rohal12 rohal12 merged commit d512ee1 into main Mar 22, 2026
5 checks passed
@rohal12 rohal12 deleted the feat/tooling-api-macro-registry branch March 22, 2026 13:14
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.

Add tooling API to expose macro registry metadata

1 participant