From 3adb04cb6e3bace6c2e8bfba326c7661ef977d54 Mon Sep 17 00:00:00 2001 From: superjvjkdf Date: Thu, 26 Mar 2026 16:03:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(SkillFileSystemHelper):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=A6=86=E7=9B=96=E8=A1=8C=E4=B8=BA=E4=B8=BA=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当技能目录已存在且强制覆盖标志为false时,现在将跳过该技能而不是返回失败状态。这样可以允许批量处理多个技能而不会因为单个技能的存在而导致整个流程中断。 --- .../io/agentscope/core/skill/util/SkillFileSystemHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java b/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java index 614d1866b..5e7d28d26 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java +++ b/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java @@ -182,7 +182,7 @@ public static boolean saveSkills(Path baseDir, List skills, boolean if (!force) { logger.info( "Skill directory already exists and force=false: {}", skillName); - return false; + continue; // Skip to the next skill if force=false } else { logger.info("Overwriting existing skill directory: {}", skillName); deleteDirectory(skillDir); From 9b89ba6f4edde22feccc2fe0baaabf355131c712 Mon Sep 17 00:00:00 2001 From: superjvjkdf Date: Thu, 26 Mar 2026 16:52:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(SkillFileSystemHelper):=20fix=E5=8D=95?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/skill/util/SkillFileSystemHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java b/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java index 5e7d28d26..39c84ac80 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java +++ b/agentscope-core/src/main/java/io/agentscope/core/skill/util/SkillFileSystemHelper.java @@ -173,6 +173,8 @@ public static boolean saveSkills(Path baseDir, List skills, boolean return false; } + int size = skills.size(); + int saveCount = 0; try { for (AgentSkill skill : skills) { String skillName = skill.getName(); @@ -215,10 +217,15 @@ public static boolean saveSkills(Path baseDir, List skills, boolean } } + saveCount++; logger.info("Successfully saved skill: {}", skillName); } + boolean allSaved = (size == saveCount); + if (!allSaved) { + logger.warn("Not all skills were saved. Saved {} of {}", saveCount, size); + } - return true; + return allSaved; } catch (IOException e) { logger.error("Failed to save skills", e); throw new RuntimeException("Failed to save skills", e); From 9a89789c77adeec6615724ddd72a65537e527460 Mon Sep 17 00:00:00 2001 From: superjvjkdf Date: Mon, 30 Mar 2026 20:18:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?test(SkillFileSystemHelper):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E6=8A=80=E8=83=BD=E4=BF=9D=E5=AD=98=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skill/util/SkillFileSystemHelperTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java b/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java index 10948c72c..8198904dc 100644 --- a/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java +++ b/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java @@ -152,6 +152,70 @@ void testSaveSkills_ExistingSkill_ForceDisabled() { assertEquals("Test Skill", loaded.getDescription()); } + @Test + @DisplayName("Should save zero skills and leave file contents unchanged when all exist and force is false") + void testSaveSkills_AllExistingSkills_ForceDisabled_NoSkillsSaved() throws IOException { + String originalTestSkill = + Files.readString( + skillsBaseDir.resolve("test-skill/SKILL.md"), StandardCharsets.UTF_8); + String originalAnotherSkill = + Files.readString( + skillsBaseDir.resolve("another-skill/SKILL.md"), StandardCharsets.UTF_8); + + AgentSkill skill1 = new AgentSkill("test-skill", "Updated Test", "Updated content 1", null); + AgentSkill skill2 = + new AgentSkill("another-skill", "Updated Another", "Updated content 2", null); + + boolean result = + SkillFileSystemHelper.saveSkills(skillsBaseDir, List.of(skill1, skill2), false); + + // 0 out of 2 saved — no coverage at all + assertFalse(result); + assertEquals( + originalTestSkill, + Files.readString( + skillsBaseDir.resolve("test-skill/SKILL.md"), StandardCharsets.UTF_8), + "test-skill SKILL.md must not be modified"); + assertEquals( + originalAnotherSkill, + Files.readString( + skillsBaseDir.resolve("another-skill/SKILL.md"), StandardCharsets.UTF_8), + "another-skill SKILL.md must not be modified"); + } + + @Test + @DisplayName("Should save new skills while leaving existing ones unchanged when force is false") + void testSaveSkills_MixedSkills_ForceDisabled_NewSavedExistingUnchanged() throws IOException { + String originalContent = + Files.readString( + skillsBaseDir.resolve("test-skill/SKILL.md"), StandardCharsets.UTF_8); + + AgentSkill existingSkill = + new AgentSkill("test-skill", "Updated Description", "Updated content", null); + AgentSkill newSkill = new AgentSkill("brand-new-skill", "Brand New", "New content", null); + + boolean result = + SkillFileSystemHelper.saveSkills( + skillsBaseDir, List.of(existingSkill, newSkill), false); + + // 1 out of 2 saved — not all saved + assertFalse(result); + + // existing skill must not be modified + assertEquals( + originalContent, + Files.readString( + skillsBaseDir.resolve("test-skill/SKILL.md"), StandardCharsets.UTF_8), + "test-skill SKILL.md must not be modified"); + + // new skill must be saved correctly + AgentSkill loaded = + SkillFileSystemHelper.loadSkill(skillsBaseDir, "brand-new-skill", "source"); + assertEquals("brand-new-skill", loaded.getName()); + assertEquals("Brand New", loaded.getDescription()); + assertEquals("New content", loaded.getSkillContent()); + } + @Test @DisplayName("Should overwrite when skill exists and force is true") void testSaveSkills_ExistingSkill_ForceEnabled() { From 601bcd87a3ec02a89a277e60abd1ae87ec1a8b00 Mon Sep 17 00:00:00 2001 From: superjvjkdf Date: Mon, 30 Mar 2026 20:25:09 +0800 Subject: [PATCH 4/4] test(SkillFileSystemHelper):formate code --- .../agentscope/core/skill/util/SkillFileSystemHelperTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java b/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java index 8198904dc..2282c367e 100644 --- a/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java +++ b/agentscope-core/src/test/java/io/agentscope/core/skill/util/SkillFileSystemHelperTest.java @@ -153,7 +153,9 @@ void testSaveSkills_ExistingSkill_ForceDisabled() { } @Test - @DisplayName("Should save zero skills and leave file contents unchanged when all exist and force is false") + @DisplayName( + "Should save zero skills and leave file contents unchanged when all exist and force is" + + " false") void testSaveSkills_AllExistingSkills_ForceDisabled_NoSkillsSaved() throws IOException { String originalTestSkill = Files.readString(