diff --git a/skills/rig/rig.ts b/skills/rig/rig.ts index f201a49..8650865 100644 --- a/skills/rig/rig.ts +++ b/skills/rig/rig.ts @@ -2652,6 +2652,13 @@ function describeSchemaType(schema: Schema): string { return `array of ${itemType}`; } if ("type" in schema) { + if ((schema as { type: string }).type === "string") { + const { minLength, format } = schema as StringSchema; + if (format === "uri") return "URL string"; + if (format === "date") return "date string (YYYY-MM-DD)"; + if (format === "path") return "path string"; + if (minLength !== undefined && minLength > 0) return "non-empty string"; + } return (schema as { type: string }).type; } if ("enum" in schema) { diff --git a/src/rig.test.ts b/src/rig.test.ts index 406cc18..a25c693 100644 --- a/src/rig.test.ts +++ b/src/rig.test.ts @@ -1962,4 +1962,48 @@ describe("missing required field error message", () => { expect(result.error.message).toContain("any"); } }); + + it("reports a missing required s.nonEmptyString field as 'non-empty string'", () => { + const schema = s.object({ slug: s.nonEmptyString, name: s.string }); + const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.message).toContain("missing required field"); + expect(result.error.message).toContain("$.slug"); + expect(result.error.message).toContain("non-empty string"); + } + }); + + it("reports a missing required s.url field as 'URL string'", () => { + const schema = s.object({ endpoint: s.url, name: s.string }); + const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.message).toContain("missing required field"); + expect(result.error.message).toContain("$.endpoint"); + expect(result.error.message).toContain("URL string"); + } + }); + + it("reports a missing required s.date field as 'date string (YYYY-MM-DD)'", () => { + const schema = s.object({ createdAt: s.date, name: s.string }); + const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.message).toContain("missing required field"); + expect(result.error.message).toContain("$.createdAt"); + expect(result.error.message).toContain("date string (YYYY-MM-DD)"); + } + }); + + it("reports a missing required s.path field as 'path string'", () => { + const schema = s.object({ filePath: s.path, name: s.string }); + const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1); + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.message).toContain("missing required field"); + expect(result.error.message).toContain("$.filePath"); + expect(result.error.message).toContain("path string"); + } + }); });