Skip to content

Commit 3a9b6eb

Browse files
Copilotalexec
andauthored
Remove URN support from frontmatter (#208)
* Initial plan * Remove URN support from frontmatter Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
1 parent 370ad9f commit 3a9b6eb

9 files changed

Lines changed: 19 additions & 161 deletions

File tree

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.24.5
55
require (
66
github.com/alecthomas/participle/v2 v2.1.4
77
github.com/hashicorp/go-getter/v2 v2.2.3
8-
github.com/leodido/go-urn v1.4.0
98
github.com/stretchr/testify v1.10.0
109
gopkg.in/yaml.v3 v3.0.1
1110
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
2626
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
2727
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
2828
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
29-
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
30-
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
3129
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
3230
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
3331
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=

pkg/codingcontext/context_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,6 @@ func TestContext_Run_Basic(t *testing.T) {
384384
}
385385
},
386386
},
387-
{
388-
name: "task with explicit URN in frontmatter",
389-
setup: func(t *testing.T, dir string) {
390-
createTask(t, dir, "file-name", "id: urn:agents:task:file-name", "Task content")
391-
},
392-
taskName: "file-name",
393-
wantErr: false,
394-
check: func(t *testing.T, result *Result) {
395-
if result.Task.FrontMatter.URN == nil || result.Task.FrontMatter.URN.String() != "urn:agents:task:file-name" {
396-
got := ""
397-
if result.Task.FrontMatter.URN != nil {
398-
got = result.Task.FrontMatter.URN.String()
399-
}
400-
t.Errorf("expected task URN 'urn:agents:task:file-name', got %q", got)
401-
}
402-
},
403-
},
404387
}
405388

406389
for _, tt := range tests {
@@ -775,45 +758,6 @@ func TestContext_Run_Rules(t *testing.T) {
775758
}
776759
},
777760
},
778-
{
779-
name: "rule URN set from frontmatter",
780-
setup: func(t *testing.T, dir string) {
781-
createTask(t, dir, "id-task", "", "Task")
782-
createRule(t, dir, ".agents/rules/my-rule.md", "id: urn:agents:rule:my-rule", "Rule with URN")
783-
createRule(t, dir, ".agents/rules/another-rule.md", "id: urn:agents:rule:another", "Rule with another URN")
784-
},
785-
taskName: "id-task",
786-
wantErr: false,
787-
check: func(t *testing.T, result *Result) {
788-
if len(result.Rules) != 2 {
789-
t.Fatalf("expected 2 rules, got %d", len(result.Rules))
790-
}
791-
792-
foundMyRule := false
793-
foundAnotherRule := false
794-
for _, rule := range result.Rules {
795-
if rule.FrontMatter.URN != nil && rule.FrontMatter.URN.String() == "urn:agents:rule:my-rule" {
796-
foundMyRule = true
797-
if !strings.Contains(rule.Content, "Rule with URN") {
798-
t.Error("my-rule should contain 'Rule with URN'")
799-
}
800-
}
801-
if rule.FrontMatter.URN != nil && rule.FrontMatter.URN.String() == "urn:agents:rule:another" {
802-
foundAnotherRule = true
803-
if !strings.Contains(rule.Content, "Rule with another URN") {
804-
t.Error("another should contain 'Rule with another URN'")
805-
}
806-
}
807-
}
808-
809-
if !foundMyRule {
810-
t.Error("expected to find rule with URN 'urn:agents:rule:my-rule'")
811-
}
812-
if !foundAnotherRule {
813-
t.Error("expected to find rule with URN 'urn:agents:rule:another'")
814-
}
815-
},
816-
},
817761
}
818762

