Skip to content

Agent-first: every part of Rupok controllable by agents, custom and Smart stamps, a customisable dock - #27

Merged
shaitrish37 merged 4 commits into
mainfrom
feat/agent-control
Nov 24, 2026
Merged

shaitrish37 merged 4 commits into
mainfrom
feat/agent-control

Conversation

@shaitrish37

@shaitrish37 shaitrish37 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

The founder's ask: every part of Rupok controllable by an AI agent, and custom stamps made by the agent (look, behaviour, and even logic). Then two more: a fully customisable Smart Dock (by hand or "make my dock like this"), and making agent-first a permanent rule for contributors.

Agent control

  • docs/agent-capabilities.md: the capability matrix, before and after, for every feature area, every setting, every dock button and every live op. Teacher only rows carry the reason (security, physical input, account or payments).
  • New live ops in crates/rupok-live (items.rs, stamps.rs): pages (list, move, delete, duplicate, rename), items (select, move, align and distribute, restyle including fill and dash, scale, group, reorder, delete, draw strokes, edit text) and stamps. They run in apply on the board and on .rpk files with the same code. Each one is a single attributed undo step.
  • Board ops (apps/board/src/agentControl.ts): modes (leaving Student view is refused), zoom and fit, replay, celebrate, set tool, the agent's own undo, PDF export, the Library (list, open, create, move, rename, trash), settings (an allowlist in agentSettings.ts) and the dock. Settings and dock changes are undone from the AI chip.
  • 44 new MCP tools (crates/rupok-cli/src/mcp_agent.rs). Document tools take an optional path (omit it for the live board). export_pdf saves the PDF the board makes into the workspace. Secrets are refused by the server before anything reaches the board.
  • Guardrails are unchanged: Allow AI to edit live, Student view, permission prompts in the chat (settings and mode switches are prompted like edits), and agent code only in the Smart Object sandbox.

Custom stamps and Smart stamps

  • Definitions: name, keywords, and art as sanitised SVG (the page-design sanitiser), emoji or a label. Optional behaviour: animation, burst, counter, sound (honours a new Stamp sounds switch) and auto-fade.
  • Smart stamps: art: "smart" plus HTML. This is an ordinary validated Smart Object bundle with no network, placed like a stamp, and it runs only in the sandbox. Custom SVG is drawn only through an image, never inline.
  • Storage: per device in IndexedDB ("My stamps"), and inside each lesson that uses a stamp (root stamps map, plus the bundle, deduplicated), so a shared lesson shows it. Stamp packs (JSON) can be imported and exported.
  • UI:
    • The Stamps palette has a "My stamps" section, a "+" button and Make a stamp with AI… (opens /stamp).
    • The stamp editor sheet has a preview, name, artwork, colour, size, animation, burst, sound, fade and counter, plus favourite, reorder and delete. It works in light and dark, uses 44px targets and the mint accent.

