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:
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user