Skip to content

Commit b3b901d

Browse files
authored
fix(skill): remove FileSystemSkillRepository empty directory validation (#397)
## AgentScope-Java Version 1.0.5-SNAPSHOT ## Description Allow users to create a FileSystemSkillRepository based on an empty folder, and complete the usage process of "empty directory -> save skills". ## Checklist Please check the following items before code is ready to be reviewed. - [x] Code has been formatted with `mvn spotless:apply` - [x] All tests are passing (`mvn test`) - [x] Javadoc comments are complete and follow project conventions - [x] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review
1 parent 93fdfa0 commit b3b901d

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

agentscope-core/src/main/java/io/agentscope/core/skill/repository/FileSystemSkillRepository.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,6 @@ public FileSystemSkillRepository(Path baseDir, boolean writeable) {
9797
"Base directory is not a directory: " + this.baseDir);
9898
}
9999

100-
// Validate directory is not empty (must contain at least one subdirectory)
101-
try (Stream<Path> entries = Files.list(this.baseDir)) {
102-
boolean hasSubdirectory = entries.anyMatch(Files::isDirectory);
103-
if (!hasSubdirectory) {
104-
throw new IllegalArgumentException(
105-
"Base directory is empty (no skill subdirectories found): " + this.baseDir);
106-
}
107-
} catch (IOException e) {
108-
throw new IllegalArgumentException(
109-
"Failed to validate base directory: " + this.baseDir, e);
110-
}
111-
112100
logger.info("FileSystemSkillRepository initialized with base directory: {}", this.baseDir);
113101
}
114102

agentscope-core/src/test/java/io/agentscope/core/skill/repository/FileSystemSkillRepositoryTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,33 @@ void testConstructor_BaseDirIsFile() throws IOException {
103103
}
104104

105105
@Test
106-
@DisplayName("Should throw exception when base directory is empty")
106+
@DisplayName("Should not throw exception when base directory is empty")
107107
void testConstructor_EmptyBaseDir() throws IOException {
108108
Path emptyDir = tempDir.resolve("empty");
109109
Files.createDirectories(emptyDir);
110-
assertThrows(IllegalArgumentException.class, () -> new FileSystemSkillRepository(emptyDir));
110+
FileSystemSkillRepository fileSystemSkillRepository =
111+
new FileSystemSkillRepository(emptyDir);
112+
assertNotNull(fileSystemSkillRepository);
113+
}
114+
115+
@Test
116+
@DisplayName("Should transform relative path to absolute in constructor")
117+
void testConstructor_RelativePath() throws IOException {
118+
Path relativePath = Path.of("relative-skills");
119+
Files.createDirectories(relativePath);
120+
121+
try {
122+
FileSystemSkillRepository fileSystemSkillRepository =
123+
new FileSystemSkillRepository(relativePath);
124+
assertNotNull(fileSystemSkillRepository);
125+
assertEquals(
126+
relativePath.toAbsolutePath().normalize().toString(),
127+
fileSystemSkillRepository.getRepositoryInfo().getLocation());
128+
} finally {
129+
if (Files.exists(relativePath)) {
130+
Files.delete(relativePath);
131+
}
132+
}
111133
}
112134

113135
// ==================== getAllSkillNames Tests ====================

0 commit comments

Comments
 (0)