Class IDE
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
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
-
Field Summary
Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
ConstructorsConstructorDescriptionIDE()Constructs a new IDE toolkit and registers its child context providers. -
Method Summary
Modifier and TypeMethodDescriptionprivate static com.intellij.openapi.project.ProjectfindHostProject(com.intellij.openapi.vfs.VirtualFile file) Resolves the open project whose content roots contain the given file, falling back to the first open project.Gets a list of system instruction strings provided by this context provider.Produces a Markdown table of every registered tool window across all open projects, with visibility/active state.voidmonitorLogs(String grepPattern, Integer tailLines) Tails the IDE log (idea.log) into the session context, with optional grep filtering, by registering it as a tailed text resource.static StringReveals and selects a file or folder in the Project tool window.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, initialize, isEffectivelyProviding, postActivate, rebindMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, error, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, isProviding, populateMessage, setParentProvider, setProviding
-
Constructor Details
-
IDE
public IDE()Constructs a new IDE toolkit and registers its child context providers.Registers the
OpenToolWindowsContextProviderso the ASI receives a live snapshot of the IDE's windowing system on every turn.
-
-
Method Details
-
getSystemInstructions
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
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), ornull.tailLines- number of trailing lines to include (defaults to 100).- Throws:
AgiToolException- if the log file cannot be located.
-
selectIn
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
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
nullif no projects are open.
-

