Summary
TestScaffold_FileCount in internal/agentkit/agentkit_test.go uses manual length-check + raw slice indexing to categorize scaffold results by directory prefix:
case len(r.Path) > 9 && r.Path[:9] == "commands/":
commands++
case len(r.Path) > 7 && r.Path[:7] == "skills/":
skills++
case len(r.Path) > 7 && r.Path[:7] == "agents/":
agents++
This pattern is fragile - the integer constants (9, 7, 7) must be manually kept in sync with the prefix string lengths. An off-by-one error is easy to introduce (as happened during the command/ - commands/ rename, where the constant changed from 8 to 9).
Expected behavior
Use strings.HasPrefix which is immune to length/index mismatches:
case strings.HasPrefix(r.Path, "commands/"):
commands++
case strings.HasPrefix(r.Path, "skills/"):
skills++
case strings.HasPrefix(r.Path, "agents/"):
agents++
Location
Summary
TestScaffold_FileCount in internal/agentkit/agentkit_test.go uses manual length-check + raw slice indexing to categorize scaffold results by directory prefix:
case len(r.Path) > 9 && r.Path[:9] == "commands/":
commands++
case len(r.Path) > 7 && r.Path[:7] == "skills/":
skills++
case len(r.Path) > 7 && r.Path[:7] == "agents/":
agents++
This pattern is fragile - the integer constants (9, 7, 7) must be manually kept in sync with the prefix string lengths. An off-by-one error is easy to introduce (as happened during the command/ - commands/ rename, where the constant changed from 8 to 9).
Expected behavior
Use strings.HasPrefix which is immune to length/index mismatches:
case strings.HasPrefix(r.Path, "commands/"):
commands++
case strings.HasPrefix(r.Path, "skills/"):
skills++
case strings.HasPrefix(r.Path, "agents/"):
agents++
Location
Discovered during review of PR refactor: migrate .opencode/command/ to .opencode/commands/ #20.