Skip to repository content31 lines · 813 B · typescript
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:57:57.430Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
commandPalette.ts
1export type PaletteCommand = {
2 id: string;
3 label: string;
4 keywords: readonly string[];
5 run(): void;
6};
7
8export function filterCommands(
9 commands: readonly PaletteCommand[],
10 query: string,
11): PaletteCommand[] {
12 const normalizedQuery = query.trim().toLocaleLowerCase();
13 if (normalizedQuery.length === 0) return [...commands];
14
15 return commands.filter(({ label, keywords }) => {
16 const searchableText = [label, ...keywords].join(" ").toLocaleLowerCase();
17 return searchableText.includes(normalizedQuery);
18 });
19}
20
21export function nextActiveIndex(
22 currentIndex: number,
23 direction: "next" | "previous",
24 commandCount: number,
25): number {
26 if (commandCount === 0) return -1;
27
28 const offset = direction === "next" ? 1 : -1;
29 return (currentIndex + offset + commandCount) % commandCount;
30}
31