原始内容
pi-emacs-which-key
Emacs-style editing and prefix-key discoverability for Pi's interactive editor.
Features
C-guniversal cancel / keyboard-quit for this editor extension.C-x,C-c,C-h, andM-xprefix maps.- Native Pi TUI which-key panel using
Container,Text, andDynamicBorder. - Emacs movement/editing keys such as
C-n,C-p,C-a,C-e,M-f,M-b,C-k,C-y,M-y.
Key map
C-x b→/resumeC-x k→/newC-x t→/treeC-x f→/forkC-x s→/sessionC-x m→/modelC-x p→/scoped-modelsC-x o→ toggle tool outputC-x C-e→ external editorC-x C-c→ quit PiC-c /→ open Pi slash command completionC-c <letter>→ extension/package command submenu (letters are assigned from meaningful extension/package names)C-c r→/reloadC-h b→/hotkeysC-h k→ describe next keyC-h m→ extension statusM-x→ open Pi slash-command completion
Install
pi install npm:pi-emacs-which-key
Then in Pi:
/reload
Development install
pi install /path/to/pi-emacs-which-key
Or run for one session without installing:
pi -e /path/to/pi-emacs-which-key/extensions/emacs-which-key.ts
Hierarchical C-c menus
C-c keeps Pi utility entries at the top level and groups extension commands by their owning extension/package:
C-c / native Pi slash-command completion
C-c r reload Pi resources (/reload)
C-c ? show the top-level C-c menu
C-c c pi-crew extension commands, for example
C-c p pi-permission-system extension commands, for example
Group letters are assigned in this order: explicit environment overrides, curated known package keys, then meaningful extension/package name fallback. If a letter is already used, emacs-which-key tries the next meaningful letter before falling back to the alphabet. Inside a group submenu, q goes back to the top-level C-c menu and / opens native slash completion.
Set PI_EMACS_WHICH_KEY_C_C_GROUP_KEYS to pin group keys. Use comma- or semicolon-separated owner=key entries, where owner is a group label such as pi-crew or an owner id such as package:npm:@scope/pkg@1.0.0; key must be one lowercase letter or digit. Example:
PI_EMACS_WHICH_KEY_C_C_GROUP_KEYS="pi-crew=c,alpha-package=a" pi
Optional selector keybindings
The extension handles C-n / C-p in Pi's editor and slash-command completion. For Pi's other built-in selection dialogs such as /model and /resume, add this to ~/.pi/agent/keybindings.json if you want Emacs navigation there too:
{
"tui.select.up": ["up", "ctrl+p"],
"tui.select.down": ["down", "ctrl+n"]
}
Then run /reload.
Notes
This package uses Pi extension APIs and native Pi TUI components. It is intentionally editor-local: it does not overwrite your global keybindings.json.