fix(crew): use strings.Split instead of filepath.SplitList for path parsing

filepath.SplitList is for PATH-like env vars (colon/semicolon separated),
not for splitting file paths. This caused inferRigFromCwd to always fail
since SplitList returns the whole path as one element, making the fallback
logic never trigger.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-18 20:41:52 -08:00
parent eb0ac8e384
commit c1954b3431

View File

@@ -291,19 +291,12 @@ func inferRigFromCwd(townRoot string) (string, error) {
return "", fmt.Errorf("not in workspace")
}
// First component should be the rig name
parts := filepath.SplitList(rel)
if len(parts) == 0 {
// Split on path separator instead
for i := 0; i < len(rel); i++ {
if rel[i] == filepath.Separator {
return rel[:i], nil
}
}
// No separator found, entire rel is the rig name
if rel != "" && rel != "." {
return rel, nil
}
// Normalize and split path - first component is the rig name
rel = filepath.ToSlash(rel)
parts := strings.Split(rel, "/")
if len(parts) > 0 && parts[0] != "" && parts[0] != "." {
return parts[0], nil
}
return "", fmt.Errorf("could not infer rig from current directory")