Implement command extraction for /merge, /resolve, /process
✅ COMPLETED
The command extraction logic was already fully implemented in apps/backend/runners/github/command_parser.py from the previous session:
-
Regex Pattern Matching
COMMAND_PATTERN = re.compile(r"/(\w+)(?:\s+([^\n]*?))?(?=\s|$|/)")- Matches commands starting with
/prefix - Captures command name and optional arguments
- Stops at whitespace, end of string, or next command
-
Command Extraction (
parse()method)- Iterates through all regex matches in the input text
- Extracts command type, arguments, position, and raw text
- Filters out unsupported commands gracefully
- Returns list of
Commandobjects in order of appearance
-
Argument Parsing (
_parse_args()method)- Splits arguments on whitespace
- Filters empty strings
- Returns clean list of argument strings
/merge [branch]- Merge specified branch or current PR/resolve [args...]- Attempt to resolve dependency conflicts/process [args...]- Process/reply to outstanding comments
All verification tests passed successfully:
# Test 1: /merge with argument
parser.parse('/merge main')
# → [Command(type='merge', args=['main'], position=0, raw_text='/merge main')]
# Test 2: /resolve without argument
parser.parse('/resolve')
# → [Command(type='resolve', args=[], position=0, raw_text='/resolve')]
# Test 3: /process without argument
parser.parse('/process')
# → [Command(type='process', args=[], position=0, raw_text='/process')]
# Test 4: Multiple commands in one comment
parser.parse('Please /merge and then /resolve dependencies')
# → [Command(type='merge', ...), Command(type='resolve', args=['dependencies'], ...)]
# Test 5: Unknown commands are ignored
parser.parse('/unknown')
# → []
# Test 6: Verification from task description
'merge' in str(parser.parse('/merge main'))
# → Trueapps/backend/runners/github/command_parser.py(already implemented)
The implementation was already complete from the previous session. No new code changes were needed.
- ✅ Subtask 1-1: Create command_parser.py module with base structure (COMPLETED)
- ✅ Subtask 1-2: Implement command extraction for /merge, /resolve, /process (COMPLETED)
- ⏳ Subtask 1-3: Add edge case handling (PENDING)
Proceed to subtask-1-3: Add edge case handling (empty input, malformed commands, special chars)