From b0f80d6a6dc911d8f502e11c8486c10c5b6e4447 Mon Sep 17 00:00:00 2001 From: fang-tech Date: Tue, 30 Dec 2025 20:55:36 +0800 Subject: [PATCH] remove empty directory validation --- .../repository/FileSystemSkillRepository.java | 12 --------- .../FileSystemSkillRepositoryTest.java | 26 +++++++++++++++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/skill/repository/FileSystemSkillRepository.java b/agentscope-core/src/main/java/io/agentscope/core/skill/repository/FileSystemSkillRepository.java index b7e5b5707..757e106a0 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/skill/repository/FileSystemSkillRepository.java +++ b/agentscope-core/src/main/java/io/agentscope/core/skill/repository/FileSystemSkillRepository.java @@ -97,18 +97,6 @@ public FileSystemSkillRepository(Path baseDir, boolean writeable) { "Base directory is not a directory: " + this.baseDir); } - // Validate directory is not empty (must contain at least one subdirectory) - try (Stream entries = Files.list(this.baseDir)) { - boolean hasSubdirectory = entries.anyMatch(Files::isDirectory); - if (!hasSubdirectory) { - throw new IllegalArgumentException( - "Base directory is empty (no skill subdirectories found): " + this.baseDir); - } - } catch (IOException e) { - throw new IllegalArgumentException( - "Failed to validate base directory: " + this.baseDir, e); - } - logger.info("FileSystemSkillRepository initialized with base directory: {}", this.baseDir); } diff --git a/agentscope-core/src/test/java/io/agentscope/core/skill/repository/FileSystemSkillRepositoryTest.java b/agentscope-core/src/test/java/io/agentscope/core/skill/repository/FileSystemSkillRepositoryTest.java index b8243214f..1c238f3bc 100644 --- a/agentscope-core/src/test/java/io/agentscope/core/skill/repository/FileSystemSkillRepositoryTest.java +++ b/agentscope-core/src/test/java/io/agentscope/core/skill/repository/FileSystemSkillRepositoryTest.java @@ -103,11 +103,33 @@ void testConstructor_BaseDirIsFile() throws IOException { } @Test - @DisplayName("Should throw exception when base directory is empty") + @DisplayName("Should not throw exception when base directory is empty") void testConstructor_EmptyBaseDir() throws IOException { Path emptyDir = tempDir.resolve("empty"); Files.createDirectories(emptyDir); - assertThrows(IllegalArgumentException.class, () -> new FileSystemSkillRepository(emptyDir)); + FileSystemSkillRepository fileSystemSkillRepository = + new FileSystemSkillRepository(emptyDir); + assertNotNull(fileSystemSkillRepository); + } + + @Test + @DisplayName("Should transform relative path to absolute in constructor") + void testConstructor_RelativePath() throws IOException { + Path relativePath = Path.of("relative-skills"); + Files.createDirectories(relativePath); + + try { + FileSystemSkillRepository fileSystemSkillRepository = + new FileSystemSkillRepository(relativePath); + assertNotNull(fileSystemSkillRepository); + assertEquals( + relativePath.toAbsolutePath().normalize().toString(), + fileSystemSkillRepository.getRepositoryInfo().getLocation()); + } finally { + if (Files.exists(relativePath)) { + Files.delete(relativePath); + } + } } // ==================== getAllSkillNames Tests ====================