MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / compareAgentIds

Function compareAgentIds

apps/vis/server/src/lib/agent-tree.ts:50–60  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

48 * transitive instead of degenerating into V8's order-dependent output.
49 */
50export function compareAgentIds(a: string, b: string): number {
51 if (a === b) return 0;
52 if (a === 'main') return -1;
53 if (b === 'main') return 1;
54 const na = /^agent-(\d+)$/.exec(a);
55 const nb = /^agent-(\d+)$/.exec(b);
56 if (na && nb) return Number(na[1]) - Number(nb[1]);
57 if (na) return -1; // all agent-N sort before any non-agent-N id
58 if (nb) return 1;
59 return a.localeCompare(b);
60}

Callers 3

discoverAgentsFromDiskFunction · 0.90
inventoryAgentsFunction · 0.90
sortAgentsFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected