Files
Agent-System/cmd/recategorize/main.go
T
weichenandCursor 3f42149457 feat(bizdev): snapshot collaborators onto Runtime and Server ports
Composition roots copy Parts once so HTTP/CLI handlers stop calling locator getters on every request.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 13:00:33 +00:00

56 lines
1.4 KiB
Go

package main
import (
"context"
"flag"
"fmt"
"os"
"time"
"chat-agent-system/internal/bizdev"
"chat-agent-system/internal/config"
)
func main() {
envPath := flag.String("env", ".env", "环境配置文件路径")
sessionID := flag.String("session", "", "指定处理的会话ID (留空则全量回填)")
flag.Parse()
cfg, err := config.Load(*envPath)
if err != nil {
fmt.Fprintf(os.Stderr, "加载配置失败: %v\n", err)
os.Exit(1)
}
svc, err := bizdev.NewService(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "NewService: %v\n", err)
os.Exit(1)
}
ctxMgr := bizdev.Snapshot(svc).Ctx
if ctxMgr == nil {
fmt.Fprintf(os.Stderr, "ContextManager 未初始化\n")
os.Exit(1)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
fmt.Println("==================================================================")
fmt.Println(" 🔄 历史消息分类回填与数据对齐工具 (Spec §3.4 A4) ")
fmt.Println("==================================================================")
if *sessionID != "" {
fmt.Printf("处理目标会话: %s\n", *sessionID)
} else {
fmt.Println("处理目标: 全量历史消息")
}
res, err := ctxMgr.RecategorizeMessages(ctx, *sessionID)
if err != nil {
fmt.Fprintf(os.Stderr, "分类回填失败: %v\n", err)
os.Exit(1)
}
fmt.Printf("✅ 分类回填完成!\n已扫描消息数: %d\n已更新分类数: %d\n", res.TotalProcessed, res.TotalUpdated)
}