819763
for _, tt := range tests {

pkg/codingcontext/markdown/frontmatter.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@ import (
55
"fmt"
66

77
"github.com/kitproj/coding-context-cli/pkg/codingcontext/mcp"
8-
"github.com/leodido/go-urn"
98
"gopkg.in/yaml.v3"
109
)
1110

1211
// BaseFrontMatter represents parsed YAML frontmatter from markdown files
1312
type BaseFrontMatter struct {
14-
// URN is an optional unique identifier for the prompt in URN format (e.g. urn:agents:task:<name>)
15-
// Automatically inferred from filename if not specified in frontmatter
16-
// In YAML frontmatter, "id" is accepted as an alias for "urn".
17-
URN *urn.URN `yaml:"urn,omitempty" json:"urn,omitempty"`
18-
1913
// Name is the skill identifier
2014
// Must be 1-64 characters, lowercase alphanumeric and hyphens only
2115
Name string `yaml:"name,omitempty" json:"name,omitempty"`
@@ -28,14 +22,12 @@ type BaseFrontMatter struct {
2822
}
2923

3024
type baseFrontMatterRaw struct {
31-
ID string `yaml:"id"`
32-
URN *urn.URN `yaml:"urn"`
3325
Name string `yaml:"name"`
3426
Description string `yaml:"description"`
3527
Content map[string]any `yaml:",inline"`
3628
}
3729

38-
// UnmarshalYAML supports "id" as an alias for URN and parses string values into *urn.URN.
30+
// UnmarshalYAML ensures inline fields are properly captured in Content.
3931
func (b *BaseFrontMatter) UnmarshalYAML(value *yaml.Node) error {
4032
var raw baseFrontMatterRaw
4133
if err := value.Decode(&raw); err != nil {
@@ -47,16 +39,6 @@ func (b *BaseFrontMatter) UnmarshalYAML(value *yaml.Node) error {
4739
if raw.Content == nil {
4840
b.Content = make(map[string]any)
4941
}
50-
if raw.URN != nil {
51-
b.URN = raw.URN
52-
return nil
53-
}
54-
if raw.ID != "" {
55-
u, ok := urn.Parse([]byte(raw.ID))
56-
if ok {
57-
b.URN = u
58-
}
59-
}
6042
return nil
6143
}
6244

pkg/codingcontext/markdown/frontmatter_command_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
2121
name: "command with standard id, name, description",
2222
command: CommandFrontMatter{
2323
BaseFrontMatter: BaseFrontMatter{
24-
URN: mustParseURN("urn:agents:command:standard"),
2524
Name: "Standard Command",
2625
Description: "This is a standard command with metadata",
2726
},
@@ -32,7 +31,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
3231
name: "command with expand false",
3332
command: CommandFrontMatter{
3433
BaseFrontMatter: BaseFrontMatter{
35-
URN: mustParseURN("urn:agents:command:no-expand"),
3634
Name: "No Expand Command",
3735
Description: "Command with expansion disabled",
3836
},
@@ -47,7 +45,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
4745
name: "command with selectors",
4846
command: CommandFrontMatter{
4947
BaseFrontMatter: BaseFrontMatter{
50-
URN: mustParseURN("urn:agents:command:selector"),
5148
Name: "Selector Command",
5249
Description: "Command with selectors",
5350
},
@@ -88,9 +85,9 @@ description: A command with standard fields
8885
`,
8986
want: CommandFrontMatter{
9087
BaseFrontMatter: BaseFrontMatter{
91-
URN: mustParseURN("urn:agents:command:named"),
9288
Name: "Named Command",
9389
Description: "A command with standard fields",
90+
Content: map[string]any{"id": "urn:agents:command:named"},
9491
},
9592
},
9693
},
@@ -103,9 +100,9 @@ expand: false
103100
`,
104101
want: CommandFrontMatter{
105102
BaseFrontMatter: BaseFrontMatter{
106-
URN: mustParseURN("urn:agents:command:no-expand"),
107103
Name: "No Expand",
108104
Description: "No expansion",
105+
Content: map[string]any{"id": "urn:agents:command:no-expand"},
109106
},
110107
ExpandParams: nil,
111108
},
@@ -121,9 +118,9 @@ selectors:
121118
`,
122119
want: CommandFrontMatter{
123120
BaseFrontMatter: BaseFrontMatter{
124-
URN: mustParseURN("urn:agents:command:selector"),
125121
Name: "Selector Command",
126122
Description: "Has selectors",
123+
Content: map[string]any{"id": "urn:agents:command:selector"},
127124
},
128125
Selectors: map[string]any{
129126
"database": "postgres",
@@ -145,9 +142,6 @@ selectors:
145142
}
146143

147144
// Compare fields individually
148-
if !urnEqual(got.URN, tt.want.URN) {
149-
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
150-
}
151145
if got.Name != tt.want.Name {
152146
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
153147
}

pkg/codingcontext/markdown/frontmatter_rule_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func TestRuleFrontMatter_Marshal(t *testing.T) {
2222
name: "rule with standard id, name, description",
2323
rule: RuleFrontMatter{
2424
BaseFrontMatter: BaseFrontMatter{
25-
URN: mustParseURN("urn:agents:rule:standard"),
2625
Name: "Standard Rule",
2726
Description: "This is a standard rule with metadata",
2827
},
@@ -50,7 +49,6 @@ func TestRuleFrontMatter_Marshal(t *testing.T) {
5049
name: "rule with all fields",
5150
rule: RuleFrontMatter{
5251
BaseFrontMatter: BaseFrontMatter{
53-
URN: mustParseURN("urn:agents:rule:all-fields"),
5452
Name: "Complete Rule",
5553
Description: "A rule with all fields",
5654
},
@@ -95,9 +93,9 @@ description: A rule with standard fields
9593
`,
9694
want: RuleFrontMatter{
9795
BaseFrontMatter: BaseFrontMatter{
98-
URN: mustParseURN("urn:agents:rule:named"),
9996
Name: "Named Rule",
10097
Description: "A rule with standard fields",
98+
Content: map[string]any{"id": "urn:agents:rule:named"},
10199
},
102100
},
103101
},
@@ -153,9 +151,6 @@ languages:
153151
}
154152

155153
// Compare fields individually
156-
if !urnEqual(got.URN, tt.want.URN) {
157-
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
158-
}
159154
if got.Name != tt.want.Name {
160155
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
161156
}

pkg/codingcontext/markdown/frontmatter_task_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func TestTaskFrontMatter_Marshal(t *testing.T) {
2525
name: "task with standard id, name, description",
2626
task: TaskFrontMatter{
2727
BaseFrontMatter: BaseFrontMatter{
28-
URN: mustParseURN("urn:agents:task:standard-task"),
2928
Name: "Standard Test Task",
3029
Description: "This is a test task with standard fields",
3130
Content: map[string]any{"task_name": "standard-task"},
@@ -37,7 +36,6 @@ func TestTaskFrontMatter_Marshal(t *testing.T) {
3736
name: "task with all fields",
3837
task: TaskFrontMatter{
3938
BaseFrontMatter: BaseFrontMatter{
40-
URN: mustParseURN("urn:agents:task:full-task"),
4139
Name: "Full Task",
4240
Description: "A task with all fields",
4341
Content: map[string]any{"task_name": "full-task"},
@@ -103,10 +101,9 @@ description: This is a standard task
103101
`,
104102
want: TaskFrontMatter{
105103
BaseFrontMatter: BaseFrontMatter{
106-
URN: mustParseURN("urn:agents:task:standard-task"),
107104
Name: "Standard Task",
108105
Description: "This is a standard task",
109-
Content: map[string]any{"task_name": "standard-task"},
106+
Content: map[string]any{"task_name": "standard-task", "id": "urn:agents:task:standard-task"},
110107
},
111108
},
112109
},
@@ -154,10 +151,12 @@ selectors:
154151
`,
155152
want: TaskFrontMatter{
156153
BaseFrontMatter: BaseFrontMatter{
157-
URN: mustParseURN("urn:agents:task:full-task"),
158154
Name: "Full Task",
159155
Description: "A complete task",
160-
Content: map[string]any{"task_name": "full-task"},
156+
Content: map[string]any{
157+
"task_name": "full-task",
158+
"id": "urn:agents:task:full-task",
159+
},
161160
},
162161
Agent: "",
163162
Languages: []string{"go"},
@@ -188,9 +187,6 @@ selectors:
188187
if gotTaskName != wantTaskName {
189188
t.Errorf("TaskName = %q, want %q", gotTaskName, wantTaskName)
190189
}
191-
if !urnEqual(got.URN, tt.want.URN) {
192-
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
193-
}
194190
if got.Name != tt.want.Name {
195191
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
196192
}

pkg/codingcontext/markdown/urn_test.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)