Class ClassFunctionalTools
java.lang.Object
org.machanism.machai.gw.maven.tools.ClassFunctionalTools
- All Implemented Interfaces:
org.machanism.machai.ai.tools.FunctionTools
public class ClassFunctionalTools
extends Object
implements org.machanism.machai.ai.tools.FunctionTools
Provides function-tool integrations for discovering Java classes and reading
reflective metadata from the classpath of one or more Maven projects.
Instances maintain a cache of ClassInfoHolder objects keyed by Maven
project base directory, allowing tool invocations to resolve classes relative
to the current working project.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty instance.ClassFunctionalTools(org.apache.maven.project.MavenProject project) Creates a new instance backed by the supplied Maven project's classpath. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTools(org.machanism.machai.ai.provider.Genai provider) Registers class-related tools with the given AI provider.Finds fully qualified class names whose simple names match the supplied regular expression.getClassInfo(Object... params) Returns reflective information for the specified class.voidscanProjectClasses(org.apache.maven.project.MavenProject project) Registers a project by scanning and caching class metadata for its base directory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.machanism.machai.ai.tools.FunctionTools
replace, setConfigurator
-
Constructor Details
-
ClassFunctionalTools
public ClassFunctionalTools(org.apache.maven.project.MavenProject project) Creates a new instance backed by the supplied Maven project's classpath.- Parameters:
project- the Maven project used to resolve classpath and output directories
-
ClassFunctionalTools
public ClassFunctionalTools()Creates an empty instance. Projects must be registered later throughscanProjectClasses(MavenProject)before tool invocations can resolve class information.
-
-
Method Details
-
scanProjectClasses
public void scanProjectClasses(org.apache.maven.project.MavenProject project) Registers a project by scanning and caching class metadata for its base directory.- Parameters:
project- the Maven project to register
-
applyTools
public void applyTools(org.machanism.machai.ai.provider.Genai provider) Registers class-related tools with the given AI provider.- Specified by:
applyToolsin interfaceorg.machanism.machai.ai.tools.FunctionTools- Parameters:
provider- the provider that receives the tool registrations
-
findClass
Finds fully qualified class names whose simple names match the supplied regular expression.- Parameters:
params- tool invocation arguments; the first argument is expected to be aHashMapcontaining aclassNameproperty and the second aFilerepresenting the current working directory- Returns:
- a comma-separated list of matching class names,
Class not found.when no matches are available, or the unsupported-project message when no project context is registered
-
getClassInfo
Returns reflective information for the specified class.The generated output may include modifiers, superclass, interfaces, non-private fields, constructors, non-private methods, annotations, class path, and dependency artifact coordinates.
- Parameters:
params- tool invocation arguments; the first argument is expected to be aHashMapcontaining aclassNameproperty and the second aFilerepresenting the current working directory- Returns:
- a HashMap describing the requested class or containing an
errorproperty when the class or project context cannot be resolved
-