Skip to content

smelt.notebook

Tier: UiHost — Requires a terminal UI; calling these from headless mode raises.

Parse, read, and apply notebook cell edits, plus compute preview data for the edit_notebook tool. UiHost-only.

smelt.notebook.apply_edit

fun(args: table): any?, string?

Apply a notebook edit (cell insert/replace/delete) described by args and persist the new file. Returns (message_table, nil) on success or (nil, err_msg) on failure. Callers are expected to hold the per-path advisory flock.

smelt.notebook.is_notebook_path

fun(path: string): boolean

Return true if path looks like a Jupyter notebook (.ipynb extension).

smelt.notebook.parse

fun(json: string): table?, string?

Parse a notebook JSON string. Returns (notebook, nil) with { nbformat, nbformat_minor, cells = { { kind, id?, source, execution_count? } } } on success, or (nil, error) on failure.

smelt.notebook.preview_data

fun(args: table): table?

Compute the preview payload for an edit_notebook call. Returns nil when the notebook can't be read/parsed or the target cell is out of range. The returned table has { edit_mode, path, title, old_source, new_source, syntax_ext }.

smelt.notebook.read

fun(path: string, offset: integer, limit: integer): string?, string?

Render a Jupyter notebook at path as cell-by-cell text starting at offset for at most limit cells. Returns (text, nil) on success or (nil, err_msg) on parse failure — same output the built-in read_file tool produces.