feat: base shortcut code

This commit is contained in:
2025-01-18 21:54:26 +01:00
parent a820b29ea9
commit 3abe88c7a2
29 changed files with 5982 additions and 123 deletions

31
utils/registry.ts Normal file
View File

@@ -0,0 +1,31 @@
import { ShortcutsResponse } from './types';
import { pingCommand } from './commands/ping';
import { timeCommand } from './commands/time';
import { anthropicCommand } from './commands/anthropic';
type CommandHandler = (
parameters?: Record<string, string>
) => Promise<ShortcutsResponse>;
export class CommandRegistry {
private commands: Map<string, CommandHandler>;
constructor() {
this.commands = new Map();
this.registerDefaultCommands();
}
private registerDefaultCommands() {
this.register('ping', pingCommand);
this.register('time', timeCommand);
this.register('anthropic', anthropicCommand);
}
register(command: string, handler: CommandHandler) {
this.commands.set(command.toLowerCase(), handler);
}
getCommand(command: string): CommandHandler | undefined {
return this.commands.get(command.toLowerCase());
}
}