@@ -7,6 +7,14 @@ const platform = process.platform;
77const arch = process . arch ;
88const pkg = `@tpsdev-ai/cli-${ platform } -${ arch } ` ;
99
10+ if ( process . argv . includes ( '--version' ) || process . argv . includes ( '-v' ) ) {
11+ // Fast-path version output even when native binary package is missing.
12+ // eslint-disable-next-line @typescript-eslint/no-var-requires
13+ const version = require ( '../package.json' ) . version ;
14+ console . log ( version ) ;
15+ process . exit ( 0 ) ;
16+ }
17+
1018// Search for the platform binary relative to this package, not the cwd.
1119// npm nests optionalDependencies inside the parent's node_modules.
1220const searchPaths = [ path . join ( __dirname , '..' ) , path . join ( __dirname , '..' , '..' ) ] ;
@@ -21,10 +29,19 @@ function runBinary() {
2129 // Fall through to error message
2230 }
2331
32+ // Fallback for source/dev installs where dist JS exists.
33+ try {
34+ const jsCli = path . join ( __dirname , '..' , 'dist' , 'bin' , 'tps.js' ) ;
35+ execFileSync ( process . execPath , [ jsCli , ...process . argv . slice ( 2 ) ] , { stdio : 'inherit' } ) ;
36+ return ;
37+ } catch ( _ ) {
38+ // continue to error output
39+ }
40+
2441 console . error ( `Failed to load native binding` ) ;
2542 console . error ( `TPS: no binary package available for ${ platform } -${ arch } .` ) ;
26- console . error ( `Run npm install -g ${ pkg } to install the platform binary package.` ) ;
27- console . error ( ' Or run from source inside the repository via `bun run tps` in packages/cli.' ) ;
43+ console . error ( `Try reinstalling main package: npm install -g @tpsdev-ai/cli@ ${ require ( '../ package.json' ) . version } ` ) ;
44+ console . error ( ` Or install platform binary directly: npm install -g ${ pkg } @ ${ require ( '../package.json' ) . version } ` ) ;
2845 process . exitCode = 1 ;
2946}
3047
0 commit comments