feat(cli): add bizdev-cli runner tool and integration tests

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WeiCHEN
2026-09-13 02:50:18 +00:00
committed by weichen
co-authored by Cursor
parent c65f5e8a3d
commit 713ff94ff8
2 changed files with 81 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"path/filepath"
"chat-agent-system/internal/bizdev"
"chat-agent-system/internal/config"
)
func main() {
taskKey := flag.String("task", "intake", "任务标识 (intake, research, cdo_quote 等)")
backend := flag.String("backend", "stub", "智能体后端 (stub, pi-agent, cursor-cli)")
project := flag.String("project", "医疗器械研发演示项目", "项目名称")
customer := flag.String("customer", "北京水木东方", "客户名称")
envPath := flag.String("env", ".env", "环境配置文件路径")
flag.Parse()
cfg, err := config.Load(*envPath)
if err != nil {
fmt.Fprintf(os.Stderr, "加载配置失败: %v\n", err)
os.Exit(1)
}
if *backend != "" {
cfg.AgentBackend = *backend
}
svc := bizdev.NewService(cfg)
res, err := svc.ExecuteTask(context.Background(), bizdev.TaskRunRequest{
TaskKey: *taskKey,
ProjectName: *project,
CustomerName: *customer,
Backend: *backend,
})
if err != nil {
fmt.Fprintf(os.Stderr, "任务执行失败: %v\n", err)
os.Exit(1)
}
fmt.Printf("=== 任务执行成功 [%s] ===\n", res.TaskKey)
fmt.Printf("耗时: %v\n", res.Duration)
fmt.Printf("工作区: %s\n", res.WorkDir)
fmt.Printf("使用的后端: %s\n", res.BackendUsed)
if len(res.Attachments) > 0 {
fmt.Printf("附加产物:\n")
for _, a := range res.Attachments {
p := filepath.Join(res.WorkDir, a.Filename)
fmt.Printf(" - %s (%d bytes) -> %s\n", a.Filename, len(a.Data), p)
}
}
}
+26
View File
@@ -0,0 +1,26 @@
package main_test
import (
"os/exec"
"path/filepath"
"strings"
"testing"
)
func moduleRoot(t *testing.T) string {
t.Helper()
out, err := exec.Command("go", "env", "GOMOD").Output()
if err != nil {
t.Fatalf("go env GOMOD: %v", err)
}
return filepath.Dir(strings.TrimSpace(string(out)))
}
func TestBizdevCLIHelpAndRun(t *testing.T) {
cmd := exec.Command("go", "run", "./cmd/bizdev-cli", "-help")
cmd.Dir = moduleRoot(t)
out, _ := cmd.CombinedOutput()
if !strings.Contains(string(out), "-task") {
t.Fatalf("cli output missing -task flag: %s", string(out))
}
}