@@ -72,22 +72,23 @@ func openFile(path string) (io.ReadCloser, bool, error) {
72
72
}
73
73
74
74
func 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 )
76
77
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
81
82
}
82
83
}
83
84
84
- content , ok , err := openFile (path )
85
+ content , ok , err := openFile (filepath . Clean ( filePath ) )
85
86
if err != nil {
86
87
return nil , false , err
87
88
} else if ! ok {
88
89
return nil , false , nil
89
90
}
90
- log .Debugf ("opened %s" , path )
91
+ log .Debugf ("opened %s" , filePath )
91
92
92
93
defer content .Close ()
93
94
@@ -99,9 +100,9 @@ func loadLocal(base *source, name string) (*source, bool, error) {
99
100
return & source {
100
101
Content : data ,
101
102
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 ,
105
106
}, true , nil
106
107
}
107
108
@@ -398,6 +399,9 @@ func complete(opts ...Options) (result Options) {
398
399
}
399
400
400
401
func 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
+
401
405
if log .IsDebug () {
402
406
start := time .Now ()
403
407
defer func () {
0 commit comments