Coordinator now takes a StageTaskRunner and injected context/KB ports. Chatflow assembler reads maturity tokens instead of the orchestration root. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package coordinator_test
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/coordinator"
|
|
"chat-agent-system/internal/intent"
|
|
)
|
|
|
|
func TestEngine_RunStatusQuery_WithWorkDir(t *testing.T) {
|
|
rec := intent.NewRecognizer()
|
|
engine := coordinator.NewCoordinatorEngine(nil)
|
|
|
|
recRes, err := rec.Recognize(context.Background(), "这次任务运行状态怎么样了?", nil)
|
|
if err != nil {
|
|
t.Fatalf("recognize: %v", err)
|
|
}
|
|
|
|
userCtx := &coordinator.UserProjectContext{
|
|
User: coordinator.UserInfo{ID: "1", Name: "用户"},
|
|
Project: coordinator.ProjectInfo{Name: "项目"},
|
|
WorkDir: "/data/dev/ws-123",
|
|
BlackboardFacts: map[string]string{},
|
|
}
|
|
|
|
res, err := engine.ProcessIntent(context.Background(), recRes, userCtx)
|
|
if err != nil {
|
|
t.Fatalf("ProcessIntent: %v", err)
|
|
}
|
|
if !strings.Contains(res.NaturalReply, "ws-123") {
|
|
t.Errorf("expected workdir in reply: %s", res.NaturalReply)
|
|
}
|
|
}
|
|
|
|
func TestEngine_RunResume_MissingWorkDirClarify(t *testing.T) {
|
|
rec := intent.NewRecognizer()
|
|
engine := coordinator.NewCoordinatorEngine(nil)
|
|
|
|
recRes, err := rec.Recognize(context.Background(), "继续上次失败的任务", nil)
|
|
if err != nil {
|
|
t.Fatalf("recognize: %v", err)
|
|
}
|
|
|
|
userCtx := &coordinator.UserProjectContext{
|
|
User: coordinator.UserInfo{ID: "1", Name: "用户"},
|
|
Project: coordinator.ProjectInfo{Name: "项目"},
|
|
BlackboardFacts: map[string]string{},
|
|
}
|
|
|
|
res, err := engine.ProcessIntent(context.Background(), recRes, userCtx)
|
|
if err != nil {
|
|
t.Fatalf("ProcessIntent: %v", err)
|
|
}
|
|
if res.Status != coordinator.StatusClarificationRequired {
|
|
t.Fatalf("expected CLARIFICATION_REQUIRED, got %s", res.Status)
|
|
}
|
|
}
|