Skip to content

feat(skill): supports baseDir being treated as a single skill directory - #1824

Open
chcodex wants to merge 16 commits into
agentscope-ai:mainfrom
chcodex:feat/skill-basedir
Open

chcodex wants to merge 16 commits into
agentscope-ai:mainfrom
chcodex:feat/skill-basedir

Conversation

@chcodex

@chcodex chcodex commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1790

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Background

When a skill repository's baseDir itself contains a SKILL.md file, the current implementation does not recognize it as a valid skill directory, requiring users to place SKILL.md in a subdirectory under baseDir.

Changes Made

  • Modified getAllSkillNames() to support root directory skill recognition
  • Modified getAllSkills() to support root directory skill loading
  • Modified loadSkill() to support root directory skill name matching check
  • Modified skillExists() to support root directory skill existence judgment
  • Added unit tests to cover the new root directory skill processing logic

How to Test

  1. Create a skill repository with SKILL.md directly in baseDir
  2. Call getAllSkills() and verify the root skill is returned
  3. Call skillExists() with the root skill name and verify it returns true
  4. Call loadSkill() with the root skill name and verify it loads successfully

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

- If baseDir itself contains SKILL.md, only the skill information of this directory will be returned.
- Modify the getAllSkillNames method to support root directory skill recognition
- Modify the getAllSkills method to support root directory skill loading
- Modify loadSkill method to support root directory skill name matching check
- Modify the skillExists method to support root directory skill existence judgment
- Add unit tests to cover the new root directory skill processing logic
- Unit tests verify the correct name, loading and existence of root skills
@chcodex
chcodex requested a review from a team June 18, 2026 04:11
@codecov

codecov Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.25000% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...re/skill/repository/FileSystemSkillRepository.java 52.17% 9 Missing and 2 partials ⚠️
...ntscope/core/skill/util/SkillFileSystemHelper.java 85.96% 7 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds support for treating baseDir itself as a single skill directory when it contains a SKILL.md file. The changes cover getAllSkillNames, getAllSkills, loadSkill (via findSkillDirectoryByName), and skillExists. Unit tests are included. However, there is a critical consistency defect: findSkillDirectoryByName does not early-return when baseDir has SKILL.md but the name doesn't match — it falls through to scan subdirectories, contradicting getAllSkillNames/getAllSkills which short-circuit in that case. Additionally, deleteSkill could accidentally delete the entire baseDir if the root-level skill name matches.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds support for treating baseDir itself as a single skill directory when it contains a SKILL.md file. The changes cover getAllSkillNames, getAllSkills, loadSkill (via findSkillDirectoryByName), and skillExists. Unit tests are included. However, there is a critical consistency defect: findSkillDirectoryByName does not early-return when baseDir has SKILL.md but the name doesn't match — it falls through to scan subdirectories, contradicting getAllSkillNames/getAllSkills which short-circuit in that case. Additionally, deleteSkill could accidentally delete the entire baseDir if the root-level skill name matches.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@AgentScopeJavaBot AgentScopeJavaBot added enhancement New feature or request area/core/tool Tool, skill, RAG abstractions labels Jun 19, 2026
@chcodex

chcodex commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

Issue 1 — findSkillDirectoryByName consistency (fixed ✅)
I've added the missing return Optional.empty() in findSkillDirectoryByName (commit 409fae01). When baseDir is a single skill directory and the requested name doesn't match the root skill, it now returns empty immediately instead of falling through to scan subdirectories, keeping consistent with getAllSkillNames/getAllSkills.

Issue 2 — deleteSkill might delete entire baseDir
When baseDir is a single-skill repository, the directory itself is the skill directory. Deleting that skill by definition means deleting the entire repository root, so this is expected behavior rather than a bug. No change needed.

@chcodex chcodex closed this Jun 26, 2026
@chcodex
chcodex deleted the feat/skill-basedir branch June 26, 2026 04:06
@chcodex
chcodex restored the feat/skill-basedir branch June 26, 2026 04:08
@chcodex chcodex reopened this Jun 26, 2026
@chcodex

chcodex commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@chickenlj Hello, please help to see if this PR is reasonable?

@chcodex

chcodex commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Is there anyone?

@jujn

jujn commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Is there anyone?

Thanks for your contribution. I'm really sorry, there are quite a few PRs and heavy review tasks. I'll take a look later.

