(prompt: string)
| 77 | /** Parse a maintain prompt into its scope + optional path focus + dry-run flag. PURE. |
| 78 | * Forms: "" (→ dead-code) · "unused-imports src/" · "lint-fix --dry-run" · "dep-bump" · "src/utils". */ |
| 79 | export function parseMaintainScope(prompt: string): { scope: MaintainScope; focus: string; dryRun: boolean } { |
| 80 | let rest = (prompt ?? '').trim(); |
| 81 | const dryRun = /(^|\s)(--dry-run|dry-run)(\s|$)/i.test(rest); |
| 82 | rest = rest.replace(/(^|\s)(--dry-run|dry-run)(\s|$)/ig, ' ').trim(); |
| 83 | let scope: MaintainScope = 'dead-code'; |
| 84 | const m = /^(unused[-_]?imports|imports|unused[-_]?locals|locals|unused[-_]?params|params|lint[-_]?fix|lint|dep[-_]?bump|deps?|dependenc(?:y|ies)|consolidate[-_]?dupes?|consolidate|duplicates?|dupes?|dedupe|extract[-_]?helpers?|parameteri[sz]e|helpers?|dead[-_]?code)\b/i.exec(rest); |
| 85 | if (m) { |
| 86 | const k = m[1]!; |
| 87 | scope = /imports/i.test(k) ? 'unused-imports' |
| 88 | : /locals/i.test(k) ? 'unused-locals' |
| 89 | : /params/i.test(k) ? 'unused-params' |
| 90 | : /lint/i.test(k) ? 'lint-fix' |
| 91 | : /dep/i.test(k) ? 'dep-bump' |
| 92 | : /consolidate|duplicate|dupe|dedupe/i.test(k) ? 'consolidate-dupes' |
| 93 | : /extract|parameteri|helper/i.test(k) ? 'extract-helper' |
| 94 | : 'dead-code'; |
| 95 | rest = rest.slice(m[0].length).trim(); |
| 96 | } |
| 97 | return { scope, focus: rest, dryRun }; |
| 98 | } |
| 99 | |
| 100 | const DEAD_CODE_SELECTION = [ |
| 101 | 'SCOPE (v1 — SAFE DEAD CODE ONLY): find and remove exactly ONE piece of provably-unused code.', |
no outgoing calls
no test coverage detected