Skip to content

fix: ClasspathSkillRepository loads skill failed in multi-module java project#837

Merged
LearningGp merged 8 commits intoagentscope-ai:mainfrom
tcsp:fix/classhpath_skill_load
Mar 4, 2026
Merged

fix: ClasspathSkillRepository loads skill failed in multi-module java project#837
LearningGp merged 8 commits intoagentscope-ai:mainfrom
tcsp:fix/classhpath_skill_load

Conversation

@tcsp
Copy link
Contributor

@tcsp tcsp commented Feb 27, 2026

AgentScope-Java Version

1.0.9

Description

fix the bug issue: #834

Checklist

Please check the following items before code is ready to be reviewed.

  • 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

@tcsp tcsp requested a review from a team February 27, 2026 04:21
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug affecting skill loading in multi-module Java projects. The core change involves refining how resource paths are extracted from JAR file URIs, ensuring that the ClasspathSkillRepository can correctly locate and load skills regardless of the project's module structure. This enhancement improves the reliability of skill discovery within packaged applications.

Highlights

  • Skill Loading Fix: Addressed a bug where ClasspathSkillRepository failed to load skills in multi-module Java projects. The issue stemmed from incorrect parsing of resource paths within JAR files.
  • Robust URI Parsing: Improved the logic for extracting the actual resource path from JAR URIs by switching from split("!")[1] to substring(lastIndexOf("!") + 1), making the path resolution more robust for complex JAR structures.
Changelog
  • agentscope-core/src/main/java/io/agentscope/core/skill/repository/ClasspathSkillRepository.java
    • Refactored the logic for extracting the actual resource path from JAR URIs to correctly handle paths in multi-module projects.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug in ClasspathSkillRepository that caused skill loading to fail in multi-module Java projects with nested JARs. The change correctly extracts the resource path from complex JAR URIs by using lastIndexOf('!') instead of split('!'). This is a robust fix for the issue. I have a minor suggestion to improve the conciseness of the new code.

Comment on lines +142 to +144
String schemeSpecificUriPath = uri.getSchemeSpecificPart();
String actualResourcePath =
schemeSpecificUriPath.substring(schemeSpecificUriPath.lastIndexOf("!") + 1);

Choose a reason for hiding this comment

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

medium

While the logic is correct, this can be made more concise for better readability. Also, using lastIndexOf('!') with a character literal is slightly more efficient than using a string.

Suggested change
String schemeSpecificUriPath = uri.getSchemeSpecificPart();
String actualResourcePath =
schemeSpecificUriPath.substring(schemeSpecificUriPath.lastIndexOf("!") + 1);
String schemeSpecificPart = uri.getSchemeSpecificPart();
String actualResourcePath = schemeSpecificPart.substring(schemeSpecificPart.lastIndexOf('!') + 1);

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fang-tech
Copy link
Contributor

LGTM, plz add more ut for this edge case

@tcsp
Copy link
Contributor Author

tcsp commented Feb 28, 2026

ok, i'll commit later.

@tcsp
Copy link
Contributor Author

tcsp commented Mar 1, 2026

I'v added the ut for this edge case.

Copy link
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

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

LGTM

@LearningGp LearningGp merged commit 84f1354 into agentscope-ai:main Mar 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants