@shareai-lab/kode 1.0.91 → 1.0.93

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 +21 -49
  2. package/package.json +2 -1
package/cli.js CHANGED
@@ -3,14 +3,10 @@
3
3
  const { spawn } = require('child_process');
4
4
  const path = require('path');
5
5
 
6
- // Prefer Bun for dev; otherwise use Node + tsx (ESM --import)
6
+ // Prefer packaged Bun runtime to execute TS/TSX directly (simple + cross-platform)
7
7
  const args = process.argv.slice(2);
8
8
  const cliPath = path.join(__dirname, 'src', 'entrypoints', 'cli.tsx');
9
9
 
10
- // Resolve tsx from this package directory (avoid CWD-based resolution on Windows/global installs)
11
- let tsxImportPath = null;
12
- try { tsxImportPath = require.resolve('tsx', { paths: [__dirname] }); } catch {}
13
-
14
10
  // Enforce minimum Node version based on package.json engines.node
15
11
  try {
16
12
  const req = "${enginesNode}"
@@ -26,48 +22,24 @@ try {
26
22
  }
27
23
  } catch {}
28
24
 
29
- // Try Bun first
30
- try {
31
- const { execSync } = require('child_process');
32
- execSync('bun --version', { stdio: 'ignore' });
33
- const child = spawn('bun', ['run', cliPath, ...args], {
34
- stdio: 'inherit',
35
- env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
36
- });
37
- child.on('exit', (code) => process.exit(code || 0));
38
- child.on('error', () => runWithNode());
39
- } catch { runWithNode(); }
40
-
41
- function runWithNode() {
42
- const baseArgs = ['--no-warnings=ExperimentalWarning', '--enable-source-maps']
43
-
44
- const tryWithImport = () => {
45
- let importArg = 'tsx'
46
- try {
47
- if (tsxImportPath) {
48
- const { pathToFileURL } = require('node:url')
49
- importArg = pathToFileURL(tsxImportPath).href
50
- }
51
- } catch {}
52
- const child = spawn(process.execPath, [...baseArgs, '--import', importArg, cliPath, ...args], {
53
- stdio: 'inherit',
54
- env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
55
- })
56
- child.on('error', () => failWithTsxHint())
57
- child.on('exit', code => {
58
- if (code && code !== 0) return failWithTsxHint()
59
- process.exit(code || 0)
60
- })
61
- }
62
-
63
- function failWithTsxHint() {
64
- console.error('')
65
- console.error('Failed to launch with Node + tsx.')
66
- console.error('Try reinstalling: npm i -g @shareai-lab/kode (ensures bundled tsx).')
67
- console.error('Or install Bun and run: bun run kode')
68
- process.exit(1)
69
- }
70
-
71
- // Single modern path: Node >= 20 + tsx via --import; fallback to tsx CLI
72
- tryWithImport()
25
+ // Find packaged Bun binary or fall back to system Bun
26
+ function findBunPath() {
27
+ const binName = process.platform === 'win32' ? 'bun.cmd' : 'bun'
28
+ const localBin = path.join(__dirname, 'node_modules', '.bin', binName)
29
+ try { require('fs').accessSync(localBin); return localBin } catch {}
30
+ return binName
73
31
  }
32
+
33
+ const bunPath = findBunPath()
34
+ const child = spawn(bunPath, [cliPath, ...args], {
35
+ stdio: 'inherit',
36
+ env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
37
+ })
38
+ child.on('error', err => {
39
+ console.error('')
40
+ console.error('Failed to start Kode using Bun runtime.')
41
+ console.error('Please install Bun or ensure it is accessible:')
42
+ console.error(' npm install -g bun')
43
+ process.exit(1)
44
+ })
45
+ child.on('exit', code => process.exit(code || 0))
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.93",
4
4
  "bin": {
5
5
  "kode": "cli.js",
6
6
  "kwa": "cli.js",
@@ -46,6 +46,7 @@
46
46
  "@img/sharp-win32-x64": "^0.33.5"
47
47
  },
48
48
  "dependencies": {
49
+ "bun": "^1.1.34",
49
50
  "@anthropic-ai/bedrock-sdk": "^0.12.6",
50
51
  "@anthropic-ai/sdk": "^0.39.0",
51
52
  "@anthropic-ai/vertex-sdk": "^0.7.0",