f500fb0286
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
30 lines
906 B
TypeScript
30 lines
906 B
TypeScript
const KEYWORD_PATTERN = /\b(ultrawork|ulw)\b/gi
|
|
const WORKTREE_FLAG_PATTERN = /--worktree(?:\s+(\S+))?/
|
|
|
|
export interface ParsedUserRequest {
|
|
planName: string | null
|
|
explicitWorktreePath: string | null
|
|
}
|
|
|
|
export function parseUserRequest(promptText: string): ParsedUserRequest {
|
|
const match = promptText.match(/<user-request>\s*([\s\S]*?)\s*<\/user-request>/i)
|
|
if (!match) return { planName: null, explicitWorktreePath: null }
|
|
|
|
let rawArg = match[1].trim()
|
|
if (!rawArg) return { planName: null, explicitWorktreePath: null }
|
|
|
|
const worktreeMatch = rawArg.match(WORKTREE_FLAG_PATTERN)
|
|
const explicitWorktreePath = worktreeMatch ? (worktreeMatch[1] ?? null) : null
|
|
|
|
if (worktreeMatch) {
|
|
rawArg = rawArg.replace(worktreeMatch[0], "").trim()
|
|
}
|
|
|
|
const cleanedArg = rawArg.replace(KEYWORD_PATTERN, "").trim()
|
|
|
|
return {
|
|
planName: cleanedArg || null,
|
|
explicitWorktreePath,
|
|
}
|
|
}
|