package intent_test import ( "context" "testing" "chat-agent-system/internal/intent" ) func TestLimitedIntentPlan_QueryThenQuery(t *testing.T) { rec := intent.NewRecognizer() res, err := rec.Recognize(context.Background(), "查一下项目风险,然后查相关法规", nil) if err != nil { t.Fatalf("recognize: %v", err) } if res.IntentPlan == nil { t.Fatal("expected intent_plan for query+query combination") } if len(res.IntentPlan.Steps) != 2 { t.Fatalf("expected 2 steps, got %d", len(res.IntentPlan.Steps)) } if res.IntentPlan.Steps[0].Frame.Goal != intent.GoalQuery { t.Errorf("step1 goal want query got %s", res.IntentPlan.Steps[0].Frame.Goal) } if res.IntentPlan.Steps[1].Frame.Goal != intent.GoalQuery { t.Errorf("step2 goal want query got %s", res.IntentPlan.Steps[1].Frame.Goal) } } func TestSupplementSubtype_InV2Frame(t *testing.T) { rec := intent.NewRecognizer() res, err := rec.Recognize(context.Background(), "客户反馈附件已上传,请入库", nil) if err != nil { t.Fatalf("recognize: %v", err) } if res.IntentFrameV2 == nil || res.IntentFrameV2.Subtype != "attach" { t.Errorf("expected subtype attach, got %+v", res.IntentFrameV2) } } func TestRunMatcher_ResumeRequiresClarification(t *testing.T) { rec := intent.NewRecognizer() res, err := rec.Recognize(context.Background(), "继续上次失败的任务", nil) if err != nil { t.Fatalf("recognize: %v", err) } if res.TopIntent.Intent != intent.IntentRunResume { t.Fatalf("expected RUN_RESUME, got %s", res.TopIntent.Intent) } if !res.RequiresClarifying && res.TopIntent.ClarificationQuestion == "" { t.Error("expected clarification when work_dir missing") } } func TestRunMatcher_StatusQuery(t *testing.T) { rec := intent.NewRecognizer() res, err := rec.Recognize(context.Background(), "上次任务运行状态怎么样了?", nil) if err != nil { t.Fatalf("recognize: %v", err) } if res.TopIntent.Intent != intent.IntentRunStatusQuery { t.Fatalf("expected RUN_STATUS_QUERY, got %s", res.TopIntent.Intent) } }