Refine onboarding state and nickname checks
This commit is contained in:
1 parent
5579db54da
commit
9c013f7d4f
33 files changed
+1523
-119
No files matched your search
@@ -26,8 +26,10 @@ function makeSession(
|
||||
chatroomId: "room-1",
|
||||
deadlineAt: "2026-04-16T12:00:00.000Z",
|
||||
joinedAt: "2026-04-16T10:00:00.000Z",
|
||||
kakaotalkNickname: "프리리/95/여/D",
|
||||
kakaotalkNicknameAliases: [],
|
||||
kakaotalkNicknameVerified: true,
|
||||
lastEventAt: "2026-04-16T10:30:00.000Z",
|
||||
nickname: "프리리/95/여/D",
|
||||
nicknameVerified: true,
|
||||
photoVerified: false,
|
||||
status: "pending",
|
||||
@@ -68,6 +70,7 @@ describe("PromptBuilder", () => {
|
||||
expect(messages[0]?.role).toBe("system");
|
||||
expect(messages[0]?.content).toContain("하트 인증이 뭐예요?");
|
||||
expect(messages[0]?.content).not.toContain("나이 제한 있나요?");
|
||||
expect(messages[0]?.content).toContain("카카오톡 닉네임");
|
||||
});
|
||||
|
||||
it("limits prompt history to the latest five turns when summary exists", () => {
|
||||
|
||||
@@ -25,7 +25,7 @@ export const EXAMPLES_BY_INTENT: Record<Intent["kind"], Example[]> = {
|
||||
"status-question": [
|
||||
{
|
||||
user: "이제 뭐 남았지?",
|
||||
assistant: "이제 방 하트 인증만 남았어요.",
|
||||
assistant: "이제 디스코드 프로필 닉네임 설정과 프로필 메시지 설정만 남아 있어요.",
|
||||
},
|
||||
{
|
||||
user: "진행상황 알려줘",
|
||||
@@ -74,7 +74,19 @@ export const EXAMPLES_BY_INTENT: Record<Intent["kind"], Example[]> = {
|
||||
{
|
||||
user: "디스코드는 언제 들어가요?",
|
||||
assistant:
|
||||
"닉네임 변경과 하트 인증을 모두 완료하신 뒤에 디스코드 안내를 받으실 수 있어요.",
|
||||
"카카오톡 닉네임 변경과 하트 인증을 완료하셨다면, 이제 디스코드 방 입장과 프로필 설정을 진행하시면 돼요.",
|
||||
},
|
||||
],
|
||||
"discord-verify-question": [
|
||||
{
|
||||
user: "디코 닉변 확인해줘",
|
||||
assistant:
|
||||
"아직 디스코드 닉네임 변경은 확인되지 않았어요.",
|
||||
},
|
||||
{
|
||||
user: "디스코드 프로필 닉네임 설정 완료했어요",
|
||||
assistant:
|
||||
"디스코드 닉네임을 확인해봤는데 아직 올바른 형식으로 확인되지는 않았어요.",
|
||||
},
|
||||
],
|
||||
"age-question": [
|
||||
|
||||
@@ -13,6 +13,12 @@ import {
|
||||
NICKNAME_FORMAT_EXAMPLE,
|
||||
TIER_CODES_TEXT,
|
||||
} from "../constants.js";
|
||||
import {
|
||||
formatRemainingSteps,
|
||||
getRemainingSteps,
|
||||
hasExtendedOnboardingTracking,
|
||||
isStep1Completed,
|
||||
} from "../state/progress.js";
|
||||
import { EXAMPLES_BY_INTENT } from "./examples.js";
|
||||
|
||||
function formatKstTimestamp(value: string | undefined): string {
|
||||
@@ -38,8 +44,8 @@ function formatNicknameStatus(session: OnboardingSession | null): string {
|
||||
}
|
||||
|
||||
return session.nicknameVerified
|
||||
? `완료 (${session.nickname})`
|
||||
: `미완료 (현재: ${session.nickname})`;
|
||||
? `완료 (${session.kakaotalkNickname})`
|
||||
: `미완료 (현재: ${session.kakaotalkNickname})`;
|
||||
}
|
||||
|
||||
function formatPhotoStatus(session: OnboardingSession | null): string {
|
||||
@@ -50,6 +56,14 @@ function formatPhotoStatus(session: OnboardingSession | null): string {
|
||||
return session.photoVerified ? "완료" : "미완료";
|
||||
}
|
||||
|
||||
function formatOptionalVerificationStatus(value: boolean | undefined): string {
|
||||
if (value === undefined) {
|
||||
return "추적 안 함";
|
||||
}
|
||||
|
||||
return value ? "완료" : "미완료";
|
||||
}
|
||||
|
||||
function formatHistory(history: ConversationMessage[]): string {
|
||||
if (history.length === 0) {
|
||||
return "(최근 대화 없음)";
|
||||
@@ -101,11 +115,13 @@ export function personaLayer(): string {
|
||||
|
||||
[커뮤니티 규칙]
|
||||
- 가입 가능 연령은 ${MIN_AGE}세 이상이야.
|
||||
- 새내기 등록은 닉네임 변경과 방 하트 인증 두 가지를 모두 완료하면 돼.
|
||||
- 새내기 등록 1단계는 카카오톡 닉네임 변경과 방 하트 인증이야.
|
||||
- 1단계 완료 후에는 디스코드 본인인증방/구인방 입장과 서버 프로필 설정이 남아 있을 수 있어.
|
||||
- 닉네임 형식은 이름/출생 연도 두 자리/성별/티어야. 예: ${NICKNAME_FORMAT_EXAMPLE}
|
||||
- 성별은 남 또는 여, 티어 코드는 ${TIER_CODES_TEXT} 중 하나야.
|
||||
- 방 하트 인증은 ${HEART_RULE_TEXT}
|
||||
- 디스코드 안내는 닉네임 변경과 하트 인증이 모두 완료된 뒤에만 해줘.`;
|
||||
- 세션에 디스코드 관련 미완료 항목이 있으면 전체 등록은 아직 완료가 아니야.
|
||||
- 디스코드 안내는 카카오톡 1단계가 완료된 뒤에만 해줘.`;
|
||||
}
|
||||
|
||||
export function policyLayer(
|
||||
@@ -144,7 +160,13 @@ export function policyLayer(
|
||||
lines.push("- 하트 인증에 대해서만 답하고 다른 절차는 언급하지 마.");
|
||||
break;
|
||||
case "discord-question":
|
||||
lines.push("- 디스코드 질문에만 답해. 완료 전이라면 먼저 온보딩 완료가 필요하다고만 알려줘.");
|
||||
lines.push("- 디스코드 질문에만 답해. 카카오톡 1단계 전이라면 먼저 닉네임 변경과 하트 인증이 필요하다고 알려줘.");
|
||||
break;
|
||||
case "discord-verify-question":
|
||||
lines.push("- 디스코드 닉네임 확인 결과만 답해.");
|
||||
lines.push("- 확인되지 않았으면 확인되지 않았다고만 답하고, 추측해서 단정하지 마.");
|
||||
lines.push("- 카카오톡 닉네임 형식이 틀리면 예시를 1개만 들고 형식에 맞게 변경해 달라고 안내해.");
|
||||
lines.push("- 사용자가 묻지 않은 디스코드 절차나 다음 단계는 먼저 붙이지 마.");
|
||||
break;
|
||||
case "age-question":
|
||||
lines.push("- 나이 제한만 간단히 답해.");
|
||||
@@ -165,11 +187,20 @@ export function stateLayer(
|
||||
session: OnboardingSession | null,
|
||||
derived: DerivedState,
|
||||
): string {
|
||||
const remaining = getRemainingSteps(session);
|
||||
|
||||
return [
|
||||
"[현재 유저 상태]",
|
||||
`- phase: ${derived.phase.kind}`,
|
||||
`- nickname: ${formatNicknameStatus(session)}`,
|
||||
`- photo: ${formatPhotoStatus(session)}`,
|
||||
`- step1(카카오톡): ${session ? (isStep1Completed(session) ? "완료" : "미완료") : "미완료"}`,
|
||||
`- 카카오톡 닉네임: ${formatNicknameStatus(session)}`,
|
||||
`- 방 하트 인증: ${formatPhotoStatus(session)}`,
|
||||
`- 디스코드 본인인증방 입장: ${formatOptionalVerificationStatus(session?.identityRoomJoined)}`,
|
||||
`- 디스코드 구인방 입장: ${formatOptionalVerificationStatus(session?.recruitingRoomJoined)}`,
|
||||
`- 디스코드 프로필 닉네임: ${formatOptionalVerificationStatus(session?.discordProfileNicknameVerified)}`,
|
||||
`- 디스코드 프로필 메시지: ${formatOptionalVerificationStatus(session?.discordProfileMessageVerified)}`,
|
||||
`- extendedTracking: ${hasExtendedOnboardingTracking(session) ? "on" : "off"}`,
|
||||
`- remaining: ${remaining.length > 0 ? formatRemainingSteps(remaining) : "없음"}`,
|
||||
`- deadline(KST): ${formatKstTimestamp(session?.deadlineAt)}`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
@@ -13,7 +13,14 @@ export function buildToolPolicy(
|
||||
}
|
||||
|
||||
if (intent === "age-question" || intent === "discord-question") {
|
||||
return "- 규칙 확인이 필요하면 lookup-community-rule 도구를 사용해 정확한 규칙만 답해.";
|
||||
return [
|
||||
"- 디스코드 일반 안내나 규칙 질문이면 lookup-community-rule 도구를 사용해 정확한 규칙만 답해.",
|
||||
"- 사용자가 디스코드 닉네임이나 프로필 설정을 끝냈다고 말하거나 반영 여부를 묻는다면 verify-discord-nickname 도구를 먼저 사용해 직접 확인해.",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
if (intent === "discord-verify-question") {
|
||||
return "- 디스코드 닉네임 확인 요청은 verify-discord-nickname 도구를 먼저 사용하고, 조회 결과만 짧게 답해.";
|
||||
}
|
||||
|
||||
if (intent === "help-where") {
|
||||
|
||||
Reference in new issue
Block a user