Skip to content

Commit 1edb218

Browse files
CopilotBukeLy
andcommitted
chore: refine command extraction and tests
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
1 parent 6fa3f5f commit 1edb218

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

agent-sdk-client/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def extract_command(text: Optional[str]) -> Optional[str]:
2222
command = trimmed.split()[0]
2323
if '@' in command:
2424
command = command.split('@', 1)[0]
25-
if not command:
25+
command = command.strip()
26+
if not command or command == '/':
2627
return None
2728
return command
2829

tests/test_command_whitelist.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
import importlib.util
1+
import runpy
22
from pathlib import Path
33

44
import pytest
55

66
CLIENT_CONFIG_PATH = Path(__file__).resolve().parent.parent / "agent-sdk-client" / "config.py"
7-
8-
spec = importlib.util.spec_from_file_location("client_config", CLIENT_CONFIG_PATH)
9-
config_module = importlib.util.module_from_spec(spec)
10-
assert spec and spec.loader
11-
spec.loader.exec_module(config_module)
12-
13-
Config = config_module.Config
14-
load_command_whitelist = config_module.load_command_whitelist
7+
config_module = runpy.run_path(CLIENT_CONFIG_PATH)
8+
Config = config_module["Config"]
9+
load_command_whitelist = config_module["load_command_whitelist"]
1510

1611

1712
def test_load_command_whitelist(tmp_path):
@@ -32,6 +27,8 @@ def test_load_command_whitelist(tmp_path):
3227
("/allowed", True),
3328
("/allowed extra args", True),
3429
("/allowed@bot", True),
30+
("/@bot", True),
31+
("/", True),
3532
("/blocked", False),
3633
(" /blocked ", False),
3734
],

0 commit comments

Comments
 (0)