@@ -72,22 +72,23 @@ func openFile(path string) (io.ReadCloser, bool, error) {
7272}
7373
7474func loadLocal (base * source , name string ) (* source , bool , error ) {
75- path := filepath .Join (base .Path , name )
75+ // We want to keep all strings in / format, and only convert to platform specific when reading
76+ filePath := path .Join (base .Path , name )
7677
77- if s , err := os .Stat (path ); err == nil && s .IsDir () {
78- toolPath := filepath .Join (base . Path , name , "tool.gpt" )
79- if s , err := os .Stat (toolPath ); err == nil && ! s .IsDir () {
80- path = toolPath
78+ if s , err := os .Stat (filepath . Clean ( filePath ) ); err == nil && s .IsDir () {
79+ toolPath := path .Join (filePath , "tool.gpt" )
80+ if s , err := os .Stat (filepath . Clean ( toolPath ) ); err == nil && ! s .IsDir () {
81+ filePath = toolPath
8182 }
8283 }
8384
84- content , ok , err := openFile (path )
85+ content , ok , err := openFile (filepath . Clean ( filePath ) )
8586 if err != nil {
8687 return nil , false , err
8788 } else if ! ok {
8889 return nil , false , nil
8990 }
90- log .Debugf ("opened %s" , path )
91+ log .Debugf ("opened %s" , filePath )
9192
9293 defer content .Close ()
9394
@@ -99,9 +100,9 @@ func loadLocal(base *source, name string) (*source, bool, error) {
99100 return & source {
100101 Content : data ,
101102 Remote : false ,
102- Path : filepath .Dir (path ),
103- Name : filepath .Base (path ),
104- Location : path ,
103+ Path : path .Dir (filePath ),
104+ Name : path .Base (filePath ),
105+ Location : filePath ,
105106 }, true , nil
106107}
107108
@@ -398,6 +399,9 @@ func complete(opts ...Options) (result Options) {
398399}
399400
400401func Program (ctx context.Context , name , subToolName string , opts ... Options ) (types.Program , error ) {
402+ // We want all paths to have / not \
403+ name = strings .ReplaceAll (name , "\\ " , "/" )
404+
401405 if log .IsDebug () {
402406 start := time .Now ()
403407 defer func () {
0 commit comments