Repository navigation
fix(run): install a local_path skill under its declared name - #400
Walternater wants to merge 1 commit into
Conversation
A local_path skill whose folder name differs from the name declared in SKILL.md was installed under the folder name, so the agent listed and invoked it by a name its own text never uses (alibaba#367). The default target is now runtime.SkillConfig.DirName: the declared name when it is a safe single path element, otherwise the source folder name. The same name drives the default skill cleanup before an agent judge, and explicit targets still win.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de7560ba69
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func (c SkillConfig) DirName() string { | ||
| name := strings.TrimSpace(c.Name) | ||
| if name != "" && name != "." && name != ".." && !strings.ContainsAny(name, `/\`) { | ||
| return name |
There was a problem hiding this comment.
Reject duplicate declared names before installation
When an eval lists two different skills with the same frontmatter name and leaves target unset, both now resolve to the same default directory; installSkill uploads each source there without clearing it, so files can be merged or overwritten and the run evaluates a different skill than either source. validateSkillRefs permits this configuration, so fail on duplicate default targets before installing them.
Useful? React with 👍 / 👎.
|
Thanks for the fix and the verification details. This substantially overlaps with #393, which is also still open: both address #367 by installing local Skills under their declared The two PRs touch the same core code paths, so it would be useful to coordinate the implementations before merging to avoid duplicating the fix or losing changes when reconciling them. Please compare with #393 and identify any distinct improvements or test coverage here that we should retain. |
|
Compared the two patches. Agreed on the overlap: #393 is the better base and should land instead of this one. It goes further than #400 in three places worth keeping:
Distinct coverage in #400 that #393 does not have, and I think is worth retaining:
I'll close #400 now and won't push to @karanb192's branch. Happy to send the two tests as a small test-only follow-up PR after #393 merges, or as a patch here if @karanb192 prefers to fold them in — just say which. |
|
Closing as superseded by #393 after @zpzjzj's note: #393 covers the same fix plus collision detection, judge naming and stricter name validation. The two distinct tests and the real-CLI evidence are offered in #393 (comment above); I'll send them as a test-only follow-up if they're not folded in there. |
The InstallSkillCmd default target is computed separately from the SkillPath default, and an explicit target must still win over the declared name. Both tests come from Walternater's alibaba#400.
* fix(agent): install a Skill under its declared name The default install folder was the source folder's basename, so a Skill copied into a differently named folder was listed and invoked under that folder's name. Use the name from SKILL.md frontmatter when it is usable as a directory name. * fix(agent): reject skills that share an install directory Two sources that declare the same name would be uploaded into one directory and mixed. Also accept a declared name only when it is safe as a directory name on every supported filesystem. * refactor(evaluator): move run skill installation into a helper Keeps setupCaseEnvironment under the complexity limit. Also state the exact name rule in both guides. * fix(judge): name judge Skills by their install directory in the prompt A judge Skill installed under its declared name was still listed in the agent judge prompt under its folder name, so the judge was told to invoke a Skill that no longer existed under that name. * test(judge): cover the folder-name fallback for judge Skill names * test(agent): cover declared names on the custom install command path The InstallSkillCmd default target is computed separately from the SkillPath default, and an explicit target must still win over the declared name. Both tests come from Walternater's alibaba#400.
Summary
A
local_pathskill whose folder name differs from thename:in itsSKILL.mdfrontmatter was installed under the folder name. Agents address theinstalled skill by that directory name, so a snapshot folder
snap/holdingname: my-skillwas listed and invoked assnap— a name its own text neveruses — and the
with_skillarm of a benchmark could run a differently namedskill without any warning (#367).
Default install targets now use the declared name.
runtime.SkillConfiggainsName(filled byresolveSkillConfigfromSKILL.md) andDirName(), whichreturns the declared name when it is a safe single path element and falls back
to the source folder name otherwise. Explicit
skills[].targetstill wins.Related issues
Changes
internal/runtime/runtime.go:SkillConfig.Name+DirName(); names thatare empty,
.,.., or contain a slash/backslash fall back to the sourcebasename so a malformed
SKILL.mdcannot escape the skill directory.internal/config/loader.go:SkillNameInDir(dir)wraps the existingparseSkillNameso callers can read the declared name from any skilldirectory (the loader's own
SkillName()keeps its behaviour).internal/evaluator/evaluator.go:resolveSkillConfigfillsName, and thedefault run-skill cleanup before an Agent judge (
removeDefaultRunSkillsBeforeJudge)removes
DirName()instead of the source basename, so cleanup matches whatwas installed.
internal/agent/agent.go,internal/agent/cli.go: the two default targetcomputations (
installSkillDefault, and the fallback target for a customInstallSkillCmd) useDirName().judge.skillsgets the same behaviourbecause it goes through the same resolver.
CHANGELOG.md.Test plan
make testpassesmake verifypasses (fmt + vet + lint, 0 issues)TestSkillConfigDirName(declared name wins; empty/./../slashed names fall back),
TestSkillNameInDir, twoCLIAgenttests(default install target; custom
InstallSkillCmddefault target;explicit target wins), and
TestRemoveDefaultRunSkillsBeforeJudge_UsesDeclaredName.the three install tests (
skill should be installed under its declared name ... .claude/skills/my-skill/SKILL.md: no such file or directory),and dropping the
Namefill reddens the cleanup test(
got "rm -rf -- '.codex/skills/snap'").environment: none+claude_code, snapshot foldersnap/with
name: my-skill,skills: [{source: local_path, path: .}]:before this change
.claude/skills/snap/, after.claude/skills/my-skill/.Notes for reviewers
InstallSkillCmdtemplate that renders{{.Target}}now receivesthe declared name in the default target instead of the folder name. That is
the point of the change, but it is a behaviour change for such templates; an
explicit
skills[].targetkeeps working unchanged.no longer do, and the issue offered install-under-name or warn as
alternatives. Happy to add one for explicit targets if you want it.
deepseek-v4.1-flash); Ireviewed the full diff and ran the verification above.