返回 DeepSeek-Reasonix
goal_research_budget.go
根目录 / internal / control / goal_research_budget.go
1 package control
2
3 import "strings"
4
5 // Legacy Goal classes remain for sidecar and deprecated CLI compatibility.
6 const (
7 BudgetClassSimple = "simple"
8 BudgetClassWrite = "write"
9 BudgetClassResearch = "research"
10 )
11
12 // ClassifyGoalBudget selects simple/write/research from goal text alone.
13 // Legacy CLI flags and sidecars apply on/off overrides in the control package.
14 func ClassifyGoalBudget(goal string) string {
15 if needsResearchBudget(goal) {
16 return BudgetClassResearch
17 }
18 if GoalNeedsWriteBudget(goal) {
19 return BudgetClassWrite
20 }
21 return BudgetClassSimple
22 }
23
24 func needsResearchBudget(goal string) bool {
25 trimmed := strings.TrimSpace(goal)
26 if trimmed == "" {
27 return false
28 }
29 lower := strings.ToLower(trimmed)
30 if strings.Contains(lower, ".reasonix/autoresearch/") {
31 return true
32 }
33 for _, kw := range researchBudgetStrongKeywords {
34 if strings.Contains(lower, kw) {
35 return true
36 }
37 }
38 return researchBudgetPhaseCount(lower) >= 4
39 }
40
41 func researchBudgetPhaseCount(lower string) int {
42 categories := 0
43 for _, group := range researchBudgetPhaseKeywords {
44 if containsAnyGoalKeyword(lower, group) {
45 categories++
46 }
47 }
48 return categories
49 }
50
51 func containsAnyGoalKeyword(s string, needles []string) bool {
52 for _, needle := range needles {
53 if strings.Contains(s, needle) {
54 return true
55 }
56 }
57 return false
58 }
59
60 var researchBudgetStrongKeywords = []string{
61 "持续", "长期", "彻底", "直到根因", "根因明确", "多轮",
62 "不要原地打转", "别原地打转", "完整方案", "完整做成方案",
63 "跑实验", "反复验证", "长期优化", "系统性研究", "持续研究",
64 "持续排查", "持续推进", "长期跑",
65 "long-horizon", "long horizon", "long-running", "keep researching",
66 "keep working", "root cause", "until the root cause", "do not spin",
67 "don't spin", "thoroughly", "systematically",
68 }
69
70 var researchBudgetPhaseKeywords = [][]string{
71 {"研究", "调研", "排查", "分析", "定位", "诊断", "research", "investigate", "diagnose", "analyze", "analysis"},
72 {"实现", "修复", "改造", "开发", "重构", "implement", "build", "fix", "refactor"},
73 {"验证", "测试", "复现", "联调", "benchmark", "verify", "validate", "test", "reproduce"},
74 {"优化", "完善", "提升", "收敛", "optimize", "improve", "tune", "polish"},
75 {"文档", "方案", "说明", "总结", "document", "docs", "writeup", "plan"},
76 {"发布", "上线", "提交", "pull request", "publish", "ship", "deploy"},
77 }
78
78 lines GO