< Summary

Information
Class: UIBlazor.Agents.BuiltInAgent
Assembly: UIBlazor
File(s): /home/runner/work/InvAit/InvAit/UIBlazor/Agents/BuiltInAgent.cs
Tag: 14_22728831704
Line coverage
95%
Covered lines: 315
Uncovered lines: 16
Coverable lines: 331
Total lines: 337
Line coverage: 95.1%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%1195.16%

File(s)

/home/runner/work/InvAit/InvAit/UIBlazor/Agents/BuiltInAgent.cs

#LineLine coverage
 1using UIBlazor.Services;
 2
 3namespace UIBlazor.Agents;
 4
 165public class BuiltInAgent(IVsBridge vsBridge, ISkillService skillService)
 6{
 167    public IReadOnlyList<Tool> Tools =
 168    [
 169        // File operations
 1610        new()
 1611        {
 1612            Name = BuiltInToolEnum.ReadFiles,
 1613            DisplayName = SharedResource.ToolReadFiles,
 1614            Category = ToolCategory.ReadFiles,
 1615            Description = "Request to read the contents of one or more files. Use start_line and line_count to read spec
 1616            ExampleToSystemMessage = $"""
 1617                                     For example, to read a specific range:
 1618                                     <function name="{BuiltInToolEnum.ReadFiles}">
 1619                                     path/to/large_file.cs
 1620                                     start_line
 1621                                     100
 1622                                     line_count
 1623                                     50
 1624                                     </function>
 1625
 1626                                     Or to read the entire file:
 1627                                     <function name="{BuiltInToolEnum.ReadFiles}">
 1628                                     path/to/file.cs
 1629                                     path/to/file2.cs
 1630                                     </function>
 1631                                     """,
 132            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.ReadFiles, args)
 1633        },
 1634        new()
 1635        {
 1636            Name = BuiltInToolEnum.ReadOpenFile,
 1637            DisplayName = SharedResource.ToolReadOpenFile,
 1638            Category = ToolCategory.ReadFiles,
 1639            Description = $"""
 1640                          To view the user's currently open file, use the {BuiltInToolEnum.ReadOpenFile} tool.
 1641                          The tool returns the absolute file path and its line-numbered content (e.g. "1 | const x = 1")
 1642                          If the user is asking about a file and you don't see any code, use this to check the current f
 1643                          """,
 1644            ExampleToSystemMessage = $"""
 1645                                     For example
 1646                                     <function name="{BuiltInToolEnum.ReadOpenFile}"></function>
 1647                                     """,
 048            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.ReadOpenFile, args)
 1649        },
 1650        new()
 1651        {
 1652            Name = BuiltInToolEnum.CreateFile,
 1653            DisplayName = SharedResource.ToolCreateFile,
 1654            Category = ToolCategory.WriteFiles,
 1655            Description = "To create a NEW file with the relative or absolute filepath and new contents.",
 1656            ExampleToSystemMessage = $"""
 1657                                     For example, to create a file located at 'path\to\file.cs', you would respond with:
 1658                                     <function name="{BuiltInToolEnum.CreateFile}">
 1659                                     \path\to\file.cs
 1660                                     Contents of the file.
 1661                                     And second line of this file.
 1662                                     </function>
 1663                                     """,
 064            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.CreateFile, args)
 1665        },
 1666        new()
 1667        {
 1668            Name = BuiltInToolEnum.ApplyDiff,
 1669            DisplayName = SharedResource.ToolApplyDiff,
 1670            Category = ToolCategory.WriteFiles,
 1671            Description = $"""
 1672                          Request to apply PRECISE, TARGETED modifications to an existing file by searching for specific
 1673                          You can perform multiple distinct search and replace operations within a single `{BuiltInToolE
 1674                          The SEARCH section must exactly match existing content including whitespace and indentation.
 1675                          If you're not confident in the exact content to search for, use the {BuiltInToolEnum.ReadFiles
 1676                          When applying the diffs, be extra careful to remember to change any closing brackets or other 
 1677                          ALWAYS make as many changes in a single '{BuiltInToolEnum.ApplyDiff}' request as possible usin
 1678                          An optional ":start_line:". The search will be 5 lines up and down.
 1679                          """,
 1680            ExampleToSystemMessage = $"""
 1681                                     For example:
 1682                                     <function name="{BuiltInToolEnum.ApplyDiff}">
 1683                                     C:\path\to\file.cs
 1684                                     :start_line:10
 1685                                     <<<<<<< SEARCH
 1686                                     old code
 1687                                     =======
 1688                                     new code
 1689                                     >>>>>>> REPLACE
 1690                                     </function>
 1691
 1692                                     <function name="{BuiltInToolEnum.ApplyDiff}">
 1693                                     C:\path\to\file222.cs
 1694                                     <<<<<<< SEARCH
 1695                                     old code
 1696                                     =======
 1697                                     new code
 1698                                     >>>>>>> REPLACE
 1699
 16100                                     :start_line:40
 16101                                     <<<<<<< SEARCH
 16102                                         var z = "old code";
 16103                                     =======
 16104                                         var isNew = true;
 16105                                         var z = isNew ? "new code" : "old code";
 16106                                     >>>>>>> REPLACE
 16107                                     </function>
 16108                                     """,
 1109            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.ApplyDiff, args)
 16110        },
 16111
 16112        // Search and navigation
 16113        new()
 16114        {
 16115            Name = BuiltInToolEnum.SearchFiles,
 16116            DisplayName = SharedResource.ToolSearchFiles,
 16117            Category = ToolCategory.ReadFiles,
 16118            Description = "To return a list of files with patches in solution directory based on a search regex pattern,
 16119            ExampleToSystemMessage = $"""
 16120                                     For example:
 16121                                     <function name="{BuiltInToolEnum.SearchFiles}">
 16122                                     ^.*\.cs$
 16123                                     </function>
 16124                                     """,
 0125            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.SearchFiles, args)
 16126        },
 16127        new()
 16128        {
 16129            Name = BuiltInToolEnum.GrepSearch,
 16130            DisplayName = SharedResource.ToolGrepSearch,
 16131            Category = ToolCategory.ReadFiles,
 16132            Description = "To perform a grep search within the project, call the grep_search tool with the regex pattern
 16133            ExampleToSystemMessage = $"""
 16134                                     For example:
 16135                                     <function name="{BuiltInToolEnum.GrepSearch}">
 16136                                     ^.*?main_services.*
 16137                                     </function>
 16138                                     """,
 0139            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GrepSearch, args)
 16140        },
 16141        new()
 16142        {
 16143            Name = BuiltInToolEnum.Dir,
 16144            DisplayName = SharedResource.ToolDir,
 16145            Category = ToolCategory.ReadFiles,
 16146            Description = "To list files and folders in a given directory, call this tool with \"dirPath\" and \"recursi
 16147            ExampleToSystemMessage = $"""
 16148                                     For example:
 16149                                     <function name="{BuiltInToolEnum.Dir}">
 16150                                     C:\path\to\dir
 16151                                     false
 16152                                     </function>
 16153                                     """,
 0154            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.Dir, args)
 16155        },
 16156
 16157        // Project and build
 16158        new()
 16159        {
 16160            Name = BuiltInToolEnum.Build,
 16161            DisplayName = SharedResource.ToolBuild,
 16162            Category = ToolCategory.Execution,
 16163            Description = "To build solution in Visual Studio. With action - Build, Rebuild or Clean. When any errors re
 16164            ExampleToSystemMessage = $"""
 16165                                     For example:
 16166                                     <function name="{BuiltInToolEnum.Build}">
 16167                                     build
 16168                                     </function>
 16169                                     """,
 0170            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.Build, args)
 16171        },
 16172        new()
 16173        {
 16174            Name = BuiltInToolEnum.GetErrors,
 16175            DisplayName = SharedResource.ToolGetErrors,
 16176            Category = ToolCategory.ReadFiles,
 16177            Description = "To get error list of current solution and current file from Visual Studio.",
 16178            ExampleToSystemMessage = $"""
 16179                                     For example:
 16180                                     <function name="{BuiltInToolEnum.GetErrors}"></function>
 16181                                     """,
 0182            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GetErrors)
 16183        },
 16184        new()
 16185        {
 16186            Name = BuiltInToolEnum.GetProjectInfo,
 16187            DisplayName = SharedResource.ToolGetProjectInfo,
 16188            Category = ToolCategory.ReadFiles,
 16189            Description = "Get information about the solution and projects. Returns list of projects, their types, targe
 16190            ExampleToSystemMessage = $"""
 16191                                     For example:
 16192                                     <function name="{BuiltInToolEnum.GetProjectInfo}"></function>
 16193                                     """,
 0194            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GetProjectInfo, args)
 16195        },
 16196        new()
 16197        {
 16198            Name = BuiltInToolEnum.GetSolutionStructure,
 16199            DisplayName = SharedResource.ToolGetSolutionStructure,
 16200            Category = ToolCategory.ReadFiles,
 16201            Description = "Get a tree-like structure of the entire solution, including projects, folders, and files.",
 16202            ExampleToSystemMessage = $"""
 16203                                     For example:
 16204                                     <function name="{BuiltInToolEnum.GetSolutionStructure}"></function>
 16205                                     """,
 0206            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GetSolutionStructure)
 16207        },
 16208
 16209        // Execution
 16210        new()
 16211        {
 16212            Name = BuiltInToolEnum.Exec,
 16213            DisplayName = SharedResource.ToolExec,
 16214            Category = ToolCategory.Execution,
 16215            Description = """
 16216                          To run a terminal command, use the execute_command tool in
 16217                          The shell is not stateful and will not remember any previous commands.
 16218                          When a command is run in the background ALWAYS suggest using shell commands to stop it; NEVER 
 16219                          When suggesting subsequent shell commands ALWAYS format them in shell command blocks.
 16220                          Do NOT perform actions requiring special/admin privileges.
 16221                          Choose terminal commands and scripts optimized for win32 and x64.
 16222                          You can also optionally include the waitForCompletion argument set to false to run the command
 16223                          """,
 16224            ExampleToSystemMessage = $"""
 16225                                      For example, to see the git log, you could respond with:
 16226                                      <function name="{BuiltInToolEnum.Exec}">
 16227                                      dotnet restore
 16228                                      </function>
 16229                                      """,
 1230            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.Exec, args)
 16231        },
 16232
 16233        // Git operations
 16234        new()
 16235        {
 16236            Name = BuiltInToolEnum.GitStatus,
 16237            DisplayName = SharedResource.ToolGitStatus,
 16238            Category = ToolCategory.ReadFiles,
 16239            Description = "Check git status of the current repository. Shows modified, staged, and untracked files.",
 16240            ExampleToSystemMessage = $"""
 16241                                     For example:
 16242                                     <function name="{BuiltInToolEnum.GitStatus}"></function>
 16243                                     """,
 0244            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GitStatus, args)
 16245        },
 16246        new()
 16247        {
 16248            Name = BuiltInToolEnum.GitLog,
 16249            DisplayName = SharedResource.ToolGitLog,
 16250            Category = ToolCategory.ReadFiles,
 16251            Description = "View git commit history. Can specify number of commits to display.",
 16252            ExampleToSystemMessage = $"""
 16253                                     For example:
 16254                                     <function name="{BuiltInToolEnum.GitLog}">
 16255                                     10
 16256                                     </function>
 16257                                     """,
 0258            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GitLog, args)
 16259        },
 16260        new()
 16261        {
 16262            Name = BuiltInToolEnum.GitDiff,
 16263            DisplayName = SharedResource.ToolGitDiff,
 16264            Category = ToolCategory.ReadFiles,
 16265            Description = "View git diff for files. Can compare working directory with staged or specific commits.",
 16266            ExampleToSystemMessage = $"""
 16267                                     For example:
 16268                                     <function name="{BuiltInToolEnum.GitDiff}">
 16269                                     false
 16270                                     </function>
 16271                                     """,
 0272            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GitDiff, args)
 16273        },
 16274        new()
 16275        {
 16276            Name = BuiltInToolEnum.GitBranch,
 16277            DisplayName = SharedResource.ToolGitBranches,
 16278            Category = ToolCategory.ReadFiles,
 16279            Description = "List git branches or get current branch information.",
 16280            ExampleToSystemMessage = $"""
 16281                                     For example:
 16282                                     <function name="{BuiltInToolEnum.GitBranch}"></function>
 16283                                     """,
 0284            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.GitBranch, args)
 16285        },
 16286        new()
 16287        {
 16288            Name = BasicEnum.SwitchMode,
 16289            DisplayName = SharedResource.ToolSwitchMode,
 16290            Category = ToolCategory.ModeSwitch,
 16291            Description = "Switch the current application mode. Available modes: Chat, Agent, Plan. Use this when you ne
 16292            ExampleToSystemMessage = $"""
 16293                                     For example, to switch to Agent mode:
 16294                                     <function name="{BasicEnum.SwitchMode}">
 16295                                     Agent
 16296                                     </function>
 16297                                     """,
 16298            // TODO тут нужен другой класс, например internalToolExec и туда же отправить браузер
 0299            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BasicEnum.SwitchMode, args)
 16300        },
 16301
 16302        // Skills
 16303        new()
 16304        {
 16305            Name = BasicEnum.ReadSkillContent,
 16306            DisplayName = SharedResource.ToolReadSkillContent,
 16307            Category = ToolCategory.ReadFiles,
 16308            Description = """
 16309                          Load the full content of a skill when you need detailed instructions.
 16310                          Skills are pre-listed in your system prompt with name and description.
 16311                          Use this tool only when you determine a skill is relevant to the current task.
 16312                          For parameter use skill name.
 16313                          """,
 16314            ExampleToSystemMessage = $"""
 16315                                     For example, to load a specific skill:
 16316                                     <function name="{BasicEnum.ReadSkillContent}">
 16317                                     ExampleSkillNameForWriteTests
 16318                                     </function>
 16319                                     """,
 0320            ExecuteAsync = (args) => skillService.LoadSkillContentMarkDownAsync(args)
 16321        },
 16322        new()
 16323        {
 16324            Name = BuiltInToolEnum.DeleteFile,
 16325            DisplayName = SharedResource.ToolDeleteFile,
 16326            Category = ToolCategory.DeleteFiles,
 16327            Description = "To delete a file, use this tool with the relative or absolute filepath.",
 16328            ExampleToSystemMessage = $"""
 16329                                     For example, to delete a file located at 'path\\to\\file.cs', you would respond wit
 16330                                     <function name="{BuiltInToolEnum.DeleteFile}">
 16331                                     C:\path\to\file.cs
 16332                                     </function>
 16333                                     """,
 0334            ExecuteAsync = (args) => vsBridge.ExecuteToolAsync(BuiltInToolEnum.DeleteFile, args)
 16335        }
 16336    ];
 337}