Skip to content

Agent Zero AI framework

fix(commands): show slash picker only for prefixes

Alessandro771d670ac1e8
diff --git a/plugins/_commands/AGENTS.md b/plugins/_commands/AGENTS.md
index dc664eb64..30196cebc 100644
--- a/plugins/_commands/AGENTS.md
+++ b/plugins/_commands/AGENTS.md
@@ -30,7 +30,7 @@
- On startup, `_commands` copies legacy `usr/plugins/commands` command and skill files into `usr/plugins/_commands` without overwriting existing files, copies scoped legacy command folders to `_commands`, and disables the legacy `commands` plugin roots to prevent duplicate WebUI popovers.
- Script commands must expose `run(payload)` and return a string or a dict with `text` and optional `effects`; `show_markdown` effects render as auto-dismissing toast notifications.
- Script commands may emit `send_message` with `text` to submit the rendered composer text immediately after command resolution.
-- Commands accept prefix syntax (`/goal objective`) and exact postfix syntax (`objective /goal`); ordinary mid-sentence mentions are not invocations.
+- Commands accept prefix syntax (`/goal objective`) and exact postfix syntax (`objective /goal`); ordinary mid-sentence mentions are not invocations. The composer picker opens only for prefix syntax, while postfix commands resolve when sent.
- WebUI sends resolve through the picker effect path, while backend-originated messages resolve before reaching the agent.
- `/stop` uses the same shared cancellation operation as the composer Stop button, including progress cleanup and terminal logging.
- Built-in `/computer-use on|off` emits a bounded `computer_use` effect. WebUI
diff --git a/plugins/_commands/README.md b/plugins/_commands/README.md
index 113fb02fd..2e9036169 100644
--- a/plugins/_commands/README.md
+++ b/plugins/_commands/README.md
@@ -7,7 +7,7 @@ This plugin lets you define reusable `/commands` as `.command.yaml` files with e
- a `.txt` template body
- a `.py` script hook
-Commands are managed from the plugin modal and can be inserted directly from the chat composer with prefix syntax (`/goal objective`) or an exact trailing command (`objective /goal`).
+Commands are managed from the plugin modal and can be inserted directly from the chat composer with prefix syntax (`/goal objective`) or an exact trailing command (`objective /goal`). The picker opens only for prefix syntax; trailing commands resolve when sent.
## Features
diff --git a/plugins/_commands/tests/test_commands_plugin.py b/plugins/_commands/tests/test_commands_plugin.py
index e6ad45da1..4e7a783cd 100644
--- a/plugins/_commands/tests/test_commands_plugin.py
+++ b/plugins/_commands/tests/test_commands_plugin.py
@@ -1,5 +1,7 @@
from __future__ import annotations
+import shutil
+import subprocess
import threading
import uuid
from dataclasses import dataclass, field
@@ -65,6 +67,33 @@ def _save_command(
return _track_paths(scope, command)
+def test_composer_picker_ignores_postfix_slashes() -> None:
+ if not shutil.which("node"):
+ pytest.skip("Node.js is required to execute the slash-picker regression.")
+
+ source = (Path(__file__).resolve().parents[1] / "webui" / "commands-slash-store.js").read_text(
+ encoding="utf-8"
+ )
+ start = source.index("function parseSlashInput(")
+ function_source = source[start : source.index("\n\nfunction notifyError", start)]
+ script = f"""
+{function_source}
+
+const leading = parseSlashInput("/goal objective", false);
+if (!leading.active || leading.query !== "goal") throw new Error("leading command hidden");
+
+const trailing = parseSlashInput("objective /goal", false);
+if (trailing.active) throw new Error("postfix command opened the picker");
+
+const path = parseSlashInput("Review /a0/usr/projects/example", false);
+if (path.active) throw new Error("path opened the picker");
+
+const resolvable = parseSlashInput("objective /goal");
+if (!resolvable.active || resolvable.query !== "goal") throw new Error("postfix resolution broke");
+"""
+ subprocess.run(["node", "-e", script], check=True, text=True)
+
+
@pytest.fixture
def scope_fixture() -> ScopeFixture:
suffix = uuid.uuid4().hex[:8]
diff --git a/plugins/_commands/webui/commands-slash-store.js b/plugins/_commands/webui/commands-slash-store.js
index 0f005721d..c44f733cc 100644
--- a/plugins/_commands/webui/commands-slash-store.js
+++ b/plugins/_commands/webui/commands-slash-store.js
@@ -22,10 +22,10 @@ function sanitizeCommandName(rawName) {
.replace(/^[-_]+|[-_]+$/g, "");
}
-function parseSlashInput(message) {
+function parseSlashInput(message, allowPostfix = true) {
const text = String(message || "");
const prefixMatch = text.match(/^\s*\/([^\s]*)(?:\s+([\s\S]*))?$/);
- const postfixMatch = prefixMatch
+ const postfixMatch = prefixMatch || !allowPostfix
? null
: text.match(/^([\s\S]*\S)\s+\/([^\s]*)\s*$/);
if (!prefixMatch && !postfixMatch) {
@@ -238,7 +238,7 @@ const model = {
this.dismissed = false;
const message = this.getInputMessage(event);
- const parsed = parseSlashInput(message);
+ const parsed = parseSlashInput(message, false);
this.active = parsed.active;
this.query = parsed.query;