expandedAgentName creates an agent name by including parent directories from the workspace folder path to avoid name collisions. Like `safeAgentName`, the second returned value will be true if using the workspace folder name, and false if it fell back to the friendly name.
(workspaceFolder string, friendlyName string, depth int)
| 1121 | // the second returned value will be true if using the workspace folder name, |
| 1122 | // and false if it fell back to the friendly name. |
| 1123 | func expandedAgentName(workspaceFolder string, friendlyName string, depth int) (string, bool) { |
| 1124 | var parts []string |
| 1125 | for part := range strings.SplitSeq(filepath.ToSlash(workspaceFolder), "/") { |
| 1126 | if part = strings.TrimSpace(part); part != "" { |
| 1127 | parts = append(parts, part) |
| 1128 | } |
| 1129 | } |
| 1130 | if len(parts) == 0 { |
| 1131 | return safeFriendlyName(friendlyName), false |
| 1132 | } |
| 1133 | |
| 1134 | components := parts[max(0, len(parts)-depth-1):] |
| 1135 | expanded := strings.Join(components, "-") |
| 1136 | |
| 1137 | return safeAgentName(expanded, friendlyName) |
| 1138 | } |
| 1139 | |
| 1140 | // makeAgentName attempts to create an agent name. It will first attempt to create an |
| 1141 | // agent name based off of the workspace folder, and will eventually fallback to a |