fix(goal): treat -- as the escape only when it is its own token

Gate quality finding (Low): `arg.startswith("--")` also matched goal text
that starts with a flag-like word, so `/goal --dry-run the migration`
silently set "dry-run the migration". Match only the standalone `--`
token (the documented `/goal -- <text>` form) and reuse the parsed rest,
so flag-like text is kept literally as on main.
This commit is contained in:
kshitijk4poor
2026-10-03 19:44:33 +05:30
committed by kshitij
parent 209fbcc47b
commit 7dd083feca
2 changed files with 4 additions and 2 deletions

View File

@@ -193,9 +193,9 @@ def dispatch_goal_command(
rest = tokens[1].strip() if len(tokens) > 1 else ""
prefix = "Invalid goal"
try:
if arg.startswith("--"):
if verb == "--":
# Verbatim goal text for goals that start with a control word (`/goal -- pause the cron`).
return _set(mgr, arg[2:].strip(), drafting=False, last_user_message=last_user_message,
return _set(mgr, rest, drafting=False, last_user_message=last_user_message,
render=render, progress=progress)
if handler := _EXACT_HANDLERS.get(arg.lower()):
return handler(mgr, "", render)

View File

@@ -148,3 +148,5 @@ def test_double_dash_sets_control_word_goal_and_announces_the_replace():
mgr.clear()
fresh = goals.GoalManager(session_id=mgr.session_id) # gateway/TUI reload per command
assert 'replaced' not in _dispatch(fresh, 'fresh objective').output
_dispatch(fresh, '--dry-run the migration')
assert goals.load_goal(mgr.session_id).goal == '--dry-run the migration'