Skip to content

Commit 9c4dacb

Browse files
committed
add completer pattern
1 parent a2b5df2 commit 9c4dacb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

AgentCrew/modules/console/completers.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import os
66
import re
77

8+
COMPLETER_PATTERN = re.compile(r"[A-z0-9-_.]+")
9+
810

911
class JumpCompleter(Completer):
1012
"""Completer that shows available conversation turns when typing /jump command."""
@@ -17,7 +19,9 @@ def get_completions(self, document, complete_event):
1719

1820
# Only provide completions for the /jump command
1921
if text.startswith("/jump "):
20-
word_before_cursor = document.get_word_before_cursor()
22+
word_before_cursor = document.get_word_before_cursor(
23+
pattern=COMPLETER_PATTERN
24+
)
2125

2226
conversation_turns = (
2327
self.message_handler.conversation_turns if self.message_handler else []
@@ -47,7 +51,9 @@ def get_completions(self, document, complete_event):
4751

4852
# Only provide completions for the /model command
4953
if text.startswith("/model "):
50-
word_before_cursor = document.get_word_before_cursor()
54+
word_before_cursor = document.get_word_before_cursor(
55+
pattern=COMPLETER_PATTERN
56+
)
5157

5258
# Get all available models from the registry
5359
all_models = []
@@ -79,7 +85,9 @@ def get_completions(self, document, complete_event):
7985

8086
# Only provide completions for the /agent command
8187
if text.startswith("/agent "):
82-
word_before_cursor = document.get_word_before_cursor()
88+
word_before_cursor = document.get_word_before_cursor(
89+
pattern=COMPLETER_PATTERN
90+
)
8391

8492
# Get all available agents from the manager
8593
all_agents = []
@@ -189,7 +197,9 @@ def __init__(self, message_handler=None):
189197
def get_completions(self, document, complete_event):
190198
text = document.text
191199
if text.startswith("/mcp "):
192-
word_before_cursor = document.get_word_before_cursor()
200+
word_before_cursor = document.get_word_before_cursor(
201+
pattern=COMPLETER_PATTERN
202+
)
193203
# Collect all prompts from all servers
194204
if self.mcp_service and hasattr(self.mcp_service, "server_prompts"):
195205
for server_id, prompts in self.mcp_service.server_prompts.items():

0 commit comments

Comments
 (0)