llm(三协议 Provider)/ session(JSONL 持久化)/ tools(Registry、围栏、 builtin、computer)/ cdp(browser)/ skills / mcp / agent(循环、两级压缩、 编排、审批门控)+ 底座 jsonl/textx/execx/diag/scratch/spill/imagecache。 产品装配代码(config 桥接、schedule 工具、memory/plan/retro/prompt) 留在 AutoGo,宿主接入方式见 MIGRATION.md。
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestDiscoveredInstructionsSection:按路径去重、限制总量,并渲染成可读段落。
|
|
func TestDiscoveredInstructionsSection(t *testing.T) {
|
|
a := &Agent{}
|
|
a.AddInstructions("/repo/sub/AGENTS.md", "SUB-RULES")
|
|
a.AddInstructions("/repo/sub/AGENTS.md", "SUB-RULES")
|
|
sec := a.InstructionsSection()
|
|
if strings.Count(sec, "SUB-RULES") != 1 {
|
|
t.Fatalf("dedupe failed: %q", sec)
|
|
}
|
|
if !strings.Contains(sec, "discovered for the subtree") || !strings.Contains(sec, "AGENTS.md") {
|
|
t.Fatalf("section shape: %q", sec)
|
|
}
|
|
|
|
for i := 0; i < maxDiscoveredFiles+4; i++ {
|
|
a.AddInstructions(fmt.Sprintf("/repo/s%d/AGENTS.md", i), "X")
|
|
}
|
|
if len(a.discoveredInstructions) != maxDiscoveredFiles {
|
|
t.Fatalf("files = %d, want cap %d", len(a.discoveredInstructions), maxDiscoveredFiles)
|
|
}
|
|
if got := a.InstructionsSection(); strings.Count(got, "X") > maxDiscoveredFiles {
|
|
t.Fatalf("cap not applied to rendered section")
|
|
}
|
|
|
|
// 空 agent 不产生额外 system 文本。
|
|
empty := &Agent{}
|
|
if got := empty.InstructionsSection(); got != "" {
|
|
t.Fatalf("empty section = %q", got)
|
|
}
|
|
}
|