| 153 | // kept forgetting to bump, so `qodex --version` reported a stale number (1.22.0) for ~50 releases |
| 154 | // even though the freshly-built dist was current — a confusing red herring. Resolve relative to this |
| 155 | // module (dist/index.js → ../package.json), with a safe fallback if the file can't be read. |
| 156 | function readVersion(): string { |
| 157 | try { |
| 158 | const here = path.dirname(fileURLToPath(import.meta.url)); |
| 159 | const pkg = JSON.parse(fsSync.readFileSync(path.join(here, '..', 'package.json'), 'utf8')); |
| 160 | return typeof pkg.version === 'string' ? pkg.version : '0.0.0'; |
| 161 | } catch { |
| 162 | return '0.0.0'; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | program |