# task-1072.1: ThreadAuto 카드뉴스 V2 업로드 (Threads + Instagram)

## 목표
ThreadAuto 카드뉴스 V2를 1건 생성하여 **Threads와 Instagram 모두에 업로드**한다.

## 실행 절차

### 1. 환경 준비
```bash
cd /home/jay/projects/ThreadAuto
unset CLAUDECODE
```
⚠️ `unset CLAUDECODE` 필수 — Claude CLI 중첩 세션 에러 방지

### 2. Instagram 크로스 포스팅 활성화 확인
`config.py`에서 `CROSS_POST_ENABLED`가 `True`인지 확인한다.
만약 `False`이면 `True`로 변경한다.

### 3. 카드뉴스 생성 + 업로드
```bash
python3 run_card_post.py
```

이 스크립트가 수행하는 작업:
1. `evergreen_topics.json`에서 토픽 선택
2. `FiveStagePipeline`으로 5단계 콘텐츠 생성
3. `fact_guard` 수치 검증
4. `CardNewsRenderer.render_from_slides()`로 5-7장 PNG 생성
5. `cross_publisher.py`를 통해 **Threads + Instagram 동시 발행**

### 4. ★ 핵심: Threads + Instagram 동시 발행
`run_card_post.py`가 `cross_publisher.py`를 사용하여 Threads와 Instagram에 동시 발행해야 한다.
만약 `run_card_post.py`가 Threads만 발행하고 Instagram을 건너뛴다면:

**수동 Instagram 발행 방법:**
```python
# Instagram 클라이언트 직접 호출
from api.instagram_client import InstagramClient
from publisher.instagram_publisher import InstagramPublisher

publisher = InstagramPublisher()
# 이미지 URL들과 캡션으로 캐러셀 발행
await publisher.publish_cardnews(image_paths, caption)
```

또는 CLI:
```bash
python3 cli.py post-carousel <image_url1> <image_url2> ... --caption "<caption>" --instagram
```

### 5. 이미지 서빙 (업로드 시 필요)
Threads/Instagram API는 공개 URL이 필요하므로 `image_server.py`가 로컬 이미지를 서빙한다.
`publisher/image_server.py`의 ImageServer가 자동으로 처리한다.

### 6. 검증 사항
- [ ] 카드뉴스 이미지 5-7장 생성 성공 (output/ 디렉토리)
- [ ] fact_guard 검증 통과
- [ ] **Threads 업로드 성공** (post_id 수신)
- [ ] **Instagram 업로드 성공** (media_id 수신)
- [ ] 두 플랫폼 모두 동일한 카드뉴스 사용 확인
- [ ] post_id, media_id를 보고서에 기록

### 7. 에러 대응
- Instagram 토큰 만료 → `cli.py instagram-auth`로 재인증
- Threads 토큰 만료 → `cli.py auth`로 재인증
- API 에러 429 → Exponential Backoff (자동, 최대 3회)
- 이미지 서빙 실패 → image_server 포트 확인 (기본 8200)
- CROSS_POST_ENABLED=False → True로 변경 후 재실행

## 브랜딩 확인
- Badge: "서울대보험크루"
- Watermark: "서울대보험쌤"
- Footer: "인카다이렉트 TOP사업단"

## 보고서
- 경로: `memory/reports/task-1072.1.md`
- 필수 포함: 선택된 토픽, 생성된 이미지 경로(파일명), Threads post_id, Instagram media_id, 발행 시각, 캡션 전문