Class FilePromptAssist

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

public final class FilePromptAssist extends Object implements PromptAssist
PromptAssist that exposes the project's file-resource tree through the @-popup. Folders render as PromptAssist.Option.DrillIn rows; files whose resolved content type is textual render as PromptAssist.Option.Insert rows whose body carries the file's content verbatim. Binary files (images, PDFs, archives, application/octet-stream) are hidden from the popup so the autocomplete only surfaces references whose bodies are useful as model context.

Eligibility. A file's content type is resolved the same way the File Resource editor resolves it — the stored content-type attribute, else an extension guess, else the binary-safe default — and tested with FileResourceUtil.isTextContentType(String), so the popup and the editor agree on which files are text.

Query format. The query string is a file-resource path with / as the separator: empty browses the workspace root, "foo/" browses inside foo, "foo/bar" browses foo filtering children by name-prefix bar.

Literal contract. Inserts produce tokens shaped @file:path/to/file.ext. The framework builds the @file: prefix from id(); the assist supplies only the /-separated path within the project's file-resource tree. The @file: prefix keeps these tokens distinct from other assists' and from anything typed by hand, and names the namespace the agent reads them under — file references carry a plain text body, so nothing downcasts them.

Snapshot semantics. Each PromptAssist.Option.Insert's supplier closes over the file's bytes captured at the moment the user selected the row — not a live re-read. A file that is renamed, deleted, or edited between selection and submit will still surface the snapshot the user originally pointed at. This matches the documented prompt-assist contract: the supplier runs on the EDT at submit time and must not block.

  • Constructor Details

  • Method Details

    • id

      public String id()
      Specified by:
      id in interface PromptAssist
      Returns:
      the machine identifier owning this assist's @<id>: token namespace. Lowercase [a-z0-9-]+, short (e.g. "tag", "opc").
      See Also:
    • label

      public String label()
      Specified by:
      label in interface PromptAssist
      Returns:
      a short friendly label for this assist to show in the UI.
    • 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.
      Specified by:
      agentContext in interface PromptAssist
      Returns:
      the Markdown fragment, or Optional.empty() when the assist has nothing to contribute (e.g. unit-test stubs).
    • options

      Description copied from interface: PromptAssist
      Fetch the rows to show for query.
      Specified by:
      options in interface PromptAssist
      Parameters:
      query - the text the user has typed past the trigger character, or the PromptAssist.Option.DrillIn.nextQuery of a row the user just selected. Empty when the user has just typed the trigger and has not yet typed anything else.
      Returns:
      the rows to render. The framework discards stale results silently, so an implementation that completes after a newer query has been issued does not need to special-case the race.