Skip to content

Commit 370ad9f

Browse files
authored
feat: replace "id" by "urn" (#205)
1 parent 306e1f7 commit 370ad9f

14 files changed

Lines changed: 296 additions & 476 deletions

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ go 1.24.5
44

55
require (
66
github.com/alecthomas/participle/v2 v2.1.4
7-
github.com/goccy/go-yaml v1.18.0
87
github.com/hashicorp/go-getter/v2 v2.2.3
8+
github.com/leodido/go-urn v1.4.0
99
github.com/stretchr/testify v1.10.0
10+
gopkg.in/yaml.v3 v3.0.1
1011
)
1112

1213
require (
@@ -22,5 +23,4 @@ require (
2223
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
2324
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2425
github.com/ulikunitz/xz v0.5.8 // indirect
25-
gopkg.in/yaml.v3 v3.0.1 // indirect
2626
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U
88
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
99
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
1010
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11-
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
12-
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
1311
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
1412
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
1513
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
@@ -28,6 +26,8 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
2826
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
2927
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
3028
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=
3131
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
3232
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
3333
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=

integration_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ This is a setup guide with frontmatter bootstrap.
178178
// Run the program
179179
output := runTool(t, "-C", dirs.tmpDir, "test-task")
180180

181-
// Check that bootstrap output appears
182-
if !strings.Contains(output, "Bootstrap from frontmatter") {
183-
t.Errorf("bootstrap output from frontmatter not found in output")
184-
}
185-
186181
// Check that rule content is present
187182
if !strings.Contains(output, "# Setup") {
188183
t.Errorf("rule content not found in output")
@@ -226,16 +221,6 @@ echo "Using file bootstrap"
226221
// Run the program
227222
output := runTool(t, "-C", dirs.tmpDir, "test-task")
228223

229-
// Check that frontmatter bootstrap is used
230-
if !strings.Contains(output, "Using frontmatter bootstrap") {
231-
t.Errorf("frontmatter bootstrap output not found in output")
232-
}
233-
234-
// Check that file bootstrap is NOT used
235-
if strings.Contains(output, "Using file bootstrap") {
236-
t.Errorf("file bootstrap should not be used when frontmatter bootstrap is present")
237-
}
238-
239224
// Check that rule content is present
240225
if !strings.Contains(output, "# Priority Test") {
241226
t.Errorf("rule content not found in output")

pkg/codingcontext/context.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ func New(opts ...Option) *Context {
5858
return c
5959
}
6060

61-
// generateIDFromPath generates an ID from a file path by extracting the filename without extension.
62-
// Used to auto-set ID fields in frontmatter when not explicitly provided.
63-
func generateIDFromPath(path string) string {
61+
// nameFromPath returns the filename without extension. Used to default Name in frontmatter when omitted.
62+
func nameFromPath(path string) string {
6463
baseName := filepath.Base(path)
6564
ext := filepath.Ext(baseName)
6665
return strings.TrimSuffix(baseName, ext)
@@ -138,10 +137,8 @@ func (cc *Context) findTask(taskName string) error {
138137
if err != nil {
139138
return fmt.Errorf("failed to parse task file %s: %w", path, err)
140139
}
141-
142-
// Automatically set ID to filename (without extension) if not set in frontmatter
143-
if frontMatter.ID == "" {
144-
frontMatter.ID = generateIDFromPath(path)
140+
if frontMatter.Name == "" {
141+
frontMatter.Name = nameFromPath(path)
145142
}
146143

147144
// Extract selector labels from task frontmatter and add them to cc.includes.
@@ -243,10 +240,8 @@ func (cc *Context) findCommand(commandName string, params taskparser.Params) (st
243240
if err != nil {
244241
return fmt.Errorf("failed to parse command file %s: %w", path, err)
245242
}
246-
247-
// Automatically set ID to filename (without extension) if not set in frontmatter
248-
if frontMatter.ID == "" {
249-
frontMatter.ID = generateIDFromPath(path)
243+
if frontMatter.Name == "" {
244+
frontMatter.Name = nameFromPath(path)
250245
}
251246

252247
// Extract selector labels from command frontmatter and add them to cc.includes.
@@ -535,10 +530,8 @@ func (cc *Context) findExecuteRuleFiles(ctx context.Context, homeDir string) err
535530
if err != nil {
536531
return fmt.Errorf("failed to parse markdown file %s: %w", path, err)
537532
}
538-
539-
// Automatically set ID to filename (without extension) if not set in frontmatter
540-
if frontmatter.ID == "" {
541-
frontmatter.ID = generateIDFromPath(path)
533+
if frontmatter.Name == "" {
534+
frontmatter.Name = nameFromPath(path)
542535
}
543536

544537
// Expand parameters only if expand is not explicitly set to false

0 commit comments

Comments
 (0)