feat: implement instruction assembly and project instruction providers with tests

This commit is contained in:
mlogclub
2026-04-14 12:00:03 +08:00
parent 9c7d70741a
commit 03fc405e4e
12 changed files with 58 additions and 129 deletions
@@ -0,0 +1,31 @@
package instruction
import (
"strings"
"testing"
)
func TestAssemblerRespectsProvidedSources(t *testing.T) {
result := NewAssembler().Assemble(AssemblerInput{
ProjectInstruction: "project-rule",
GovernanceInstruction: "governance-rule",
AgentInstruction: "agent-rule",
SkillInstruction: "skill-rule",
ToolAppendices: []string{"tool-rule-1", "tool-rule-2"},
})
if !strings.Contains(result.Text, "项目级规则:\nproject-rule") {
t.Fatalf("missing project instruction: %s", result.Text)
}
if !strings.Contains(result.Text, "系统治理规则:\ngovernance-rule") {
t.Fatalf("missing governance instruction: %s", result.Text)
}
if !strings.Contains(result.Text, "当前技能上下文:\nskill-rule") {
t.Fatalf("missing skill instruction: %s", result.Text)
}
if !strings.Contains(result.Text, "工具补充规则:\ntool-rule-1") {
t.Fatalf("missing tool appendix: %s", result.Text)
}
if !result.Summary.HasProjectRule || !result.Summary.HasGovernanceRule || !result.Summary.HasAgentRule || !result.Summary.HasSkillRule || !result.Summary.HasToolRule {
t.Fatalf("unexpected summary: %#v", result.Summary)
}
}