Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix: tolerate extended Windows root stat
sunsunsun9beea3e6afbd
diff --git a/archify.zip b/archify.zipindex 5e27c7e1..a632339d 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/renderers/shared/path-semantics.mjs b/archify/renderers/shared/path-semantics.mjsindex ad88094a..b88da614 100644--- a/archify/renderers/shared/path-semantics.mjs+++ b/archify/renderers/shared/path-semantics.mjs@@ -199,6 +199,14 @@ function statBigInt(targetPath) {return fs.statSync(targetPath, { bigint: true });}+function ordinaryWindowsRoot(extendedRoot) {+ const drive = extendedRoot.match(/^\\\\\?\\([A-Za-z]:\\)$/u);+ if (drive) return drive[1];++ const unc = extendedRoot.match(/^\\\\\?\\UNC\\([^\\]+)\\([^\\]+)\\$/iu);+ return unc ? `\\\\${unc[1]}\\${unc[2]}\\` : null;+}+function hasStableIdentity(stat) {return typeof stat?.dev === 'bigint'&& typeof stat?.ino === 'bigint'@@ -327,19 +335,36 @@ function resolvePlan({ root, segments }, side, depth) {let currentStat;try {current = fs.realpathSync.native(root);- currentStat = statBigInt(current);} catch (error) {// 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.+ // filesystem root (for example \\?\C:\). The namespace was already+ // validated by splitWindowsAbsolute, so retain its exact spelling for+ // traversal.if (process.platform === 'win32'&& error?.code === 'EISDIR'- && root.startsWith('\\\\?\\')) {+ && ordinaryWindowsRoot(root)) {+ current = root;+ } else {+ return {+ ok: false,+ failure: systemFailure('root-resolution-failed', error, { side }),+ };+ }+ }++ try {+ currentStat = statBigInt(current);+ } catch (error) {+ // The same Node/Windows edge can occur during stat after realpath succeeds.+ // A drive or share root is short enough for its ordinary spelling, while+ // `current` remains namespaced so descendants keep long-path semantics.+ const ordinaryRoot = process.platform === 'win32'+ && error?.code === 'EISDIR'+ ? ordinaryWindowsRoot(root)+ : null;+ if (ordinaryRoot && ordinaryRoot !== current) {try {- current = root;- currentStat = statBigInt(current);+ currentStat = statBigInt(ordinaryRoot);} catch (statError) {return {ok: false,diff --git a/archify/test/path-semantics.test.mjs b/archify/test/path-semantics.test.mjsindex 0aae1888..a44b9fbc 100644--- a/archify/test/path-semantics.test.mjs+++ b/archify/test/path-semantics.test.mjs@@ -27,7 +27,8 @@ function expectResult(value, expectedStatus) {function mockWindowsFilesystem(t, {entriesExist = true,preserveExtendedRealpaths = false,- extendedDriveRootRealpathIsDirectory = false,+ extendedRootRealpathIsDirectory = false,+ extendedRootStatIsDirectory = false,symbolicLinks = [],} = {}) {const platform = Object.getOwnPropertyDescriptor(process, 'platform');@@ -36,6 +37,7 @@ function mockWindowsFilesystem(t, {const realpathCalls = [];const lstatCalls = [];+ const statCalls = [];const identities = new Map();let nextIdentity = 1n;const canonicalPath = (targetPath) => {@@ -55,6 +57,13 @@ function mockWindowsFilesystem(t, {return path.win32.normalize(canonical);};const statFor = (targetPath) => {+ statCalls.push(String(targetPath));+ if (extendedRootStatIsDirectory+ && /^\\\\\?\\(?:[A-Za-z]:\\|UNC\\[^\\]+\\[^\\]+\\)$/iu.test(String(targetPath))) {+ const error = new Error(`virtual Windows extended root is a directory: ${targetPath}`);+ error.code = 'EISDIR';+ throw error;+ }const key = canonicalPath(targetPath).toLocaleLowerCase('en-US');if (!identities.has(key)) {identities.set(key, nextIdentity);@@ -73,9 +82,9 @@ 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}`);+ if (extendedRootRealpathIsDirectory+ && /^\\\\\?\\(?:[A-Za-z]:\\|UNC\\[^\\]+\\[^\\]+\\)$/iu.test(String(targetPath))) {+ const error = new Error(`virtual Windows extended root is a directory: ${targetPath}`);error.code = 'EISDIR';throw error;}@@ -107,7 +116,7 @@ function mockWindowsFilesystem(t, {error.code = 'EINVAL';throw error;});- return { lstatCalls, realpathCalls };+ return { lstatCalls, realpathCalls, statCalls };}test('Windows drive and share roots reach native resolution as complete filesystem roots', (t) => {@@ -139,7 +148,10 @@ test('Windows drive and share roots reach native resolution as complete filesyst});test('Windows extended drive roots retain stable identity when native realpath reports EISDIR', (t) => {- mockWindowsFilesystem(t, { extendedDriveRootRealpathIsDirectory: true });+ const { statCalls } = mockWindowsFilesystem(t, {+ extendedRootRealpathIsDirectory: true,+ extendedRootStatIsDirectory: true,+ });expectResult(sameLocation(String.raw`\\?\C:\reports\diagram.html`,@@ -147,6 +159,37 @@ test('Windows extended drive roots retain stable identity when native realpath r),'match',);+ assert.ok(statCalls.includes('C:\\'));+});++test('Windows extended drive roots retain traversal spelling when root stat reports EISDIR', (t) => {+ const { statCalls } = mockWindowsFilesystem(t, {+ preserveExtendedRealpaths: true,+ extendedRootStatIsDirectory: true,+ });+ expectResult(+ sameLocation(+ String.raw`\\?\C:\reports\diagram.html`,+ String.raw`C:\reports\diagram.html`,+ ),+ 'match',+ );+ assert.ok(statCalls.includes('C:\\'));+});++test('Windows extended UNC roots use ordinary share identity when root APIs report EISDIR', (t) => {+ const { statCalls } = mockWindowsFilesystem(t, {+ extendedRootRealpathIsDirectory: true,+ extendedRootStatIsDirectory: true,+ });+ expectResult(+ sameLocation(+ String.raw`\\?\UNC\server\share\reports\diagram.html`,+ String.raw`\\server\share\reports\diagram.html`,+ ),+ 'match',+ );+ assert.ok(statCalls.includes(`${String.raw`\\server\share`}\\`));});test('Windows device and malformed extended namespaces fail closed before filesystem access', (t) => {