mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 15:09:46 +08:00
fix: prefer rg in agent prompts
This commit is contained in:
@@ -388,6 +388,12 @@ class PromptManager:
|
||||
info_lines.extend(
|
||||
f" - {command}: {path}" for command, path in available_commands
|
||||
)
|
||||
# `rg` 同时覆盖文件枚举和文本检索,且比通用 shell 查找更适合
|
||||
# Agent 的代码阅读与定位场景;只有在它不可用或不适合时才退回其他工具。
|
||||
if any(command == "rg" for command, _ in available_commands):
|
||||
info_lines.append(
|
||||
"- When searching files or text, prefer `rg` / `rg --files`. Only fall back to other search tools when `rg` is unavailable or unsuitable."
|
||||
)
|
||||
|
||||
return "\n".join(info_lines)
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ class TestAgentPromptStyle(unittest.TestCase):
|
||||
self.assertIn("- 可用系统命令(可通过 `execute_command` 调用):", prompt)
|
||||
self.assertIn(" - ssh: /usr/bin/ssh", prompt)
|
||||
self.assertIn(" - rg: /opt/homebrew/bin/rg", prompt)
|
||||
self.assertIn(
|
||||
"When searching files or text, prefer `rg` / `rg --files`",
|
||||
prompt,
|
||||
)
|
||||
self.assertNotIn(" - git:", prompt)
|
||||
|
||||
def test_base_prompt_omits_shell_command_section_when_none_available(self):
|
||||
|
||||
Reference in New Issue
Block a user