en-US/about_Invoke-CodeAssistant.help.txt
|
# about_Invoke-CodeAssistant
## SHORT DESCRIPTION Provides a PowerShell interface to an AI-powered code assistant for generating, reviewing, and refactoring code. ## LONG DESCRIPTION The `Invoke-CodeAssistant` function sends code content to an AI model via the TechToolbox runtime. It supports various modes of interaction including general assistance, static analysis, security reviews, refactoring, test generation, combined analysis, and module-level review. ### Parameters **-Code** Specifies the source code text to be processed by the AI assistant. This parameter is mandatory. **-FileName** Specifies the name of the file associated with the provided code. This helps the AI understand the context (e.g., .ps1, .cs, .json). This parameter is mandatory. **-Mode** Specifies the type of assistance required from the AI model. The available modes are: - General: General-purpose coding help and explanations. - Static: Static code analysis to identify potential issues. - Security: Security-focused review to find vulnerabilities. - Refactor: Suggestions for improving code structure and readability. - Tests: Generation of unit or integration tests. - Combined: A combination of static, security, and refactoring analyses. - ModuleReview: High-level review of an entire module's design and consistency. The default value is 'General'. **-Encoding** Specifies the character encoding for the input code string. The AI model expects UTF-8 by default. Valid values are: - UTF8 (Default) - ASCII - Unicode - UTF7 - UTF32 - Default - OEM The default value is 'UTF8'. ## EXAMPLES ### Example 1: General Code Assistance ```powershell Invoke-CodeAssistant -Code "Get-Process | Where-Object {$_.CPU -gt 100}" -FileName "script.ps1" ``` This command sends a PowerShell snippet to the AI for general explanation or improvement. ### Example 2: Security Review ```powershell $code = @' Invoke-RestMethod -Uri $url -UseBasicParsing '@ Invoke-CodeAssistant -Code $code -FileName "api_call.ps1" -Mode Security ``` This command asks the AI to review the provided code specifically for security vulnerabilities. ## NOTES - This function requires the TechToolbox runtime to be initialized and configured with valid AI model settings in `config.json`. - The routing of requests to specific models is determined by the selected `-Mode` parameter. ## SEE ALSO - Invoke-TechAgent - Initialize-TechToolboxRuntime ## KEYWORDS AI, Code Assistant, Automation, Scripting |