UNPKG

@hivetechs/hive-ai

Version:

Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API

54 lines 1.97 kB
/** * Utility functions for reading package version dynamically */ import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { readFileSync, existsSync } from 'fs'; /** * Get the current package version dynamically from package.json */ export async function getCurrentVersion() { try { // First try from the module's location (when compiled to dist/) const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Try different possible locations for package.json const possiblePaths = [ join(__dirname, '..', '..', 'package.json'), // From dist/utils/ join(__dirname, '..', '..', '..', 'package.json'), // From src/utils/ join(process.cwd(), 'package.json') // From current working directory ]; for (const packagePath of possiblePaths) { if (existsSync(packagePath)) { try { const pkg = JSON.parse(readFileSync(packagePath, 'utf8')); if (pkg && pkg.version) { return pkg.version; } } catch (error) { // Continue to next path continue; } } } // Final fallback: check environment variable set by npm if (process.env.npm_package_version) { return process.env.npm_package_version; } console.warn('Could not determine package version from any source'); return 'unknown'; } catch (error) { console.warn('Failed to read package version:', error); return 'unknown'; } } /** * Get version for display purposes (with fallback) */ export async function getDisplayVersion() { const version = await getCurrentVersion(); return version === 'unknown' ? 'development' : version; } //# sourceMappingURL=version-utils.js.map