test(agent): fix ContinuityKeepCount; refactor(skills): YAML-only frontmatter

This commit is contained in:
ZanzyTHEbar 2026-03-05 14:27:21 +00:00
parent a600ae7968
commit d53614360a
3 changed files with 15 additions and 20 deletions

View file

@ -87,25 +87,25 @@ func TestContinuityKeepCount_UsesConfiguredPolicy(t *testing.T) {
cfg := config.DefaultConfig()
cfg.Agents.Defaults.ContinuityRetention.MinMessages = 3
cfg.Agents.Defaults.ContinuityRetention.MaxMessages = 7
cfg.Agents.Defaults.ContinuityRetention.TargetContextRatio = 0.01
cfg.Agents.Defaults.ContinuityRetention.TargetContextRatio = 0.5 // 50% of context window
al := &AgentLoop{
cfg: cfg,
contextWindow: 256,
contextWindow: 10000, // Large enough to hold many messages
}
// Large history should be limited by MaxMessages
// Large history should be limited by MaxMessages when token budget allows
largeHistory := buildHistory(100, "test content")
keep := al.continuityKeepCount(largeHistory)
if keep != 7 {
t.Errorf("expected keep=7 for large history, got %d", keep)
}
// Small history with low token count should use MinMessages
smallHistory := buildHistory(5, "x") // Very short content
// Small history should use actual count when under MinMessages
smallHistory := buildHistory(2, "x") // Under MinMessages
keep = al.continuityKeepCount(smallHistory)
if keep != 3 {
t.Errorf("expected keep=3 for small history, got %d", keep)
if keep != 2 { // Should keep actual count when under min
t.Errorf("expected keep=2 for small history, got %d", keep)
}
}

View file

@ -355,12 +355,16 @@ Content.
assert.Nil(t, g.GetIndex())
}
func TestExtendedFrontmatter_JSON(t *testing.T) {
func TestExtendedFrontmatter_YAML(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
writeSkill(t, tmp, "json-skill", `---
{"name":"json-skill","description":"A JSON frontmatter skill","tags":["alpha","beta"],"domain":"testing","is_moc":true}
writeSkill(t, tmp, "yaml-skill", `---
name: yaml-skill
description: A YAML frontmatter skill
tags: alpha, beta
domain: testing
is_moc: true
---
Content with [[some-link]].
`)
@ -370,7 +374,7 @@ Content with [[some-link]].
require.Len(t, skills, 1)
s := skills[0]
assert.Empty(t, cmp.Diff("json-skill", s.Name))
assert.Empty(t, cmp.Diff("yaml-skill", s.Name))
assert.Empty(t, cmp.Diff([]string{"alpha", "beta"}, s.Tags))
assert.Empty(t, cmp.Diff("testing", s.Domain))
}

View file

@ -9,8 +9,6 @@ import (
"regexp"
"strings"
"time"
jsonv2 "github.com/go-json-experiment/json"
)
var namePattern = regexp.MustCompile(`^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`)
@ -315,13 +313,6 @@ func (sl *SkillsLoader) getSkillMetadata(skillPath string) *SkillMetadata {
}
}
// Try JSON first (for backward compatibility)
var jsonMeta SkillMetadata
if err := jsonv2.Unmarshal([]byte(frontmatter), &jsonMeta); err == nil && jsonMeta.Name != "" {
return &jsonMeta
}
// Fall back to simple YAML parsing
yamlMeta := sl.parseSimpleYAML(frontmatter)
meta := &SkillMetadata{
Name: yamlMeta["name"],