Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.24.5
require (
github.com/alecthomas/participle/v2 v2.1.4
github.com/hashicorp/go-getter/v2 v2.2.3
github.com/leodido/go-urn v1.4.0
github.com/stretchr/testify v1.10.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
Expand Down
56 changes: 0 additions & 56 deletions pkg/codingcontext/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,23 +384,6 @@ func TestContext_Run_Basic(t *testing.T) {
}
},
},
{
name: "task with explicit URN in frontmatter",
setup: func(t *testing.T, dir string) {
createTask(t, dir, "file-name", "id: urn:agents:task:file-name", "Task content")
},
taskName: "file-name",
wantErr: false,
check: func(t *testing.T, result *Result) {
if result.Task.FrontMatter.URN == nil || result.Task.FrontMatter.URN.String() != "urn:agents:task:file-name" {
got := ""
if result.Task.FrontMatter.URN != nil {
got = result.Task.FrontMatter.URN.String()
}
t.Errorf("expected task URN 'urn:agents:task:file-name', got %q", got)
}
},
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -775,45 +758,6 @@ func TestContext_Run_Rules(t *testing.T) {
}
},
},
{
name: "rule URN set from frontmatter",
setup: func(t *testing.T, dir string) {
createTask(t, dir, "id-task", "", "Task")
createRule(t, dir, ".agents/rules/my-rule.md", "id: urn:agents:rule:my-rule", "Rule with URN")
createRule(t, dir, ".agents/rules/another-rule.md", "id: urn:agents:rule:another", "Rule with another URN")
},
taskName: "id-task",
wantErr: false,
check: func(t *testing.T, result *Result) {
if len(result.Rules) != 2 {
t.Fatalf("expected 2 rules, got %d", len(result.Rules))
}

foundMyRule := false
foundAnotherRule := false
for _, rule := range result.Rules {
if rule.FrontMatter.URN != nil && rule.FrontMatter.URN.String() == "urn:agents:rule:my-rule" {
foundMyRule = true
if !strings.Contains(rule.Content, "Rule with URN") {
t.Error("my-rule should contain 'Rule with URN'")
}
}
if rule.FrontMatter.URN != nil && rule.FrontMatter.URN.String() == "urn:agents:rule:another" {
foundAnotherRule = true
if !strings.Contains(rule.Content, "Rule with another URN") {
t.Error("another should contain 'Rule with another URN'")
}
}
}

if !foundMyRule {
t.Error("expected to find rule with URN 'urn:agents:rule:my-rule'")
}
if !foundAnotherRule {
t.Error("expected to find rule with URN 'urn:agents:rule:another'")
}
},
},
}

for _, tt := range tests {
Expand Down
20 changes: 1 addition & 19 deletions pkg/codingcontext/markdown/frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import (
"fmt"

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

// BaseFrontMatter represents parsed YAML frontmatter from markdown files
type BaseFrontMatter struct {
// URN is an optional unique identifier for the prompt in URN format (e.g. urn:agents:task:<name>)
// Automatically inferred from filename if not specified in frontmatter
// In YAML frontmatter, "id" is accepted as an alias for "urn".
URN *urn.URN `yaml:"urn,omitempty" json:"urn,omitempty"`

// Name is the skill identifier
// Must be 1-64 characters, lowercase alphanumeric and hyphens only
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Expand All @@ -28,14 +22,12 @@ type BaseFrontMatter struct {
}

type baseFrontMatterRaw struct {
ID string `yaml:"id"`
URN *urn.URN `yaml:"urn"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Content map[string]any `yaml:",inline"`
}

// UnmarshalYAML supports "id" as an alias for URN and parses string values into *urn.URN.
// UnmarshalYAML ensures inline fields are properly captured in Content.
func (b *BaseFrontMatter) UnmarshalYAML(value *yaml.Node) error {
var raw baseFrontMatterRaw
if err := value.Decode(&raw); err != nil {
Expand All @@ -47,16 +39,6 @@ func (b *BaseFrontMatter) UnmarshalYAML(value *yaml.Node) error {
if raw.Content == nil {
b.Content = make(map[string]any)
}
if raw.URN != nil {
b.URN = raw.URN
return nil
}
if raw.ID != "" {
u, ok := urn.Parse([]byte(raw.ID))
if ok {
b.URN = u
}
}
return nil
}

Expand Down
12 changes: 3 additions & 9 deletions pkg/codingcontext/markdown/frontmatter_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
name: "command with standard id, name, description",
command: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:standard"),
Name: "Standard Command",
Description: "This is a standard command with metadata",
},
Expand All @@ -32,7 +31,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
name: "command with expand false",
command: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:no-expand"),
Name: "No Expand Command",
Description: "Command with expansion disabled",
},
Expand All @@ -47,7 +45,6 @@ func TestCommandFrontMatter_Marshal(t *testing.T) {
name: "command with selectors",
command: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:selector"),
Name: "Selector Command",
Description: "Command with selectors",
},
Expand Down Expand Up @@ -88,9 +85,9 @@ description: A command with standard fields
`,
want: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:named"),
Name: "Named Command",
Description: "A command with standard fields",
Content: map[string]any{"id": "urn:agents:command:named"},
},
},
},
Expand All @@ -103,9 +100,9 @@ expand: false
`,
want: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:no-expand"),
Name: "No Expand",
Description: "No expansion",
Content: map[string]any{"id": "urn:agents:command:no-expand"},
},
ExpandParams: nil,
},
Expand All @@ -121,9 +118,9 @@ selectors:
`,
want: CommandFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:command:selector"),
Name: "Selector Command",
Description: "Has selectors",
Content: map[string]any{"id": "urn:agents:command:selector"},
},
Selectors: map[string]any{
"database": "postgres",
Expand All @@ -145,9 +142,6 @@ selectors:
}