Customisable dock

  • modes.ts DockConfig is extended additively: ordered groups, an optional split second dock, size, per-button sizes, large icons, per mode, plus named layouts (Left-handed, Minimal teaching, Maths class, Default, the teacher's own). The core tools always stay, and warnings appear when nothing leads back to Settings.
  • Customize dock editor:
    • Drag and drop between the tray and groups, keyboard pick-up (Enter, arrow keys, Delete), separators, position, split, sizes and reset.
    • Changes are live on the real dock.
    • Open it from the dock's ⋯ menu, by holding the grip, or from Settings → Teaching modes.
    • The UI config import and export includes the new keys and saved layouts.
  • Customize dock with AI… (/dock) in the ⋯ menu.

Agent-first, permanently

  • AGENTS.md rule 8 and CONTRIBUTING: new features ship with a live op, an MCP tool, docs, tests and a matrix row, and follow the guardrails.
  • PR template checkbox: "Agent-controllable".
  • crates/rupok-cli/tests/agent_capabilities.rs (runs in cargo test) fails when:
    • a settings registry entry, dock button or live op has no row in the matrix;
    • the matrix's set_setting rows differ from the board's allowlist.

Format

Additive, approved by the founder, proposed, pending RFC: the root stamps map (spec/rupok-format.md § Custom stamps) and Smart stamps (spec/smart-object.md). There is a ROADMAP row for this work. Core change: Edits.texts and Edits.stamp_defs (off the ink path).

How it was tested

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (all green).
  • Rust tests:
    • rupok-live/src/agent_ops_tests.rs (13 tests): every new write is one attributed undo step; validation; Student view; board ops refused by the document; stamp lifecycle; Smart stamp sandbox rules and dedup; device-library defs.
    • The wasm live engine: selection, restyle and undo, an untagged teacher placement, the editor check.
    • The MCP e2e on files; the fake ACP agent's /stamp flow in tests/chat.rs.
  • Wasm build (release-wasm) + wasm-bindgen; tsc --noEmit; vite build.
  • bench/latency/pen-latency.mjs --swiftshader --check: all budgets pass. On a machine with load average 23, earlier runs had one noisy "first frame of next stroke" result; it passed on the final run. The dock and stamps are outside the pen path.
  • cargo run -p rupok-bench --release (core touched): stroke commit p99 0.04 ms, pen → wet 0.11 ms, wet vs dry 0.00 %. The frame budgets failed only from machine load.
  • Board e2e (agent-control.mjs, real rupok mcp --live paired with Chrome): 40/40 pass. It covers:
    • an SVG stamp with sparkle and counter;
    • a Smart dice that rolls on tap, in a sandbox without allow-same-origin;
    • an unsafe SVG refused;
    • Teach mode, a restyled selection and the split left/right dock with groups;
    • settings (dark theme; a permission switch refused);
    • PDF export to the workspace and page reorder;
    • the teacher renames, makes and deletes stamps;
    • the teacher drags a button in the editor, keyboard move and reset;
    • stamps, My stamps and the Teach dock surviving save and reload.

Checklist

  • Tests added or updated, and they pass.
  • fmt and clippy clean; wasm builds.
  • Perf-sensitive? Core Edits gained two fields (not on the ink path). Bench and pen-latency were run; results are above.
  • Format change? Proposed, pending RFC, as the founder approved; spec updated.
  • Agent-controllable: yes, see docs/agent-capabilities.md.
  • Docs updated (ai-agents.md, skill, ui-config.md, ROADMAP).

Limitations

  • add_shape/add_table remain live-only (the engine owns shape geometry). restyle_items sets a shape's width without regenerating arrowheads; scale_items is uniform.
  • When a Smart stamp's HTML changes on several pages, that is one undo step per page (as with update_smart_object).
  • Picture insert, PDF import, stamp-pack import, fullscreen and the overlay stay teacher only: they need the teacher's files or a user gesture.
  • Settings and dock changes are undone from the AI chip, not Ctrl+Z, because they are not part of the lesson.
  • library_create_lesson with open: false briefly opens the new lesson and returns to the previous one.
  • Page thumbnails draw custom stamps as their fallback text.

Every part of the lesson an agent can change, as one attributed undo step,
on a lesson file and on the live board with the same code:

- pages: list_pages, move_pages, delete_pages, duplicate_pages, set_page_title
- items: select_items, move_items, align_items (align and distribute,
  groups move as one), restyle_items (colour, width, brush, fill, dash,
  opacity, text size), scale_items, group/ungroup, reorder_items,
  delete_items, draw_stroke, update_text
- stamps: list_stamps, add_stamp (built-in or custom), create_stamp,
  update_stamp, delete_stamp; custom stamps with sanitised SVG, emoji or a
  label, declarative behaviour, and Smart stamps (a tiny Smart Object
  bundle, validated, no network)
- board-app ops (modes, view, replay, export, library, settings, dock) are
  typed in Op and refused by the document

Core: Edits gains texts and stamp_defs; the lesson's root stamps map holds
custom stamp definitions (proposed, pending RFC).
mcp_agent.rs adds the agent-control tools: pages, items, stamps (file and
live, path optional), modes, zoom, replay, celebrate, set_tool,
undo_last_change, export_pdf (the board makes it, the server saves it in
the workspace), the Library, settings (allowlist; secrets refused before
they reach the board) and the Smart Dock (live). doc_op runs any document
op on a lesson file. Tests: MCP e2e on files, the fake ACP agent's /stamp
flow in the chat test, and agent_capabilities.rs, which fails CI when a
setting, dock button or live op has no row in docs/agent-capabilities.md.
- My stamps: the teacher's stamps in IndexedDB and in lessons that use
  them; a stamp editor (preview, name, artwork, colour, size, animation,
  burst, sound, fade, counter); stamp packs; Make a stamp with AI (/stamp).
  Custom SVG is drawn only as an image; Smart stamps run as sandboxed
  Smart Objects; behaviour plays on placement (sounds honour a new switch).
- Smart Dock: ordered groups, a split second dock, button sizes, large
  icons, per mode; named layouts (Left-handed, Minimal teaching, Maths
  class, the teacher's own); a Customize dock editor (drag, keyboard,
  reset), from the dock's menu, a long press on the grip or Settings;
  Customize dock with AI (/dock).
- agentControl.ts runs the board-app ops for agents (modes, view, replay,
  export, Library, settings allowlist, dock) with Undo from the AI chip.
AGENTS.md rule 8 and CONTRIBUTING: every user-facing feature ships with a
live op, an MCP tool, docs, tests and a row in docs/agent-capabilities.md,
with the guardrails. PR template checkbox. ai-agents.md and the skill gain
the full tool list, examples, a stamp design guide and the dock guide.
Spec: the root stamps map and Smart stamps (proposed, pending RFC);
ui-config.md documents dock groups, split, sizes and saved layouts.
@shaitrish37
shaitrish37 merged commit 659fec1 into main Nov 24, 2026
13 checks passed
shaitrish37 added a commit that referenced this pull request Nov 24, 2026
…ting

Joined with #26 and #27:
- show_progress and the AI in action, Class mode and students-ask settings
  get rows in docs/agent-capabilities.md; the four presentation settings
  (progress, sparkle, chime, line-by-line solutions) join the agent
  allowlist, Class mode and what students may ask stay the teacher's.
- MCP annotations: the annotations test covers the agent-control tools;
  every write tool from #26/#27 declares idempotentHint, destructiveHint is
  kept for real deletes (delete_items, delete_pages, delete_stamp,
  library_trash) and dropped from undo_last_change (it only takes back the
  agent's own step); library_list counts as a read.
- Class mode confirms the new destructive ops (delete_pages, delete_stamp,
  library_trash, dock layout changes) like the others.
- update_text fits new words or a new size inside the page like add_text
  (never spilling onto a new page), with a regression test.
- show_progress is a board-only op, like the voice ops.
- Clippy (all targets): slice::from_ref in a voice test.

# Conflicts:
#	AGENTS.md
#	apps/board/src/live.ts
#	crates/rupok-cli/src/lib.rs
#	crates/rupok-cli/src/mcp.rs
#	crates/rupok-cli/tests/fake-acp-agent.mjs
#	crates/rupok-live/src/op.rs
#	docs/ai-agents.md
@shaitrish37
shaitrish37 deleted the feat/agent-control branch November 24, 2026 10:16
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant