fix(working-directory): move within into dsh-util-workspace-path

forge's Host code imported within from dsh-working-directory, a runtime
value edge the dependency policy refuses for a client-host package. The
helper is a stateless lexical containment test, so it now lives in the
browser-safe workspace-path utility, which joins duplicateSafePackages;
the directory service, the subagent manager, and forge import it from
there and carry the utility as an ordinary dependency.

Review: https://github.com/deepseek-harness/deepseek-harness/pull/7817#discussion_r4454836492
This commit is contained in:
LegGasai committed 2026-11-04 11:33:17 +08:00
1 parent 20383ff779
commit 58ee5a6edf
27 files changed
+107 -58

No files matched your search

+19
View File
@@ -18,6 +18,25 @@ export function isAbsoluteWorkspacePath(path: string): boolean {
return path.startsWith('/') || isWindowsStylePath(path)
}
/**
* Whether `path` is `root` or lies below it. Both are canonical absolute paths of one execution
* world in the same spelling, so the test is lexical and never touches the filesystem: the path
* equals the directory or continues it past a separator. Windows spellings compare
* case-insensitively, as their filesystems do.
* @param root - canonical absolute directory.
* @param path - canonical absolute path to test.
* @returns true for `root` itself and every path below it.
*/
export function within(root: string, path: string): boolean {
const windows = isWindowsStylePath(root)
const separator = windows && root.includes('\\') ? '\\' : '/'
const base = windows ? root.toLowerCase() : root
const candidate = windows ? path.toLowerCase() : path
const directory = base.length > 1 && base.endsWith(separator) ? base.slice(0, -1) : base
const prefix = directory.endsWith(separator) ? directory : directory + separator
return candidate === directory || candidate.startsWith(prefix)
}
/**
* Resolve a Workspace-relative path into the Host-facing spelling used by path operations.
* @param cwd - Session Workspace root, when known.