fix: CLI 오류 계약 통일 — 공용 load_json·exit code 표·pptx_import 비-pptx 처리 (#89)#121
Merged
Conversation
- scripts/_cli.py 신설: stdlib load_json — 파일 없음·깨진 JSON·OSError 를 한 줄 error: 로 exit 1 (트레이스백 없음). render·pptx_export·plantuml_export 공유. - exit code 계약 확정(0/1/2)·진단 프리픽스를 소문자 error:/warning: 로 통일 (검증기 3종·skills/flowcast/SKILL.md 계약과 일치). render.py 9곳 포함. - render.py: 출력 쓰기 앞 out.parent.mkdir(parents=True, exist_ok=True). - pptx_export: _import_pptx() 의존성 검사(exit 2)를 load_json 앞에 유지 (#71 순서 고정). - pptx_import: zipfile.BadZipFile → exit 1, 빈 slides(.docx류) → exit 1 (기존 {slides:[]}+exit 0 조용한 성공 봉합). - agents/diagram-drawer.md: exit code 표 + pptx 비-0 종료 partial 규칙. - 테스트: 프리픽스 단언 갱신(plantuml·pptx_export) + 신규 7건 (깨진 JSON·mkdir·BadZipFile·빈 slides). 미사용 import json 제거. Closes #89
… 유닛테스트 (#89) 리뷰(3렌즈→verify) 확정 5건 반영. 모두 이 PR이 세운 "트레이스백 없음" 계약의 미완성 갭. - _cli.py: 비-UTF8 바이트(UTF-16 BOM·이진 파일 오입력) → UnicodeDecodeError 는 ValueError 하위라 OSError/JSONDecodeError 에 안 걸려 트레이스백이 샜다. 별도 분기 ("error: UTF-8 디코딩 실패") 추가. - plantuml_export/pptx_export: 최상위가 object 가 아닌 유효 JSON(배열·스칼라)에서 data.get 이 AttributeError 트레이스백을 냈다. render.py 처럼 isinstance 가드 → 검증기가 "최상위 JSON은 object여야 함" 한 줄로 거른다. - tests/test_cli.py 신설: load_json 네 분기(파일없음·깨진 JSON·비-UTF8·OSError=디렉토리)를 직접 단언 — 커버 0이던 OSError 분기·구체 메시지 고정. + exporter 최상위 배열 CLI 테스트. 489 passed · 0 골든 drift · 3.9 import smoke/compileall OK.
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.
요약
스크립트마다 제각각이던 파일 없음·깨진 JSON 처리(traceback vs 한 줄)와 에러 프리픽스·exit code 규약을 통일한다.
변경
scripts/_cli.py신설 — stdlibload_json(path): 파일 없음·깨진 JSON(JSONDecodeError)·OSError를 한 줄error:로 exit 1(트레이스백 없음).render·pptx_export·plantuml_export가 공유.0=성공 / 1=입력·검증 오류 / 2=선택 의존성·선택 출력 실패. exit 3 은 신설하지 않는다(skills/*문구 전면 갱신 유발).error:/warning:로(검증기 3종·skills/flowcast/SKILL.md계약과 일치). render.py 9곳 + 두 exporter 포함.render.py— 출력 쓰기 앞out.parent.mkdir(parents=True, exist_ok=True).pptx_import.py—zipfile.BadZipFile→ exit 1, 빈slides(유효 zip 이지만 pptx 아님, 예: .docx) → exit 1. 기존{slides: []}+ exit 0 조용한 성공을 봉합.agents/diagram-drawer.md— exit code 표 +pptx_export비-0 종료(1·2 모두)는 export 만 실패 →pptx: null,status: partial.채택하지 않은 것 (이슈 명시)
pptx_export의_import_pptx()의존성 검사(exit 2)를 데이터 로드 뒤로 옮기지 않았다 — fix: pptx_export.py만 검증기를 호출하지 않아 잘못된 JSON이 traceback으로 터진다 #71 순서 유지.test_missing_pptx_exit2_precedes_validation이 그대로 통과한다(python-pptx 미설치 + 깨진 JSON → exit 2).검증
python3 -m pytest tests/→ 483 passed (프리픽스 단언 갱신 + 신규 7건: 깨진 JSON·mkdir·BadZipFile·빈 slides).validate_plugin_manifest.pyexit 0 ·regen-examples.sh골든 drift 0(렌더링 동작 무변화) · 3.9 import smoke·compileall OK.Closes #89