format()
format(
ast,options?):FormatterOutput
Defined in: formatters/src/standalone.ts:56
Format a PromptScript AST using a specified or default formatter.
This is a convenience function for one-off formatting without manually creating formatter instances. For repeated formatting operations, consider using the formatter classes directly for better performance.
Parameters
ast
The resolved PromptScript AST to format
options?
Format options including which formatter to use
Returns
The formatter output (path and content)
Throws
Error if the specified formatter is not found
Example
import { format } from '@promptscript/formatters';
// Use default formatter (GitHub)const output = format(ast);
// Specify formatter by nameconst claudeOutput = format(ast, { formatter: 'claude' });
// Use custom optionsconst cursorOutput = format(ast, { formatter: 'cursor', version: 'legacy',});