[Feature] Jupyter notebook (.ipynb) aware read and edit tools
Description
Add Jupyter notebook support to the file tools. Reading an .ipynb today returns the raw JSON (cell metadata, execution counts, base64 image outputs and all), and editing it with string_replace or write_file works on that JSON text, which is easy to corrupt. A search of source/ for ipynb or notebook handling finds nothing.
Use Case
Data and ML work happens in notebooks. A model asked to "fix the plotting cell" or "add a train/test split" has to wade through hundreds of lines of JSON and base64 output, wastes context, and often produces a notebook that no longer opens because a quote, comma or cell id was broken.
Proposed Solution
read_fileon an.ipynbreturns a compact per-cell view: cell index, type, source, and a short text-only summary of outputs (images and long outputs elided with a size note).- A dedicated
edit_notebooktool (or notebook-aware mode instring_replace) with operations to replace a cell's source, insert a cell at an index, delete a cell, and change a cell type, which rewrites the JSON through a parser and keeps untouched cells byte-identical, including metadata and outputs. - Plain
write_fileandstring_replaceon a notebook are rejected with a message pointing at the notebook tool, in the same way the project already guards PDF and DOCX files. - The edit preview shows the changed cells rather than a JSON diff.
Alternatives Considered
- Convert to a script with an external tool, edit, convert back. Loses outputs and metadata and needs extra tools installed.
- Tell users to avoid notebooks with the agent. Excludes a large group of users.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
The notebook format is plain JSON (nbformat 4), so no new dependency is required. Checkpoints and the read tracker already treat files as opaque content, so they keep working unchanged.
Please assign this to me, Thankyou
@akramcodez Can I try this one
Hi @Sravan1011, thanks so much for your interest in this issue! @puri-adityakumar asked to be assigned first, so I'm assigning it to them. In the meantime, please feel free to look through the other open issues. We'd love to have your help! 🙌