협상 카드 카탈로그 팝업 — 서버 카드 목록 API + 발동 중 하이라이트

- GET /v1/nego/cards: 일반 카드 9종(정본 nego_card.json) + 와일드카드 2종, 테스트 추가(15 통과)
- 엔진 판단 패널 '전체 카드' 버튼 → 모달: ID·이름·스크립트, 현재 발동 카드 하이라이트,
  변수 {…} 안내, 로딩·실패 상태, X/배경/ESC 닫기

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP
This commit is contained in:
민헌andClaude Fable 5 committed 2026-08-31 15:07:57 +09:00
1 parent 9f5bf64b02
commit 7bcd7a0f39
5 files changed
+166 -1

No files matched your search

+29
View File
@@ -1,11 +1,20 @@
"""상태 확인 엔드포인트."""
import json
from fastapi import APIRouter, Request
from common.paths import RESOURCES_DIR
from router.v1.nego.protocol import HealthResponse
router = APIRouter(tags=["admin"])
# 와일드카드는 스텝 ID로 관리되므로 표시용 이름을 여기서 부여한다
WILD_CARD_LABELS = {
"wild_card_1pct": "1% 추가 제안",
"wild_card_budget": "재원부족 제안",
}
@router.get("/health", response_model=HealthResponse)
async def health_check():
@@ -31,3 +40,23 @@ async def get_config(request: Request):
},
"cards": engine.card_script_repo.count(),
}
@router.get("/v1/nego/cards")
async def list_cards(request: Request):
"""협상 카드 전체 목록 — 데모 콘솔의 카드 팝업용 (정본 = resources/cards)."""
engine = request.app.state.engine
cards = [
{"card_id": c.get("card_id"), "card_name": c.get("card_name"), "script": c.get("script", "")}
for c in engine.card_script_repo.find_all()
]
wild_cards = []
try:
wild = json.loads((RESOURCES_DIR / "cards" / "wild_card.json").read_text(encoding="utf-8"))
wild_cards = [
{"card_id": key, "card_name": WILD_CARD_LABELS.get(key, key), "script": item.get("script", "")}
for key, item in wild.items()
]
except (OSError, json.JSONDecodeError):
pass
return {"cards": cards, "wild_cards": wild_cards}