I see. The tests create skills at one level deep (skills/alpha/SKILL.md), but the issue is about nested skills (skills/development/skill-creator/SKILL.md). The scanForSkills function only scans immediate children, so nested skills are missed.
Looking at the test TestDetectContext_MultiSkillWithSkillsDir, it creates:
skills/alpha/SKILL.md
skills/beta/SKILL.md
But in the issue:
skills/development/skill-creator/SKILL.md
The skill is 2 levels deep under skills/. The scanForSkills function reads immediate children of skills/ which are development/, copilot-exclusive/, testing/. Then for each, it calls tryParseSkill("skills/development/") which looks for skills/development/SKILL.md. That file doesn't exist.
So the fix needs to make scanForSkills recursive, like how cmd_coverage.go's discoverSkillFiles works.
Let me now modify the scanForSkills function to be recursive. I'll use filepath.WalkDir similar to discoverSkillFiles in cmd_coverage.go.
Actually, I need to be careful here. The function is called scanForSkills and it's used in multiple places. I should make sure my changes don't break anything.
Let me check if there are any tests that would break:
TestDetectContext_MultiSkillWithSkillsDir - skills are at skills/alpha/SKILL.md, which is 1 level deep. My change should still work.
TestDetectContext_MultiSkillSiblingDirs - skills are at skill-a/SKILL.md and skill-b/SKILL.md, which is direct children of the root. Should still work.
Actually wait, looking at the scanForSkills function more carefully:
func scanForSkills(parentDir string) []SkillInfo {
entries, err := os.ReadDir(parentDir)
...
for _, entry := range entries {
if !entry.IsDir() || strings.HasPrefix(entry.Name(), ".") {
continue
}
childDir := filepath.Join(parentDir, entry.Name())
if info, ok := tryParseSkill(childDir); ok {
skills = append(skills, info)
}
}
return skills
}
This function:
- Reads immediate children of
parentDir
- For each directory child, checks if it contains a SKILL.md
- Returns only those that have a SKILL.md directly in them
The fix should be to make this recursive:
- Walk through all subdirectories
- For each directory containing SKILL.md, return it as a skill
But I need to be careful: the function is also used in step 4 of DetectContext:
// 4. Scan immediate children of dir for SKILL.md
skills = scanForSkills(absDir)
If I make it recursive, this would change behavior. Currently it only finds skills that are immediate children of the current directory. If I make it recursive, it would also find skills nested inside subdirectories of the current directory.
For step 4 (scanning immediate children), making it recursive seems correct - if there's a SKILL.md somewhere in the current directory or its subdirectories, it should be found.
Let me also check where scanForSkills is used:
- Step 3:
skills = scanForSkills(skillsDir) - scanning the configured skills directory
- Step 3b:
githubSkills = scanForSkills(githubSkillsDir) - scanning GitHub skills directory
- Step 4:
skills = scanForSkills(absDir) - scanning immediate children
For all of these, making it recursive seems like the right thing. The only concern is performance, but for a typical repo, this shouldn't be a problem.
Let me also check what happens with discoverSkillFiles in cmd_coverage.go. It uses filepath.WalkDir which recursively walks. But it also has logic to skip hidden directories and node_modules/vendor.
I should make scanForSkills use filepath.WalkDir with similar skipping logic.
Wait, actually I need to think about this more carefully. The scanForSkills function is called with skillsDir as the argument. In step 3, skillsDir is either skills/ or an absolute path from config. If I make it recursive, it will walk all subdirectories under skills/, which is what we want.
But in step 4, absDir is the root directory. If I make scanForSkills recursive, it will walk ALL subdirectories of the root, including the skills/ directory itself. This could lead to duplicate discoveries.
Actually, let me re-read step 3 and step 4:
// 3. Check for configured skills subdirectory with SKILL.md children
var skillsDir string
skillsDir = filepath.Join(absDir, o.skillsDir) // e.g., "skills/"
var skills []SkillInfo
if isDir(skillsDir) {
skills = scanForSkills(skillsDir) // scans "skills/"
}
...
if len(skills) > 0 {
return &WorkspaceContext{...Skills: skills...}
}
// 4. Scan immediate children of dir for SKILL.md
skills = scanForSkills(absDir) // scans root directory
if len(skills) > 0 {
return &WorkspaceContext{...Skills: skills...}
}
So step 3 scans the configured skills directory, and step 4 only runs if step 3 didn't find anything. They're mutually exclusive in practice.
Actually, the code is:
if len(skills) > 0 {
return &WorkspaceContext{...}
}
...
// 4
skills = scanForSkills(absDir)
if len(skills) > 0 {
return &WorkspaceContext{...}
}
So if step 3 finds skills, it returns immediately and step 4 is never reached. Good, so there's no overlap.
But wait, there's also the .github/skills check:
// 3b. Also check .github/skills/ directory (GitHub Copilot convention)
githubSkillsDir := filepath.Join(absDir, ".github", "skills")
if isDir(githubSkillsDir) && !samePath(skillsDir, githubSkillsDir) {
githubSkills := scanForSkills(githubSkillsDir)
skills = mergeSkillsByName(skills, githubSkills)
}
if len(skills) > 0 {
return &WorkspaceContext{...}
}
This merges skills from .github/skills/ with skills from the configured directory.
OK so the key insight is that:
- Step 3 scans
skills/ for skills
- Step 3b scans
.github/skills/ for skills
- Step 4 scans the root directory for skills (only if step 3 finds nothing)
All of these should now use recursive scanning to find nested skills.
Let me now write the fix. I'll modify scanForSkills to use filepath.WalkDir for recursive scanning.
Actually wait, I want to think about this more carefully. Looking at the original function:
func scanForSkills(parentDir string) []SkillInfo {
entries, err := os.ReadDir(parentDir)
...
for _, entry := range entries {
if !entry.IsDir() || strings.HasPrefix(entry.Name(), ".") {
continue
}
childDir := filepath.Join(parentDir, entry.Name())
if info, ok := tryParseSkill(childDir); ok {
skills = append(skills, info)
}
}
return skills
}
This only checks immediate children. The issue is that when skills are nested (e.g., skills/development/skill-creator/SKILL.md), it won't find them because it only checks skills/development/ for a SKILL.md (which doesn't exist).
The fix is to recursively walk subdirectories. Here's my plan:
func scanForSkills(parentDir string) []SkillInfo {
var skills []SkillInfo
err := filepath.WalkDir(parentDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
name := d.Name()
if strings.HasPrefix(name, ".") || name == "node_modules" || name == "vendor" {
return fs.SkipDir
}
return nil
}
if d.Name() != "SKILL.md" && !skill.IsAgentFile(d.Name()) {
return nil
}
// SKILL.md takes priority: skip .agent.md if SKILL.md exists in same dir
if skill.IsAgentFile(d.Name()) {
skillMDPath := filepath.Join(filepath.Dir(path), "SKILL.md")
if isFile(skillMDPath) {
return nil
}
}
if info, ok := tryParseSkill(filepath.Dir(path)); ok {
skills = append(skills, info)
}
return nil
})
if err != nil {
return skills
}
return skills
}
Wait, but I need to be careful about the import. Let me check what's imported in the workspace.go file.
Also, I need to make sure I handle hidden directories properly. The original code skips directories starting with .. Let me also add node_modules and vendor to be consistent with discoverSkillFiles.
Actually, looking at the current scanForSkills implementation more carefully:
if !entry.IsDir() || strings.HasPrefix(entry.Name(), ".") {
continue
}
It skips:
- Non-directory entries
- Directories starting with
.
And it checks if the directory has a SKILL.md directly in it. The fix should recursively walk and do the same.
Now, let me also think about a potential issue: if we're scanning skills/development/ recursively and there's both skills/development/SKILL.md and skills/development/subdir/SKILL.md, we should find both. But with the original code, we'd only find the first one. My fix would find both, which is correct.
But wait, there's also a potential duplicate issue. If scanForSkills is called on skills/, it would walk all subdirectories. But then step 4 calls scanForSkills(absDir) which would also walk skills/. However, as I noted earlier, step 4 only runs if step 3 doesn't find any skills, so there's no overlap.
Actually, I realize I need to be more careful. Let me re-check the discoverSkillFiles function in cmd_coverage.go:
func discoverSkillFiles(root string, discoverPaths []string) (map[string]string, error) {
searchRoots := []string{
filepath.Join(root, "skills"),
filepath.Join(root, ".github", "skills"),
}
...
for _, sr := range searchRoots {
if !isDir(sr) {
continue
}
err := filepath.WalkDir(sr, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("error walking %s: %w", path, err)
}
if d.IsDir() {
name := d.Name()
if strings.HasPrefix(name, ".") || name == "node_modules" || name == "vendor" {
return fs.SkipDir
}
return nil
}
...
})
}
}
This uses filepath.WalkDir to walk recursively through skills/ and .github/skills/. This is exactly what I want to do in scanForSkills.
Let me now write the fix. I need to:
- Import
"io/fs" in workspace.go (since WalkDir uses fs.DirEntry and fs.SkipDir)
- Change
scanForSkills to use filepath.WalkDir
Wait, I also notice that discoverSkillFiles has this logic:
if skill.IsAgentFile(d.Name()) {
skillMDPath := filepath.Join(filepath.Dir(path), "SKILL.md")
if isFile(skillMDPath) {
return nil
}
}
This means if we find an .agent.md file and there's also a SKILL.md in the same directory, we skip the .agent.md (since SKILL.md takes priority). I should include this logic in my fix.
OK let me write the fix now.
Actually, I just realized something. Looking at the test case TestDetectContext_MultiSkillWithSkillsDir:
writeFile(t, filepath.Join(root, "skills", "alpha", "SKILL.md"), skillMD("alpha"))
writeFile(t, filepath.Join(root, "skills", "beta", "SKILL.md"), skillMD("beta"))
The skills are at:
skills/alpha/SKILL.md
skills/beta/SKILL.md
And the test expects to find both. The current scanForSkills would:
- Read
skills/ entries: alpha/, beta/
- Check
tryParseSkill("skills/alpha/") → finds SKILL.md → returns skill info
- Check
tryParseSkill("skills/beta/") → finds SKILL.md → returns skill info
So this test passes. But if we had:
skills/development/alpha/SKILL.md
skills/development/beta/SKILL.md
The current code would:
- Read
skills/ entries: development/
- Check
tryParseSkill("skills/development/") → no SKILL.md → returns false
- No skills found!
That's the bug! My fix should make scanForSkills recursive, so it would:
- Walk
skills/development/alpha/ → find SKILL.md → add skill
- Walk
skills/development/beta/ → find SKILL.md → add skill
Let me also write a test to verify the fix works for nested skills.
Now let me write the fix:
// scanForSkills recursively scans for SKILL.md files under parentDir.
func scanForSkills(parentDir string) []SkillInfo {
var skills []SkillInfo
err := filepath.WalkDir(parentDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
name := d.Name()
if strings.HasPrefix(name, ".") || name == "node_modules" || name == "vendor" {
return fs.SkipDir
}
return nil
}
// Only consider SKILL.md and .agent.md files
if d.Name() != "SKILL.md" && !skill.IsAgentFile(d.Name()) {
return nil
}
// SKILL.md takes priority: skip .agent.md if SKILL.md exists in same dir
if skill.IsAgentFile(d.Name()) {
skillMDPath := filepath.Join(filepath.Dir(path), "SKILL.md")
if isFile(skillMDPath) {
return nil
}
}
skillDir := filepath.Dir(path)
if info, ok := tryParseSkill(skillDir); ok {
skills = append(skills, info)
}
return nil
})
if err != nil {
return skills
}
return skills
}
Wait, I need to import "io/fs" in the workspace.go file. Let me check if it's already imported.
Looking at the imports in workspace.go:
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/microsoft/waza/internal/skill"
"github.com/microsoft/waza/internal/utils"
)
I need to add "io/fs" to the imports.
Let me write the fix now.
Wait, actually I need to double-check something. Let me also look at how the coverage command works to confirm my understanding.
Looking at discoverSkillFiles in cmd_coverage.go:
func discoverSkillFiles(root string, discoverPaths []string) (map[string]string, error) {
searchRoots := []string{
filepath.Join(root, "skills"),
filepath.Join(root, ".github", "skills"),
}
...
for _, sr := range searchRoots {
if !isDir(sr) {
continue
}
err := filepath.WalkDir(sr, func(path string, d fs.DirEntry, err error) error {
...
})
}
...
}
Yes, it uses filepath.WalkDir to recursively walk through skills/. So coverage finds all skills recursively.
And scanForSkills only scans immediate children. So check doesn't find nested skills.
OK, I'm confident in my fix. Let me write it now.
Actually, I realize there might be another issue. Looking at the issue description again:
### `waza check skills/development/skill-creator`
Output includes:
```text
Evaluation Suite: Not Found
When the user runs `waza check skills/development/skill-creator`:
1. `LooksLikePath("skills/development/skill-creator")` returns true (contains `/`)
2. So it goes to the branch that passes `nil` as `wsCtx` to `checkReadiness`
3. `checkReadiness` is called with `skillDir = "skills/development/skill-creator"`
4. It finds `SKILL.md` in that directory
5. It tries to find evals using `workspace.FindEval(wsCtx, ...)` but `wsCtx` is `nil`
6. It then tries workspace detection: `workspace.DetectContext(wd)` where `wd` is the current directory
7. If the workspace has nested skills, `DetectContext` might not find the skill-creator skill (because `scanForSkills` is not recursive)
8. So `FindEval` can't find the eval
But wait, even if `DetectContext` finds other skills in the workspace, it might not find the specific skill that the user is checking. And `FindEval` requires the skill to be in the workspace context.
Actually, looking at the `checkReadiness` code again:
```go
if !report.hasEval {
// Try workspace detection from the working directory
if wd, wdErr := os.Getwd(); wdErr == nil {
if autoCtx, ctxErr := workspace.DetectContext(wd); ctxErr == nil {
if evalPath, findErr := workspace.FindEval(autoCtx, sk.Frontmatter.Name); findErr == nil && evalPath != "" {
report.hasEval = true
report.evalPath = evalPath
}
}
}
}
So it tries to detect the workspace and find the eval using the skill's name from the frontmatter. The issue is that if the skill is not found in the workspace context, FindEval will return an error.
And FindEval calls FindSkill:
func FindEval(wsCtx *WorkspaceContext, skillName string) (string, error) {
si, err := FindSkill(wsCtx, skillName)
if err != nil {
return "", err
}
...
}
func FindSkill(ctx *WorkspaceContext, name string) (*SkillInfo, error) {
for i := range ctx.Skills {
if ctx.Skills[i].Name == name {
return &ctx.Skills[i], nil
}
}
return nil, fmt.Errorf("skill %q not found in workspace", name)
}
So if the skill name doesn't match any skill in the workspace context, FindEval returns an error. This is caught by the if findErr == nil check in checkReadiness.
And if the workspace context has skills from step 3 (scanning skills/) but those skills are only at the top level (not nested), then the specific skill (e.g., "skill-creator") won't be found.
Wait, actually I need to trace through this more carefully. Let me assume the workspace has:
skills/development/skill-creator/SKILL.md (with name "skill-creator")
evals/skill-creator/eval.yaml
When the user runs waza check skills/development/skill-creator from the workspace root:
resolveWorkspace is NOT called because LooksLikePath returns true
- Instead,
checkReadiness("skills/development/skill-creator", nil) is called
- Inside
checkReadiness:
- Finds
SKILL.md at skills/development/skill-creator/SKILL.md
- Parses it and gets
sk.Frontmatter.Name = "skill-creator"
wsCtx is nil, so the first if wsCtx != nil block is skipped
- Then it tries workspace detection:
if wd, wdErr := os.Getwd(); wdErr == nil {
if autoCtx, ctxErr := workspace.DetectContext(wd); ctxErr == nil {
if evalPath, findErr := workspace.FindEval(autoCtx, sk.Frontmatter.Name); findErr == nil && evalPath != "" {
...
}
}
}
DetectContext(wd) is called without configDetectOptions(), so it uses defaults: skillsDir="skills"
scanForSkills("skills/") is called, but it only checks immediate children
skills/development/ doesn't have a SKILL.md, so it's not found
DetectContext returns ctx with Type = ContextNone and Skills = []
FindEval(ctx, "skill-creator") returns error "skill not found"
- So
hasEval remains false
That's the bug! The workspace detection in checkReadiness doesn't use recursive skill discovery.
But wait, there's another issue. Even if DetectContext found the skills, FindEval requires the specific skill to be in the context. But the workspace context would have skills found by scanForSkills, which only finds top-level skills. So even if there were a top-level skill, it wouldn't find "skill-creator".
Actually, I think there are TWO bugs:
scanForSkills only finds top-level skills, not nested skills
checkReadiness doesn't use configDetectOptions() when doing workspace detection
The second issue is also important because if the .waza.yaml has custom paths like paths.skills: my-skills/, the default skillsDir="skills" wouldn't work.
Let me check the second issue more carefully. In checkReadiness:
if !report.hasEval {
// Try workspace detection from the working directory
if wd, wdErr := os.Getwd(); wdErr == nil {
if autoCtx, ctxErr := workspace.DetectContext(wd); ctxErr == nil {
if evalPath, findErr := workspace.FindEval(autoCtx, sk.Frontmatter.Name); findErr == nil && evalPath != "" {
report.hasEval = true
report.evalPath = evalPath
}
}
}
}
Yes, it calls workspace.DetectContext(wd) without any options. This means it uses the default skillsDir="skills" and evalsDir="evals".
But looking at the issue description, the workspace has:
paths:
skills: skills/
evals: evals/
Which are the default values, so this wouldn't cause an issue for the specific case in the issue. But it's still a bug that should be fixed.
However, the PRIMARY bug is the non-recursive skill discovery. Let me focus on fixing that first.
My plan:
- Modify
scanForSkills in workspace/workspace.go to use filepath.WalkDir for recursive discovery
- Also modify
checkReadiness in cmd_check.go to use configDetectOptions() when doing workspace detection (optional, but good for consistency)
Actually wait, let me re-read the issue one more time to make sure I understand it correctly.
From the issue:
### `waza check skill-creator`
Output includes:
```text
no SKILL.md found in <workspace root>
So when the user runs `waza check skill-creator`, it says "no SKILL.md found in <workspace root>". This means the command is falling through to the fallback case:
```go
// Fallback: current directory
skillDir := "."
And checkReadiness(".") checks for ./SKILL.md which doesn't exist.
But wait, let me trace through waza check skill-creator more carefully:
len(args) = 1, args[0] = "skill-creator"
workspace.LooksLikePath("skill-creator") → false (no /, \, no file extension, not .)
- So it calls
resolveWorkspace(args)
- In
resolveWorkspace:
ctx, err := workspace.DetectContext(wd, configDetectOptions()...)
- This detects the workspace with config options
- If the workspace has nested skills,
scanForSkills might not find "skill-creator"
- So
ctx.Skills might not contain "skill-creator"
- Then:
si, err := workspace.FindSkill(ctx, "skill-creator")
- If "skill-creator" is not in
ctx.Skills, this returns an error
- Back in
runCheck:
wsCtx, err := resolveWorkspace(args)
if err == nil && len(wsCtx.Skills) > 0 {
return runCheckForSkills(cmd, wsCtx, format)
}
- If
resolveWorkspace returned an error, this block is skipped
- Falls through to the fallback case
So the root cause is that scanForSkills doesn't find nested skills, so the workspace context doesn't contain "skill-creator", and FindSkill fails.
OK, I'm now fully confident. The fix is to make scanForSkills recursive.
Let me also check if there are any other places that might need similar fixes. Looking at the code, the main places that discover skills are:
scanForSkills in workspace/workspace.go - needs to be recursive
discoverSkillFiles in cmd_coverage.go - already recursive ✓
And eval discovery:
FindEval in workspace/workspace.go - this is called after skills are discovered. If skills aren't discovered, FindEval can't work.
Actually, let me think about this from a different angle. Even if scanForSkills is recursive and finds all skills, there's still the issue that when the user runs waza check skills/development/skill-creator, the wsCtx is nil, so the workspace-aware detection is skipped.
In that case, the fallback workspace detection in checkReadiness should work IF:
DetectContext finds the skill in the workspace
FindEval can find the eval for that skill
With my fix to make scanForSkills recursive, DetectContext would find the skill. And FindEval would find the eval using the separated convention (evals/skill-creator/eval.yaml).
So my fix should resolve the issue. Let me implement it.
But actually, I'm now thinking... there might be a simpler fix. Instead of modifying scanForSkills, I could modify checkReadiness to use resolveEvalPath or something similar that finds evals independently of the workspace context.
Let me look at resolveEvalPath in workspace_resolve.go:
func resolveEvalPath(si *workspace.SkillInfo) (string, error) {
wd, err := os.Getwd()
...
wsCtx, err := workspace.DetectContext(wd, configDetectOptions()...)
...
// Ensure the skill is in the context so FindEval can locate it
found := false
for _, s := range wsCtx.Skills {
if s.Name == si.Name {
found = true
break
}
}
if !found {
wsCtx.Skills = append(wsCtx.Skills, *si)
}
evalPath, err := workspace.FindEval(wsCtx, si.Name)
...
}
This function has a workaround: if the skill is not in the workspace context, it adds it. But it also needs si (SkillInfo) as input, which requires knowing the skill directory.
In checkReadiness, we already know the skill directory (skillDir) and we've parsed the SKILL.md to get the skill name. So we could create a SkillInfo and use it to find the eval.
But actually, the current code already does something similar:
if !report.hasEval {
// Try workspace detection from the working directory
if wd, wdErr := os.Getwd(); wdErr == nil {
if autoCtx, ctxErr := workspace.DetectContext(wd); ctxErr == nil {
if evalPath, findErr := workspace.FindEval(autoCtx, sk.Frontmatter.Name); findErr == nil && evalPath != "" {
report.hasEval = true
report.evalPath = evalPath
}
}
}
}
The issue is that FindEval requires the skill to be in the context. If the skill is not found (because scanForSkills didn't find it), FindEval returns an error.
So the fix could be either:
- Make
scanForSkills recursive (so the skill is found in the context)
- Modify
FindEval or checkReadiness to handle the case where the skill is not in the context but the eval path can still be computed from the skill name
Option 1 is the more fundamental fix because it addresses the root cause. Option 2 is a workaround that only fixes the eval discovery, not the skill discovery in general.
Let me go with option 1: make scanForSkills recursive.
Actually, let me also think about whether I should fix both scanForSkills AND the workspace detection in checkReadiness. The checkReadiness function currently does:
if wsCtx != nil {
// Use provided workspace context
}
if !report.hasEval {
// Fallback: detect workspace from CWD
autoCtx, ctxErr := workspace.DetectContext(wd)
}
The issue is that the fallback detection uses workspace.DetectContext(wd) without configDetectOptions(). This means it doesn't respect the custom paths from .waza.yaml.
But looking at the issue description, the workspace has paths.skills: skills/ and paths.evals: evals/, which are the default values. So this wouldn't cause an issue in the specific case. However, it's still a bug that should be fixed for correctness.
OK let me implement both fixes:
- Make
scanForSkills recursive
- Use
configDetectOptions() in the fallback workspace detection in checkReadiness
Actually wait, I should be careful. The checkReadiness function is in cmd/waza/cmd_check.go, not in the workspace package. If I call configDetectOptions() from there, it would load the project config, which might not always be the right thing to do.
Let me look at what configDetectOptions() does again:
func configDetectOptions() []workspace.DetectOption {
wd, err := os.Getwd()
if err != nil {
return nil
}
cfg, err := projectconfig.Load(wd)
if err != nil {
return nil
}
skillsDir := cfg.Paths.Skills
evalsDir := cfg.Paths.Evals
if cfg.Dir != "" {
skillsDir = filepath.Join(cfg.Dir, skillsDir)
evalsDir = filepath.Join(cfg.Dir, evalsDir)
}
return []workspace.DetectOption{
workspace.WithSkillsDir(skillsDir),
workspace.WithEvalsDir(evalsDir),
}
}
It loads the project config from the current working directory. If the config is not found or there's an error, it returns nil, which means default options will be used.
So in checkReadiness, I could call configDetectOptions():
if !report.hasEval {
if wd, wdErr := os.Getwd(); wdErr == nil {
options := configDetectOptions()
if autoCtx, ctxErr := workspace.DetectContext(wd, options...); ctxErr == nil {
if evalPath, findErr := workspace.FindEval(autoCtx, sk.Frontmatter.Name); findErr == nil && evalPath != "" {
report.hasEval = true
report.evalPath = evalPath
}
}
}
}
This would respect custom paths from .waza.yaml. And with my fix to scanForSkills, nested skills would also be found.
OK, let me implement both fixes now.
Actually wait, I want to be careful about one more thing. The configDetectOptions function calls os.Getwd() and then projectconfig.Load(wd). But checkReadiness is called from runCheck, which already has access to the current directory. And configDetectOptions is already called in resolveWorkspace. So this should be fine.
But actually, looking at the call chain:
runCheck is called by cobra
- If the arg is a path,
checkReadiness(skillDir, nil) is called
checkReadiness tries workspace detection
In this case, the current working directory is where the user ran waza check, not necessarily the workspace root. So calling configDetectOptions() in checkReadiness would use the correct current working directory.
OK, I'm confident in my plan. Let me implement it.
Wait, one more thing. Let me also check if there's a way to directly compute the eval path from the skill name without going through FindEval. Looking at FindEval:
func FindEval(wsCtx *WorkspaceContext, skillName string) (string, error) {
si, err := FindSkill(wsCtx, skillName)
if err != nil {
return "", err
}
evalsDir := wsCtx.EvalsDir
...
// Priority 1: separated convention
separated = filepath.Join(wsCtx.Root, evalsDir, skillName, "eval.yaml")
if isFile(separated) {
return separated, nil
}
// Priority 2: nested subdir inside skill directory
nested := filepath.Join(si.Dir, "evals", "eval.yaml")
if isFile(nested) {
return nested, nil
}
// Priority 3: co-located / legacy
colocated := filepath.Join(si.Dir, "eval.yaml")
if isFile(colocated) {
return colocated, nil
}
return "", nil
}
The priority order is:
{root}/evals/{skill-name}/eval.yaml (separated convention)
{skill-dir}/evals/eval.yaml (nested subdir)
{skill-dir}/eval.yaml (co-located)
For the issue case, the eval is at evals/skill-creator/eval.yaml. So priority 1 should find it.
The issue is that FindEval requires the skill to be in the workspace context (to get si.Dir for priorities 2 and 3). But for priority 1, we only need wsCtx.Root and wsCtx.EvalsDir, which can be computed independently.
So another option would be to modify checkReadiness to try priority 1 directly without going through FindEval:
if !report.hasEval {
// Try workspace-aware detection
if wd, wdErr := os.Getwd(); wdErr == nil {
options := configDetectOptions()
if autoCtx, ctxErr := workspace.DetectContext(wd, options...); ctxErr == nil {
evalsDir := autoCtx.EvalsDir
if evalsDir == "" {
evalsDir = "evals"
}
// Priority 1: separated convention
separated := filepath.Join(autoCtx.Root, evalsDir, sk.Frontmatter.Name, "eval.yaml")
if isFile(separated) {
report.hasEval = true
report.evalPath = separated
}
}
}
}
But this is getting complicated. Let me just fix scanForSkills to be recursive, which is the root cause. That way, the existing code paths will work correctly.
Actually, I realize that the simplest fix is:
- Make
scanForSkills recursive (so nested skills are found)
- Make the fallback workspace detection in
checkReadiness use configDetectOptions() (so custom paths are respected)
With these two changes, the existing code paths in checkReadiness will work correctly:
DetectContext will find nested skills
FindSkill will find the specific skill by name
FindEval will find the eval
Let me implement this now.
Actually, I want to also think about whether using configDetectOptions() in checkReadiness could cause any issues. The function loads the project config from the current working directory. If the user runs waza check skills/development/skill-creator from the workspace root, this would work correctly.
But what if the user runs waza check from a subdirectory within the workspace? For example, waza check from skills/development/. In that case, configDetectOptions() would try to load the project config from skills/development/, which might not find it.
Actually, projectconfig.Load probably searches up the directory tree for the config file. Let me check.
<tool_call>
<function=bash_terminal>
<parameter=command>
cat /waza/internal/projectconfig/projectconfig.go 2>/dev/null || find /waza -name "projectconfig*" -type f
</tool_call>