Skip to content
Logo

Output & save hooks

Output routing

Set output on the command (or override from a TypeScript MacroResult):

RoutingEffect
discardIgnore stdout for the buffer
replaceSelectionReplace selection
replaceDocumentReplace whole document
replaceInputReplace whatever was used as input
insertTextInsert at cursor
insertSnippetInsert as snippet
newDocumentOpen a scratch tab
showAsTooltipTooltip
copyToClipboardClipboard
showAsToastToast

showAsHTML was removed. Use newDocument with language + optional openInPreview (HTML preview is a sandboxed iframe).

newDocument language & preview

Scratch tabs need a highlighter. Set language on the command (extension / lang id: diff, json, ts, md, html, svg, …) or return it from a TypeScript macro:

return { text, output: Output.newDocument, language: 'diff' }

Runtime language wins over the manifest. Default is txt (plain).

Set openInPreview = true (manifest) or openInPreview: true (macro result) to open the scratch on the Preview chip when the language supports it (html, htm, md / markdown / mdx, svg, mmd / mermaid). Otherwise it opens on Code. Macro result wins over the manifest.

recur bundles lint errors if the manifest sets openInPreview without output = "newDocument" or with a non-previewable language.

willSave

triggers = ["willSave"] (often with formatters) runs before WriteFile under a ~15s overall budget (each command timeoutMs ≤ 12s).

On failure/timeout, empty stdout, or shrinking the document by more than ~90% (when the original is >100 chars), Recur writes the original document and shows a toast. The transform is discarded.

Shipped examples: JSON Format on Save; Go / Rust / Python / JavaScript / Shell formatters (pass through if the tool is missing from PATH).