From d219639ac7041cbaa3df77a88810fdcf1c9cfe8c Mon Sep 17 00:00:00 2001 From: Mikola Lysenko Date: Thu, 22 Jan 2026 15:26:04 -0500 Subject: [PATCH 1/3] feat: add bun global package support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add getBunGlobalPrefix() function to detect bun's global package path - Update getGlobalNodeModulesPaths() to include pnpm, yarn, and bun paths - Export getBunGlobalPrefix() for external use 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/crawlers/npm-crawler.ts | 29 ++++++++++++++++++++++- src/utils/global-packages.ts | 45 ++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/crawlers/npm-crawler.ts b/src/crawlers/npm-crawler.ts index 3c2727e..8c8573a 100644 --- a/src/crawlers/npm-crawler.ts +++ b/src/crawlers/npm-crawler.ts @@ -104,6 +104,22 @@ function getPnpmGlobalPrefix(): string | null { } } +/** + * Get the bun global node_modules path + */ +function getBunGlobalPrefix(): string | null { + try { + const binPath = execSync('bun pm bin -g', { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'], + }).trim() + const bunRoot = path.dirname(binPath) + return path.join(bunRoot, 'install', 'global', 'node_modules') + } catch { + return null + } +} + /** * NPM ecosystem crawler for discovering packages in node_modules */ @@ -150,6 +166,12 @@ export class NpmCrawler { paths.push(yarnPath) } + // Try bun global path + const bunPath = getBunGlobalPrefix() + if (bunPath) { + paths.push(bunPath) + } + return paths } @@ -498,4 +520,9 @@ export class NpmCrawler { } // Re-export global prefix functions for backward compatibility -export { getNpmGlobalPrefix, getYarnGlobalPrefix, getPnpmGlobalPrefix } +export { + getNpmGlobalPrefix, + getYarnGlobalPrefix, + getPnpmGlobalPrefix, + getBunGlobalPrefix, +} diff --git a/src/utils/global-packages.ts b/src/utils/global-packages.ts index 5f14441..d1ece8a 100644 --- a/src/utils/global-packages.ts +++ b/src/utils/global-packages.ts @@ -51,6 +51,23 @@ export function getPnpmGlobalPrefix(): string | null { } } +/** + * Get the bun global node_modules path + * @returns The path to bun's global node_modules directory, or null if not available + */ +export function getBunGlobalPrefix(): string | null { + try { + const binPath = execSync('bun pm bin -g', { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'], + }).trim() + const bunRoot = path.dirname(binPath) + return path.join(bunRoot, 'install', 'global', 'node_modules') + } catch { + return null + } +} + /** * Get the global node_modules path, with support for custom override * @param customPrefix - Optional custom path to use instead of auto-detection @@ -65,7 +82,7 @@ export function getGlobalPrefix(customPrefix?: string): string { /** * Get all global node_modules paths for package lookup - * Currently returns npm global path, but could be extended for yarn global, etc. + * Returns paths from all detected package managers (npm, pnpm, yarn, bun) * @param customPrefix - Optional custom path to use instead of auto-detection * @returns Array of global node_modules paths */ @@ -73,7 +90,31 @@ export function getGlobalNodeModulesPaths(customPrefix?: string): string[] { if (customPrefix) { return [customPrefix] } - return [getNpmGlobalPrefix()] + + const paths: string[] = [] + + try { + paths.push(getNpmGlobalPrefix()) + } catch { + // npm not available + } + + const pnpmPath = getPnpmGlobalPrefix() + if (pnpmPath) { + paths.push(pnpmPath) + } + + const yarnPath = getYarnGlobalPrefix() + if (yarnPath) { + paths.push(yarnPath) + } + + const bunPath = getBunGlobalPrefix() + if (bunPath) { + paths.push(bunPath) + } + + return paths } /** From 9768c30e8fc7183fc735ce89a91034e369fdf87c Mon Sep 17 00:00:00 2001 From: Mikola Lysenko Date: Thu, 22 Jan 2026 17:59:59 -0500 Subject: [PATCH 2/3] feat: export getBunGlobalPrefix from crawlers module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Export the getBunGlobalPrefix function to allow checking bun's global package prefix. Also adds test coverage for the export. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/commands/scan.test.ts | 2 ++ src/crawlers/index.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/commands/scan.test.ts b/src/commands/scan.test.ts index 08345af..067d131 100644 --- a/src/commands/scan.test.ts +++ b/src/commands/scan.test.ts @@ -436,11 +436,13 @@ describe('crawlers module', () => { getNpmGlobalPrefix, getYarnGlobalPrefix, getPnpmGlobalPrefix, + getBunGlobalPrefix, } = await import('../crawlers/index.js') assert.equal(typeof getNpmGlobalPrefix, 'function') assert.equal(typeof getYarnGlobalPrefix, 'function') assert.equal(typeof getPnpmGlobalPrefix, 'function') + assert.equal(typeof getBunGlobalPrefix, 'function') }) }) }) diff --git a/src/crawlers/index.ts b/src/crawlers/index.ts index 78235e9..094936a 100644 --- a/src/crawlers/index.ts +++ b/src/crawlers/index.ts @@ -4,4 +4,5 @@ export { getNpmGlobalPrefix, getYarnGlobalPrefix, getPnpmGlobalPrefix, + getBunGlobalPrefix, } from './npm-crawler.js' From 217e121dbb7d422d5cbcb47b73a87fdb0e4848d3 Mon Sep 17 00:00:00 2001 From: Mikola Lysenko Date: Fri, 23 Jan 2026 14:53:29 -0500 Subject: [PATCH 3/3] feat: add deno global package support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add getDenoGlobalPrefix() function to discover packages installed globally via Deno's npm cache. This enables socket-patch to find and patch packages installed using `deno install npm:`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/crawlers/npm-crawler.ts | 27 +++++++++++++++++++++++++++ src/utils/global-packages.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/crawlers/npm-crawler.ts b/src/crawlers/npm-crawler.ts index 8c8573a..a8ec43a 100644 --- a/src/crawlers/npm-crawler.ts +++ b/src/crawlers/npm-crawler.ts @@ -120,6 +120,26 @@ function getBunGlobalPrefix(): string | null { } } +/** + * Get the deno global npm cache path + */ +function getDenoGlobalPrefix(): string | null { + try { + const result = execSync('deno info --json', { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'], + }) + const info = JSON.parse(result) + // Deno stores npm packages at: denoDir/npm/registry.npmjs.org/ + if (info.denoDir) { + return path.join(info.denoDir, 'npm', 'registry.npmjs.org') + } + return null + } catch { + return null + } +} + /** * NPM ecosystem crawler for discovering packages in node_modules */ @@ -172,6 +192,12 @@ export class NpmCrawler { paths.push(bunPath) } + // Try deno global path + const denoPath = getDenoGlobalPrefix() + if (denoPath) { + paths.push(denoPath) + } + return paths } @@ -525,4 +551,5 @@ export { getYarnGlobalPrefix, getPnpmGlobalPrefix, getBunGlobalPrefix, + getDenoGlobalPrefix, } diff --git a/src/utils/global-packages.ts b/src/utils/global-packages.ts index d1ece8a..f581a7e 100644 --- a/src/utils/global-packages.ts +++ b/src/utils/global-packages.ts @@ -68,6 +68,27 @@ export function getBunGlobalPrefix(): string | null { } } +/** + * Get the deno global npm cache path + * @returns The path to deno's npm cache directory, or null if not available + */ +export function getDenoGlobalPrefix(): string | null { + try { + const result = execSync('deno info --json', { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'], + }) + const info = JSON.parse(result) + // Deno stores npm packages at: denoDir/npm/registry.npmjs.org/ + if (info.denoDir) { + return path.join(info.denoDir, 'npm', 'registry.npmjs.org') + } + return null + } catch { + return null + } +} + /** * Get the global node_modules path, with support for custom override * @param customPrefix - Optional custom path to use instead of auto-detection @@ -114,6 +135,11 @@ export function getGlobalNodeModulesPaths(customPrefix?: string): string[] { paths.push(bunPath) } + const denoPath = getDenoGlobalPrefix() + if (denoPath) { + paths.push(denoPath) + } + return paths }