Index of every page on this site: llms.txt
All skills
domesticmouse avatar

/egui-command-engine

@606a5d5
Run it yourself

Use this skill when exploring, explaining, tracing, adding, or modifying commands in an engine-first egui application: understanding the three-tier command taxonomy (Engine CommandSpecs, Shell/Tool UI commands, and Automation transports), wiring egui menu items, implementing schema-driven dialogs, or writing panic_hunt fuzz tests.

  • 2 files
  • 10.2 KB
  • Updated 3 weeks ago
  • GitHub
Use this Skill: https://skilld.dev/gh/domesticmouse/skills/egui-command-engine

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈88 tokens for metadata: the name and description. ≈1.3k when used: this file. ≈1.2k more on demand in 1 file.

Description uses 4.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈354 characters, or 4.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Engine-First Command Architecture & UI Wiring

In an engine-first egui architecture, everything is a command. Menu items, toolbar actions, keyboard shortcuts, interactive canvas/viewport gestures, panel controls, and external automation all flow through a unified command architecture in crates/engine and crates/ui-egui.

Three-Tier Command Taxonomy

  1. Engine Commands (CommandSpec in crates/engine/src/commands.rs + <domain>_cmds.rs):
    • Dispatched via Session::execute(id, params) (synchronous) or Session::start(id, params) (background jobs in jobs.rs).
    • Includes state-mutating commands (journal: true, recorded in undo/redo History via Session::edit) and read-only queries (journal: false, e.g. session.inspect, document.inspect, command.list, job.status).
  2. Shell & Tool Commands (crates/engine/src/shell_commands.rs & crates/ui-egui/src/menus.rs):
    • Pure UI/window/view actions (SHELL_COMMANDS, re-exported as menus::UI_COMMANDS, e.g., view.zoomIn, window.toggle.*, window.theme.*) and toolbar tool-selection commands (TOOLS, tools.select.<tool>).
    • Declared in crates/engine/src/shell_commands.rs so headless sessions know every bindable shortcut ID for shortcut customization and conflict detection, and executed by crates/ui-egui/src/menus.rs::invoke.
    • menus::invoke also intercepts interactive menu clicks (e.g., file.new with empty params, or commands needing modal input) to open egui dialogs or file pickers before delegating to Session::execute.
  3. Transport & Automation Protocol Commands (crates/automation & crates/ui-egui/src/control.rs):
    • External drivers wrap the engine registry: CLI (<app>-cli commands / run), headless JSON-RPC (<app>-cli serve: engine.execute, engine.commands, doc.*), MCP server (command_list, command_run, command_batch, doc_inspect), and the live GUI TCP control channel (--control: command.run, command.list, ui.inspect, ui.screenshot, ui.pointer, ui.key, ui.menu.invoke).

Step-by-Step Checklist: Adding a Command

1. Define the Canonical Command ID

  • Register or look up the menu item in crates/ui-egui/src/menu_catalog.rs.
  • Using the exact ID from menu_catalog.rs automatically lights up the menu item in the egui menu bar without manual UI wiring.
  • For non-menu actions (e.g., interactive drag gestures or sub-commands), use a consistent dotted camelCase convention (e.g., node.transform.set) and an empty menu path &[].

2. Implement the Domain Logic in the Lowest Applicable Layer (L0–L2)

  • Place pure domain logic and data transformations in L0–L2 crates rather than inside ui-egui or command glue.
  • Keep domain logic pure and deterministic so it can be unit-tested without spinning up a full session or UI.

3. Register the CommandSpec in crates/engine

  • Create or update a focused command module crates/engine/src/<domain>_cmds.rs exposing pub fn specs() -> Vec<CommandSpec> and register it in crates/engine/src/commands.rs.
  • Populate every CommandSpec field (see command-and-control-patterns.md):
    • id, label, menu, shortcut
    • params: concise JSON schema doc string (e.g., '{"scale":f32=1.0,"mode":"a|b"="a"}'), read by agents and CLI tools via command_list. Add closed-schema commands to STRICT in crates/engine/src/param_check.rs so Session::execute rejects misspelled/unknown keys across all transports ("coalesce" and "target" are accepted universally).
    • enabled: fn(&Session) -> Result<(), String> returning a clear human/agent-readable disabled reason (shown in tooltips and returned by command_list).
    • run: fn(&mut Session, &Value) -> Result<Value> that validates parameters and records one undo step via Session::edit.
    • journal: true for state-mutating commands, false for read-only queries.

4. Validate Adversarial Input (Never Panic)

  • Validate all JSON parameters before allocating or indexing: reject negative sizes, NaN/inf, zero divisors, or out-of-range IDs with Err(EngineError::BadParams { .. }).
  • Never use unwrap(), expect(), or unchecked slice indexing [i].

5. Wire egui Dialogs and State (If Parameterized)

  • Parameterized commands can use schema-driven egui dialogs with live preview (crates/ui-egui/src/dialogs.rs).
  • All UI state must live in crates/ui-egui/src/state.rs (UiState, serializable via serde) and use design tokens from theme::Tokens rather than hard-coded pixel/color constants.

6. Write Comprehensive Tests

Run the verification suite before finishing (see egui-testing-infrastructure for panic_hunt, menu parity ratchets, and MCP acceptance testing):

cargo test -p <app>-engine --lib --tests
cargo test -p <app>-engine --test panic_hunt -- --ignored
cargo clippy -p <app>-engine -p <app>-ui-egui --all-targets -- -D warnings

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 606a5d5. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 weeks ago

README badge

README badge for domesticmouse/skills/egui-command-engine