Documentation
¶
Overview ¶
Package resolvepath resolves user-supplied resource paths the way Pi's resolvePath does. It sits below internal/codingagent and coding/packagecontent so both share one implementation. Ports packages/coding-agent/src/utils/paths.ts:75-106.
Index ¶
- func Normalize(path string) (string, error)
- func NormalizeUnicodeSpaces(s string) string
- func NormalizeWindowsShellPath(filePath string) string
- func Resolve(input, baseDir string) (string, error)
- func ResolvePackagePath(input, baseDir string) (string, error)
- func ResolveTrimmed(input, baseDir string) (string, error)
- func Trim(input string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize applies Pi's default path normalization: a leading "~" or "~/" expands to the home directory and a file:// URL becomes its path through Node's fileURLToPath, whose errors it returns. An empty path stays empty.
func NormalizeUnicodeSpaces ¶
NormalizeUnicodeSpaces replaces each non-standard Unicode space with an ASCII space, Pi's resolvePath option normalizeUnicodeSpaces. It scans the path instead of running a regexp: a regexp match takes its matcher from a sync.Pool, whose per-P array the first use after a collection reallocates (GOMAXPROCS*128 bytes), and every read and write tool call resolves a path. Bytes that are not part of such a space, ill-formed UTF-8 included, are copied as they are, as ReplaceAllString copies them.
func NormalizeWindowsShellPath ¶
NormalizeWindowsShellPath converts a Git Bash, MSYS, Cygwin or WSL drive path to the form native Windows APIs accept.
upstream: utils/paths.ts normalizeWindowsShellPath
func Resolve ¶
Resolve normalizes input and baseDir, then resolves the input to an absolute path. An empty baseDir uses the process working directory.
func ResolvePackagePath ¶
ResolvePackagePath uses the package manager's HOME || homedir() tilde expansion and trims the input, without changing normalization of baseDir. Ports packages/coding-agent/src/core/package-manager.ts:221-223,2145-2151.
func ResolveTrimmed ¶
ResolveTrimmed is Resolve after String.prototype.trim, the { trim: true } option Pi's resource loader and package manager pass.
Types ¶
This section is empty.