Skip to content

Add GenerationErrorCode enum and Transcript struct - #5

Merged
hahwul merged 1 commit into
mainfrom
cosmic-spectrograph
Mar 29, 2026
Merged

Add GenerationErrorCode enum and Transcript struct#5
hahwul merged 1 commit into
mainfrom
cosmic-spectrograph

Conversation

@hahwul

@hahwul hahwul commented Mar 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • GenerationErrorCode enum 추가: Swift FFI의 FFIErrorCode와 1:1 매핑되는 에러 코드 enum으로 매직 넘버를 대체하고, exhaustive case in 매칭으로 컴파일 타임 안전성 확보
  • Transcript struct 추가: 세션 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 (examples/*.cr) --no-codegen 컴파일 확인

…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)
@hahwul
hahwul merged commit 231b198 into main Mar 29, 2026
1 check passed
@hahwul
hahwul deleted the cosmic-spectrograph branch March 29, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant