@@ -67,12 +67,12 @@ func (cc *Context) visitMarkdownFiles(searchDirFn func(path string) []string, vi
6767 if _ , err := os .Stat (dir ); os .IsNotExist (err ) {
6868 continue
6969 } else if err != nil {
70- return err
70+ return fmt . Errorf ( "failed to stat directory %s: %w" , dir , err )
7171 }
7272
7373 err := filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
7474 if err != nil {
75- return err
75+ return fmt . Errorf ( "failed to walk path %s: %w" , path , err )
7676 }
7777 ext := filepath .Ext (path ) // .md or .mdc
7878 if info .IsDir () || ext != ".md" && ext != ".mdc" {
@@ -94,7 +94,7 @@ func (cc *Context) visitMarkdownFiles(searchDirFn func(path string) []string, vi
9494 return visitor (path )
9595 })
9696 if err != nil {
97- return err
97+ return fmt . Errorf ( "failed to walk directory %s: %w" , dir , err )
9898 }
9999 }
100100
@@ -118,7 +118,7 @@ func (cc *Context) findTask(taskName string) error {
118118 var frontMatter markdown.TaskFrontMatter
119119 md , err := markdown .ParseMarkdownFile (path , & frontMatter )
120120 if err != nil {
121- return err
121+ return fmt . Errorf ( "failed to parse task file %s: %w" , path , err )
122122 }
123123
124124 // Extract selector labels from task frontmatter and add them to cc.includes.
@@ -132,7 +132,7 @@ func (cc *Context) findTask(taskName string) error {
132132 if frontMatter .Agent != "" {
133133 agent , err := ParseAgent (frontMatter .Agent )
134134 if err != nil {
135- return err
135+ return fmt . Errorf ( "failed to parse agent from task frontmatter: %w" , err )
136136 }
137137 cc .agent = agent
138138 }
@@ -152,7 +152,7 @@ func (cc *Context) findTask(taskName string) error {
152152 // Parse the task content (including user_prompt) to separate text blocks from slash commands
153153 task , err := taskparser .ParseTask (taskContent )
154154 if err != nil {
155- return err
155+ return fmt . Errorf ( "failed to parse task content: %w" , err )
156156 }
157157
158158 // Build the final content by processing each block
@@ -174,7 +174,7 @@ func (cc *Context) findTask(taskName string) error {
174174 } else if block .SlashCommand != nil {
175175 commandContent , err := cc .findCommand (block .SlashCommand .Name , block .SlashCommand .Params ())
176176 if err != nil {
177- return err
177+ return fmt . Errorf ( "failed to find command %s: %w" , block . SlashCommand . Name , err )
178178 }
179179 finalContent .WriteString (commandContent )
180180 }
@@ -218,7 +218,7 @@ func (cc *Context) findCommand(commandName string, params taskparser.Params) (st
218218 var frontMatter markdown.CommandFrontMatter
219219 md , err := markdown .ParseMarkdownFile (path , & frontMatter )
220220 if err != nil {
221- return err
221+ return fmt . Errorf ( "failed to parse command file %s: %w" , path , err )
222222 }
223223
224224 // Extract selector labels from command frontmatter and add them to cc.includes.
0 commit comments