diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index ffbd532fd5..a41397a1c8 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -340,6 +340,36 @@ "text": "Monitoring Applications", "path": "studio/monitoring-applications.md" }, + { + "text": "AI Agent", + "items": [ + { + "text": "Overview", + "path": "studio/ai-agent.md", + "isIndex": true + }, + { + "text": "Configuration", + "path": "studio/ai-agent-configuration.md" + }, + { + "text": "Workflows", + "path": "studio/ai-agent-workflows.md" + }, + { + "text": "Built-in Capabilities", + "path": "studio/ai-agent-built-in-capabilities.md" + }, + { + "text": "Git Integration", + "path": "studio/ai-agent-git-integration.md" + }, + { + "text": "Coding with AI Agent", + "path": "studio/coding-with-ai-agent.md" + } + ] + }, { "text": "Working with Kubernetes", "path": "studio/kubernetes.md" diff --git a/docs/en/studio/ai-agent-built-in-capabilities.md b/docs/en/studio/ai-agent-built-in-capabilities.md new file mode 100644 index 0000000000..9753b2feee --- /dev/null +++ b/docs/en/studio/ai-agent-built-in-capabilities.md @@ -0,0 +1,166 @@ +```json +//[doc-seo] +{ + "Description": "Capability matrix for ABP Studio AI Agent modes, built-in tools, Studio automation tools, connected MCP tools, subagents, and hidden tool boundaries." +} +``` + +# ABP Studio: AI Agent Built-in Capabilities + +````json +//[doc-nav] +{ + "Next": { + "Name": "AI Agent Git Integration", + "Path": "studio/ai-agent-git-integration" + } +} +```` + +ABP Studio exposes tools to the AI Agent based on the selected mode, run context, tool settings, permissions, and connected MCP server tools. The tool list is locked per running Agent-mode session to keep prompt caching and execution stable while other sessions run in parallel. + +## Mode Capability Matrix + +| Capability | Agent | Plan | Ask | +| --- | --- | --- | --- | +| Find files | Yes | Yes | Yes | +| Read files | Yes | Yes | Yes | +| Search code | Yes | Yes | Yes | +| ABP-aware outlines | Yes | Yes | Yes | +| Semantic code search | Yes | Yes | Yes | +| Ask user | Yes | Yes | Yes | +| Web search | Yes | Yes | Yes | +| Fetch URL | Yes | Yes | Yes | +| Fetch AI skills | Yes, when available | Yes, when available | Yes, when available | +| Write/edit/delete/rename files | Yes | No | No | +| Download files | Yes | No | No | +| Save learned lessons | Yes | No | No | +| Run shell command | Yes | No | No | +| Add migration | Yes | No | No | +| Create/read/update plan files | No | Yes | No | +| Update active plan steps | Yes | No | No | +| Search/read ABP docs directly | No | No | Yes | +| Studio automation tools | Yes | No | No | +| Connected MCP tools | Yes | No | No | +| Spawn subagents | Yes | Yes | Yes | + +ABP documentation tools are available to Ask mode and ABP documentation subagents. The main Agent-mode tool list does not include direct ABP docs search/read tools; Agent mode can use the ABP documentation subagent when documentation research is needed. + +## File Tools + +The file tools are scope-aware and `.abpignore`-aware. + +| Tool | Description | +| --- | --- | +| `find_files` | Finds files by filename or glob under accessible directories. Build output and dependency folders such as `bin`, `obj`, and `node_modules` are excluded. | +| `read_files` | Reads up to 10 files per call. Supports line ranges. Large files are automatically truncated. | +| `write_file` | Writes file content in Agent mode. | +| `edit_file_batch` | Applies structured edits in Agent mode. | +| `delete_path` | Deletes a file or directory in Agent mode. | +| `rename_path` | Renames or moves a file or directory in Agent mode. | + +Write operations use file change tracking. When another session modifies a file after it was read, the agent is instructed to re-read before overwriting. + +## Code Intelligence + +| Tool | Description | +| --- | --- | +| `search_code` | Searches exact or regex text across source and configuration files. | +| `get_outlines` | Returns ABP-aware outlines for code structures such as entities, DTOs, services, repositories, DbContexts, controllers, modules, and methods. | +| `semantic_code_search` | Searches indexed code by meaning rather than exact text. | + +These tools are available in all modes and are the primary way the agent grounds answers in the current solution. + +## Web And External Content + +| Tool | Description | +| --- | --- | +| `web_search` | Searches the web for current or external information. | +| `fetch_url` | Fetches a URL after domain permission is granted. Large content is cached under `.abpstudio/url-cache`. | +| `download_file` | Downloads a file in Agent mode after explicit permission. Downloads are limited to 10 MB. | + +URL fetch and download permissions are independent. Downloads always require explicit confirmation. + +## User Interaction + +The `ask_user` tool lets the agent request missing information during a run. Pending questions are tracked per session, so parallel sessions can wait for independent user input without sharing state. + +## Shell And Migration Tools + +Agent mode can run shell commands through `run_shell_command`. Shell execution is permission-gated and can be serialized with other workspace operations when required. + +The `add_migration` tool adds Entity Framework Core migrations for configured migration projects. Build and migration execution share a gate so concurrent sessions do not run incompatible `dotnet` operations at the same time. + +## Studio Automation Tools + +Agent mode can use enabled ABP Studio automation tools. + +| Tool | Description | +| --- | --- | +| `dotnet_build` | Builds the solution or targeted project context. | +| `build_solution` | Builds the whole solution when exposed by the run context. | +| `build_module` | Builds a selected module. | +| `build_package` | Builds a selected package. | +| `get_exceptions` | Reads monitored application exceptions. | +| `get_logs` | Reads monitored application logs. | +| `get_requests` | Reads monitored HTTP request data. | +| `get_events` | Reads monitored distributed event data. | +| `start_applications` | Starts applications from the active run profile. | +| `stop_applications` | Stops applications from the active run profile. | +| `start_containers` | Starts containers from the active run profile. | +| `stop_containers` | Stops containers from the active run profile. | +| `run_task` | Runs configured Studio tasks. | +| `install_libs` | Installs client-side library files. | +| `generate_csharp_proxies` | Generates C# client proxies. | +| `generate_angular_proxies` | Generates Angular client proxies. | + +Some solution-structure tools are not exposed because their information is already injected into the system prompt. This avoids redundant tool calls. + +## Hidden Tools + +The following implemented Studio tool categories are intentionally hidden from the AI Agent: + +- Custom command listing and execution. +- Kubernetes chart and service listing. +- Embedded browser tools. + +These tools may exist in Studio for other features, but they are not part of the AI Agent's callable tool surface. + +## Subagents + +The `spawn_subagent` tool delegates bounded research work to read-only specialist subagents. + +| Subagent type | Purpose | +| --- | --- | +| `research` | Performs solution/code research using read-only tools. | +| `websearch` | Performs web-focused research. | +| `abpdocsearcher` | Searches and reads ABP documentation for framework-specific questions. | + +Subagents are read-only. They are intended for parallel research and return summarized findings to the main agent. + +## MCP Tools + +Configured MCP server tools can be added to Agent mode when: + +- The MCP server is configured and enabled. +- The server connection is successful. +- The individual MCP tool is not disabled in settings. + +MCP resources are visible in settings and can be opened for inspection, but the Agent-mode callable surface is composed from MCP tools. Plan and Ask modes do not receive MCP tools. + +This capability lets the AI Agent consume tools from external MCP servers. It does not make ABP Studio AI Agent an MCP server for external clients. + +## Tool Execution Gates + +ABP Studio serializes selected operations to reduce parallel-session conflicts. + +| Gate | Serialized operations | +| --- | --- | +| Build/migration | `dotnet_build` and migration execution. | +| Install libs | Client library installation. | +| Generate proxies | C# and Angular proxy generation. | +| Analysis | Studio package analysis. | +| Run task | Per task name. | +| Custom command | Per custom command name, for internal command execution paths. | + +These gates do not prevent parallel conversations; they serialize operations that would conflict at the workspace or process level. diff --git a/docs/en/studio/ai-agent-configuration.md b/docs/en/studio/ai-agent-configuration.md new file mode 100644 index 0000000000..fcc4af83a9 --- /dev/null +++ b/docs/en/studio/ai-agent-configuration.md @@ -0,0 +1,157 @@ +```json +//[doc-seo] +{ + "Description": "Configuration reference for ABP Studio AI Agent models, reasoning, context limits, parallel sessions, permissions, MCP tool connections, AI rules, and learned lessons." +} +``` + +# ABP Studio: AI Agent Configuration + +````json +//[doc-nav] +{ + "Next": { + "Name": "AI Agent Workflows", + "Path": "studio/ai-agent-workflows" + } +} +```` + +AI Agent configuration controls model selection, execution limits, enabled tools, tool permissions, MCP tool connections, AI rules, and learned lessons. + +## Model Provider + +ABP Studio uses an OpenRouter-backed model configuration by default. Studio maintains a model list with metadata such as provider, context length, maximum completion tokens, image support, reasoning support, and tool support. + +The built-in default model set includes: + +| Model | Default role | Context length | +| --- | --- | --- | +| Claude Sonnet 4.6 | Main agent | 1,000,000 | +| Claude Haiku 4.5 | Research and text processing | 200,000 | +| Claude Opus 4.7 | Optional high-capability model | 1,000,000 | +| GPT-5.5 | Optional main/review model | 1,050,000 | +| GLM-5.1 | Optional text/code model without image support | 200,000 | + +The available model catalog can be refreshed from OpenRouter and is cached locally for a limited period. + +![model-selector-menu](./images/ai-agent/model-selector-menu.png) + +## Model Roles + +ABP Studio separates model roles so each AI operation can use a model suited to its cost and capability profile. + +| Role | Used by | Default behavior | +| --- | --- | --- | +| Main Model | Normal Agent, Plan, and Ask conversations | Uses the active model selected for the agent. | +| Research Model | Research and ABP documentation subagents | Defaults to Claude Haiku 4.5. Can be set to same as main. | +| Text Processor Model | Lightweight text processing, error summarization, commit message generation, and lesson consolidation | Defaults to Claude Haiku 4.5. Can be set to same as main. | +| Git Review Model | AI Review in the Git panel | Defaults to "Ask me every time". Can be set to same as main or a fixed model. | + +The Git Review model picker does not change the main conversation model. When "Ask me every time" is selected, Studio asks for a model before each AI Review and passes that model only to the review run. + +![model-settings-agents](./images/ai-agent/model-settings-agents.png) + +![model-settings-git-review](./images/ai-agent/model-settings-git-review.png) + +## Reasoning Effort + +Reasoning effort controls the model's reasoning budget where the selected model/provider supports it. Supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. The default is `low`. + +When the context limit is set to `Max`, Studio uses the maximum context behavior for the model and increases reasoning effort for the run. + +## Context Limit + +The context limit controls the maximum context size used for agent runs. The default option is `300K`. The `Max` option delegates to the model's maximum context behavior. + +Large context settings can improve broad solution understanding, but they also increase latency and model cost. Narrow AI scopes and targeted attachments should be preferred when the task is limited to a module or package. + +## Parallel Sessions + +ABP Studio can run multiple agent sessions in parallel. The default maximum is 3 concurrent sessions, and the configured range is 1 to 5. Prompts beyond the limit are queued. + +Each running session locks its own model settings and tool snapshot so global settings changes do not mutate an already-running session. + +## Tool Enablement + +ABP Studio groups Studio automation tools in settings. Disabled tools are removed from the agent tool list before a run starts. + +Core Studio tools are available to Agent mode when enabled: + +- Build. +- Monitor exceptions, logs, HTTP requests, and distributed events. +- Start and stop applications. +- Start and stop containers. +- Run tasks. + +Extended Studio tools are loaded only when the run context enables them. These include specialized operations such as package/module builds, library installation, and proxy generation. + +Tools that exist for internal Studio use can be hidden from the AI agent. Hidden tools are not exposed to the model even when they are implemented in Studio. + +## Tool Permissions + +Some tools require explicit permission before execution. + +| Tool category | Permission behavior | +| --- | --- | +| Shell commands | Studio prompts before command execution unless the command has been allowed. | +| URL fetches | Studio prompts per domain unless the domain has been allowed. | +| File downloads | Studio always asks before downloading. | + +Permission choices include allow once, allow always, and skip. "Allow always" persists in the AI Agent settings and is reused by future sessions. + +## MCP Tool Connections + +ABP Studio can connect to user-configured Model Context Protocol (MCP) servers and expose their tools to Agent mode. This is an MCP client integration for the AI Agent. ABP Studio AI Agent does not expose itself as an MCP server for external AI clients. + +MCP server connections can be configured with: + +| Transport | Configuration | +| --- | --- | +| Stdio | Command, arguments, and environment variables. | +| HTTP | URL and headers. | + +Studio imports MCP server configuration from Cursor, Claude, VS Code, Windsurf, and bare MCP server JSON formats. Studio exports MCP server configuration in the standard `mcpServers` JSON shape. + +Connected MCP servers show their connection status, tool count, tools, and resources. Individual MCP tools can be disabled. Disabled MCP tools are omitted from Agent mode. MCP resources can be opened from settings for inspection. + +MCP tools are added only for connected and enabled servers. Plan and Ask modes do not receive MCP tools. + +![mcp-servers-settings](./images/ai-agent/mcp-servers-settings.png) + +## `.abpignore` + +The `.abpignore` file is placed in the solution root and uses `.gitignore` syntax. Files matched by `.abpignore` are inaccessible to the agent even when they are under the active AI scope. + +The default exclusions protect common secret and credential files, including: + +- `appsettings.secrets.json` +- `.env` files except `.env.example` +- certificate and key files such as `.pfx`, `.p12`, `.pem`, `.key`, and `.p8` +- local development Helm values +- tunnel and temporary key files + +## AI Rules + +AI rules are Markdown files with YAML frontmatter and the `.mdc` extension. Rules can be global or solution-specific. + +| Location | Scope | +| --- | --- | +| `%USERPROFILE%/.abp/studio/rules` | Global rules available on the machine. | +| `.abpstudio/ai-rules` | Solution rules shared with the solution when committed. | + +Rule frontmatter supports: + +```yaml +name: Rule Name +description: Short rule description +alwaysApply: true +``` + +Always-apply rules are injected into the agent's system prompt. Non-always-apply rules are exposed as available skills and can be loaded by the agent with the `fetch_ai_skills` tool. When a solution skill and a global skill have the same name, the solution skill takes precedence. + +## Learned Lessons + +The `save_lesson` tool records verified corrections into `.abpstudio/ai-rules/ai-learned-lessons.mdc`. Learned lessons are injected as high-priority context in future sessions. + +The agent is instructed to save a lesson only after a user correction is verified against source or tool output. When the learned lessons file becomes large, Studio can consolidate it with the text processor model. diff --git a/docs/en/studio/ai-agent-git-integration.md b/docs/en/studio/ai-agent-git-integration.md new file mode 100644 index 0000000000..2c7dac7d15 --- /dev/null +++ b/docs/en/studio/ai-agent-git-integration.md @@ -0,0 +1,146 @@ +```json +//[doc-seo] +{ + "Description": "Technical reference for ABP Studio AI Agent Git integration, AI Review, changed-file prompting, commit messages, merge conflicts, and GitHub issue or pull request handoff." +} +``` + +# ABP Studio: AI Agent Git Integration + +````json +//[doc-nav] +{ + "Next": { + "Name": "Coding with AI Agent", + "Path": "studio/coding-with-ai-agent" + } +} +```` + +ABP Studio integrates AI Agent features into the Git and GitHub workflow. The integration uses selected files, staged or working-tree diffs, review notes, GitHub issue/PR context, and image attachments to build prompts for dedicated AI review or coding sessions. + +## AI Review + +AI Review runs from the Git panel against selected changed files. It is a dedicated review flow, separate from the normal Agent chat. + +AI Review: + +- Uses only selected files. +- Skips binary files. +- Uses staged diffs for staged files and working-tree diffs for unstaged files. +- Annotates diff lines with actual line numbers. +- Streams suggestions back to the Git panel. +- Can inspect related source files with read/search tools. +- Can ask an ABP documentation subagent to verify ABP-specific patterns. +- Applies always-apply global and solution AI rules to the review. + +The review model is selected from the Git Review Model setting. When configured as "Ask me every time", Studio shows a model picker before starting the review. + +## Review Scope + +AI Review focuses on changed lines. Surrounding code can be used to understand context, but suggestions are attached to changed lines. + +The reviewer checks for: + +- Bugs and logic errors. +- Security issues. +- Performance problems. +- Code quality issues. +- ABP and DDD pattern violations. + +Generated files such as migrations can be skipped by the reviewer when they are recognized as generated output. + +## Suggestion Severity + +AI Review suggestions have one of the following severities: + +| Severity | Meaning | +| --- | --- | +| Error | A likely bug, crash, security issue, data loss risk, or other high-priority defect. | +| Warning | A potential production issue, bad practice, ABP convention violation, or maintainability problem. | +| Info | A lower-priority design or naming issue worth considering. | +| Confirmation | Positive confirmation for exceptional code. Limited to rare cases. | + +## Review Notes + +The Git panel can store user notes and AI suggestions against files and lines. Review content is used in two ways: + +- It can block commit actions while unresolved review content exists. +- It can be sent to the AI Agent as an implementation prompt. + +Blocking review content includes user notes and AI suggestions with severities other than `Info` and `Confirmation`. + +## Sending Review Findings To The Agent + +The Git panel can send review findings to AI Agent. Studio builds a prompt that includes: + +- A request to review and apply the notes for the current Git changes. +- File paths. +- Line numbers. +- Line type and line content. +- AI suggestions. +- User notes. + +Confirmation suggestions are excluded. Info suggestions are treated as optional context; warning and error suggestions are emphasized. + +The prompt instructs the agent to implement the requested changes, not only explain them. + +## Commit Message Generation + +Commit message generation uses selected file diffs and the Text Processor Model. It skips binary files and truncates large diffs before sending them to the model. + +The generator returns a concise past-tense commit message. It is intended to summarize the selected changes, not the whole repository state. + +## Merge Conflict Handoff + +When unresolved merge conflicts exist, the Git panel can send the conflict list to AI Agent. The generated prompt asks the agent to resolve conflicts and request clarification when the correct resolution is ambiguous. + +Conflict handoff can use the current session or create a new session. It starts with analysis skipped so the prompt is centered on the conflict files. + +## GitHub Issue Handoff + +GitHub issue details can be sent to AI Agent from Studio when GitHub integration is connected. + +The generated issue prompt includes: + +- Issue number and title. +- State. +- Author. +- Labels. +- Description. +- Included comments. +- Attached images referenced by the issue body or included comments. + +Comments can be excluded from the AI prompt. Images that belong to excluded comments are not attached. The prompt instructs the agent to solve the issue by making the necessary code changes. + +## GitHub Pull Request Handoff + +Pull request details can be sent to AI Agent when the current branch matches the PR branch. + +The generated PR prompt includes: + +- PR number and title. +- State. +- Author. +- Base and head branches. +- Labels. +- Included reviews. +- Included comments. +- Included requested changes. +- File path and line information for review comments when available. +- Diff hunks for review comments when available. +- Attached images from included comments and requested changes. + +Reviews, comments, and requested changes can be excluded from the AI prompt. Only included items are sent. + +## Image Attachments + +GitHub issue and PR handoff can attach downloaded images to the agent prompt. The prompt text annotates image references with the corresponding attached file name so the model can connect the image file to the original issue, comment, or review context. + +Image handling still depends on the selected model's image support. If the model does not support images, the normal attachment restrictions apply. + +## GitHub URL Fetching In Agent Chat + +Agent URL fetching can enrich GitHub URLs with issue or pull request information when GitHub integration is available. Pull request URL context can include review comments up to Studio's fetch limits. + +This is separate from the explicit GitHub issue/PR "Send to AI Agent" actions in the Git UI. diff --git a/docs/en/studio/ai-agent-workflows.md b/docs/en/studio/ai-agent-workflows.md new file mode 100644 index 0000000000..c55341024e --- /dev/null +++ b/docs/en/studio/ai-agent-workflows.md @@ -0,0 +1,117 @@ +```json +//[doc-seo] +{ + "Description": "Technical reference for ABP Studio AI Agent workflows, AI scopes, automatic pre/post actions, plan files, and workflow storage." +} +``` + +# ABP Studio: AI Agent Workflows + +````json +//[doc-nav] +{ + "Next": { + "Name": "AI Agent Built-in Capabilities", + "Path": "studio/ai-agent-built-in-capabilities" + } +} +```` + +AI Agent workflows define repeatable actions that Studio can run before or after an agent task. Workflows are associated with run profiles and are selected before a session starts. + +## Workflow Types + +| Type | Storage | Sharing behavior | +| --- | --- | --- | +| Personal workflow | `.abpstudio/workflows/*.json` | Local to the solution workspace and visible in all run profiles. | +| Shared workflow | The active `.abprun.json` run profile under the `workflows` section | Stored with the run profile and intended for source control. | + +The shared/personal setting is fixed when the workflow is created. + +## Workflow Structure + +A workflow contains: + +- `Id` +- `Name` +- `Description` +- `IsShared` +- `BeforeTasks` +- `AfterTasks` + +Each workflow task stores its action type and action-specific targets such as modules, packages, application names, folders, containers, task names, proxy options, or migration project path. + +## Supported Actions + +| Action | Description | +| --- | --- | +| Build | Builds the solution, selected modules, selected packages, or all configured targets. | +| Start Application | Starts selected applications, applications in selected folders, or all runnable applications. | +| Stop Application | Stops selected applications, applications in selected folders, or all targeted applications. | +| Restart Application | Runs the configured restart application workflow action for selected targets. | +| Start Containers | Starts selected containers or all containers. | +| Stop Containers | Stops selected containers or all containers. | +| Run Task | Runs selected Studio tasks. | +| Add Migration | Adds a database migration for the configured migration project when entity changes require it. | +| Install Libs | Installs client-side library files when the task requires it. | +| Generate C# Proxies | Generates C# client proxies with configured URL, module, service type, folder, target package, and contract options. | +| Generate Angular Proxies | Generates Angular proxies with configured URL, module, service type, and working directory. | + +## Before Tasks + +Before tasks run automatically only in Agent mode. Before the model receives control, Studio can run solution/package analysis and then execute the workflow's before tasks through the corresponding Studio tools. + +Plan and Ask modes are read-only and do not execute before tasks. + +## After Tasks + +After tasks are injected into the agent instructions as post-task guidance. The agent is expected to run relevant post-steps after completing the main work, but Studio treats them as contextual workflow guidance rather than unconditional execution. + +The agent may skip after tasks that are not relevant to the actual changes. For example, migration, build, library installation, and proxy generation actions are used only when the completed code changes require them. + +## Automatic Analysis And Build + +Agent mode performs ABP-aware analysis around coding tasks: + +- Before execution, Studio analyzes packages unless the run is explicitly started with analysis skipped. +- After execution, Studio checks changed packages. +- If the workflow already includes a build after task, Studio avoids duplicating that build and performs analysis of changed packages. +- If no build after task is present, Studio can build and analyze changed packages after the agent turn. + +This behavior applies to Agent mode. Read-only modes do not perform build or mutation steps. + +## Workflow Selection And Session Locking + +The selected workflow is stored on the session at execution time. A background session keeps using its original workflow even if the foreground run profile or workflow selection changes. + +Once a session has a cached system prompt, configuration that changes the prompt is locked for that session. New sessions receive the latest selected workflow. + +## AI Scopes In Workflows + +AI scopes and workflows are independent but complementary. The scope determines which directories agent file tools can access. The workflow determines which automation actions are available or recommended for the task. + +A workflow can target applications, containers, packages, modules, and tasks from the active run profile even when the AI scope is narrowed to a smaller area. File access remains governed by the scope. + +## Plan Files + +Plan mode creates and updates plan files under `.abpstudio/plans`. A plan file is a technical implementation document, not a chat transcript. + +Agent mode can attach to an active plan and update step state while implementing it. Plan step updates use stable step identifiers so progress can survive conversation turns. + +## Applying Plans + +When a plan is applied, Studio builds a prompt from the plan and sends it to the agent. The agent then works in Agent mode with the active plan context and updates plan steps as it completes work. + +## Workflow Design Constraints + +Workflows should contain deterministic project actions. They are not a replacement for prompts, AI rules, or review instructions. + +Recommended workflow contents: + +- Build steps required by the solution. +- Application/container start or stop steps required for verification. +- Proxy generation steps required after API contract changes. +- Migration steps for known database projects. +- Run tasks used by the team for validation. + +Avoid putting broad or ambiguous requirements into workflows. Use AI rules for coding standards and prompts for task-specific instructions. diff --git a/docs/en/studio/ai-agent.md b/docs/en/studio/ai-agent.md new file mode 100644 index 0000000000..365803ef7f --- /dev/null +++ b/docs/en/studio/ai-agent.md @@ -0,0 +1,97 @@ +```json +//[doc-seo] +{ + "Description": "Technical reference for the ABP Studio AI Agent operating model, modes, sessions, scopes, prompts, attachments, and context handling." +} +``` + +# ABP Studio: AI Agent + +````json +//[doc-nav] +{ + "Next": { + "Name": "AI Agent Configuration", + "Path": "studio/ai-agent-configuration" + } +} +```` + +ABP Studio AI Agent is an integrated coding agent for ABP solutions. It combines solution metadata, run profile metadata, ABP-specific code analysis, controlled tool access, AI rules, and conversation state into agent sessions that can answer questions, create plans, and modify the solution depending on the selected mode. + +![ai-agent](./images/ai-agent/ai-agent-panel.png) + +The agent is solution-aware. Its system context includes the current solution, modules, packages, runnable applications, containers, tasks, run profile information, active AI scope, active workflow, enabled AI rules, and available tools for the selected mode. + +## Modes + +The selected mode determines the agent's effective permission boundary. + +| Mode | Purpose | Tool boundary | +| --- | --- | --- | +| Agent | Coding and execution | Can read and write files, run shell commands, add migrations, run enabled Studio tools, call connected MCP tools, and update active plan steps. | +| Plan | Read-only planning | Can inspect code and documentation, create or update plan files, and use read-only subagents. It cannot modify solution files or run shell/write tools. | +| Ask | Read-only question answering | Can inspect code, search/read ABP documentation, fetch relevant AI skills, and use read-only subagents. It cannot create plans or modify files. | + +Mode selection is per session. A session keeps its selected mode for subsequent prompts unless the user changes it before sending the next message. + +## Sessions + +An AI Agent session stores the conversation, selected model, selected mode, AI scope, workflow, context notes, queued prompts, active plan state, attachments, and context usage. + +The first message of a session locks the configuration that affects the system prompt. The active AI scope and workflow are stored on the session so a background session continues with the configuration that was active when it started. Changing the foreground run profile, scope, or workflow does not rewrite the context of a running session. + +ABP Studio keeps multiple sessions per solution. Sessions can run in parallel up to the configured maximum. Additional prompts are queued until an execution slot is available. + +## Prompt Queue + +Prompts can be queued while a session is running. Queued prompts are attached to the same session and are sent after the current agent turn completes. The queue preserves the session configuration, including mode, scope, model, workflow, and active plan state. + +## Attachments + +The agent supports file and image attachments for prompts. Attachments are stored under the ABP Studio agent files area and become part of the prompt context for the target session. + +Attachment limits are enforced by ABP Studio: + +| Limit | Value | +| --- | --- | +| Maximum files per prompt | 10 | +| Maximum size per file | 20 MB | +| Supported file extensions | `.png`, `.jpg`, `.jpeg`, `.gif`, `.bmp`, `.webp`, `.txt`, `.md`, `.cs`, `.js`, `.ts`, `.json` | + +Image attachments require a selected model that supports image input. If the selected model does not support images, the agent rejects image attachments for that run. + +## URL Context + +URLs attached to a prompt are fetched and included as contextual material when permitted. URL fetching uses explicit domain permission. Large fetched content is cached under `.abpstudio/url-cache` instead of being injected directly into the prompt. + +## AI Scopes + +An AI scope restricts which directories the agent can access. A scope can include the whole solution, selected modules, selected packages, and external folders. + +Scope resolution follows these rules: + +- The whole-solution scope includes the solution root and all module directories. +- Selected modules include their module directories. +- Selected packages include package directories. +- Existing external folders are included; missing external folders are ignored. +- Overlapping directories are collapsed to avoid duplicate indexing. +- The solution `.abpstudio` folder is accessible so the agent can read and write its own agent state, plans, rules, and workflow files where applicable. + +All file paths used by agent tools are validated against the resolved session scope. Rooted paths are accepted only when they are inside an accessible directory. Files excluded by `.abpignore` are blocked even if they are under an accessible directory. + +## Context Notes + +The agent maintains hidden context notes for long-running sessions. These notes preserve useful state across prompts without exposing implementation-only notes in the visible conversation. + +## Active Plans + +Plan files are stored under `.abpstudio/plans`. Plan mode can create and update plan files. Agent mode can execute an active plan and update step status through the plan-step tool. Active plan state is stored on the session and is cleared when all plan steps are completed. + +## Run Profile Context + +When a run profile is active, the system prompt includes information about runnable applications, containers, tasks, and workflow-related targets. This context allows the agent to call Studio tools by name without rediscovering the solution structure through file search. + +## Privacy Boundary + +The agent uses the files, prompts, Studio tool outputs, connected MCP tool outputs, attachments, and URLs supplied to a session. Sensitive files can be excluded with `.abpignore`; tool permissions restrict shell commands, domain fetches, and downloads. diff --git a/docs/en/studio/coding-with-ai-agent.md b/docs/en/studio/coding-with-ai-agent.md new file mode 100644 index 0000000000..72127f81d8 --- /dev/null +++ b/docs/en/studio/coding-with-ai-agent.md @@ -0,0 +1,141 @@ +```json +//[doc-seo] +{ + "Description": "Technical guidance for coding with ABP Studio AI Agent, including mode selection, scopes, prompting, verification, Git review handoff, Studio tools, MCP tools, and parallel sessions." +} +``` + +# ABP Studio: Coding with AI Agent + +````json +//[doc-nav] +{ + "Next": { + "Name": "Working with Kubernetes", + "Path": "studio/kubernetes" + } +} +```` + +This document describes coding practices for ABP Studio AI Agent. It focuses on how to shape agent runs so the agent receives the correct context, uses the correct tools, and verifies changes with the same ABP Studio automation available to the developer. + +## Mode Selection + +Use the mode that matches the expected side effect. + +| Work type | Mode | +| --- | --- | +| Code changes, migrations, builds, proxy generation, app/container control, Studio tool execution, or MCP tool execution | Agent | +| Technical implementation design before coding | Plan | +| Explanation, source navigation, ABP documentation lookup, and codebase questions | Ask | + +Plan and Ask are read-only modes. They are appropriate when the desired output is a technical answer or implementation plan rather than modified files. + +## Scope Selection + +Set the AI scope before the first prompt in a session. The first message locks the scope for that session. + +Use a narrow scope when the task is isolated to one module or package. Use the whole-solution scope when the task depends on cross-module contracts, shared infrastructure, or multiple applications. + +External folders should be added only when their contents are required by the task. Files outside the resolved scope are not accessible to agent file tools. + +## Prompt Context + +Prompts should identify the target behavior, relevant packages, constraints, and expected verification. The agent already receives solution and run profile context, so prompts should focus on task-specific decisions. + +Useful prompt context includes: + +- The user-facing behavior to change. +- Affected module, package, or application names. +- Relevant file paths when known. +- API, DTO, database, or permission constraints. +- Required validation commands or Studio workflow. +- Whether migrations or proxy generation are expected. + +Avoid placing durable coding rules in every prompt. Use AI rules for project standards and prompts for task-specific requirements. + +## Changed-File Prompting + +When the task is based on current Git changes, use the Git panel selection or review handoff instead of manually describing all changes. Studio can build prompts from selected staged or working-tree diffs, AI suggestions, user review notes, line numbers, and line content. + +This keeps the prompt aligned with the actual Git state and avoids missing files that are selected in the commit/review workflow. + +## AI Review Handoff + +AI Review is a review workflow, not an implementation workflow. After suggestions are produced, send the review content to AI Agent when the intent is to apply fixes. + +The handoff prompt contains verified suggestions, user notes, file paths, and line references. The agent then runs in the normal coding workflow and can edit files, run builds, and update active plan steps depending on the session mode and tools. + +## Plans + +Use Plan mode for changes with broad design impact, uncertain architecture, or multiple implementation phases. Plan files are stored under `.abpstudio/plans` and can be applied later in Agent mode. + +An active plan gives Agent mode a durable implementation checklist. Agent mode updates plan step state as work completes. + +## Verification + +Agent mode has access to Studio build and automation tools when enabled. Verification should match the changed surface. + +| Change type | Typical verification | +| --- | --- | +| Application or domain code | Build affected package or solution. | +| Entity or DbContext changes | Add migration if required, then build. | +| HTTP API contract changes | Regenerate C# or Angular proxies when the consuming project requires them. | +| UI or client library changes | Install libs when new ABP module library assets are introduced. | +| Runtime behavior | Start required applications or containers and inspect logs, requests, exceptions, or events. | +| Review fixes | Re-run AI Review or build/test the affected packages. | + +Workflow after tasks can encode common verification steps, but the agent can skip workflow actions that do not apply to the completed changes. + +## Migrations + +Database migrations should be generated only when model changes require them. Workflows can configure the migration project so the agent can add a migration through the `add_migration` tool. + +Migration generation is serialized with build operations to avoid concurrent `dotnet` conflicts across sessions. + +## Proxy Generation + +Proxy generation is appropriate when API contract changes must be consumed by C# or Angular clients. + +Workflow actions can configure: + +- API base URL. +- Module name. +- Service type filter: `all`, `application`, or `integration`. +- Output folder or Angular working directory. +- C# target package. +- Whether C# contract classes are generated. + +## MCP Tools + +Use configured MCP tools when the agent must work with an external system that is not covered by built-in ABP Studio tools. MCP tools are available only in Agent mode, only when the MCP server is connected, and only when the individual tool is enabled. + +Because MCP tools can have side effects defined by the connected server, keep MCP connections limited to trusted servers and disable tools that should not be callable by the AI Agent. + +MCP tool configuration is for adding external tools to the AI Agent. It does not expose ABP Studio AI Agent as an MCP server for other AI clients. + +## AI Rules And Lessons + +Use always-apply AI rules for standards that should affect every run, such as architecture rules, naming conventions, security requirements, or team-specific ABP patterns. + +Use on-demand AI skills for specialized knowledge that should be loaded only when relevant. This keeps the system prompt smaller and avoids applying unrelated instructions. + +Learned lessons are for verified corrections. They should represent durable mistakes and corrections, not task notes. + +## Parallel Sessions + +Parallel sessions are useful for independent work, research, and review. Each session locks its model settings, scope, workflow, and tool snapshot when it starts. + +Avoid running multiple Agent-mode sessions that edit the same files. Studio detects some stale-file situations and serializes selected tool operations, but it does not replace normal coordination for overlapping edits. + +## Limits And Failure Modes + +Common boundaries: + +- Files outside the active AI scope are inaccessible. +- Files matched by `.abpignore` are inaccessible. +- Image attachments require a model with image support. +- Shell, URL fetch, and download operations can wait for permission. +- Disabled Studio tools and disabled MCP tools are omitted from the tool list. +- Plan and Ask modes cannot modify files. +- Hidden internal Studio tools are not exposed to the agent. diff --git a/docs/en/studio/images/ai-agent/ai-agent-panel.png b/docs/en/studio/images/ai-agent/ai-agent-panel.png new file mode 100644 index 0000000000..8240b81bbb Binary files /dev/null and b/docs/en/studio/images/ai-agent/ai-agent-panel.png differ diff --git a/docs/en/studio/images/ai-agent/mcp-servers-settings.png b/docs/en/studio/images/ai-agent/mcp-servers-settings.png new file mode 100644 index 0000000000..1cf4d4036b Binary files /dev/null and b/docs/en/studio/images/ai-agent/mcp-servers-settings.png differ diff --git a/docs/en/studio/images/ai-agent/model-selector-menu.png b/docs/en/studio/images/ai-agent/model-selector-menu.png new file mode 100644 index 0000000000..94fc464b88 Binary files /dev/null and b/docs/en/studio/images/ai-agent/model-selector-menu.png differ diff --git a/docs/en/studio/images/ai-agent/model-settings-agents.png b/docs/en/studio/images/ai-agent/model-settings-agents.png new file mode 100644 index 0000000000..1f130d4888 Binary files /dev/null and b/docs/en/studio/images/ai-agent/model-settings-agents.png differ diff --git a/docs/en/studio/images/ai-agent/model-settings-git-review.png b/docs/en/studio/images/ai-agent/model-settings-git-review.png new file mode 100644 index 0000000000..52fe97612b Binary files /dev/null and b/docs/en/studio/images/ai-agent/model-settings-git-review.png differ diff --git a/docs/en/studio/monitoring-applications.md b/docs/en/studio/monitoring-applications.md index 04dac9ef13..d994f6206c 100644 --- a/docs/en/studio/monitoring-applications.md +++ b/docs/en/studio/monitoring-applications.md @@ -11,8 +11,8 @@ //[doc-nav] { "Next": { - "Name": "Working with Kubernetes", - "Path": "studio/kubernetes" + "Name": "AI Agent", + "Path": "studio/ai-agent" } } ```` diff --git a/docs/en/studio/overview.md b/docs/en/studio/overview.md index 256389f79d..13e539ebcf 100644 --- a/docs/en/studio/overview.md +++ b/docs/en/studio/overview.md @@ -1,7 +1,7 @@ ```json //[doc-seo] { - "Description": "Explore ABP Studio's key features like Solution Explorer, Kubernetes Integration, and AI Assistant to optimize your ABP application development and management." + "Description": "Explore ABP Studio's key features like Solution Explorer, Kubernetes Integration, AI Agent, and monitoring to optimize your ABP application development and management." } ``` @@ -19,7 +19,7 @@ ## Introduction -ABP Studio, a comprehensive desktop application, offers a wide range of features and functionalities tailored to streamline the development and management of ABP-based applications. This article provides an overview of the key components of ABP Studio, including the Solution Explorer, Solution Runner, Kubernetes Integration, AI Assistant, Application Monitoring Area, Background Tasks, Notifications and Logs. Understanding these components is essential for efficiently utilizing ABP Studio to its full potential. +ABP Studio, a comprehensive desktop application, offers a wide range of features and functionalities tailored to streamline the development and management of ABP-based applications. This article provides an overview of the key components of ABP Studio, including the Solution Explorer, Solution Runner, Kubernetes Integration, AI Agent, Application Monitoring Area, Background Tasks, Notifications and Logs. Understanding these components is essential for efficiently utilizing ABP Studio to its full potential. ![overview-intro](./images/overview/overview-intro.png) @@ -69,7 +69,7 @@ The Welcome Screen is the initial user interface users encounter upon starting A ## Sidebar -Located on the left side of the interface, the Left Area is a panel that provides quick access to various functionalities like [Solution Explorer](./solution-explorer.md), [Solution Runner](./running-applications.md), Kubernetes Integration, and AI Assistant. Now let's examine each item. +Located on the left side of the interface, the Left Area is a panel that provides quick access to various functionalities like [Solution Explorer](./solution-explorer.md), [Solution Runner](./running-applications.md), Kubernetes Integration, and AI Agent. Now let's examine each item. ### Solution Explorer @@ -99,20 +99,22 @@ This pane is dedicated to managing Kubernetes services. It simplifies the proces ![kubernetes-integration-kubernetes-panel](./images/overview/kubernetes-integration-kubernetes.png) -### AI Assistant +### AI Agent -The AI Assistant is an integrated chat interface within ABP Studio that provides intelligent assistance for ABP-related questions. You can access it from the left sidebar by clicking the AI icon. +The AI Agent is an integrated coding agent in ABP Studio. It can answer ABP-related questions, create implementation plans, and work on the current solution with controlled access to files, Studio tools, workflows, Git context, and configured MCP tools. -![ai-assistant](./images/overview/ai-assistant.png) +![ai-agent](./images/ai-agent/ai-agent-panel.png) -Key features of the AI Assistant include: +Key features of the AI Agent include: -- **Chat Interface**: Ask anything about ABP Framework, and get instant, context-aware responses to help with your development workflow. -- **File Attachments**: Attach files to your conversations to get more specific assistance with your code or configuration. -- **Recent Chats**: Access your conversation history to continue previous discussions or reference past solutions. -- **Credits System**: The AI Assistant uses a credits-based system, with usage tracked and displayed in the interface. +- **Agent Modes**: Use Agent, Plan, or Ask mode depending on whether the session should modify files, create a plan, or answer questions. +- **Solution Context**: Work with the active solution, selected AI scope, run profile, workflow, and model settings. +- **Attachments**: Attach supported files or images to provide task-specific context. +- **Studio Integration**: Use enabled Studio tools for build, monitoring, applications, containers, tasks, proxies, migrations, and Git-related workflows. -> **Note**: Review the Privacy Notice available in the AI Assistant panel to understand how your data is handled. +> **Note**: Review the Privacy Notice available in the AI Agent panel to understand how your data is handled. + +For the technical AI Agent reference, see [ABP Studio: AI Agent](./ai-agent.md). ## Application Monitoring Area