| |
| |
| |
| |
| |
|
|
|
|
| export interface ParsedCommand {
|
| isPrixCommand: boolean
|
| command: 'plan' | 'fix' | 'review' | 'help' | null
|
| args: string[]
|
| rawCommand: string
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| export const parsePrixCommand = (commentBody: string): ParsedCommand => {
|
| const trimmed = commentBody.trim()
|
|
|
|
|
| const prixCommandRegex = /^[/!]?prix\s+(\w+)(.*)$/i
|
| const match = trimmed.match(prixCommandRegex)
|
|
|
| if (!match) {
|
| return {
|
| isPrixCommand: false,
|
| command: null,
|
| args: [],
|
| rawCommand: ''
|
| }
|
| }
|
|
|
| const commandStr = match[1].toLowerCase()
|
| const argsStr = match[2].trim()
|
| const args = argsStr ? argsStr.split(/\s+/).filter(Boolean) : []
|
|
|
|
|
| const commandMap: Record<string, ParsedCommand['command']> = {
|
| plan: 'plan',
|
| fix: 'fix',
|
| review: 'review',
|
| help: 'help'
|
| }
|
|
|
| const command = commandMap[commandStr] || null
|
|
|
| return {
|
| isPrixCommand: true,
|
| command,
|
| args,
|
| rawCommand: match[0]
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| export const isBotComment = (
|
| username: string | undefined,
|
| botUsername: string = 'prix-ai[bot]'
|
| ): boolean => {
|
| if (!username) return false
|
| const normalizedUsername = username.toLowerCase()
|
| const normalizedBot = botUsername.toLowerCase()
|
| return (
|
| normalizedUsername === normalizedBot || normalizedUsername.endsWith('[bot]')
|
| )
|
| }
|
|
|