refactor(cleanup): simplify pass on R-b
The retired --profile is one list the parser drops (with its value, never an error) instead of a valued flag in six schemas, so the removed-surfaces check exempts one parser line, not seven; seen red on the old parser. The empty OPTIONAL_STRING_KEYS machinery, a one-item loop and an unused plugin-data dir go; the removed-surfaces check reads each file once; the Phase 8 slice in executor-prose-pins asserts both anchors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
94400c6c3b
commit
fdb401d0ab
9 changed files with 52 additions and 60 deletions
|
|
@ -13,37 +13,40 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { isMain } from '../util/is-main.mjs';
|
||||
|
||||
// --profile: retired in cleanup R-b: the value is consumed and ignored.
|
||||
// Flags retired with a value (cleanup R-b): the flag and the word after it,
|
||||
// when that word is not a flag, are consumed and dropped, never an error.
|
||||
const RETIRED_VALUED = ['--profile'];
|
||||
|
||||
const FLAG_SCHEMA = {
|
||||
trekbrief: {
|
||||
boolean: ['--quick', '--fg'],
|
||||
valued: ['--profile', '--approve'],
|
||||
valued: ['--approve'],
|
||||
aliases: {},
|
||||
},
|
||||
trekresearch: {
|
||||
boolean: ['--quick', '--local', '--external', '--fg'],
|
||||
valued: ['--project', '--profile'],
|
||||
valued: ['--project'],
|
||||
aliases: {},
|
||||
},
|
||||
trekplan: {
|
||||
boolean: ['--quick', '--fg'],
|
||||
valued: ['--project', '--brief', '--export', '--decompose', '--profile'],
|
||||
valued: ['--project', '--brief', '--export', '--decompose'],
|
||||
multi: ['--research'],
|
||||
aliases: {},
|
||||
},
|
||||
trekexecute: {
|
||||
boolean: ['--resume', '--dry-run', '--validate', '--fg'],
|
||||
valued: ['--project', '--step', '--session', '--profile'],
|
||||
valued: ['--project', '--step', '--session'],
|
||||
aliases: {},
|
||||
},
|
||||
trekreview: {
|
||||
boolean: ['--quick', '--fg', '--dry-run', '--validate', '--answers'],
|
||||
valued: ['--project', '--since', '--profile'],
|
||||
valued: ['--project', '--since'],
|
||||
aliases: {},
|
||||
},
|
||||
trekcontinue: {
|
||||
boolean: ['--help', '--cleanup', '--confirm', '--dry-run'],
|
||||
valued: ['--profile'],
|
||||
valued: [],
|
||||
aliases: {},
|
||||
},
|
||||
trekendsession: {
|
||||
|
|
@ -112,6 +115,11 @@ export function parseArgs(argString, command) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (RETIRED_VALUED.includes(tok)) {
|
||||
if (i + 1 < tokens.length && !tokens[i + 1].startsWith('--')) i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (schema.multi && schema.multi.includes(tok)) {
|
||||
const collected = [];
|
||||
while (i + 1 < tokens.length && !tokens[i + 1].startsWith('--')) {
|
||||
|
|
|
|||
|
|
@ -31,15 +31,7 @@ const OPTIONAL_KEYS = [
|
|||
|
||||
const OPTIONAL_BOOLEAN_KEYS = new Set(OPTIONAL_KEYS);
|
||||
|
||||
// Optional string-typed manifest keys (v4.1 Step 3 — additive forward-compat).
|
||||
// Unlike OPTIONAL_BOOLEAN_KEYS, absence is NOT defaulted — the field is simply
|
||||
// missing from `parsed` so downstream consumers can distinguish "not set" from
|
||||
// "explicitly empty string".
|
||||
const OPTIONAL_STRING_KEYS = [];
|
||||
|
||||
const OPTIONAL_STRING_KEYS_SET = new Set(OPTIONAL_STRING_KEYS);
|
||||
|
||||
export { OPTIONAL_KEYS, OPTIONAL_STRING_KEYS };
|
||||
export { OPTIONAL_KEYS };
|
||||
|
||||
/**
|
||||
* Extract the first fenced YAML block whose first non-blank line begins with
|
||||
|
|
@ -118,19 +110,6 @@ export function parseManifest(stepBody) {
|
|||
}
|
||||
}
|
||||
|
||||
// v4.1 Step 3 — string-typed optional keys. Absence == not-present (no default,
|
||||
// unlike boolean keys above) so downstream can distinguish unset vs empty string.
|
||||
for (const k of OPTIONAL_STRING_KEYS_SET) {
|
||||
if (k in parsed) {
|
||||
if (typeof parsed[k] !== 'string') {
|
||||
errors.push(issue(
|
||||
'MANIFEST_OPTIONAL_TYPE',
|
||||
`${k} must be string if present (got ${typeof parsed[k]})`,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { valid: errors.length === 0, errors, warnings, parsed };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue