Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e0a2723e3 | ||
|
|
34b1822426 |
@@ -8,7 +8,7 @@
|
||||
- 설계·계획: [`docs/gemnoki-project-plan.pdf`](docs/gemnoki-project-plan.pdf), 개발 구조·인터페이스: [`docs/dev/ARCHITECTURE.md`](docs/dev/ARCHITECTURE.md)
|
||||
- 범인찾기 · 리플레이 동기화 계획서 v1.2 (결정 반영): [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf) · 원본 · 비용 계산 · 프롬프트 초안: `docs/report/culprit/` (실제로 쓰는 프롬프트는 `site/server/prompt/`)
|
||||
- **제작 완료 보고서 (M0~M8)**: [`docs/gemnoki-final-report.pdf`](docs/gemnoki-final-report.pdf) · 단계별 테스트 기록: [`docs/dev/test-results.md`](docs/dev/test-results.md)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0) (`GameVoiceRecorder-1.0.0-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.0.0-portable.exe`)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.3.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.0) (`GameVoiceRecorder-1.3.0-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.3.0-portable.exe`) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
|
||||
## 로그인 · 관리자 (v1.2.0~)
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
- **전적 사이트 점수 참고**: 평점과 범인은 전적 사이트 점수에서 출발해 승부처 · 역할 · 경제 · 음성 소통으로 더하고 뺀다 (지시문 v1.2)
|
||||
- **기록 점수** (0~10, 모든 경기): OP.GG OP스코어를 우리 기록으로 다시 계산한 점수 + 경기/팀 순위 + MVP · ACE + 점수를 올리고 깎은 지표. 발로란트는 OP.GG 가 밝힌 입력(라운드 승률 · KAST · ACS · 피해 격차), 롤은 킬 관여 · 데스 · 딜/받은 피해/골드 비중 · CS · 레벨 · CC · 와드. 계수는 OP.GG 공식 MCP 로 받은 실제 경기의 OP스코어에 맞췄다 (교차 검증: 발로란트 상관 0.97 · 평균 오차 0.49점, 롤 상관 0.94 · 0.60점 · 팀 최하위 일치 85%). `packages/shared/src/rating.ts`, 맞추는 도구 `tools/opscore-fit/`
|
||||
- **OP.GG 실제 OP스코어**: 분석할 때 OP.GG 공식 MCP(`mcp-api.op.gg`)에서 그 경기를 찾으면 그 사이트의 실제 점수를 같이 준다 (롤: 시작 시각 · 길이로 찾고 10명, 발로란트: 경기 번호로 선수마다). 내전(사용자 설정 게임)은 OP.GG 에 없어 기록 점수만 쓴다. `site/server/src/opgg.ts`, 끄기 `CULPRIT_OPGG=0`
|
||||
- **LOL.PS 라인전**: 롤 15분에 맞라인 상대와 CS · 골드 · 경험치 차
|
||||
- **LOL.PS 라인전**: LOL.PS 라인전 점수의 입력과 같은 10 · 15분 맞라이너 CS · 골드 · 경험치 차 (LOL.PS 점수 모델은 공개되지 않아 차이 값만). 참고한 원문 · 구현 대응: [`tools/opscore-fit/README.md`](tools/opscore-fit/README.md)
|
||||
- 실제 E2E (2026-10-15, `app/scripts/culprit-real-e2e.mts`): 실제 Claude Opus 5.5(생각 high) + 실제 OP.GG. 발로란트 시연 경기 42초 · $0.15, 롤 실제 랭크 경기(OP.GG 점수 10명 찾음) 36초 · $0.11. 기록 · [`docs/dev/test-results.md`](docs/dev/test-results.md)
|
||||
- 리플레이 동기화: 공식 · 비공식 API 로 리플레이 시간을 읽을 수 있을 때만 넣는다 (화면 글자 인식(OCR) · 게임 설정 파일 고치기는 하지 않음). Windows 실기 확인 전이라 v1.3.0 에는 없다
|
||||
- 앱: 경기 상세에서 추가 지표 저장(발로란트 피해량 · 받은 피해 · KAST · 첫킬 · 설치/해체 · 라운드별 장비, 롤 포지션 · 딜량 · 시야 · 10/15분 CS), "분석할 수 있는 경기" 판정(경기 결과 · 녹음 공백 1분 · 음성 변환), 근거 번호가 달린 AI 자료 만들기, 결과 저장(`culprit_analyses`). `app/src/core/culprit.ts`
|
||||
@@ -65,6 +65,7 @@
|
||||
| M6 단어사전 · UI/UX | 핫워드·교정 사전, 사이트 교정 반영, 테마·애니메이션·효과음 | ✅ 완료 ([사전 효과](docs/dev/test-results.md)) |
|
||||
| M7 실사용 테스트 | 통합 테스트, 성능·안정화 | ✅ 완료 (GPU 실음성: CER 3.6%, 지연 1.05초 · [기록](docs/dev/test-results.md)) |
|
||||
| M8 파인튜닝 | 교정 데이터 + 합성 음성 LoRA 학습, 오류율 비교 후 교체 | ✅ 완료 (GPU 시험 학습: CER 4.8% → 1.8%) |
|
||||
| 범인찾기 (v1.3.0) | AI(Claude Opus 5.5 high) 10명 평점 · 팀별 범인 · 근거, 기록 점수(OP.GG OP스코어 방식) · OP.GG 실제 점수 · LOL.PS 라인전 | ✅ 완료 (실제 Claude · OP.GG E2E, 사이트 배포, [v1.3.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.0) · 리플레이 동기화는 Windows 실기 확인 뒤) |
|
||||
|
||||
## 저장소 구조
|
||||
|
||||
|
||||
4
app/package-lock.json
generated
4
app/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gvr-app",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"productName": "겜녹이",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
|
||||
"private": true,
|
||||
"main": "dist/main.cjs",
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
CulpritMatchItem,
|
||||
CulpritPlayer,
|
||||
CulpritRefTarget,
|
||||
LaneDiff,
|
||||
MatchPlayer,
|
||||
MatchRound,
|
||||
PlayerRating,
|
||||
@@ -364,7 +365,7 @@ function ratingLines(game: string, players: CulpritPlayer[]): string[] {
|
||||
const head =
|
||||
game === 'valorant'
|
||||
? '# 기록 점수 (0~10, OP.GG OP스코어 방식: 라운드 승률 · KAST · ACS · 피해 격차를 실제 OP.GG 점수에 맞춘 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점)'
|
||||
: '# 기록 점수 (0~10, OP.GG OP스코어 방식: 킬 관여 · 데스 · 딜/받은 피해 · 골드 · CS · 레벨 · CC · 와드를 실제 OP.GG 점수에 맞춘 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점, 라인전 = LOL.PS 방식 15분 맞라인 상대와의 차)';
|
||||
: '# 기록 점수 (0~10, OP.GG OP스코어 방식: 킬 관여 · 데스 · 딜/받은 피해 · 골드 · CS · 레벨 · CC · 와드를 실제 OP.GG 점수에 맞춘 계산. 경기 순위/팀 순위, 경기 평균보다 점수를 올린 강점 · 깎은 약점, 라인전 = LOL.PS 라인전 점수의 입력인 10 · 15분 맞라이너와의 CS · 골드 · 경험치 차)';
|
||||
const out = [head];
|
||||
if (players.some((p) => p.rating?.basic)) out.push('# (추가 지표가 없어 K/D/A · 골드 · CS 같은 기본 기록으로만 낸 점수다)');
|
||||
const idOf = new Map(players.map((p) => [p.puuid, p.id]));
|
||||
@@ -374,7 +375,8 @@ function ratingLines(game: string, players: CulpritPlayer[]): string[] {
|
||||
const up = r.parts.filter((x) => x.good).map((x) => x.text);
|
||||
const down = r.parts.filter((x) => !x.good).map((x) => x.text);
|
||||
const parts = [up.length ? `강점 ${up.join(', ')}` : '', down.length ? `약점 ${down.join(', ')}` : ''].filter(Boolean).join(' / ');
|
||||
const lane = r.lane ? ` 라인전(15분 vs ${idOf.get(r.lane.vs) ?? '?'}) CS${signedNum(r.lane.cs)} 골드${signedNum(r.lane.gold)} 경험치${signedNum(r.lane.xp)}` : '';
|
||||
const at = (min: number, d?: LaneDiff) => (d ? ` ${min}분 CS${signedNum(d.cs)} 골드${signedNum(d.gold)} 경험치${signedNum(d.xp)}` : '');
|
||||
const lane = r.lane ? ` 라인전(vs ${idOf.get(r.lane.vs) ?? '?'})${at(10, r.lane.at10)}${at(15, r.lane.at15)}` : '';
|
||||
out.push(`${p.id} ${r.score.toFixed(1)}점 ${r.rank}위/팀${r.teamRank}위${r.badge ? ` ${r.badge}` : ''}${parts ? ` · ${parts}` : ''}${lane ? ` ·${lane}` : ''}`);
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -138,12 +138,14 @@ test('범인찾기: 롤 포지션 · 시야 · 10/15분 지표와 골드 차', (
|
||||
assert.match(input.text, /\n# 골드 차\(우리-상대\): 5분 [+-][\d,]+ · 10분/);
|
||||
assert.match(input.text, /\n\[e\d+\] \d+:\d+ 킬 P\d+ → P\d+/);
|
||||
assert.match(input.text, /\n\[e\d+\] \d+:\d+ 내셔 남작 처치 우리 팀 · P2\n/);
|
||||
// 기록 점수 + LOL.PS 방식 라인전 (15분 맞라인 상대와 차)
|
||||
// 기록 점수 + LOL.PS 라인전 점수의 입력 (10 · 15분 맞라이너와 차)
|
||||
assert.match(input.text, /\n# 기록 점수 \(0~10, OP\.GG OP스코어 방식/);
|
||||
assert.match(input.text, /\nP1 \d+\.\d점 \d+위\/팀\d위.* · 라인전\(15분 vs P6\) CS[+-][\d,]+ 골드[+-][\d,]+ 경험치[+-][\d,]+\n/);
|
||||
assert.match(input.text, /\nP1 \d+\.\d점 \d+위\/팀\d위.* · 라인전\(vs P6\) 10분 CS[+-][\d,]+ 골드[+-][\d,]+ 경험치[+-][\d,]+ 15분 CS[+-][\d,]+ 골드[+-][\d,]+ 경험치[+-][\d,]+\n/);
|
||||
const p1 = input.players.find((p) => p.id === 'P1')!;
|
||||
const p6 = input.players.find((p) => p.id === 'P6')!;
|
||||
assert.equal(p1.rating!.lane!.cs, -p6.rating!.lane!.cs, '맞라인 차는 서로 반대');
|
||||
assert.equal(p1.rating!.lane!.at15!.cs, -p6.rating!.lane!.at15!.cs, '맞라인 차는 서로 반대');
|
||||
assert.equal(p1.rating!.lane!.at10!.xp, -p6.rating!.lane!.at10!.xp);
|
||||
assert.ok(p1.rating!.lane!.at10!.cs !== undefined && p1.rating!.lane!.at15!.gold !== undefined);
|
||||
assert.equal(input.players.filter((p) => p.rating?.badge).length, 2);
|
||||
assert.equal(p1.tag !== undefined, true);
|
||||
});
|
||||
|
||||
@@ -142,3 +142,12 @@ VOICE E2E PASS
|
||||
- AI 평점은 전적 사이트 점수에서 출발해 승부처 · 대화로 조정됨 (롤 10명 AI 평점과 OP.GG 점수 차 평균 0.2점, 최대 0.5점). 범인 이유에 "OP.GG 점수 3.0으로 경기 최하위", "기록 점수는 현우와 5.0점 공동 최하위 … 그래서 Duck" 처럼 점수와 근거를 같이 씀
|
||||
- 이 롤 경기에서 기록 점수와 실제 OP.GG 점수 차: 평균 0.5점, 팀 최하위 2팀 모두 일치
|
||||
- 단위 · 통합 테스트: 앱 40개 · 사이트 서버 18개 통과 (`rating.test.ts`: 실제 OP.GG 표본 20경기 · 발로란트 40명으로 평균 오차와 팀 최하위 일치 확인)
|
||||
- 배포: 사이트 서버(.5 `gvr-web`)에 `ANTHROPIC_API_KEY` 넣고 배포, 컨테이너 안에서 Claude API(`claude-opus-5-5` 200) · OP.GG MCP(200, 세션 받음) 연결 확인, healthz 정상
|
||||
- Windows CI (be89317, full): worker_setup · ocr_lang · worker_pytest · win_smoke · worker_build · worker_exe_smoke · app_build · app_smoke 모두 PASS, 앱 버전 1.3.0 → Gitea 릴리스 v1.3.0
|
||||
|
||||
## 범인찾기 v1.3.1 (2026-10-15)
|
||||
|
||||
- OP.GG 클라이언트: 세션이 끝났다는 404 를 받으면 MCP 규격대로 새로 `initialize` 하고 한 번 다시 부른다 (가짜 서버로 재시작 → 새 세션 → 계속 사용 확인, 503 은 다시 시작하지 않고 실패)
|
||||
- OP.GG "조회 실패"와 "경기 없음"을 나눈다: 결과 `meta.opgg.error`, 화면 "OP.GG 조회 실패 · 기록 점수로 분석", 지시문 "이 줄이 없으면 OP.GG 에 없는 경기이거나 조회하지 못한 경기". 실제 OP.GG: 랭크 경기 10명 찾음, 잘못된 주소 → `error` (3번 중 3번 실패: OP.GG 404)
|
||||
- LOL.PS 라인전: LOL.PS 원문 정의("10, 15분 맞라이너 골드차, 경험치차, cs차이")대로 10분 값을 더해 10 · 15분 차이를 보여 준다. 참고한 원문과 구현 대응은 `tools/opscore-fit/README.md`
|
||||
- 테스트: 앱 40개 · 사이트 서버 20개 통과, 화면 오류 · CSP 위반 없음
|
||||
|
||||
@@ -290,8 +290,8 @@ export interface CulpritAnalysis {
|
||||
usage?: { input: number; output: number; cacheRead?: number; cacheWrite?: number };
|
||||
inputStats?: CulpritInput['stats'];
|
||||
fallback?: boolean;
|
||||
/** OP.GG 실제 점수를 찾았는지 · 못 찾은 이유 */
|
||||
opgg?: { found: boolean; note?: string };
|
||||
/** OP.GG 실제 점수를 찾았는지 · 못 찾은 이유. error = 조회 실패로 확인 못 함 (경기 없음과 다르다) */
|
||||
opgg?: { found: boolean; error?: boolean; note?: string };
|
||||
};
|
||||
}
|
||||
export interface CulpritMatchItem {
|
||||
|
||||
@@ -6,7 +6,8 @@ import { LOL_MODEL, VALORANT_MODEL, type LinearModel } from './rating-model.js';
|
||||
* - 발로란트: OP.GG OP스코어. OP.GG 가 밝힌 입력(라운드 승률 · KAST · ACS · 피해량 격차)을 실제 OP.GG 점수에 맞춘 선형 모델
|
||||
* - 롤: OP.GG OP스코어. 킬 관여 · 데스 · 딜/받은 피해 비중 · 골드 · CS · 레벨 · CC · 와드를 실제 OP.GG 점수에 맞춘 선형 모델
|
||||
* (포지션별로 나눠도 나아지지 않았다. 딜 · 받은 피해 · 와드 비중이 포지션 차이를 담고, 내전은 포지션 추정이 틀릴 수 있다)
|
||||
* - 롤 라인전: LOL.PS 처럼 15분 맞라인 상대와 CS · 골드 · 경험치 차 (점수에는 넣지 않고 따로 보여 준다)
|
||||
* - 롤 라인전: LOL.PS 라인전 점수의 입력과 같은 10 · 15분 맞라이너 골드 · 경험치 · CS 차 (LOL.PS 점수 자체는 AI 추론이라 공개되지 않아
|
||||
* 점수로 바꾸지 않고 차이 값만 보여 준다. 원문 · 근거: tools/opscore-fit/README.md)
|
||||
* 계수는 tools/opscore-fit (OP.GG 공식 MCP 로 받은 실제 경기) 에서 만든다. 승패 · MVP/ACE 표시도 OP.GG 와 같다.
|
||||
*/
|
||||
|
||||
@@ -17,6 +18,12 @@ export interface RatingPart {
|
||||
good: boolean;
|
||||
}
|
||||
|
||||
export interface LaneDiff {
|
||||
cs: number;
|
||||
gold: number;
|
||||
xp: number;
|
||||
}
|
||||
|
||||
export interface PlayerRating {
|
||||
/** 0~10, 0.1 단위 */
|
||||
score: number;
|
||||
@@ -28,8 +35,8 @@ export interface PlayerRating {
|
||||
badge: 'MVP' | 'ACE' | null;
|
||||
/** 점수를 가장 많이 올리고 깎은 지표 (각각 최대 2개) */
|
||||
parts: RatingPart[];
|
||||
/** 롤 15분 맞라인 비교 (LOL.PS 라인전 지표). 맞상대를 모르면 없음 */
|
||||
lane?: { vs: string; cs: number; gold: number; xp: number };
|
||||
/** 롤 10 · 15분 맞라이너와의 차 (LOL.PS 라인전 점수의 입력). 맞상대를 모르면 없음, 그 시각 기록이 없으면 그 칸만 없음 */
|
||||
lane?: { vs: string; at10?: LaneDiff; at15?: LaneDiff };
|
||||
/** 추가 지표 없이 기본 기록(K/D/A 등)만으로 낸 점수 */
|
||||
basic: boolean;
|
||||
}
|
||||
@@ -188,15 +195,17 @@ export function rateLol(players: MatchPlayer[], minutes: number, allyWin: boolea
|
||||
const scores = feats.map((f) => apply(model, f));
|
||||
const parts = feats.map((f) => explain(model, f, mean, LOL_INFO));
|
||||
const out = finish(players, scores, parts, !full, (p) => (allyWin === null ? null : p.ally === allyWin));
|
||||
// 라인전 (LOL.PS): 같은 포지션 상대가 딱 한 명이면 15분 차이
|
||||
// 라인전 (LOL.PS): 같은 포지션 상대가 딱 한 명이면 10 · 15분 차이
|
||||
const diff = (a?: LaneDiff, b?: LaneDiff): LaneDiff | undefined => (a && b ? { cs: a.cs - b.cs, gold: a.gold - b.gold, xp: a.xp - b.xp } : undefined);
|
||||
for (const p of players) {
|
||||
const role = p.stats?.role;
|
||||
const a = p.stats?.at15;
|
||||
if (!role || !LANES.has(role) || !a) continue;
|
||||
const r = out.get(p.puuid);
|
||||
if (!r || !role || !LANES.has(role)) continue;
|
||||
const opp = players.filter((q) => q.team !== p.team && q.stats?.role === role);
|
||||
const b = opp.length === 1 ? opp[0].stats?.at15 : undefined;
|
||||
if (!b) continue;
|
||||
out.get(p.puuid)!.lane = { vs: opp[0].puuid, cs: a.cs - b.cs, gold: a.gold - b.gold, xp: a.xp - b.xp };
|
||||
if (opp.length !== 1) continue;
|
||||
const at10 = diff(p.stats?.at10, opp[0].stats?.at10);
|
||||
const at15 = diff(p.stats?.at15, opp[0].stats?.at15);
|
||||
if (at10 || at15) r.lane = { vs: opp[0].puuid, ...(at10 ? { at10 } : {}), ...(at15 ? { at15 } : {}) };
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ user 메시지의 <match> 안에 경기 자료가 온다.
|
||||
- 참가자: P1~P10 번호, 이름, 팀, 요원·챔피언과 역할(포지션), 스탯, 음성 유무(음성O / 음성X).
|
||||
- 기록 점수: 전적 사이트 OP.GG 의 OP스코어를 같은 방식으로 이 경기 기록에서 다시 계산한 0~10점. 경기 순위 · 팀 순위, 이긴 팀 1등 MVP · 진 팀 1등 ACE, 그 점수를 경기 평균보다 올린 강점과 깎은 약점이 붙는다.
|
||||
발로란트는 라운드 승률 · KAST · ACS · 피해 격차, 롤은 킬 관여 · 데스 · 딜/받은 피해/골드 비중 · CS · 레벨 · CC · 와드로 낸다. 실제 OP.GG 점수와 평균 0.5~0.6점 차이다.
|
||||
롤 "라인전(15분 vs P6) CS+12 골드+640 경험치+210" = 전적 사이트 LOL.PS 방식의 라인전 지표, 15분에 맞라인 상대보다 앞선(+) · 뒤진(-) 값.
|
||||
- "OP.GG 실제 OP스코어" 줄이 있으면 이 경기를 OP.GG 에서 찾은 그 사이트의 실제 점수다. 기록 점수보다 이것을 먼저 본다. 없으면 OP.GG 에 없는 경기(내전 등)다.
|
||||
롤 "라인전(vs P6) 10분 CS+5 골드+300 경험치+120 15분 CS+12 골드+640 경험치+210" = 전적 사이트 LOL.PS 가 라인전 점수를 낼 때 쓰는 값. 10분 · 15분에 맞라이너보다 앞선(+) · 뒤진(-) CS · 골드 · 경험치.
|
||||
- "OP.GG 실제 OP스코어" 줄이 있으면 이 경기를 OP.GG 에서 찾은 그 사이트의 실제 점수다. 기록 점수보다 이것을 먼저 본다. 이 줄이 없으면 OP.GG 에 없는 경기(내전 등)이거나 조회하지 못한 경기다.
|
||||
- 시간 순서의 줄. 줄 앞 번호가 근거 번호다.
|
||||
- [e번호] 게임 이벤트 (킬, 스파이크, 오브젝트, 라운드 결과 등)
|
||||
- [u번호] 음성 문장. 디스코드 음성채널에서 자동 음성 인식으로 받아 적은 것이라 글자가 틀릴 수 있다.
|
||||
|
||||
@@ -363,12 +363,12 @@ export function registerCulprit(app: FastifyInstance, o: CulpritOptions) {
|
||||
let fallback = false;
|
||||
try {
|
||||
// 전적 사이트 점수: 이 경기가 OP.GG 에 있으면 실제 OP스코어를 자료에 붙인다 (없거나 실패해도 기록 점수로 계속)
|
||||
let opggMeta: { found: boolean; note?: string } | undefined;
|
||||
let opggMeta: { found: boolean; error?: boolean; note?: string } | undefined;
|
||||
let input = raw;
|
||||
if (opgg && raw.lookup) {
|
||||
publish(matchId, 'collect', 'OP.GG 점수 찾는 중');
|
||||
const r = await lookupOpgg(raw, opgg).catch((e) => ({ scores: new Map(), found: false, note: `OP.GG 연결 실패 (${String(e?.message ?? e).slice(0, 80)})` }));
|
||||
opggMeta = { found: r.found, ...(r.note ? { note: r.note } : {}) };
|
||||
const r = await lookupOpgg(raw, opgg).catch((e) => ({ scores: new Map(), found: false, error: true, note: `OP.GG 연결 실패 (${String(e?.message ?? e).slice(0, 80)})` }));
|
||||
opggMeta = { found: r.found, ...(r.error ? { error: true } : {}), ...(r.note ? { note: r.note } : {}) };
|
||||
input = withOpgg(raw, r);
|
||||
log.info({ matchId, opgg: opggMeta, n: r.scores.size }, '범인찾기 OP.GG 점수');
|
||||
}
|
||||
|
||||
@@ -15,9 +15,14 @@ export interface OpggResult {
|
||||
/** P번호 → 점수 (0~10) · OP.GG 경기 순위 (롤만) */
|
||||
scores: Map<string, { score: number; rank: number | null }>;
|
||||
found: boolean;
|
||||
/** 조회가 실패해서 경기가 있는지 확인하지 못했다 (OP.GG 장애 · 연결 실패). "경기 없음"과 다르다 */
|
||||
error?: boolean;
|
||||
note?: string;
|
||||
}
|
||||
|
||||
/** 세션이 끝났다는 서버 응답 (MCP 규격: 404 → 새로 initialize) */
|
||||
class SessionExpired extends Error {}
|
||||
|
||||
export type ToolCaller = (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
||||
|
||||
/** MCP 스트리머블 HTTP 클라이언트 (세션 하나로 여러 번 부른다) */
|
||||
@@ -31,6 +36,7 @@ export function opggCaller(opts: { url?: string; timeoutMs?: number; fetchFn?: t
|
||||
const headers: Record<string, string> = { 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'user-agent': 'gvr-site/1.3' };
|
||||
if (sid) Object.assign(headers, { 'mcp-session-id': sid, 'mcp-protocol-version': PROTOCOL });
|
||||
const r = await f(url, { method: 'POST', headers, body: JSON.stringify(body), signal: AbortSignal.timeout(timeoutMs) });
|
||||
if (sid && r.status === 404) throw new SessionExpired('OP.GG 세션 만료');
|
||||
if (!r.ok) throw new Error(`OP.GG ${r.status}`);
|
||||
const s = r.headers.get('mcp-session-id');
|
||||
const text = await r.text();
|
||||
@@ -38,13 +44,26 @@ export function opggCaller(opts: { url?: string; timeoutMs?: number; fetchFn?: t
|
||||
const json = text.trimStart().startsWith('{') ? text : (text.split('\n').filter((l) => l.startsWith('data:')).pop() ?? '').slice(5);
|
||||
return { sid: s, data: JSON.parse(json) };
|
||||
};
|
||||
return async (name, args) => {
|
||||
if (!sid) {
|
||||
let starting: Promise<void> | null = null;
|
||||
const start = () =>
|
||||
(starting ??= (async () => {
|
||||
sid = null;
|
||||
const init = await post({ jsonrpc: '2.0', id: id++, method: 'initialize', params: { protocolVersion: PROTOCOL, capabilities: {}, clientInfo: { name: 'gvr', version: '1.3' } } });
|
||||
if (!init.sid) throw new Error('OP.GG 세션 없음');
|
||||
sid = init.sid;
|
||||
if (!sid) throw new Error('OP.GG 세션 없음');
|
||||
})().finally(() => (starting = null)));
|
||||
const toolCall = (name: string, args: Record<string, unknown>) => post({ jsonrpc: '2.0', id: id++, method: 'tools/call', params: { name, arguments: args } });
|
||||
return async (name, args) => {
|
||||
if (!sid) await start();
|
||||
let res;
|
||||
try {
|
||||
res = await toolCall(name, args);
|
||||
} catch (e) {
|
||||
// 세션이 끝났으면(서버 재시작 · 만료) 새 세션으로 한 번 다시
|
||||
if (!(e instanceof SessionExpired)) throw e;
|
||||
await start();
|
||||
res = await toolCall(name, args);
|
||||
}
|
||||
const res = await post({ jsonrpc: '2.0', id: id++, method: 'tools/call', params: { name, arguments: args } });
|
||||
if (res.data.error) throw new Error(`OP.GG ${name}: ${res.data.error.message ?? 'error'}`);
|
||||
const text = res.data.result?.content?.[0]?.text ?? '';
|
||||
if (res.data.result?.isError) throw new Error(`OP.GG ${name}: ${String(text).slice(0, 200)}`);
|
||||
@@ -109,6 +128,7 @@ export function parseOpgg(text: string): unknown {
|
||||
return val();
|
||||
}
|
||||
|
||||
const NOT_FOUND = 'OP.GG 에 이 경기가 없습니다 (사용자 설정 게임은 OP.GG 에 올라가지 않습니다)';
|
||||
const riotKey = (name: string, tag: string) => `${name}#${tag}`.toLowerCase().replace(/\s+/g, '');
|
||||
|
||||
/** 이 경기를 OP.GG 에서 찾아 참가자별 실제 점수. 전체 제한 시간 안에 못 끝나면 그때까지 찾은 만큼 */
|
||||
@@ -123,12 +143,26 @@ export async function lookupOpgg(input: CulpritInput, call: ToolCaller, opts: {
|
||||
// 우리 사람(음성 · 앱 계정)부터 찾아본다
|
||||
const order = [...tagged].sort((a, b) => Number(!!b.userId) - Number(!!a.userId) || Number(a.team !== 'ally') - Number(b.team !== 'ally'));
|
||||
|
||||
let calls = 0;
|
||||
let failed = 0;
|
||||
let lastError = '';
|
||||
const fail = (e: unknown) => {
|
||||
failed++;
|
||||
lastError = String((e as Error)?.message ?? e).slice(0, 80);
|
||||
};
|
||||
/** 못 찾았을 때: 조회가 모두(또는 일부) 실패했으면 "확인 못 함", 다 성공했는데 없으면 "경기 없음" */
|
||||
const missing = (): OpggResult =>
|
||||
failed
|
||||
? { scores, found: false, error: true, note: `OP.GG 조회 실패로 이 경기를 확인하지 못했습니다 (${calls}번 중 ${failed}번 실패: ${lastError})` }
|
||||
: { scores, found: false, note: NOT_FOUND };
|
||||
|
||||
if (input.game === 'valorant') {
|
||||
let seen = false;
|
||||
// 각자의 최근 경기 목록에 자기 opScore 만 있다 → 사람마다 부른다 (동시에 3개까지)
|
||||
const queue = [...order];
|
||||
const worker = async () => {
|
||||
for (let p = queue.shift(); p && Date.now() < deadline; p = queue.shift()) {
|
||||
calls++;
|
||||
try {
|
||||
const list = (await call('valorant_list_player_matches', { game_name: p.name, tag_line: p.tag })) as any;
|
||||
const arr: any[] = Array.isArray(list) ? list : (list?.data ?? []);
|
||||
@@ -136,19 +170,20 @@ export async function lookupOpgg(input: CulpritInput, call: ToolCaller, opts: {
|
||||
if (!hit) continue;
|
||||
seen = true;
|
||||
if (typeof hit.opScore === 'number' && (!hit.puuid || hit.puuid === p.puuid)) scores.set(p.id, { score: Math.round(hit.opScore / 10) / 10, rank: null });
|
||||
} catch {
|
||||
/* 이 사람은 건너뛴다 */
|
||||
} catch (e) {
|
||||
fail(e); // 이 사람은 건너뛴다
|
||||
}
|
||||
}
|
||||
};
|
||||
await Promise.all([worker(), worker(), worker()]);
|
||||
if (!seen) return { scores, found: false, note: 'OP.GG 에 이 경기가 없습니다 (사용자 설정 게임은 OP.GG 에 올라가지 않습니다)' };
|
||||
if (!seen) return missing();
|
||||
return { scores, found: scores.size > 0, note: scores.size < input.players.length ? `OP.GG 에서 ${scores.size}명 점수를 찾았습니다` : undefined };
|
||||
}
|
||||
|
||||
// 롤: 한 사람의 최근 경기에서 같은 경기(시작 ±5분 · 길이 ±2분)를 찾는다
|
||||
for (const p of order.slice(0, 3)) {
|
||||
if (Date.now() >= deadline) break;
|
||||
calls++;
|
||||
try {
|
||||
const hist = (await call('lol_list_summoner_matches', {
|
||||
game_name: p.name,
|
||||
@@ -162,6 +197,7 @@ export async function lookupOpgg(input: CulpritInput, call: ToolCaller, opts: {
|
||||
(x) => Math.abs(Date.parse(x.created_at) - lk.startedAt) < 5 * 60000 && Math.abs((x.game_length_second ?? 0) - lk.durationSec) < 120,
|
||||
);
|
||||
if (!g) continue;
|
||||
calls++;
|
||||
const det = (await call('lol_get_summoner_game_detail', {
|
||||
region,
|
||||
game_id: g.id,
|
||||
@@ -178,11 +214,11 @@ export async function lookupOpgg(input: CulpritInput, call: ToolCaller, opts: {
|
||||
if (s && typeof s.op_score === 'number') scores.set(q.id, { score: Math.round(s.op_score * 10) / 10, rank: typeof s.op_score_rank === 'number' ? s.op_score_rank : null });
|
||||
}
|
||||
return { scores, found: scores.size > 0, note: scores.size ? undefined : 'OP.GG 경기에서 참가자를 맞추지 못했습니다' };
|
||||
} catch {
|
||||
/* 다음 사람으로 */
|
||||
} catch (e) {
|
||||
fail(e); // 다음 사람으로
|
||||
}
|
||||
}
|
||||
return { scores, found: false, note: 'OP.GG 에 이 경기가 없습니다 (사용자 설정 게임은 OP.GG 에 올라가지 않습니다)' };
|
||||
return missing();
|
||||
}
|
||||
|
||||
/** AI 자료에 붙일 줄 (찾은 것만) */
|
||||
|
||||
@@ -9,7 +9,7 @@ import { buildServer } from '../src/app.ts';
|
||||
import type { Config } from '../src/config.ts';
|
||||
import { checkResult, costOf, normRef, type ModelCall } from '../src/culprit.ts';
|
||||
import { buildSystemPrompt, KnowledgeAuto, outputSchema, replaceAutoSection } from '../src/culprit-prompt.ts';
|
||||
import { lookupOpgg, parseOpgg, type ToolCaller } from '../src/opgg.ts';
|
||||
import { lookupOpgg, opggCaller, parseOpgg, type ToolCaller } from '../src/opgg.ts';
|
||||
|
||||
const tmp = () => fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'gvr-culprit-srv-'));
|
||||
|
||||
@@ -291,6 +291,27 @@ test('범인찾기: 결과 확인 규칙 · 비용 계산 · 프롬프트 조립
|
||||
assert.deepEqual(schema.required, ['summary', 'confidence', 'confidence_note', 'teams', 'players']);
|
||||
});
|
||||
|
||||
test('범인찾기 서버: OP.GG 조회 실패는 "경기 없음"과 따로 저장하고 기록 점수로 분석을 마친다', async () => {
|
||||
const h = await harness({
|
||||
calls: [(i) => ok(i)],
|
||||
opgg: async () => {
|
||||
throw new Error('OP.GG 503');
|
||||
},
|
||||
});
|
||||
try {
|
||||
assert.equal((await h.post(h.login('user1'))).status, 202);
|
||||
await waitFor(() => h.stages().includes('done') || h.stages().includes('failed'));
|
||||
assert.deepEqual(h.stages(), ['collect', 'thinking', 'verify', 'done']);
|
||||
assert.ok(!h.seen[0].user.includes('# OP.GG 실제 OP스코어'));
|
||||
const info = (await (await fetch(`${h.base}/api/culprit/matches/${h.matchId}`, { headers: { cookie: h.login('member1') } })).json()) as CulpritMatchInfo;
|
||||
assert.equal(info.analysis!.meta.opgg!.found, false);
|
||||
assert.equal(info.analysis!.meta.opgg!.error, true);
|
||||
assert.match(info.analysis!.meta.opgg!.note!, /조회 실패/);
|
||||
} finally {
|
||||
await h.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('범인찾기 서버: OP.GG 에 경기가 있으면 실제 OP스코어를 자료 · 결과에 붙인다', async () => {
|
||||
const puuidOf: Record<string, string> = {};
|
||||
const calls: string[] = [];
|
||||
@@ -372,9 +393,56 @@ test('OP.GG: 응답 해석 · 롤 경기 찾기 (시작 시각 · 길이) · 못
|
||||
const miss = await lookupOpgg({ ...input, lookup: { ...input.lookup!, startedAt: Date.parse('2026-10-14T10:00:00+09:00') } }, caller);
|
||||
assert.equal(miss.found, false);
|
||||
assert.match(miss.note!, /OP\.GG 에 이 경기가 없습니다/);
|
||||
// 연결 실패도 분석을 멈추지 않는다 (찾지 못함으로)
|
||||
// 조회가 실패하면 "경기 없음"이 아니라 "확인 못 함" (분석은 멈추지 않는다)
|
||||
const down = await lookupOpgg(input, async () => {
|
||||
throw new Error('down');
|
||||
throw new Error('OP.GG 503');
|
||||
});
|
||||
assert.equal(down.found, false);
|
||||
assert.equal(down.error, true);
|
||||
assert.match(down.note!, /OP\.GG 조회 실패로 이 경기를 확인하지 못했습니다 \(3번 중 3번 실패: OP\.GG 503\)/);
|
||||
assert.equal(miss.error, undefined, '조회는 됐는데 없으면 error 아님');
|
||||
const vMiss = await lookupOpgg({ ...input, game: 'valorant' }, async () => []);
|
||||
assert.deepEqual([vMiss.found, vMiss.error, /이 경기가 없습니다/.test(vMiss.note!)], [false, undefined, true]);
|
||||
// 일부만 실패하고 못 찾았으면 확인 못 함
|
||||
let k = 0;
|
||||
const vHalf = await lookupOpgg({ ...input, game: 'valorant' }, async () => {
|
||||
if (k++ % 2) throw new Error('OP.GG 503');
|
||||
return [];
|
||||
});
|
||||
assert.equal(vHalf.error, true);
|
||||
});
|
||||
|
||||
test('OP.GG 클라이언트: 세션이 끝나면(404) 새로 initialize 하고 다시 부른다', async () => {
|
||||
let serverSid = 's1';
|
||||
let inits = 0;
|
||||
const seen: { method: string; sid: string | null }[] = [];
|
||||
const fetchFn = (async (_url: string, init: any) => {
|
||||
const body = JSON.parse(init.body);
|
||||
const sid = init.headers['mcp-session-id'] ?? null;
|
||||
seen.push({ method: body.method, sid });
|
||||
if (body.method === 'initialize') {
|
||||
inits++;
|
||||
if (sid) return new Response('bad', { status: 400 });
|
||||
return new Response(JSON.stringify({ jsonrpc: '2.0', id: body.id, result: {} }), { status: 200, headers: { 'mcp-session-id': serverSid } });
|
||||
}
|
||||
if (sid !== serverSid) return new Response('session not found', { status: 404 });
|
||||
if (body.params.name === 'boom') return new Response('unavailable', { status: 503 });
|
||||
// SSE 로 줄 때도 읽는다
|
||||
const msg = JSON.stringify({ jsonrpc: '2.0', id: body.id, result: { content: [{ type: 'text', text: JSON.stringify({ ok: body.params.name, sid }) }] } });
|
||||
return new Response(`event: message\ndata: ${msg}\n\n`, { status: 200, headers: { 'content-type': 'text/event-stream' } });
|
||||
}) as typeof fetch;
|
||||
const call = opggCaller({ url: 'http://opgg.test/mcp', fetchFn });
|
||||
assert.deepEqual(await call('a', {}), { ok: 'a', sid: 's1' });
|
||||
// 서버가 재시작해 세션이 사라졌다
|
||||
serverSid = 's2';
|
||||
assert.deepEqual(await call('b', {}), { ok: 'b', sid: 's2' });
|
||||
assert.deepEqual(await call('c', {}), { ok: 'c', sid: 's2' }, '새 세션을 계속 쓴다');
|
||||
assert.equal(inits, 2);
|
||||
assert.deepEqual(
|
||||
seen.map((x) => `${x.method}:${x.sid ?? '-'}`),
|
||||
['initialize:-', 'tools/call:s1', 'tools/call:s1', 'initialize:-', 'tools/call:s2', 'tools/call:s2'],
|
||||
);
|
||||
// 세션 문제가 아닌 실패(503)는 다시 initialize 하지 않고 그대로 실패
|
||||
await assert.rejects(call('boom', {}), /OP\.GG 503/);
|
||||
assert.equal(inits, 2);
|
||||
});
|
||||
|
||||
@@ -428,7 +428,9 @@ function ResultView({ info, budget, onBack, onReanalyze }: { info: CulpritMatchI
|
||||
{a.meta.opgg && (
|
||||
<>
|
||||
<br />
|
||||
{a.meta.opgg.found ? 'OP.GG 실제 점수 참고' : 'OP.GG 에 없는 경기 · 기록 점수로 분석'}
|
||||
<span title={a.meta.opgg.note}>
|
||||
{a.meta.opgg.found ? 'OP.GG 실제 점수 참고' : a.meta.opgg.error ? 'OP.GG 조회 실패 · 기록 점수로 분석' : 'OP.GG 에 없는 경기 · 기록 점수로 분석'}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{budget?.canReanalyze && (
|
||||
@@ -558,11 +560,16 @@ function RefLine({ p, parts = false }: { p: CulpritPlayer; parts?: boolean }) {
|
||||
{x.good ? '▲' : '▼'} {x.text}
|
||||
</span>
|
||||
))}
|
||||
{parts && r?.lane && (
|
||||
<span className={r.lane.gold >= 0 ? 'up' : 'down'} title="LOL.PS 방식 라인전: 15분에 맞라인 상대와의 차">
|
||||
15분 라인전 CS {signed(r.lane.cs)} · 골드 {signed(r.lane.gold)}
|
||||
</span>
|
||||
)}
|
||||
{parts &&
|
||||
r?.lane &&
|
||||
([10, 15] as const).map((min) => {
|
||||
const d = min === 10 ? r.lane!.at10 : r.lane!.at15;
|
||||
return d ? (
|
||||
<span key={min} className={d.gold >= 0 ? 'up' : 'down'} title="LOL.PS 라인전 점수의 입력: 맞라이너와의 CS · 골드 · 경험치 차">
|
||||
{min}분 라인전 CS {signed(d.cs)} · 골드 {signed(d.gold)} · 경험치 {signed(d.xp)}
|
||||
</span>
|
||||
) : null;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,5 +14,18 @@
|
||||
| 롤 (기본 기록만) | 위에서 딜 · 받은 피해 · CC · 와드 뺀 것 | 상관 0.940 · 평균 오차 0.61점 · 팀 최하위 일치 83% |
|
||||
|
||||
- 롤은 포지션별로 나눈 모델이 더 낫지 않아 하나로 쓴다 (딜 · 받은 피해 · 와드 비중이 포지션 차이를 담는다. 내전은 포지션 추정이 틀릴 수 있다).
|
||||
- 롤 라인전 비교(15분 맞라인 상대와 CS · 골드 · 경험치 차)는 LOL.PS 방식으로 따로 보여 준다 (점수에는 넣지 않음, OP.GG 자료에 15분 값이 없다).
|
||||
- 표본은 OP.GG MCP 로 닿는 마스터~챌린저(롤) · 레디언트 근처(발로란트) 경기다. OP.GG 점수가 같은 실력대 안에서 매기는 상대 점수라 낮은 티어에도 그대로 쓰지만, 친구 내전에서 실제 경기를 더 모으면 다시 맞춘다.
|
||||
|
||||
## 참고한 원문과 구현 대응 (2026-10-15 확인)
|
||||
|
||||
사이트 화면 · 도움말 문구는 각 사이트가 내려주는 한국어 문구(HTML · 번역 JS)에서 그대로 옮겼다.
|
||||
|
||||
| 사이트 | 원문 인용 (… = 생략) | 우리 구현 |
|
||||
|---|---|---|
|
||||
| OP.GG 롤 (`op.gg/ko/lol/summoners/…` 의 `op_score_desc` · `op_score_info_tooltip`) | "역할군과 라인전, 킬/데스/데미지/시야장악/오브젝트 파괴 등의 지표를 종합해 게임 내 활약 정도를 측정하는 평점 시스템입니다." "평점은 0~10점을 기준으로 경기에 기여한 정도에 따라 차등 부여됩니다. 탈주 등 패배에 결정적인 영향을 끼친 경우 0점에 가까운 점수가 부여됩니다." MVP = "해당 경기에서 가장 뛰어난 활약을 보여준 1명", ACE = "팀은 비록 패배했지만 승리팀 못지 않은 활약을 보여준 1명" | 0~10 기록 점수 (롤 모델), MVP = 이긴 팀 1등 · ACE = 진 팀 1등. 계수는 OP.GG MCP 의 실제 `op_score` 에 맞춤 |
|
||||
| OP.GG 발로란트 (`op.gg/ko/valorant/profile/…` 의 `op_score_description`) | "라운드 승률, KAST, 평균 전투 점수(ACS), 피해량 격차(DDΔ) 등 발로란트의 핵심 지표를 기반으로 … 산출한 종합 실력 지표입니다." "전체 플레이어 풀을 기준으로, 같은 실력대 대비 얼마나 뛰어난 퍼포먼스를 보였는지 점수화" · `kast_tooltip` "라운드별 킬·어시·생존·트레이드 기여 비율" | 발로란트 모델 입력 = 라운드 승률 · KAST(5초 트레이드) · ACS · 라운드당 (준 피해 - 받은 피해). 계수는 MCP 의 실제 `opScore`(0~1000) 에 맞춤 |
|
||||
| LOL.PS (`lol.ps` 번역 문자열 `summoner_lane_score_desc`) | "맞라이너 대비 소환사가 라인전을 몇 대 몇 정도로 수행하는지에 대한 점수입니다. 라인전 점수는 해당 소환사 챔피언의 10, 15분 맞라이너 골드차, 경험치차, cs차이 등을 바탕으로 최종 승리에 어느정도 기여하였는가를 AI기반으로 추론하여 계산합니다." | 같은 입력인 **10 · 15분 맞라이너 골드 · 경험치 · CS 차**를 앱 기록(LCU 타임라인 10 · 15분 프레임)에서 계산해 참가자마다 보여 주고 AI 자료에 넣는다 (`rating.ts` `lane`). LOL.PS 의 AI 추론 모델은 공개되지 않아 점수로 바꾸지 않는다 |
|
||||
| LOL.PS PS 스코어 (번역 문자열) | "PS스코어는 라인전 점수, 캐리력 점수, 재화 활용도를 기반으로 산출 … 재화 활용도는 골드 당 kda, 골드 당 딜량, 한타 당 딜량 등으로 계산됩니다." 라인전 지표 탭: 레벨 격차 · 최대 CS 격차 · 시간대별 격차("게임 시간별로 발생한 맞라이너와의 CS, 골드, 경험치 격차") | 참고만 했다. PS 스코어는 공개 API · 실제 값이 없어 맞출 수 없고, 골드 비중 · 딜 비중 · KDA 는 OP.GG 모델 입력에 이미 들어 있다 |
|
||||
|
||||
- OP.GG MCP 는 OP.GG 가 AI 도구용으로 공개한 서버다 (`https://mcp-api.op.gg/mcp`, 키 없음, 도구 목록: `tools/list`). 롤 `lol_get_summoner_game_detail` 은 10명의 `op_score` · `op_score_rank`, 발로란트 `valorant_list_player_matches` 는 본인 `opScore` 를 준다.
|
||||
- LOL.PS 는 공개 API 가 없어 실제 점수를 받아 오지 않는다.
|
||||
|
||||
Reference in New Issue
Block a user