Skip to content

[v0.3] Add command registry and M-x #46

Description

@owainlewis

Goal: Add a small command registry and M-x so Cortex has one discoverable command path instead of growing ad hoc command entry points.

Context: The PRD says every action should resolve to a named command and that the command registry should power M-x and key remapping later.
The current slash command surface is useful, but it is not the long-term Emacs-shaped command surface.
This should land after the minibuffer foundation in #28.

Proposed approach:

  • Introduce a static command registry with stable command names, descriptions, and dispatch targets.
  • Route existing keybound commands and slash commands through the same registry where this keeps the code smaller.
  • Add M-x on top of the minibuffer.
  • Show command names in a plain completion or filtered list only if that is cheap with the current minibuffer.
  • Preserve the existing slash commands until they can be removed or folded in deliberately.

Acceptance criteria:

  • Every existing editor action has one stable command name.
  • M-x opens a minibuffer prompt for commands.
  • Submitting a known command dispatches the same behavior as its keybinding or slash command.
  • Unknown command input reports a clear error without editing the buffer.
  • Existing keybindings, slash commands, save, quit, picker, and search behavior still work.
  • The command registry is small, static, and easy to inspect in tests.

Verification:

  • Run cargo test.
  • Manually run at least save, quit cancel, open file, undo, and search through M-x where available.
  • Manually confirm normal editing resumes after cancel and after unknown command input.
  • Manually confirm the shell is usable after exit.

Out of scope:

  • User remapping.
  • Fuzzy command completion unless the minibuffer already makes it cheap.
  • Scripting.
  • Plugin hooks.
  • Command history.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions