#!/usr/bin/env node /** * SpecVerse specification language CLI * Generated from SpecVerse specification */ import { Command } from 'commander'; import { readFileSync } from 'fs'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { registerValidateCommand } from './commands/validate.js'; import { registerValidateManifestCommand } from './commands/validate-manifest.js'; import { registerValidateBundleCommand } from './commands/validate-bundle.js'; import { registerInferCommand } from './commands/infer.js'; import { registerRealizeCommand } from './commands/realize.js'; import { registerInitCommand } from './commands/init.js'; import { registerGenCommand } from './commands/gen.js'; import { registerDevCommand } from './commands/dev.js'; import { registerCacheCommand } from './commands/cache.js'; import { registerAiCommand } from './commands/ai.js'; import { registerSessionCommand } from './commands/session.js'; import { registerLibCommand } from './commands/lib.js'; import { registerSkillCommand } from './commands/skill.js'; // Read version: climb from the running module's dir, checking package.json at // every level, until we find @specverse/self's. This is robust to wherever the // bundle lands (dist/cli.mjs, bin/, dist/cli/, …) — the previous fixed-offset // list (../../, ../../../, …) skipped ../package.json, which is exactly where // @specverse/self/package.json sits next to dist/cli.mjs, so it always fell back // to the (stale) build-time version. Falls back only when nothing is found. const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); let _version = '4.0.0'; try { let _dir = __dirname; for (let _depth = 0; _depth < 10; _depth++) { try { const pkg = JSON.parse(readFileSync(join(_dir, 'package.json'), 'utf8')); if (pkg.name === '@specverse/self' && pkg.version) { _version = pkg.version; break; } } catch { /* no readable package.json at this level — keep climbing */ } const _parent = dirname(_dir); if (_parent === _dir) break; // reached filesystem root _dir = _parent; } } catch { /* use fallback */ } const program = new Command(); program .name('specverse') .description('SpecVerse specification language CLI') .version(_version); // Register all commands registerValidateCommand(program); registerValidateManifestCommand(program); registerValidateBundleCommand(program); registerInferCommand(program); registerRealizeCommand(program); registerInitCommand(program); registerGenCommand(program); registerDevCommand(program); registerCacheCommand(program); registerAiCommand(program); registerSessionCommand(program); registerLibCommand(program); registerSkillCommand(program); // Parse and execute program.parseAsync(process.argv).catch((error) => { console.error('Error:', error.message); process.exit(1); });