Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
122 changes: 122 additions & 0 deletions .agents/scripts/prepare-marimo-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
set -euo pipefail

usage() {
echo "usage: $0 notebook.ipynb --name example-name [--force] [--fail-on-check]" >&2
}

script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd -- "$script_dir/../.." && pwd)"

input="${1:-}"
if [[ -z "$input" || "$input" == "-h" || "$input" == "--help" ]]; then
usage
if [[ -z "$input" ]]; then
exit 1
fi
exit 0
fi
shift

name=""
force=0
fail_on_check=0
while (($#)); do
case "$1" in
--name)
shift
(($#)) || {
echo "missing value for --name" >&2
exit 1
}
name="$1"
;;
--force)
force=1
;;
--fail-on-check)
fail_on_check=1
;;
*)
echo "unknown argument: $1" >&2
exit 1
;;
esac
shift
done

[[ -n "$name" ]] || {
usage
exit 1
}

[[ "$input" == *.ipynb ]] || {
echo "input must be a .ipynb file: $input" >&2
exit 1
}

[[ -f "$input" ]] || {
echo "input file does not exist: $input" >&2
exit 1
}

input_dir="$(cd -- "$(dirname -- "$input")" && pwd)"
input="$input_dir/$(basename -- "$input")"

slug="$name"
[[ "$slug" =~ ^[A-Za-z0-9][A-Za-z0-9_-]*$ ]] || {
echo "--name must be a slug like 'mnist-registry' or 'mnist_registry' (no paths, dots, or spaces): $slug" >&2
exit 1
}

module_name="${slug//-/_}"
target_dir="examples/marimo/$slug"
target_py="$target_dir/$module_name.py"
Comment on lines +72 to +74
debug_dir="$target_dir/.conversion"
report="$debug_dir/conversion-report.md"
check_output="$debug_dir/marimo-check.txt"

cd "$repo_root"
if [[ -e "$target_py" && "$force" -eq 0 ]]; then
echo "target notebook already exists: $target_py" >&2
echo "pass --force to overwrite it" >&2
exit 1
fi
mkdir -p "$target_dir" "$debug_dir"

uvx marimo convert "$input" -o "$target_py"

check_status=0
uvx marimo check "$target_py" > "$check_output" 2>&1 || check_status=$?

cat > "$report" <<EOF
# Conversion Report

Source notebook: \`$input\`
Generated notebook: \`$target_py\`

## Processing

- Created target directory: \`$target_dir\`
- Created temporary debug directory: \`$debug_dir\`
- Ran: \`uvx marimo convert "$input" -o "$target_py"\`
- Ran: \`uvx marimo check "$target_py"\`

## Check Result

Exit code: \`$check_status\`

See \`.conversion/marimo-check.txt\`.

## Next Agent Step

Polish \`$target_py\` into an idiomatic repo-ready marimo example.
EOF

if ((check_status)); then
echo "marimo check reported issues; see $check_output" >&2
fi

if ((fail_on_check)); then
exit "$check_status"
fi
21 changes: 6 additions & 15 deletions .agents/skills/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ plus optional `references/` files.

| Skill | Purpose |
| --- | --- |
| [`marimo-example-notebook`](marimo-example-notebook/SKILL.md) | **Start here** for creating or refactoring example notebooks in this repo. Encodes wandb/examples conventions and best practices. |
| [`marimo-notebook`](marimo-notebook/SKILL.md) | General marimo notebook format and mechanics (vendored). |
| [`jupyter-to-marimo`](jupyter-to-marimo/SKILL.md) | Converting existing Jupyter notebooks to marimo (vendored). |
| [`marimo-wandb-notebooks`](marimo-wandb-notebooks/SKILL.md) | **Start here** for creating or refactoring example notebooks in this repo. Encodes wandb/examples conventions and best practices. |

## Vendored skills
## Scripts

`marimo-notebook` and `jupyter-to-marimo` are vendored verbatim from
[marimo-team/skills](https://github.com/marimo-team/skills) (Apache-2.0,
LICENSE included in each directory) so agents can use them without
network access.

- Upstream commit: `62d78d97278e0517c2270a8fbafd3f95a59df9cd`
- Vendored: 2026-07-20

To refresh, re-copy `marimo-notebook/` and `jupyter-to-marimo/`
from upstream and update the commit SHA above. Do not edit vendored files
in place — repo-specific guidance belongs in `marimo-example-notebook`.
Use [`../scripts/prepare-marimo-example.sh`](../scripts/prepare-marimo-example.sh)
to create the initial marimo notebook from a Jupyter `.ipynb`, capture
`marimo check` output, and write a temporary `.conversion/` report directory
for the polishing pass.
201 changes: 0 additions & 201 deletions .agents/skills/jupyter-to-marimo/LICENSE

This file was deleted.

42 changes: 0 additions & 42 deletions .agents/skills/jupyter-to-marimo/SKILL.md

This file was deleted.

Loading