feat(start-work): add --worktree flag parsing from user request
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user