diff --git a/src/cli.ts b/src/cli.ts index 2566aa4b..873de2d0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,4 +1,7 @@ #!/usr/bin/env node +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { dirname, join } from 'node:path'; import { Cli, Builtins } from 'clipanion'; import { InstallCommand, @@ -15,10 +18,16 @@ import { UICommand, } from './commands/index.js'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); +const packageJsonPath = join(__dirname, '../../package.json'); +const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); +const version = packageJson.version || '1.2.0'; + const cli = new Cli({ binaryLabel: 'skillkit', binaryName: 'skillkit', - binaryVersion: '1.1.0', + binaryVersion: version, }); cli.register(Builtins.HelpCommand); diff --git a/src/tui/screens/Home.tsx b/src/tui/screens/Home.tsx index e7631d91..386e2327 100644 --- a/src/tui/screens/Home.tsx +++ b/src/tui/screens/Home.tsx @@ -1,4 +1,7 @@ import { useState, useEffect } from 'react'; +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { dirname, join } from 'node:path'; import { Box, Text } from 'ink'; import { colors, logo } from '../theme.js'; import type { Screen } from '../App.js'; @@ -17,6 +20,18 @@ const logoSmall = ` ╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩ `.trim(); +function getVersion(): string { + try { + const __filename = fileURLToPath(import.meta.url); + const __dirname = dirname(__filename); + const packageJsonPath = join(__dirname, '../../../package.json'); + const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); + return packageJson.version || '1.2.0'; + } catch { + return '1.2.0'; + } +} + function scramble(target: string, progress: number): string { return target.split('\n').map(line => { return line.split('').map((char, i) => { @@ -30,6 +45,7 @@ function scramble(target: string, progress: number): string { export function Home({ cols = 80, rows = 24 }: HomeProps) { const [progress, setProgress] = useState(0); const [display, setDisplay] = useState(''); + const version = getVersion(); const useLogo = cols < 80 ? logoSmall : logo; @@ -75,7 +91,7 @@ export function Home({ cols = 80, rows = 24 }: HomeProps) { )} - v1.1.0 - Works with 17 AI agents + v{version} - Works with 17 AI agents );