@shareai-lab/kode 1.0.97 → 1.0.99

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.
package/cli.js CHANGED
@@ -3,27 +3,23 @@
3
3
  const { spawn } = require('child_process');
4
4
  const path = require('path');
5
5
 
6
- // Prefer Bun if available for speed; otherwise use Node + tsx
6
+ // Prefer Bun if available for speed; otherwise use Node + tsx preload
7
7
  const args = process.argv.slice(2);
8
8
  const cliPath = path.join(__dirname, 'src', 'entrypoints', 'cli.tsx');
9
9
 
10
10
  // Resolve tsx from this package directory (stable across global installs)
11
11
  let tsxImportPath = null;
12
- let tsxCliPath = null;
13
12
  try { tsxImportPath = require.resolve('tsx', { paths: [__dirname] }); } catch {}
14
- try { tsxCliPath = require.resolve('tsx/cli', { paths: [__dirname] }); } catch {}
15
13
 
16
14
  // Enforce minimum Node version based on package.json engines.node
17
15
  try {
18
- const req = "${enginesNode}"
16
+ const req = ">=20.18.1"
19
17
  const m = req.match(/(\d+)\.(\d+)\.(\d+)/)
20
18
  const [maj, min, pat] = process.versions.node.split('.').map(Number)
21
19
  const [rMaj, rMin, rPat] = m ? m.slice(1).map(Number) : [20, 18, 1]
22
20
  const tooOld = (maj < rMaj) || (maj === rMaj && (min < rMin || (min === rMin && pat < rPat)))
23
21
  if (tooOld) {
24
- console.error(
25
- 'Error: Node.js ' + req + ' is required. Please upgrade Node.'
26
- );
22
+ console.error('Error: Node.js ' + req + ' is required. Please upgrade Node.')
27
23
  process.exit(1)
28
24
  }
29
25
  } catch {}
@@ -42,9 +38,9 @@ function runWithBun() {
42
38
  stdio: 'inherit',
43
39
  env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
44
40
  })
45
- child.on('error', () => runWithTsxCLI())
41
+ child.on('error', () => runWithTsxImport())
46
42
  child.on('exit', code => {
47
- if (code && code !== 0) return runWithTsxCLI()
43
+ if (code && code !== 0) return runWithTsxImport()
48
44
  process.exit(code || 0)
49
45
  })
50
46
  }
@@ -57,25 +53,10 @@ function runWithTsxImport() {
57
53
  importArg = pathToFileURL(tsxImportPath).href
58
54
  }
59
55
  } catch {}
60
- const { pathToFileURL } = require('node:url')
61
- const cliUrl = pathToFileURL(cliPath).href
62
56
  const baseArgs = ['--no-warnings=ExperimentalWarning', '--enable-source-maps']
63
- const child = spawn(process.execPath, [...baseArgs, '--import', importArg, cliUrl, ...args], {
57
+ const child = spawn(process.execPath, [...baseArgs, '--import', importArg, cliPath, ...args], {
64
58
  stdio: 'inherit',
65
- env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
66
- })
67
- child.on('error', () => runWithTsxCLI())
68
- child.on('exit', code => {
69
- if (code && code !== 0) return runWithTsxCLI()
70
- process.exit(code || 0)
71
- })
72
- }
73
-
74
- function runWithTsxCLI() {
75
- if (!tsxCliPath) return fail()
76
- const child = spawn(process.execPath, [tsxCliPath, '--esm', cliPath, ...args], {
77
- stdio: 'inherit',
78
- env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
59
+ env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm'), TSX_TSCONFIG_PATH: path.join(__dirname, 'tsconfig.json') },
79
60
  })
80
61
  child.on('error', () => fail())
81
62
  child.on('exit', code => process.exit(code || 0))
@@ -84,7 +65,7 @@ function runWithTsxCLI() {
84
65
  function fail() {
85
66
  console.error('')
86
67
  console.error('Failed to start Kode.')
87
- console.error('Try installing Bun: npm i -g bun, or ensure tsx is available.')
68
+ console.error('If you see top-level await/CJS errors on Windows, ensure tsx is available and up-to-date.')
88
69
  process.exit(1)
89
70
  }
90
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shareai-lab/kode",
3
- "version": "1.0.97",
3
+ "version": "1.0.99",
4
4
  "bin": {
5
5
  "kode": "cli.js",
6
6
  "kwa": "cli.js",
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }