Class IDE

All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable

public class IDE extends AnahataToolkit
Provides tools for interacting with the IntelliJ IDEA IDE itself: tailing the IDE log, revealing files in the Project view, and reporting the state of the tool-window system.

This is the IntelliJ port of the NetBeans IDE toolkit. Log tailing reuses the shared core resource pipeline (PathHandle + TextView + TextViewportSettings) unchanged. The NetBeans TopComponent/Output-window crawl is replaced by the platform ToolWindowManager, exposed both as a tool and as the child OpenToolWindowsContextProvider.

Author:
anahata
  • Constructor Details

    • IDE

      public IDE()
      Constructs a new IDE toolkit and registers its child context providers.

      Registers the OpenToolWindowsContextProvider so the ASI receives a live snapshot of the IDE's windowing system on every turn.

  • Method Details

    • getSystemInstructions

      public List<String> getSystemInstructions() throws Exception
      Gets a list of system instruction strings provided by this context provider. These are typically prepended to the conversation as high-level guidance.

      Explains, host-specifically, that in-context resources reflect on-disk state (not unsaved editor buffers) and points the model at the Editor/ToolWindows providers for live editor state.

      Returns:
      A list of system instruction strings.
      Throws:
      Exception - if an error occurs during instruction generation.
    • monitorLogs

      public void monitorLogs(String grepPattern, Integer tailLines) throws AgiToolException
      Tails the IDE log (idea.log) into the session context, with optional grep filtering, by registering it as a tailed text resource.
      Parameters:
      grepPattern - optional regex to filter log lines (e.g. ERROR), or null.
      tailLines - number of trailing lines to include (defaults to 100).
      Throws:
      AgiToolException - if the log file cannot be located.
    • selectIn

      public static String selectIn(String path) throws AgiToolException
      Reveals and selects a file or folder in the Project tool window.

      Maps the NetBeans "Select in Projects" behaviour. Runs on the EDT because it drives the Project view UI.

      Parameters:
      path - the absolute path of the file or folder to reveal.
      Returns:
      a confirmation message.
      Throws:
      AgiToolException - if the path cannot be resolved or hosted by an open project.
    • getToolWindowsMarkdown

      public String getToolWindowsMarkdown()
      Produces a Markdown table of every registered tool window across all open projects, with visibility/active state.
      Returns:
      a Markdown table, or a message when nothing is open.
    • findHostProject

      private static com.intellij.openapi.project.Project findHostProject(com.intellij.openapi.vfs.VirtualFile file)
      Resolves the open project whose content roots contain the given file, falling back to the first open project.
      Parameters:
      file - the file to host.
      Returns:
      a hosting project, or null if no projects are open.