Class UserLibraryPromptAssist

java.lang.Object
com.inductiveautomation.ignition.designer.ai.embed.LibraryPromptAssist
com.inductiveautomation.ignition.designer.ai.embed.UserLibraryPromptAssist
All Implemented Interfaces:
PromptAssist

public final class UserLibraryPromptAssist extends LibraryPromptAssist
LibraryPromptAssist over the project's user-defined script library — the Jython modules authored under "Project Library" — letting the user drop a reference to a symbol they authored into an AI prompt. Operates on the live, parsed project scripts maintained by ScriptIndexer, so insert-row bodies reflect the current source.

Functions, classes, and module-level values render as PromptAssist.Option.Insert rows whose body carries the symbol's rendered documentation. Packages and script modules render as PromptAssist.Option.InsertOrDrillIn rows: confirming references the module as a whole — a body listing the symbols directly inside it — and expanding browses into it.

Inserts produce tokens shaped @library:<path> (e.g. @library:myUtils.helpers.calibrate, @library:myUtils.helpers), where the path is exactly the callable name; user-library symbols need no system. prefix.

  • Constructor Details

    • UserLibraryPromptAssist

      public UserLibraryPromptAssist(DesignableProject project, Supplier<Map<String, com.inductiveautomation.ignition.common.script.typing.CompletionDescriptor>> indexSupplier)
      Parameters:
      project - the project whose library resources refine drill-in labels (module vs package).
      indexSupplier - source of the parsed script index, consulted on every browse so edits surface immediately; ScriptIndexer::getIndexedScripts outside of tests.
  • Method Details

    • agentContext

      public Optional<String> agentContext()
      Description copied from interface: PromptAssist
      Self-description appended to the embedded agent's system prompt. The embed concatenates the fragments from every mounted assist into a single addendum so each provider documents its own token shape and reference-body schema in one place, decoupled from any specific agent's translation rules. Fragments are expected to be Markdown; the embed adds a heading for each assist using PromptAssist.label() and joins them with blank lines.

      The embed's framing already tells the model every token is shaped @<id>:<path> and announces this assist's @<id>: prefix in its section heading, so the fragment should not restate the generic shape. It should cover:

      • the grammar of the <path> portion, with a concrete example token;
      • the schema of the <reference token="...">body</reference> body the embed will attach when one of those tokens appears — the line names (Path:, Type:, …) the agent should look for and what they mean;
      • a one-line statement of what the reference represents semantically (so the agent can reason about it without knowing this assist exists).
      Fragments should stay host-language-agnostic — say what the reference is, not how to spell it in a particular tool's syntax. The hosting agent's own system prompt is responsible for translating the body's identifier into whatever expression/script/query syntax it speaks.
      Returns:
      the Markdown fragment, or Optional.empty() when the assist has nothing to contribute (e.g. unit-test stubs).
    • library

      protected ScriptLibrary library()
      Description copied from class: LibraryPromptAssist
      The library this assist browses. Called on every LibraryPromptAssist.options(String) invocation, off the EDT; a ScriptLibrary is a cheap fixed view, so implementations build one against their source's current state per call.
      Specified by:
      library in class LibraryPromptAssist
    • drillInDetail

      protected String drillInDetail(String path)
      Labels the row "module" when path resolves to a real script module (a non-folder library resource) and "package" when it is only a grouping folder.
      Overrides:
      drillInDetail in class LibraryPromptAssist