// Compare fields individually
if !urnEqual(got.URN, tt.want.URN) {
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
}
if got.Name != tt.want.Name {
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/codingcontext/markdown/frontmatter_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestRuleFrontMatter_Marshal(t *testing.T) {
name: "rule with standard id, name, description",
rule: RuleFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:rule:standard"),
Name: "Standard Rule",
Description: "This is a standard rule with metadata",
},
Expand Down Expand Up @@ -50,7 +49,6 @@ func TestRuleFrontMatter_Marshal(t *testing.T) {
name: "rule with all fields",
rule: RuleFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:rule:all-fields"),
Name: "Complete Rule",
Description: "A rule with all fields",
},
Expand Down Expand Up @@ -95,9 +93,9 @@ description: A rule with standard fields
`,
want: RuleFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:rule:named"),
Name: "Named Rule",
Description: "A rule with standard fields",
Content: map[string]any{"id": "urn:agents:rule:named"},
},
},
},
Expand Down Expand Up @@ -153,9 +151,6 @@ languages:
}

// Compare fields individually
if !urnEqual(got.URN, tt.want.URN) {
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
}
if got.Name != tt.want.Name {
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
}
Expand Down
14 changes: 5 additions & 9 deletions pkg/codingcontext/markdown/frontmatter_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestTaskFrontMatter_Marshal(t *testing.T) {
name: "task with standard id, name, description",
task: TaskFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:task:standard-task"),
Name: "Standard Test Task",
Description: "This is a test task with standard fields",
Content: map[string]any{"task_name": "standard-task"},
Expand All @@ -37,7 +36,6 @@ func TestTaskFrontMatter_Marshal(t *testing.T) {
name: "task with all fields",
task: TaskFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:task:full-task"),
Name: "Full Task",
Description: "A task with all fields",
Content: map[string]any{"task_name": "full-task"},
Expand Down Expand Up @@ -103,10 +101,9 @@ description: This is a standard task
`,
want: TaskFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:task:standard-task"),
Name: "Standard Task",
Description: "This is a standard task",
Content: map[string]any{"task_name": "standard-task"},
Content: map[string]any{"task_name": "standard-task", "id": "urn:agents:task:standard-task"},
},
},
},
Expand Down Expand Up @@ -154,10 +151,12 @@ selectors:
`,
want: TaskFrontMatter{
BaseFrontMatter: BaseFrontMatter{
URN: mustParseURN("urn:agents:task:full-task"),
Name: "Full Task",
Description: "A complete task",
Content: map[string]any{"task_name": "full-task"},
Content: map[string]any{
"task_name": "full-task",
"id": "urn:agents:task:full-task",
},
},
Agent: "",
Languages: []string{"go"},
Expand Down Expand Up @@ -188,9 +187,6 @@ selectors:
if gotTaskName != wantTaskName {
t.Errorf("TaskName = %q, want %q", gotTaskName, wantTaskName)
}
if !urnEqual(got.URN, tt.want.URN) {
t.Errorf("URN = %q, want %q", urnString(got.URN), urnString(tt.want.URN))
}
if got.Name != tt.want.Name {
t.Errorf("Name = %q, want %q", got.Name, tt.want.Name)
}
Expand Down
30 changes: 0 additions & 30 deletions pkg/codingcontext/markdown/urn_test.go

This file was deleted.

Loading