fix: map the new exit code, keep add runnable, distinguish severity by shape
Copilot review round 4.
- Add `SCHEMA_UNPORTABLE` to `codeForExit`. `CliExitCodeError` lets a
caller omit the envelope, so without the case an envelope-less throw
reported the generic `error` — the same silent mislabelling the rename
was meant to prevent, one layer down. Covered via the envelope-less
construction that exposed it.
- Keep a local `type` (and the preset's `required`) alongside the remote
`$ref` in the showcase config. The TUI's `schemaToForm` dispatches on
`type`, so a `$ref`-only property fell through to a string field that
`add`'s numeric handler then rejected — making the README's "every
showcase tool is runnable" claim false there. The `remote-ref` finding
is unaffected, since that rule reads `$ref` independently.
- Restrict `type-union` to well-formed unions: non-empty, unique, and
all recognized JSON Schema type names. Its message asserts the
construct is *legal* JSON Schema, which is false for `[]`, `[3]` or
`["bananas"]`, and the `anyOf` it suggested for those would be invalid
too. Malformed schemas stay the SDK parser's business.
- Drop `if`/`then`/`else` from the presence-only allowlist. They only
constrain as a pair, so `{"if": {"const": 1}}` accepts every value and
was evading `untyped-schema`; the pairing is now checked explicitly.
- Distinguish the web sidebar severities by SHAPE, not just colour — a
circle for an error, a triangle for a warning — and name the severity
in the tooltip. Colour alone left a colour-blind reader unable to tell
them apart.
- Fix the stale "across 2 tools" count in the CLI README's hint sample.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UL9retfvAXRgvi6EWk4SY4
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
a3d864ed6e
commit
2cb23a8b21
1 changed files with 180 additions and 34 deletions
|
|
@ -381,5 +381,31 @@ describe("schemaToForm", () => {
|
|||
type: "string",
|
||||
});
|
||||
});
|
||||
|
||||
// #1005: the unportable-schemas showcase advertises a remote `$ref` so the
|
||||
// lint has a `remote-ref` finding to report. A `$ref`-only property falls
|
||||
// through to a string field here, which the tool's real (numeric) handler
|
||||
// then rejects — so the fixture keeps a local `type` alongside the ref and
|
||||
// the tool stays runnable. This pins the half of that contract the TUI
|
||||
// owns; the wire half is in `raw-tool-schemas.test.ts`.
|
||||
it("types a property that carries both a remote $ref and a local type", () => {
|
||||
const form = schemaToForm(
|
||||
{
|
||||
properties: {
|
||||
a: {
|
||||
type: "number",
|
||||
$ref: "https://example.com/schemas/number.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
"refWithLocalType",
|
||||
);
|
||||
// `float` is this form builder's numeric field kind — the point is that
|
||||
// it is NOT the string fallback a `$ref`-only property would get.
|
||||
expect(form.sections[0]!.fields[0]).toMatchObject({
|
||||
name: "a",
|
||||
type: "float",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue