MCPcopy
hub / github.com/codeaashu/claude-code / generateUniqueTeammateName

Function generateUniqueTeammateName

src/tools/shared/spawnMultiAgent.ts:267–294  ·  view source on GitHub ↗
(
  baseName: string,
  teamName: string | undefined,
)

Source from the content-addressed store, hash-verified

265 * @internal Exported for testing
266 */
267export async function generateUniqueTeammateName(
268 baseName: string,
269 teamName: string | undefined,
270): Promise<string> {
271 if (!teamName) {
272 return baseName
273 }
274
275 const teamFile = await readTeamFileAsync(teamName)
276 if (!teamFile) {
277 return baseName
278 }
279
280 const existingNames = new Set(teamFile.members.map(m => m.name.toLowerCase()))
281
282 // If the base name doesn't exist, use it as-is
283 if (!existingNames.has(baseName.toLowerCase())) {
284 return baseName
285 }
286
287 // Find the next available suffix
288 let suffix = 2
289 while (existingNames.has(`${baseName}-${suffix}`.toLowerCase())) {
290 suffix++
291 }
292
293 return `${baseName}-${suffix}`
294}
295
296// ============================================================================
297// Spawn Handlers

Callers 3

handleSpawnSplitPaneFunction · 0.85
handleSpawnInProcessFunction · 0.85

Calls 2

readTeamFileAsyncFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected