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

    Constructors
    Constructor
    Description
    Creates 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 Type
    Method
    Description
    void
    applyTools(org.machanism.machai.ai.provider.Genai provider)
    Registers class-related tools with the given AI provider.
    findClass(Object... params)
    Finds fully qualified class names whose simple names match the supplied regular expression.
    getClassInfo(Object... params)
    Returns reflective information for the specified class.
    void
    scanProjectClasses(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, wait

    Methods 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 through scanProjectClasses(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:
      applyTools in interface org.machanism.machai.ai.tools.FunctionTools
      Parameters:
      provider - the provider that receives the tool registrations
    • findClass

      public String findClass(Object... params)
      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 a HashMap containing a className property and the second a File representing 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

      public HashMap<String,Object> getClassInfo(Object... params)
      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 a HashMap containing a className property and the second a File representing the current working directory
      Returns:
      a HashMap describing the requested class or containing an error property when the class or project context cannot be resolved