mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
Add contract_gen.py: a pure, deterministic generator that discovers every StrEnum/dataclass/card defined in contract.py (plus EntryMode, ConversationItem, and SessionView) via introspection and emits the checked-in contract_schema.json (JSON Schema draft 2020-12) and web/.../contract/types.ts. The discriminated ConversationItem union is built from _Card.__subclasses__(), one oneOf/union branch per card kind. test_contract.py gains a lockstep test that byte-compares a fresh generate() call against the checked-in files (guards drift/hand-edits) and a jsonschema.validate test that proves the generated schema is itself valid and accepts a real SessionView instance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>