feat(start-work): add plan name normalization and quote stripping
- Add WRAPPING_QUOTES_PATTERN to parse-user-request.ts to strip quotes from plan names
- Add normalizePlanLookupValue() to context-info-builder.ts for slug normalization
- Enhanced findPlanByName() with normalized exact and partial matching
- Allows human-readable plan names (e.g., "my feature plan") to match slugged filenames (e.g., my-feature-plan.md)
🤖 Generated with OhMyOpenCode assistance
This commit is contained in:
@@ -17,12 +17,33 @@ import { createWorktreeActiveBlock } from "./worktree-block"
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import { HOOK_NAME } from "./start-work-hook"
|
||||
|
||||
function normalizePlanLookupValue(value: string): string {
|
||||
return value
|
||||
.trim()
|
||||
.replace(/^["'`]+|["'`]+$/g, "")
|
||||
.toLowerCase()
|
||||
.replace(/[\s_]+/g, "-")
|
||||
.replace(/[^a-z0-9-]+/g, "-")
|
||||
.replace(/-+/g, "-")
|
||||
.replace(/^-+|-+$/g, "")
|
||||
}
|
||||
|
||||
function findPlanByName(plans: string[], requestedName: string): string | null {
|
||||
const lowerName = requestedName.toLowerCase()
|
||||
const normalizedRequestedName = normalizePlanLookupValue(requestedName)
|
||||
const exactMatch = plans.find((p) => getPlanName(p).toLowerCase() === lowerName)
|
||||
if (exactMatch) return exactMatch
|
||||
const normalizedExactMatch = plans.find((planPath) =>
|
||||
normalizePlanLookupValue(getPlanName(planPath)) === normalizedRequestedName,
|
||||
)
|
||||
if (normalizedExactMatch) return normalizedExactMatch
|
||||
const partialMatch = plans.find((p) => getPlanName(p).toLowerCase().includes(lowerName))
|
||||
return partialMatch || null
|
||||
if (partialMatch) return partialMatch
|
||||
|
||||
const normalizedPartialMatch = plans.find((planPath) =>
|
||||
normalizePlanLookupValue(getPlanName(planPath)).includes(normalizedRequestedName),
|
||||
)
|
||||
return normalizedPartialMatch || null
|
||||
}
|
||||
|
||||
function buildAutoSelectedPlanContext(params: {
|
||||
|
||||
Reference in New Issue
Block a user