Class WorkspacePathNormalizer
Only the prefix matching the current filesystem mode is registered, so there is no risk
of a sandbox prefix (/workspace/) accidentally matching a real host directory in
local mode, or vice versa.
Paths that don't match any registered prefix pass through unchanged, preserving the ability to access non-workspace files in modes that allow it.
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Normalizes a path using the namespace for the supplied runtime context.static WorkspacePathNormalizerCreates a normalizer that strips the given prefix.static WorkspacePathNormalizerCreates a normalizer that tries multiple prefixes in order.static WorkspacePathNormalizerof(String workspacePrefix, NamespaceFactory namespaceFactory) Creates a normalizer that also strips the runtime namespace beneath the workspace prefix.
-
Method Details
-
of
Creates a normalizer that strips the given prefix.- Parameters:
workspacePrefix- the workspace root path for the active mode (e.g."/workspace"for sandbox, or the host workspace absolute path for local)
-
of
Creates a normalizer that tries multiple prefixes in order. Use only when the active mode has more than one valid prefix (e.g. local-with-shell where project dir and workspace dir are both valid roots). -
of
Creates a normalizer that also strips the runtime namespace beneath the workspace prefix. This is needed when a prompt advertises a session-scoped absolute path while the filesystem applies the same namespace to relative paths at operation time.- Parameters:
workspacePrefix- the unscoped workspace rootnamespaceFactory- factory for the current runtime namespace
-
normalize
Deprecated.Normalize a path to workspace-relative form by stripping the active mode's prefix.Callers using a normalizer with a namespace factory should use
normalize(String, RuntimeContext)so the operation context is available. This overload is retained for compatibility and uses an empty context.- Parameters:
path- the raw path (absolute or relative)- Returns:
- workspace-relative path, or the original path if no registered prefix matched
-
normalize
Normalizes a path using the namespace for the supplied runtime context.Namespaced workspace prefixes are checked before the unscoped prefix, so an absolute path such as
/workspace/session-1/file.txtbecomesfile.txtrather thansession-1/file.txtwhen the active namespace issession-1.- Parameters:
path- the raw path (absolute or relative)runtimeContext- current operation context- Returns:
- workspace-relative path, or the original path if no registered prefix matched
-