Remove heuristic subagent config shortcut

This commit is contained in:
lpf
2026-03-13 16:06:30 +08:00
parent 029676b375
commit 60eee65fec
5 changed files with 1 additions and 311 deletions

View File

@@ -10,31 +10,6 @@ import (
"github.com/YspCoder/clawgo/pkg/runtimecfg"
)
func DraftConfigSubagent(description, agentIDHint string) map[string]interface{} {
desc := strings.TrimSpace(description)
lower := strings.ToLower(desc)
role := inferDraftRole(lower)
agentID := strings.TrimSpace(agentIDHint)
if agentID == "" {
agentID = inferDraftAgentID(role, lower)
}
displayName := inferDraftDisplayName(role, agentID)
toolAllowlist := inferDraftToolAllowlist(role)
keywords := inferDraftKeywords(role, lower)
return map[string]interface{}{
"agent_id": agentID,
"role": role,
"display_name": displayName,
"description": desc,
"notify_main_policy": "final_only",
"system_prompt_file": "agents/" + agentID + "/AGENT.md",
"memory_namespace": agentID,
"tool_allowlist": toolAllowlist,
"routing_keywords": keywords,
"type": "worker",
}
}
func UpsertConfigSubagent(configPath string, args map[string]interface{}) (map[string]interface{}, error) {
configPath = strings.TrimSpace(configPath)
if configPath == "" {
@@ -284,113 +259,3 @@ func normalizeKeywords(items []string) []string {
}
return out
}
func inferDraftRole(lower string) string {
switch {
case containsDraftKeyword(lower, "test", "regression", "qa", "鍥炲綊", "娴嬭瘯", "楠岃瘉"):
return "testing"
case containsDraftKeyword(lower, "doc", "docs", "readme", "鏂囨。", "璇存槑"):
return "docs"
case containsDraftKeyword(lower, "research", "investigate", "analyze", "璋冪爺", "鍒嗘瀽", "鐮旂┒"):
return "research"
default:
return "coding"
}
}
func inferDraftAgentID(role, lower string) string {
switch role {
case "testing":
if containsDraftKeyword(lower, "review", "瀹℃煡", "reviewer") {
return "reviewer"
}
return "tester"
case "docs":
return "doc_writer"
case "research":
return "researcher"
default:
if containsDraftKeyword(lower, "frontend", "ui", "鍓嶇") {
return "frontend-coder"
}
if containsDraftKeyword(lower, "backend", "api", "鍚庣") {
return "backend-coder"
}
return "coder"
}
}
func inferDraftDisplayName(role, agentID string) string {
switch role {
case "testing":
return "Test Agent"
case "docs":
return "Docs Agent"
case "research":
return "Research Agent"
default:
if strings.Contains(agentID, "frontend") {
return "Frontend Code Agent"
}
if strings.Contains(agentID, "backend") {
return "Backend Code Agent"
}
return "Code Agent"
}
}
func inferDraftToolAllowlist(role string) []string {
switch role {
case "testing":
return []string{"shell", "filesystem", "process_manager", "sessions"}
case "docs":
return []string{"filesystem", "read_file", "write_file", "edit_file", "repo_map", "sessions"}
case "research":
return []string{"web_search", "web_fetch", "repo_map", "sessions", "memory_search"}
default:
return []string{"filesystem", "shell", "repo_map", "sessions"}
}
}
func inferDraftKeywords(role, lower string) []string {
seed := []string{}
switch role {
case "testing":
seed = []string{"test", "regression", "verify", "鍥炲綊", "娴嬭瘯", "楠岃瘉"}
case "docs":
seed = []string{"docs", "readme", "document", "鏂囨。", "璇存槑"}
case "research":
seed = []string{"research", "analyze", "investigate", "璋冪爺", "鍒嗘瀽", "鐮旂┒"}
default:
seed = []string{"code", "implement", "fix", "refactor", "浠g爜", "瀹炵幇", "淇", "閲嶆瀯"}
}
if containsDraftKeyword(lower, "frontend", "鍓嶇", "ui") {
seed = append(seed, "frontend", "ui", "鍓嶇")
}
if containsDraftKeyword(lower, "backend", "鍚庣", "api") {
seed = append(seed, "backend", "api", "鍚庣")
}
return normalizeKeywords(seed)
}
func inferDraftSystemPrompt(role, description string) string {
switch role {
case "testing":
return "浣犺礋璐f祴璇曘€侀獙璇併€佸洖褰掓鏌ヤ笌椋庨櫓鍙嶉銆備换鍔℃弿杩帮細" + description
case "docs":
return "浣犺礋璐f枃妗g紪鍐欍€佺粨鏋勬暣鐞嗗拰璇存槑琛ュ叏銆備换鍔℃弿杩帮細" + description
case "research":
return "浣犺礋璐h皟鐮斻€佸垎鏋愩€佹瘮杈冩柟妗堬紝骞惰緭鍑虹粨璁轰笌渚濇嵁銆備换鍔℃弿杩帮細" + description
default:
return "浣犺礋璐d唬鐮佸疄鐜颁笌閲嶆瀯锛岃緭鍑哄叿浣撲慨鏀瑰缓璁拰鍙樻洿缁撴灉銆備换鍔℃弿杩帮細" + description
}
}
func containsDraftKeyword(text string, items ...string) bool {
for _, item := range items {
if strings.Contains(text, strings.ToLower(strings.TrimSpace(item))) {
return true
}
}
return false
}