Add GenerationErrorCode enum and Transcript struct - #5
Merged
Conversation
…istency Inspired by apple/python-apple-fm-sdk, this introduces three improvements: - GenerationErrorCode enum replacing magic numbers in error_from_swift and error_from_stream, with exhaustive case-in matching for compile-time safety - Transcript struct as a first-class object wrapping session transcript JSON, with lazy-cached entries access, to_json(IO) overload, and from_json helper - Session.transcript returning Transcript object and Session.from_transcript accepting Transcript in addition to raw String (backward compatible)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GenerationErrorCodeenum 추가: Swift FFI의FFIErrorCode와 1:1 매핑되는 에러 코드 enum으로 매직 넘버를 대체하고, exhaustivecase in매칭으로 컴파일 타임 안전성 확보Transcriptstruct 추가: 세션 transcript를 퍼스트클래스 객체로 관리. lazy 캐싱된entries접근,to_json(IO)오버로드,from_json헬퍼 제공Session#transcript메서드와Session.from_transcript(Transcript)오버로드 추가 (기존transcript_json/from_transcript(String)하위 호환 유지)apple/python-apple-fm-sdk와 비교하여 부족한 부분을 개선.
Test plan
crystal build src/fm.cr --no-codegen통과crystal build spec/fm_spec.cr --no-codegen통과examples/*.cr)--no-codegen컴파일 확인