Skip to content

Commit 67844bc

Browse files
authored
feat: relax skill name/description length limits in lenient mode (#215)
* test: expect lenient mode to include skills with oversized name or description * feat: include skills with oversized name or description in lenient mode
1 parent 1d3fffa commit 67844bc

2 files changed

Lines changed: 42 additions & 11 deletions

File tree

pkg/codingcontext/context.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,17 +1088,15 @@ func (cc *Context) validateAndAddSkill(frontmatter markdown.SkillFrontMatter, sk
10881088
const maxSkillNameLen = 64
10891089
if len(frontmatter.Name) > maxSkillNameLen {
10901090
if lenient {
1091-
cc.logger.Warn("skipping skill: name exceeds maximum length", "path", skillFile, "length", len(frontmatter.Name))
1092-
1093-
return nil
1091+
cc.logger.Warn("skill name exceeds maximum length", "path", skillFile, "length", len(frontmatter.Name))
10941092
} else if cc.lintMode {
10951093
cc.lintCollector.recordError(skillFile, LintErrorKindSkillValidation,
10961094
fmt.Sprintf("%v: %s (got %d)", ErrSkillNameLength, skillFile, len(frontmatter.Name)))
10971095

10981096
return nil
1097+
} else {
1098+
return fmt.Errorf("%w: %s (got %d)", ErrSkillNameLength, skillFile, len(frontmatter.Name))
10991099
}
1100-
1101-
return fmt.Errorf("%w: %s (got %d)", ErrSkillNameLength, skillFile, len(frontmatter.Name))
11021100
}
11031101

11041102
if frontmatter.Description == "" {
@@ -1118,14 +1116,16 @@ func (cc *Context) validateAndAddSkill(frontmatter markdown.SkillFrontMatter, sk
11181116

11191117
const maxSkillDescLen = 1024
11201118
if len(frontmatter.Description) > maxSkillDescLen {
1121-
if cc.lintMode {
1119+
if lenient {
1120+
cc.logger.Warn("skill description exceeds maximum length", "path", skillFile, "length", len(frontmatter.Description))
1121+
} else if cc.lintMode {
11221122
cc.lintCollector.recordError(skillFile, LintErrorKindSkillValidation,
11231123
fmt.Sprintf("%v: %s (got %d)", ErrSkillDescriptionLength, skillFile, len(frontmatter.Description)))
11241124

11251125
return nil
1126+
} else {
1127+
return fmt.Errorf("%w: %s (got %d)", ErrSkillDescriptionLength, skillFile, len(frontmatter.Description))
11261128
}
1127-
1128-
return fmt.Errorf("%w: %s (got %d)", ErrSkillDescriptionLength, skillFile, len(frontmatter.Description))
11291129
}
11301130

11311131
absPath, err := filepath.Abs(skillFile)

pkg/codingcontext/context_test.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@ name: no-desc-skill
27952795
},
27962796
},
27972797
{
2798-
name: "lenient: skip skill when name exceeds max length",
2798+
name: "lenient: include skill when name exceeds max length",
27992799
setup: func(t *testing.T, strictDir, lenientDir string) {
28002800
t.Helper()
28012801
createTask(t, strictDir, "test-task", "", "Test task content")
@@ -2812,8 +2812,39 @@ description: Valid description
28122812
wantErr: false,
28132813
checkFunc: func(t *testing.T, result *Result) {
28142814
t.Helper()
2815-
if len(result.Skills.Skills) != 0 {
2816-
t.Errorf("expected 0 skills (skipped due to name too long), got %d", len(result.Skills.Skills))
2815+
if len(result.Skills.Skills) != 1 {
2816+
t.Fatalf("expected 1 skill (lenient mode allows oversized name), got %d", len(result.Skills.Skills))
2817+
}
2818+
wantName := "this-is-a-very-long-skill-name-that-exceeds-the-maximum-allowed-length-of-64-characters"
2819+
if result.Skills.Skills[0].Name != wantName {
2820+
t.Errorf("expected skill name %q, got %q", wantName, result.Skills.Skills[0].Name)
2821+
}
2822+
},
2823+
},
2824+
{
2825+
name: "lenient: include skill when description exceeds max length",
2826+
setup: func(t *testing.T, strictDir, lenientDir string) {
2827+
t.Helper()
2828+
createTask(t, strictDir, "test-task", "", "Test task content")
2829+
2830+
longDesc := strings.Repeat("a", 1025)
2831+
createSkill(t, lenientDir, filepath.Join(".agents", "skills", "long-desc-skill"), fmt.Sprintf(`---
2832+
name: long-desc-skill
2833+
description: %s
2834+
---
2835+
2836+
# Long Desc Skill
2837+
`, longDesc))
2838+
},
2839+
taskName: "test-task",
2840+
wantErr: false,
2841+
checkFunc: func(t *testing.T, result *Result) {
2842+
t.Helper()
2843+
if len(result.Skills.Skills) != 1 {
2844+
t.Fatalf("expected 1 skill (lenient mode allows oversized description), got %d", len(result.Skills.Skills))
2845+
}
2846+
if got := len(result.Skills.Skills[0].Description); got != 1025 {
2847+
t.Errorf("expected description length 1025, got %d", got)
28172848
}
28182849
},
28192850
},

0 commit comments

Comments
 (0)