Class ActProcessor


public class ActProcessor extends AIFileProcessor
Processor that runs Ghostwriter in "Act" mode.

An act is a predefined prompt template stored as a .toml file. Act files can be loaded from bundled classpath resources (under /acts) and/or from a user-specified directory.

Act format

Act files are parsed as TOML and support a small set of keys:

  • instructions: provider system instructions
  • inputs: a prompt template; String.format(String, Object...) is used to inject user-provided prompt text
  • gw.threads: enables module multi-threading
  • gw.excludes: comma-separated scan exclusions
  • gw.nonRecursive: disables module recursion
  • any other key is forwarded to the underlying configuration

Execution

When executing an act, Ghostwriter will scan matching files and run the act's composed prompt against each file. Acts may also declare a prologue and/or epilogue list of related acts to run before/after the main scan.

  • Field Details

    • ACTS_BASENAME_PREFIX

      public static final String ACTS_BASENAME_PREFIX
      Classpath base directory for built-in act definitions.
      See Also:
  • Constructor Details

    • ActProcessor

      public ActProcessor(File projectDir, Configurator configurator, String genai)
      Creates an act processor.
      Parameters:
      projectDir - root directory used as a base for relative paths
      configurator - configuration source
      genai - provider key/name (including model)
  • Method Details

    • setDefaultPrompt

      public void setDefaultPrompt(String act)
      Loads an act definition and applies it as the current execution defaults.

      The act argument supports the form <name> [prompt], where the optional prompt portion is inserted into the act's inputs template. If no prompt is provided, AIFileProcessor.getDefaultPrompt() is used.

      Overrides:
      setDefaultPrompt in class AIFileProcessor
      Parameters:
      act - act name plus optional prompt text
    • loadAct

      public static void loadAct(String name, Map<String,Object> properties, String actsLocation) throws IOException
      Loads an act definition into the provided map, supporting inheritance via the basedOn property.

      This method attempts to load the specified act from both a user-defined directory (custom act) and the built-in classpath resources. If both are present, the custom act wraps (overrides) the built-in act, allowing for extension or modification of base act behavior.

      If the act specifies a basedOn property, the parent act is loaded first (recursively), and its properties are merged. The child act's properties then override or extend the parent.

      Parameters:
      name - the name of the act to load (without the .toml extension)
      properties - destination map to populate with parsed act properties
      actsLocation - optional directory containing user-defined (custom) act files; may be null
      Throws:
      IOException - if reading act content fails
      IllegalArgumentException - if the specified act cannot be found in either location
    • tryLoadActFromClasspath

      public static org.tomlj.TomlParseResult tryLoadActFromClasspath(Map<String,Object> properties, String name) throws IOException
      Attempts to load an act definition from classpath resources.
      Parameters:
      properties - destination for parsed dotted properties
      name - act name (without .toml)
      Returns:
      parsed TOML result, or null when the act is not found
      Throws:
      IOException - if the resource cannot be read
    • tryLoadActFromDirectory

      public static org.tomlj.TomlParseResult tryLoadActFromDirectory(Map<String,Object> properties, String name, String actsLocation) throws IOException
      Attempts to load an act definition from a user-defined directory.
      Parameters:
      properties - destination for parsed dotted properties
      name - act name (without .toml)
      actsLocation - directory containing *.toml act files (may be null)
      Returns:
      parsed TOML result, or null when not found
      Throws:
      IOException - if the file cannot be read
    • setActData

      static void setActData(Map<String,Object> properties, org.tomlj.TomlParseResult toml)
      Copies dotted-string keys from the TOML parse result into properties.

      If a key already exists in properties, the new value is formatted into the old value using String.format(String, Object...).

      Parameters:
      properties - properties destination
      toml - TOML parse result
    • applyActData

      void applyActData(Map<String,Object> properties)
      Applies loaded act data to this processor's configuration and runtime settings.
      Parameters:
      properties - properties loaded from TOML acts
    • setActsLocation

      public void setActsLocation(String actsLocation)
      Sets the directory used for loading external act definition files.
      Parameters:
      actsLocation - directory containing *.toml act files
    • processParentFiles

      protected void processParentFiles(ProjectLayout projectLayout) throws IOException
      Processes non-module files and directories directly under the project directory.
      Overrides:
      processParentFiles in class AbstractFileProcessor
      Parameters:
      projectLayout - project layout
      Throws:
      IOException - if file reading fails
    • processFile

      protected void processFile(ProjectLayout projectLayout, File file) throws IOException
      Executes the act against a single file.
      Overrides:
      processFile in class AbstractFileProcessor
      Parameters:
      projectLayout - project layout
      file - file to process
      Throws:
      IOException - if provider execution fails