mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2025-09-14 20:07:24 +00:00
Refactor command processing for simpler intent detection and execution
This commit is contained in:
parent
051b501fa7
commit
bfa1c4330f
@ -269,57 +269,67 @@ function Process-Command {
|
|||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Host "🔄 Processing command: $Command" -ForegroundColor Cyan
|
Write-Host "`n🔍 Processing command: $Command" -ForegroundColor Yellow
|
||||||
|
|
||||||
# Add command to memory
|
# Add command to memory
|
||||||
$memoryId = Add-MemoryEntry -Type "command" -Content $Command -MemoryPath $MemoryPath
|
Add-MemoryEntry -Type "command" -Content $Command -MemoryPath $MemoryPath
|
||||||
|
|
||||||
# Analyze command with AI
|
# Analyze command intent
|
||||||
$analysis = Invoke-AIAnalysis -Command $Command -Config $Config
|
$commandLower = $Command.ToLower()
|
||||||
|
|
||||||
# Generate response
|
# Simple intent detection
|
||||||
$response = @"
|
if ($commandLower -match "get-childitem|ls|dir|show|list") {
|
||||||
🤖 PowerShell AI Agent Response
|
Write-Host "📁 Navigation command detected" -ForegroundColor Green
|
||||||
===============================
|
$result = Invoke-Expression $Command
|
||||||
|
Write-Host "Navigation completed successfully" -ForegroundColor Green
|
||||||
Command: $Command
|
|
||||||
Intent: $($analysis.intent)
|
|
||||||
Confidence: $($analysis.confidence)
|
|
||||||
|
|
||||||
$($analysis.response)
|
|
||||||
|
|
||||||
Suggested Actions:
|
|
||||||
$(($analysis.suggestedActions | ForEach-Object { "- $_" }) -join "`n")
|
|
||||||
|
|
||||||
Memory ID: $memoryId
|
|
||||||
"@
|
|
||||||
|
|
||||||
Write-Host $response -ForegroundColor White
|
|
||||||
|
|
||||||
# Speak response if voice is enabled
|
|
||||||
if ($Config.Voice.Enabled) {
|
|
||||||
Speak-Response -Text $analysis.response
|
|
||||||
}
|
}
|
||||||
|
elseif ($commandLower -match "start|run|execute|invoke") {
|
||||||
# Execute suggested actions if autopilot is enabled
|
Write-Host "⚡ Execution command detected" -ForegroundColor Green
|
||||||
if ($Config.Autopilot.Enabled) {
|
$result = Invoke-Expression $Command
|
||||||
Write-Host "🤖 Autopilot: Executing suggested actions..." -ForegroundColor Green
|
Write-Host "Command executed successfully" -ForegroundColor Green
|
||||||
foreach ($action in $analysis.suggestedActions) {
|
}
|
||||||
try {
|
elseif ($commandLower -match "analyze|check|review|test") {
|
||||||
Write-Host "Executing: $action" -ForegroundColor Yellow
|
Write-Host "🔍 Analysis command detected" -ForegroundColor Green
|
||||||
Invoke-Expression $action | Out-Null
|
$result = Invoke-Expression $Command
|
||||||
}
|
Write-Host "Analysis completed" -ForegroundColor Green
|
||||||
catch {
|
}
|
||||||
Write-Warning "Failed to execute $action : $_"
|
elseif ($commandLower -match "create|new|add|build") {
|
||||||
|
Write-Host "🛠️ Creation command detected" -ForegroundColor Green
|
||||||
|
$result = Invoke-Expression $Command
|
||||||
|
Write-Host "Creation completed" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
elseif ($commandLower -match "modify|change|update|edit") {
|
||||||
|
Write-Host "✏️ Modification command detected" -ForegroundColor Green
|
||||||
|
$result = Invoke-Expression $Command
|
||||||
|
Write-Host "Modification completed" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
elseif ($commandLower -match "delete|remove|clear") {
|
||||||
|
Write-Host "🗑️ Deletion command detected" -ForegroundColor Green
|
||||||
|
Write-Warning "⚠️ Deletion command detected"
|
||||||
|
if ($Config.Security.RequireConfirmation) {
|
||||||
|
$confirmation = Read-Host "Are you sure you want to delete? (y/N)"
|
||||||
|
if ($confirmation -ne "y") {
|
||||||
|
Write-Host "Deletion cancelled" -ForegroundColor Yellow
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$result = Invoke-Expression $Command
|
||||||
|
Write-Host "Deletion completed" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "❓ General command execution" -ForegroundColor Yellow
|
||||||
|
$result = Invoke-Expression $Command
|
||||||
|
Write-Host "Command completed" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
return $analysis
|
# Add response to memory
|
||||||
|
Add-MemoryEntry -Type "response" -Content "Command processed successfully" -Context $Command -MemoryPath $MemoryPath
|
||||||
|
|
||||||
|
return $result
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "Failed to process command: $_"
|
Write-Error "Failed to process command: $_"
|
||||||
return $null
|
Add-MemoryEntry -Type "error" -Content "Error: $_" -Context $Command -MemoryPath $MemoryPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user