@shareai-lab/kode 1.0.91 → 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.js +29 -2
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -9,7 +9,9 @@ const cliPath = path.join(__dirname, 'src', 'entrypoints', 'cli.tsx');
9
9
 
10
10
  // Resolve tsx from this package directory (avoid CWD-based resolution on Windows/global installs)
11
11
  let tsxImportPath = null;
12
+ let tsxCliPath = null;
12
13
  try { tsxImportPath = require.resolve('tsx', { paths: [__dirname] }); } catch {}
14
+ try { tsxCliPath = require.resolve('tsx/cli', { paths: [__dirname] }); } catch {}
13
15
 
14
16
  // Enforce minimum Node version based on package.json engines.node
15
17
  try {
@@ -60,6 +62,19 @@ function runWithNode() {
60
62
  })
61
63
  }
62
64
 
65
+ const tryWithTsxBinary = () => {
66
+ if (!tsxCliPath) return failWithTsxHint()
67
+ const child = spawn(process.execPath, [tsxCliPath, cliPath, ...args], {
68
+ stdio: 'inherit',
69
+ env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
70
+ })
71
+ child.on('error', () => failWithTsxHint())
72
+ child.on('exit', code => {
73
+ if (code && code !== 0) return failWithTsxHint()
74
+ process.exit(code || 0)
75
+ })
76
+ }
77
+
63
78
  function failWithTsxHint() {
64
79
  console.error('')
65
80
  console.error('Failed to launch with Node + tsx.')
@@ -68,6 +83,18 @@ function runWithNode() {
68
83
  process.exit(1)
69
84
  }
70
85
 
71
- // Single modern path: Node >= 20 + tsx via --import; fallback to tsx CLI
72
- tryWithImport()
86
+ // Windows prefers tsx CLI due to top-level await in CJS transforms
87
+ if (process.platform === 'win32') {
88
+ tryWithTsxBinary()
89
+ } else {
90
+ // Non-Windows: try import-based first, then fallback
91
+ let attempted = false
92
+ const child = spawn(process.execPath, [...baseArgs, '--eval', ''], { stdio: 'ignore' })
93
+ child.on('error', () => {})
94
+ child.on('exit', () => {
95
+ if (attempted) return
96
+ attempted = true
97
+ tryWithImport()
98
+ })
99
+ }
73
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shareai-lab/kode",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "bin": {
5
5
  "kode": "cli.js",
6
6
  "kwa": "cli.js",