MCPcopy Create free account
hub / github.com/anomalyco/opencode / createCommandShim

Function createCommandShim

packages/tui/src/plugin/command-shim.ts:85–109  ·  view source on GitHub ↗
(
  keymap: TuiPluginApi["keymap"],
  dialog: CommandShimDialog,
  keybinds: LegacyKeybinds,
)

Source from the content-addressed store, hash-verified

83}
84
85export function createCommandShim(
86 keymap: TuiPluginApi["keymap"],
87 dialog: CommandShimDialog,
88 keybinds: LegacyKeybinds,
89): TuiPluginApi["command"] {
90 const shimDialog = createCommandShimDialog(dialog)
91 return {
92 register(cb) {
93 warnOnce("api.command.register", "api.keymap.registerLayer({ commands, bindings })", warnCommandShim)
94 const commands = cb()
95 return keymap.registerLayer({
96 commands: commands.map((item) => toCommand(item, shimDialog)),
97 bindings: toBindings(commands, keybinds),
98 })
99 },
100 trigger(value) {
101 warnOnce("api.command.trigger", "api.keymap.dispatchCommand(name)", warnCommandShim)
102 keymap.dispatchCommand(value)
103 },
104 show() {
105 warnOnce("api.command.show", `api.keymap.dispatchCommand("${COMMAND_PALETTE_SHOW}")`, warnCommandShim)
106 keymap.dispatchCommand(COMMAND_PALETTE_SHOW)
107 },
108 }
109}

Callers 2

createTuiApiAdaptersFunction · 0.90
pluginApiFunction · 0.90

Calls 1

createCommandShimDialogFunction · 0.85

Tested by

no test coverage detected