mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: remove hardcoded npm pattern suggestions
- Remove automatic addition of generic 'npm' and 'npm run' patterns - Remove unused translation keys for hardcoded npm suggestions - Let LLM suggestions be the sole source of command patterns - Improves security by avoiding overly broad permission patterns - Fix React hooks linting warning
This commit is contained in:
parent
38fb80fe19
commit
63f4a27448
2 changed files with 11 additions and 67 deletions
|
|
@ -110,40 +110,13 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
|
|||
// Found an operator, process the current command
|
||||
const trimmedCommand = currentCommand.trim()
|
||||
if (trimmedCommand) {
|
||||
// For npm commands, generate multiple pattern options
|
||||
if (trimmedCommand.startsWith("npm ")) {
|
||||
// Add the specific pattern
|
||||
const specificPattern = extractCommandPattern(trimmedCommand)
|
||||
if (specificPattern) {
|
||||
patterns.push({
|
||||
pattern: specificPattern,
|
||||
description: getPatternDescription(specificPattern),
|
||||
})
|
||||
}
|
||||
|
||||
// Add broader npm patterns
|
||||
if (trimmedCommand.startsWith("npm run ")) {
|
||||
// Add "npm run" pattern
|
||||
patterns.push({
|
||||
pattern: "npm run",
|
||||
description: t("chat:commandExecution.allowAllNpmRun"),
|
||||
})
|
||||
}
|
||||
|
||||
// Add "npm" pattern
|
||||
// Extract pattern for the command
|
||||
const pattern = extractCommandPattern(trimmedCommand)
|
||||
if (pattern) {
|
||||
patterns.push({
|
||||
pattern: "npm",
|
||||
description: t("chat:commandExecution.allowAllNpm"),
|
||||
pattern,
|
||||
description: getPatternDescription(pattern),
|
||||
})
|
||||
} else {
|
||||
// For non-npm commands, just add the extracted pattern
|
||||
const pattern = extractCommandPattern(trimmedCommand)
|
||||
if (pattern) {
|
||||
patterns.push({
|
||||
pattern,
|
||||
description: getPatternDescription(pattern),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
currentCommand = ""
|
||||
|
|
@ -162,40 +135,13 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
|
|||
// Process the last command
|
||||
const trimmedCommand = currentCommand.trim()
|
||||
if (trimmedCommand) {
|
||||
// For npm commands, generate multiple pattern options
|
||||
if (trimmedCommand.startsWith("npm ")) {
|
||||
// Add the specific pattern
|
||||
const specificPattern = extractCommandPattern(trimmedCommand)
|
||||
if (specificPattern) {
|
||||
patterns.push({
|
||||
pattern: specificPattern,
|
||||
description: getPatternDescription(specificPattern),
|
||||
})
|
||||
}
|
||||
|
||||
// Add broader npm patterns
|
||||
if (trimmedCommand.startsWith("npm run ")) {
|
||||
// Add "npm run" pattern
|
||||
patterns.push({
|
||||
pattern: "npm run",
|
||||
description: t("chat:commandExecution.allowAllNpmRun"),
|
||||
})
|
||||
}
|
||||
|
||||
// Add "npm" pattern
|
||||
// Extract pattern for the command
|
||||
const pattern = extractCommandPattern(trimmedCommand)
|
||||
if (pattern) {
|
||||
patterns.push({
|
||||
pattern: "npm",
|
||||
description: t("chat:commandExecution.allowAllNpm"),
|
||||
pattern,
|
||||
description: getPatternDescription(pattern),
|
||||
})
|
||||
} else {
|
||||
// For non-npm commands, just add the extracted pattern
|
||||
const pattern = extractCommandPattern(trimmedCommand)
|
||||
if (pattern) {
|
||||
patterns.push({
|
||||
pattern,
|
||||
description: getPatternDescription(pattern),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +151,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
|
|||
)
|
||||
|
||||
return uniquePatterns
|
||||
}, [command, suggestions, showSuggestions, t])
|
||||
}, [command, suggestions, showSuggestions])
|
||||
|
||||
// The command's output can either come from the text associated with the
|
||||
// task message (this is the case for completed commands) or from the
|
||||
|
|
|
|||
|
|
@ -212,8 +212,6 @@
|
|||
"pid": "PID: {{pid}}",
|
||||
"exited": "Exited ({{exitCode}})",
|
||||
"addToAllowedCommands": "Add to Allowed Auto-Execute Commands",
|
||||
"allowAllNpmRun": "Allow all npm run commands",
|
||||
"allowAllNpm": "Allow all npm commands",
|
||||
"manageCommands": "Manage Command Permissions",
|
||||
"commandManagementDescription": "Click ✓ to allow auto-execution, ✗ to deny execution"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue