Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e4ded51
Add internal code mode module for programmatic notebook control
manzt Mar 11, 2026
7371d28
Clean up code mode internals
manzt Mar 12, 2026
7d2fb39
Guard control loop against unhandled exceptions
manzt Mar 11, 2026
670cfc2
Guard code mode context helpers against unhandled exceptions
pre-commit-ci[bot] Mar 12, 2026
aa8f6cf
Hoist imports
manzt Mar 12, 2026
192ed07
Batch code notifications and include cell configs
manzt Mar 12, 2026
bf9aa15
Support cell lookup by ID and name in CellsView
manzt Mar 12, 2026
fc19503
Flatten code mode API to async context manager with batched ops
pre-commit-ci[bot] Mar 12, 2026
3f487e2
Add install_packages to code mode context
manzt Mar 13, 2026
20883bb
Extract plan internals from _context.py into _plan.py
manzt Mar 13, 2026
653f861
Queue install_packages and suppress missing-package alerts
manzt Mar 13, 2026
6b3c913
Raise RuntimeError when code_mode ctx used outside async with
manzt Mar 13, 2026
ff3ea2c
Rename `add_cell` to `create_cell`
manzt Mar 13, 2026
df30900
Suppress missing-package alert for headless requests
manzt Mar 13, 2026
8c36db3
Add dry-run compile check and queue-based set_ui_value
manzt Mar 13, 2026
f56b728
Preserve existing cell config on update_cell code changes
manzt Mar 13, 2026
8c7f7e9
Add docstrings with examples to code mode context API
manzt Mar 13, 2026
d74ba86
Fix state cleanup in code mode cell deletion and updates
manzt Mar 13, 2026
5777732
Delegate code mode graph mutations to mutate_graph
manzt Mar 13, 2026
c90916d
Restore cell ordering after mutate_graph
manzt Mar 13, 2026
e106ca5
Fix cell reordering and state propagation in code mode
pre-commit-ci[bot] Mar 13, 2026
0ed7fdd
Fix compile check for delete+create and rename update_cell to edit_cell
manzt Mar 13, 2026
a3ce2c3
Print operation summary on code_mode context exit
manzt Mar 14, 2026
c9ca784
fix: expose .buffer on ThreadSafeStdout/Stderr for package installation
manzt Mar 14, 2026
df6f33f
Auto-instantiate notebook on /api/execute
manzt Mar 14, 2026
d417caf
Add cell naming and setup cell migration to code_mode
manzt Mar 15, 2026
4f9e1e7
Resolve pending cell names in _resolve_target
manzt Mar 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions marimo/_code_mode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2026 Marimo. All rights reserved.
"""Code mode: programmatic notebook editing via async context manager.
.. warning::
**Internal, agent-only API.** Not part of marimo's public API.
No versioning guarantees. May change or be removed without notice.
Usage::
import marimo._code_mode as cm
async with cm.get_context() as ctx:
# Create cells (appends at end by default)
cid = ctx.create_cell("x = 1")
ctx.create_cell("y = x + 1", after=cid)
# Update cells by ID or name
ctx.edit_cell("my_cell", code="z = 42")
# Delete cells
ctx.delete_cell("old_cell")
# Move cells
ctx.move_cell("my_cell", after="other_cell")
# Read cells (works outside the context manager too)
ctx = cm.get_context()
ctx.cells[0] # by index
ctx.cells["my_cell"] # by name
"""

from __future__ import annotations

from marimo._code_mode._context import (
AsyncCodeModeContext,
NotebookCellData,
get_context,
)

__all__ = [
"AsyncCodeModeContext",
"NotebookCellData",
"get_context",
]
Loading
Loading