Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix: resolve extended Windows drive roots

sunsunsuna142e5f6df11
diff --git a/archify.zip b/archify.zip
index 4041fdca..5e27c7e1 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/renderers/shared/path-semantics.mjs b/archify/renderers/shared/path-semantics.mjs
index a31d7e3e..ad88094a 100644
--- a/archify/renderers/shared/path-semantics.mjs
+++ b/archify/renderers/shared/path-semantics.mjs
@@ -329,10 +329,29 @@ function resolvePlan({ root, segments }, side, depth) {
current = fs.realpathSync.native(root);
currentStat = statBigInt(current);
} catch (error) {
- return {
- ok: false,
- failure: systemFailure('root-resolution-failed', error, { side }),
- };
+ // Node on Windows can report EISDIR while resolving a valid extended
+ // drive root (for example \\?\C:\). The namespace was already validated by
+ // splitWindowsAbsolute, so retain its exact spelling and bind traversal to
+ // the root's stable filesystem identity instead of discarding long-path
+ // semantics by converting it back to an ordinary drive path.
+ if (process.platform === 'win32'
+ && error?.code === 'EISDIR'
+ && root.startsWith('\\\\?\\')) {
+ try {
+ current = root;
+ currentStat = statBigInt(current);
+ } catch (statError) {
+ return {
+ ok: false,
+ failure: systemFailure('root-resolution-failed', statError, { side }),
+ };
+ }
+ } else {
+ return {
+ ok: false,
+ failure: systemFailure('root-resolution-failed', error, { side }),
+ };
+ }
}
for (let index = 0; index < segments.length; index += 1) {
diff --git a/archify/test/path-semantics.test.mjs b/archify/test/path-semantics.test.mjs
index 3876c04a..0aae1888 100644
--- a/archify/test/path-semantics.test.mjs
+++ b/archify/test/path-semantics.test.mjs
@@ -27,6 +27,7 @@ function expectResult(value, expectedStatus) {
function mockWindowsFilesystem(t, {
entriesExist = true,
preserveExtendedRealpaths = false,
+ extendedDriveRootRealpathIsDirectory = false,
symbolicLinks = [],
} = {}) {
const platform = Object.getOwnPropertyDescriptor(process, 'platform');
@@ -72,6 +73,12 @@ function mockWindowsFilesystem(t, {
t.mock.method(fs.realpathSync, 'native', (targetPath) => {
realpathCalls.push(String(targetPath));
+ if (extendedDriveRootRealpathIsDirectory
+ && /^\\\\\?\\[A-Za-z]:\\$/u.test(String(targetPath))) {
+ const error = new Error(`virtual Windows extended drive root is a directory: ${targetPath}`);
+ error.code = 'EISDIR';
+ throw error;
+ }
return preserveExtendedRealpaths
? path.win32.normalize(String(targetPath))
: canonicalPath(targetPath);
@@ -131,6 +138,17 @@ test('Windows drive and share roots reach native resolution as complete filesyst
assert.ok(realpathCalls.includes(`${String.raw`\\?\C:`}\\`));
});
+test('Windows extended drive roots retain stable identity when native realpath reports EISDIR', (t) => {
+ mockWindowsFilesystem(t, { extendedDriveRootRealpathIsDirectory: true });
+ expectResult(
+ sameLocation(
+ String.raw`\\?\C:\reports\diagram.html`,
+ String.raw`C:\reports\diagram.html`,
+ ),
+ 'match',
+ );
+});
+
test('Windows device and malformed extended namespaces fail closed before filesystem access', (t) => {
const { lstatCalls, realpathCalls } = mockWindowsFilesystem(t);
for (const [targetPath, reason] of [