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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ go 1.24.5

require (
github.com/alecthomas/participle/v2 v2.1.4
github.com/goccy/go-yaml v1.18.0
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
)

require (
Expand All @@ -22,5 +23,4 @@ require (
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
Expand All @@ -28,6 +26,8 @@ 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
15 changes: 0 additions & 15 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ This is a setup guide with frontmatter bootstrap.
// Run the program
output := runTool(t, "-C", dirs.tmpDir, "test-task")

// Check that bootstrap output appears
if !strings.Contains(output, "Bootstrap from frontmatter") {
t.Errorf("bootstrap output from frontmatter not found in output")
}

// Check that rule content is present
if !strings.Contains(output, "# Setup") {
t.Errorf("rule content not found in output")
Expand Down Expand Up @@ -226,16 +221,6 @@ echo "Using file bootstrap"
// Run the program
output := runTool(t, "-C", dirs.tmpDir, "test-task")

// Check that frontmatter bootstrap is used
if !strings.Contains(output, "Using frontmatter bootstrap") {
t.Errorf("frontmatter bootstrap output not found in output")
}

// Check that file bootstrap is NOT used
if strings.Contains(output, "Using file bootstrap") {
t.Errorf("file bootstrap should not be used when frontmatter bootstrap is present")
}

// Check that rule content is present
if !strings.Contains(output, "# Priority Test") {
t.Errorf("rule content not found in output")
Expand Down
23 changes: 8 additions & 15 deletions pkg/codingcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func New(opts ...Option) *Context {
return c
}

// generateIDFromPath generates an ID from a file path by extracting the filename without extension.
// Used to auto-set ID fields in frontmatter when not explicitly provided.
func generateIDFromPath(path string) string {
// nameFromPath returns the filename without extension. Used to default Name in frontmatter when omitted.
func nameFromPath(path string) string {
baseName := filepath.Base(path)
ext := filepath.Ext(baseName)
return strings.TrimSuffix(baseName, ext)
Expand Down Expand Up @@ -138,10 +137,8 @@ func (cc *Context) findTask(taskName string) error {
if err != nil {
return fmt.Errorf("failed to parse task file %s: %w", path, err)
}

// Automatically set ID to filename (without extension) if not set in frontmatter
if frontMatter.ID == "" {
frontMatter.ID = generateIDFromPath(path)
if frontMatter.Name == "" {
frontMatter.Name = nameFromPath(path)
}

// Extract selector labels from task frontmatter and add them to cc.includes.
Expand Down Expand Up @@ -243,10 +240,8 @@ func (cc *Context) findCommand(commandName string, params taskparser.Params) (st
if err != nil {
return fmt.Errorf("failed to parse command file %s: %w", path, err)
}

// Automatically set ID to filename (without extension) if not set in frontmatter
if frontMatter.ID == "" {
frontMatter.ID = generateIDFromPath(path)
if frontMatter.Name == "" {
frontMatter.Name = nameFromPath(path)
}

// Extract selector labels from command frontmatter and add them to cc.includes.
Expand Down Expand Up @@ -535,10 +530,8 @@ func (cc *Context) findExecuteRuleFiles(ctx context.Context, homeDir string) err
if err != nil {
return fmt.Errorf("failed to parse markdown file %s: %w", path, err)
}

// Automatically set ID to filename (without extension) if not set in frontmatter
if frontmatter.ID == "" {
frontmatter.ID = generateIDFromPath(path)
if frontmatter.Name == "" {
frontmatter.Name = nameFromPath(path)
}

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