mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
feat(errors): name the fields a failure's recovery selects so the CLI renders their flags (#11644)
* feat(errors): name the fields a failure's recovery selects so the CLI renders their flags
AnalysisError gains related { parameters, operations } (contract fields and operation names), projected as details.related_parameters / related_operations and kept through the domain re-attribution helpers. The CLI projection adds details.related_cli_flags for its own command's fields. inspect_plist's missing-default failure and inspect_sqlite_database's column-evaluation failure name fields only in their text.
* test(sqlite): check MCP omits CLI flags on the failure that names related fields
This commit is contained in:
1 parent
2a31e064f3
commit
0035d8edb3
11 files changed
+168
-17
No files matched your search
@@ -27,7 +27,9 @@ export const isObject = (
|
||||
* Issue paths owned by this operation take the CLI key, and a per-call
|
||||
* control a failure reports (`details.limit.parameter`, which services name
|
||||
* by contract field) gains `cli_flag`, the option that sets it on this
|
||||
* command. Any other output is returned unchanged.
|
||||
* command, and the fields its recovery names (`details.related_parameters`)
|
||||
* gain `related_cli_flags`, each field's option. Any other output is returned
|
||||
* unchanged.
|
||||
*/
|
||||
export const projectCliInputFields = <Output>(
|
||||
output: Output,
|
||||
@@ -37,17 +39,45 @@ export const projectCliInputFields = <Output>(
|
||||
if (!isObject(error) || !isObject(error.details)) return output;
|
||||
const issues = renamedIssues(error, error.details, binding);
|
||||
const limit = flaggedLimit(error.details.limit, binding);
|
||||
if (issues === undefined && limit === undefined) return output;
|
||||
const relatedFlags = relatedCliFlags(error.details, binding);
|
||||
if (issues === undefined && limit === undefined && relatedFlags === undefined)
|
||||
return output;
|
||||
return {
|
||||
...error,
|
||||
details: {
|
||||
...error.details,
|
||||
...(issues === undefined ? {} : { issues }),
|
||||
...(limit === undefined ? {} : { limit }),
|
||||
...(relatedFlags === undefined
|
||||
? {}
|
||||
: { related_cli_flags: relatedFlags }),
|
||||
},
|
||||
} as Output;
|
||||
};
|
||||
|
||||
/**
|
||||
* The option of each field this command's failure names for its recovery,
|
||||
* keyed by contract field, or undefined when it takes none of them. Fields
|
||||
* of another operation are that command's to render.
|
||||
*/
|
||||
const relatedCliFlags = (
|
||||
details: Record<string, JsonValue>,
|
||||
binding: CliInputFieldBinding,
|
||||
): Record<string, JsonValue> | undefined => {
|
||||
if (
|
||||
details.operation !== binding.operation ||
|
||||
!Array.isArray(details.related_parameters)
|
||||
)
|
||||
return undefined;
|
||||
const flags: Record<string, JsonValue> = {};
|
||||
for (const parameter of details.related_parameters) {
|
||||
if (typeof parameter !== "string") continue;
|
||||
const flag = cliFlagFor(parameter, binding);
|
||||
if (flag !== undefined) flags[parameter] = flag;
|
||||
}
|
||||
return Object.keys(flags).length === 0 ? undefined : flags;
|
||||
};
|
||||
|
||||
/** Issue paths renamed to CLI keys, or undefined when none changes. */
|
||||
const renamedIssues = (
|
||||
error: Record<string, JsonValue>,
|
||||
|
||||
Reference in new issue
Block a user