@jujn jujn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileSystemSkillRepository # getAllSkills() still only scans subdirectories, so a single-skill repository with SKILL.md directly under baseDir is still invisible on the main runtime path.

@chcodex

chcodex commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've fixed FileSystemSkillRepository.getAllSkills() to check if baseDir itself contains SKILL.md. When it does, the method now loads and returns that single skill using the same mtime/size caching logic used for subdirectory skills — so root-level skills are now visible on the main runtime path.

Commit: 9851351

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jujn

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

My PR didn't make it into RC5. 😭

Comment on lines 300 to 303
public static boolean deleteSkill(Path baseDir, String skillName) {
Optional<Path> skillDir = findSkillDirectoryByName(baseDir, skillName);
if (skillDir.isEmpty()) {
logger.warn("Skill directory does not exist: {}", skillName);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleteSkill() reuse findSkillDirectoryByName().
If the deleteSkill method is triggered subsequently, and the passed in skill name exactly matches the name of the root directory, the entire baseDir directory will be deleted directly.
It is recommended to specially handle the root level skill in deleteSkill().

@jujn

jujn commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

My PR didn't make it into RC5. 😭

Maybe in 2.0 GA. ❤

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jujn Thanks for the review! Regarding the deleteSkill issue with root-level skills:

When baseDir itself is a single-skill repository, deleting that root skill would delete the entire baseDir directory. I'm considering this fix:

  1. In deleteSkill(), compare whether findSkillDirectoryByName returned baseDir itself
  2. If it is a root-level skill, delete all contents (SKILL.md + resources) but keep the baseDir directory itself intact
  3. For normal subdirectory skills, behavior stays unchanged

This avoids accidentally deleting the entire repository root while still properly removing the skill. Does this approach look reasonable to you?

@jujn

jujn commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator
  1. If it is a root-level skill, delete all contents (SKILL.md + resources) but keep the baseDir directory itself intact

Can we just delete skill.md? Because other files are equally important to users

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jujn Agreed. Updated deleteSkill() to only remove SKILL.md for root-level skills, keeping other files intact. Commit: 521c512

deleteDirectory(skillDir.get());
if (dirToDelete.equals(absoluteBaseDir)) {
// Root-level skill: only remove SKILL.md, keep other files intact
Files.delete(dirToDelete.resolve(SKILL_FILE_NAME));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest: Files.deleteIfExists

return false;
}

Path dirToDelete = skillDir.get();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest: skillDir.get().toAbsolutePath().normalize();

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jujn Thanks for the review! I've updated the PR with the fix.

return false;
}

boolean ok = SkillFileSystemHelper.saveSkills(baseDir, skills, force);

@jujn jujn Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here call SkillFileSystemHelper.saveSkills. For a single skill warehouse such as baseDir/SKILL.md, success is returned, but it is actually written to baseDir/skillName/SKILL.md.

@chcodex

chcodex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jujn PR updated with saveSkills root-level skill handling and a potential null pointer fix in resource writing path.

Comment on lines +245 to +247
boolean isRootSkill =
hasSkillFile(baseDir)
&& skillName.equals(readSkillName(baseDir).orElse(null));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the saved skill name does not match the existing root skill.md name. A success will still be returned and written to the subdirectory, but the skill will not be visible later.

@jujn

jujn commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

让 ai 帮忙多检查下吧,我刚看了下还有一些问题。我们必须要对用户负责

@chcodex

chcodex commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@jujn Fixed in d0561e9. Removed the name-matching guard so root-level branch now behaves the same as the subdirectory branch — neither validates the skill name against the location, both just write what they're given.

@chcodex

chcodex commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

让 ai 帮忙多检查下吧,我刚看了下还有一些问题。我们必须要对用户负责

ok

* @param force Whether to overwrite existing skills
* @return true if all skills were saved, false otherwise
*/
public static boolean saveSkills(Path baseDir, List<AgentSkill> skills, boolean force) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root-level force=true save path is still destructive. When baseDir/SKILL.md exists, this branch walks baseDir and deletes every child before writing the new skill. For a single-skill repository, baseDir is also the repository root, so this can delete unrelated files, or any file that is not owned by the skill.

@chcodex chcodex Jul 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn The specification clearly states: a skill is a directory that must contain at least SKILL.md, optionally includes standard subdirectories such as scripts/, references/, assets/, as well as any other files or directories. In other words, everything under the skill directory belongs to that skill — there is no distinction between "skill files vs. user-irrelevant files." The entire directory serves as the carrier of the skill, making it difficult to determine whether a particular file should or should not belong to the skill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn Do you have any opinions?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn The specification clearly states: a skill is a directory that must contain at least SKILL.md, optionally includes standard subdirectories such as scripts/, references/, assets/, as well as any other files or directories. In other words, everything under the skill directory belongs to that skill — there is no distinction between "skill files vs. user-irrelevant files." The entire directory serves as the carrier of the skill, making it difficult to determine whether a particular file should or should not belong to the skill.

I respect your opinion. But let me remind you: you never know what users will do locally

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn Can I proceed with the previously discussed approach of removing the root directory? This shouldn’t break any existing code—after all, single-skill support inside Git repositories isn’t implemented yet. If this works for you, I’ll submit the code.

* @param force Whether to overwrite existing skills
* @return true if all skills were saved, false otherwise
*/
public static boolean saveSkills(Path baseDir, List<AgentSkill> skills, boolean force) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saveSkills() still accepts multiple skills for a root-level repository, but a root-level repository can only expose one skill. With force=true, the loop will overwrite baseDir/SKILL.md once per input skill and return success for the whole list, while only the last skill remains visible through getAllSkills()/getSkill(). That makes the return value misleading and silently drops earlier saved skills.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn Strict validation + throw exception: when the root directory scenario occurs and skills.size() > 1, directly throw an IllegalArgumentException("Root-level skill repository can only contain one skill"). This is the cleanest approach and is consistent with the style of loadSkill/AgentSkill constructors throwing exceptions for illegal parameters. Does this seem reasonable?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jujn Strict validation + throw exception: when the root directory scenario occurs and skills.size() > 1, directly throw an IllegalArgumentException("Root-level skill repository can only contain one skill"). This is the cleanest approach and is consistent with the style of loadSkill/AgentSkill constructors throwing exceptions for illegal parameters. Does this seem reasonable?

It looks fine

@chcodex

chcodex commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@chickenlj @jujn Single-directory skills (where baseDir itself serves as a skill repository) are a widely used and essential scenario. Could you please share your thoughts on how we should proceed with this PR? Any guidance on further modifications would be greatly appreciated.

@oss-maintainer oss-maintainer left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Lets baseDir itself be a single skill directory (contains SKILL.md) instead of a container of skill subdirectories, across getAllSkillNames, getAllSkills, loadSkill, skillExists, saveSkills and deleteSkill, plus 14 new tests. The read side is careful and the two defects raised in the earlier review thread are genuinely fixed — findSkillDirectoryByName now short-circuits (SkillFileSystemHelper.java:538-545) so a root skill can't be shadowed by subdirectories, and deleteSkill deletes only SKILL.md (:349). @jujn's ask of "let AI check it once more, there are still some problems" is fair: the write side is where the remaining problems are.

Two data-integrity problems stand out (this review is submitted as a comment, not a formal changes-requested — the review state is @jujn's to decide):

  • [Critical] With force=true, the root branch deletes every entry under baseDir, not the previous skill's files (:256-270). baseDir is caller-supplied — a checked-out repo, a mounted workspace, a directory holding READMEs, .git or other skills' subdirectories — and all of it is gone before SKILL.md is rewritten. The container branch is much narrower: it deletes only validateAndResolvePath(baseDir, skillName). A mid-walk Files.delete failure also throws out of the forEach, leaving the directory half-emptied with nothing written back.
  • [Critical] The root branch never uses skill.getName() and never calls validateAndResolvePath, so the mode check (hasSkillFile(baseDir)) is re-evaluated per skill inside the loop: saveSkills(rootDir, List.of(a, b), true) writes a, then iteration b wipes a's SKILL.md and resources and writes itself, and allSaved still returns true because both iterations incremented saveCount. With force=false the same call silently saves one of two and returns false. A root-mode repository can hold exactly one skill, so the call needs a size/name guard rather than an implicit last-writer-wins.

Also flagged, inline: resource keys are still resolved with skillDir.resolve(entry.getKey()) and no containment check (:300), which matters more now that skillDir is the user's baseDir; the mode is inferred from the filesystem rather than configured, so a stray SKILL.md at the root of an existing container repository hides every sub-skill with no warning, and the two code paths use different predicates (hasSkillFile — a Files.walk(dir, 1) that also matches a directory named SKILL.md — vs Files.exists); FileSystemSkillRepository's new branch copies ~35 lines of the cache body, returns before skillCache.keySet().retainAll(seenDirs) (:253) so container-mode snapshots stop being pruned while root mode is active, and turns one bad root SKILL.md into an empty repository instead of skipping just that skill.

Suggested shape: resolve the mode once per operation behind an explicit singleSkillDirectory opt-in (or auto-detect only when no subdirectory contains a SKILL.md, and warn when both exist), share one isRootSkillDir(Path) predicate everywhere, scope the force cleanup to the previous skill's SKILL.md + its recorded resource keys, reject root-mode saves of more than one skill or a name mismatch, and extract the mtime+size cache lookup so the two branches cannot drift. The new tests are a good base — the three I'd add first are saveSkills(root, List.of(a, b), true), a mixed root+sub layout, and a .. resource key.

CLA is signed and CI is green; mergeable_state is blocked pending maintainer review. No merge action taken.


Automated review by github-manager-bot

Path skillDir;
Path skillFile;
// Root-level skill: baseDir itself contains SKILL.md
if (hasSkillFile(baseDir)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mode is re-decided inside the for (AgentSkill skill : skills) loop. When baseDir itself is the skill, every iteration resolves to the same baseDir/SKILL.md, so a batch save destroys all but the last skill:

Path root = ...;                       // root/SKILL.md exists (name = "A")
saveSkills(root, List.of(skillA, skillB), true);
// iter A: hasSkillFile(root) -> skillFile exists -> walk root, delete everything -> write A
// iter B: hasSkillFile(root) -> skillFile exists -> walk root, delete everything (incl. A)
//         -> write B
// returns allSaved == true; A's SKILL.md and resources are gone silently

With force=false the second skill hits continue at line 250, so saveCount != size and the method returns false — the first skill was still written, and the caller cannot tell which one failed.

Since a root-level repository can hold exactly one skill by definition, the guard belongs above the loop: if hasSkillFile(baseDir) and skills.size() > 1, throw IllegalArgumentException (or fall back to the subdirectory layout) instead of letting iterations overwrite each other.

continue;
} else {
logger.info("Overwriting existing root skill: {}", skillName);
// Delete all contents except baseDir itself

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force=true in the root branch deletes the entire content of baseDir, not the files this skill owns:

try (Stream<Path> paths = Files.walk(skillDir)) {          // skillDir == baseDir here
    paths.sorted(Comparator.reverseOrder())
         .filter(path -> !path.equals(skillDir))
         .forEach(path -> Files.delete(path));
}

baseDir is supplied by the embedding application — a skills directory under a user's workspace, a mounted repo root, a directory someone also keeps READMEs, dotfiles or an existing sub/SKILL.md in. The subdirectory branch is scoped to validateAndResolvePath(baseDir, skillName) and only ever deletes that one skill folder; the root branch has no such bound. If a Files.delete fails partway (permission, read-only file), the RuntimeException at line 262 leaves baseDir half-emptied, and the caller has no way to recover.

Could the cleanup be limited to what the previous root skill actually owned — its SKILL.md plus the resource keys recorded for that skill (mirroring SkillFileSystemHelper.loadResources) — with a hard refusal to delete any path outside that set? And a log line per deleted path so a half-emptied directory is diagnosable after the fact.

skillDir = baseDir.toAbsolutePath().normalize();
skillFile = skillDir.resolve(SKILL_FILE_NAME);
if (Files.exists(skillFile)) {
if (!force) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root branch never validates or even uses skillName, which drops two guarantees the subdirectory branch relies on:

  • validateAndResolvePath (line 383) normalizes the name and rejects .. escapes. Nothing equivalent runs here, so the write target is unconditional.
  • The name is not compared with the existing root skill's name. Saving a skill called other into a repository whose root SKILL.md is named A overwrites A's content; the file's front matter then says other, getAllSkillNames returns ["other"], and every consumer that cached A (skill caches, sub-agent skill references) silently resolves to different content. loadSkill is strict about this exact mismatch — testLoadSkill_RootLevelSkillNameMismatch asserts IllegalArgumentException — so saveSkills being permissive is inconsistent with the read path.

Comparing skillName with readSkillName(baseDir) and rejecting a mismatch (or writing the skill into a subdirectory instead) would line the two paths up.

*/
public static List<String> getAllSkillNames(Path baseDir) {
// If baseDir itself is a skill directory, return only that skill
if (hasSkillFile(baseDir)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root vs container mode is inferred from hasSkillFile(baseDir) on every call, and hasSkillFile (line 407) is Files.walk(dir, 1).anyMatch(name equals "SKILL.md") — it also returns true for a directory named SKILL.md, and it costs a directory listing instead of one Files.isRegularFile(baseDir.resolve("SKILL.md")) stat. FileSystemSkillRepository.getAllSkills() uses Files.exists(baseDir/SKILL.md) for the same decision, so the two implementations infer the mode slightly differently.

Two consequences of inferring rather than configuring:

  1. An existing container-mode repository that gains a SKILL.md at its root (easy to do by accident — a saved skill, a doc file) instantly hides all of its sub-skills, with no warning.
  2. After deleteSkill removes the root SKILL.md, the mode flips back to container, and any leftover resource subdirectory that happens to contain a SKILL.md now surfaces as a skill — i.e. deleted skill data can come back into getAllSkills().

A singleSkillDirectory flag (explicit opt-in on the repository/helper entry points) plus one shared isRootSkillDir(Path) predicate would make the mode deterministic, cheaper, and consistent with FileSystemSkillRepository. The call count also matters in the save path: hasSkillFile(baseDir) runs once per skill in the list.

Map<String, String> resources = skill.getResources();
for (Map.Entry<String, String> entry : resources.entrySet()) {
Path resourceFile = skillDir.resolve(entry.getKey());
Files.createDirectories(resourceFile.getParent());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource keys are still resolved without containment checks — skillDir.resolve(entry.getKey()) accepts .. and absolute paths, so Map.of("../../../../tmp/x", "...") writes outside the skill directory. The same guard the name path already has would fix it:

Path abs = skillDir.toAbsolutePath().normalize();
Path target = abs.resolve(entry.getKey()).normalize();
if (!target.startsWith(abs)) {
    throw new IllegalArgumentException("resource path escapes skill directory: " + entry.getKey());
}

This pre-dates the PR, but root mode changes the blast radius: skillDir is now the caller's baseDir rather than a per-skill folder, so an escaping key writes next to baseDir instead of next to one skill inside it. Since skills can be loaded from a git repository or an archive (this PR's stated use case is exactly "a skill repo checked out as baseDir"), the resource map is not trusted input.

Small related nit on the same hunk: Files.createDirectories(resourceFile.getParent()) runs before the new content != null check, so a null-content resource now creates an empty directory and writes nothing. Moving the createDirectories inside the null guard keeps the tree clean.

@Override
public List<AgentSkill> getAllSkills() {
// If baseDir itself is a skill directory, return only that skill
Path baseDirKey = baseDir.toAbsolutePath().normalize();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root branch is ~35 lines copied from the container loop below (stat → mtime+size compare → loadSkillFromDirectory(..., !lazy) → skillCache.put), and it returns before skillCache.keySet().retainAll(seenDirs) at line 253, so root and container mode handle cache eviction differently. Concretely: a repository that was in container mode accumulates per-skill snapshots, and once baseDir gains a root SKILL.md those entries are never pruned again, because every subsequent call takes this early return.

Worth also deciding what this branch is meant to return when the root file fails to parse: the container branch skips one bad skill and keeps the others, while this branch yields List.of() for the whole repository — a defensible choice, but it is the only place a single malformed SKILL.md blanks the repository, so it should be stated in the javadoc.

Extracting the shared body into private Optional<AgentSkill> loadWithCache(Path dir) used by both branches would remove the copy-paste and the eviction asymmetry in one go.

@oss-maintainer

Copy link
Copy Markdown
Collaborator

Small correction on the review above: it was submitted as a comment, not a formal changes requested review, so my two [Critical] items shouldn't be read as a blocking review state from this account — the review decision stays with the maintainers (@jujn already has the PR in changes-requested). Flagging them as blocking issues in my analysis is what I meant: the force=true wipe scope at SkillFileSystemHelper.java:256 and the per-iteration mode re-detection at :247 are the two I'd want answered before merge.


Automated note by github-manager-bot

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/tool Tool, skill, RAG abstractions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 单技能仓库(无 skills 子目录)无法加载技能

4 participants