-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Expose the macro registry for external tooling (LSP servers, linters, CLI checkers) so they can enumerate all registered macros and their metadata without relying on hardcoded definitions or config files.
Motivation
We're building a standalone Spindle LSP server (@rohal12/spindle-lsp) that provides diagnostics, completions, hover, and other IDE features for any editor (VS Code, Neovim, Claude Code, etc.).
Currently, the macro registry in registry.ts is a private Map with only getMacro(name) and isSubMacro(name) exposed. There's no way to:
- Enumerate all registered macros (built-in + custom)
- Retrieve macro metadata (block status, sub-macros, parameter definitions, storeVar flag)
- Distinguish built-in macros from user-defined ones
This forces tooling to maintain a separate hardcoded macro list (macros.json) that can drift out of sync with the engine.
Proposed API
// New export from Spindle
interface MacroMetadata {
name: string;
block: boolean;
subMacros: string[];
storeVar?: boolean;
interpolate?: boolean;
merged?: boolean;
source: 'builtin' | 'user'; // distinguish origin
description?: string; // optional doc string for tooling
parameters?: ParameterDef[]; // optional typed parameter schema
}
// On Story API
Story.getMacroRegistry(): MacroMetadata[]
// Or as a standalone export for headless/Node.js use
import { getMacroRegistry } from '@rohal12/spindle/tooling';Implementation Notes
- Preserve metadata from
defineMacro()config in the registry (currentlyinterpolate,merged,storeVarare used during setup but not stored) - Add an optional
descriptionandparametersfield toMacroDefinitionso macro authors can provide tooling hints - Export a
toolingentry point that doesn't require browser DOM, so the LSP can import it in Node.js - Consider a
--dump-macrosCLI flag on the compile script that outputs the registry as JSON
Use Cases
- LSP server - Auto-discover all macros for diagnostics, completions, hover docs
- CLI checker (
spindle-lsp check) - Validate macro usage without a config file - Documentation generation - Auto-generate macro reference from registry metadata
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request