MCPcopy Create free account
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / registerCommands

Function registerCommands

lib/tui/commands.ts:3–31  ·  view source on GitHub ↗
(api: TuiApi, commands: DcpCommand[])

Source from the content-addressed store, hash-verified

1import type { DcpCommand, TuiApi } from "./types"
2
3export function registerCommands(api: TuiApi, commands: DcpCommand[]) {
4 const keymap = (api as any).keymap
5 if (keymap?.registerLayer) {
6 keymap.registerLayer({
7 commands: commands.map((command) => ({
8 namespace: "palette",
9 name: command.name,
10 title: command.title,
11 desc: command.description,
12 category: "DCP",
13 slashName: command.slashName,
14 slashAliases: command.slashAliases,
15 run: command.run,
16 })),
17 })
18 return
19 }
20
21 api.command?.register(() =>
22 commands.map((command) => ({
23 title: command.title,
24 value: command.name,
25 description: command.description,
26 category: "DCP",
27 slash: { name: command.slashName, aliases: command.slashAliases },
28 onSelect: command.run,
29 })),
30 )
31}

Callers 1

tuiFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected