resolvepath

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(path string) (string, error)

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

func NormalizeUnicodeSpaces(s string) string

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

func NormalizeWindowsShellPath(filePath string) string

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

func Resolve(input, baseDir string) (string, error)

Resolve normalizes input and baseDir, then resolves the input to an absolute path. An empty baseDir uses the process working directory.

func ResolvePackagePath

func ResolvePackagePath(input, baseDir string) (string, error)

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

func ResolveTrimmed(input, baseDir string) (string, error)

ResolveTrimmed is Resolve after String.prototype.trim, the { trim: true } option Pi's resource loader and package manager pass.

func Trim

func Trim(input string) string

Trim applies String.prototype.trim, including BOM but excluding NEL.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL