aurix-ai 2.7.7 → 2.7.9
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/bin/aurix.js +45 -13
- package/package.json +1 -1
- package/scripts/postinstall.mjs +69 -46
package/bin/aurix.js
CHANGED
|
@@ -19,23 +19,55 @@ try {
|
|
|
19
19
|
runtime = 'bun';
|
|
20
20
|
} catch {}
|
|
21
21
|
|
|
22
|
+
// Use shell: false with an absolute path to the Node binary. shell: true
|
|
23
|
+
// triggers DEP0190 (args concatenated without escaping). process.execPath
|
|
24
|
+
// points at the real node.exe even when launched through a .cmd shim on
|
|
25
|
+
// Windows, so spawn() works without shell: true.
|
|
26
|
+
let runtimeBin = process.execPath;
|
|
27
|
+
if (runtime === 'bun') {
|
|
28
|
+
try {
|
|
29
|
+
runtimeBin = execSync('bun -e "process.stdout.write(process.execPath)"', { encoding: 'utf8' }).trim() || 'bun';
|
|
30
|
+
} catch {
|
|
31
|
+
runtimeBin = 'bun';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
const nodeArgs = [];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
let selfRelaunch = false;
|
|
37
|
+
|
|
38
|
+
if (runtime === 'node' && !process.env.AURIX_RELAUNCHED) {
|
|
39
|
+
// OpenTUI's backend does `require("node:ffi")` which is experimental in
|
|
40
|
+
// Node 22.5+. Probe whether it already works without a flag, and only
|
|
41
|
+
// inject --experimental-ffi if it actually fails AND the flag is valid
|
|
42
|
+
// on this Node build. If neither works, launch without the flag and let
|
|
43
|
+
// the in-process fallback render a diagnostic message.
|
|
44
|
+
let needsFlag = false;
|
|
45
|
+
try {
|
|
46
|
+
execSync(`"${runtimeBin}" -e "require(\\"node:ffi\\")"`, { stdio: 'ignore' });
|
|
47
|
+
} catch {
|
|
48
|
+
needsFlag = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (needsFlag) {
|
|
52
|
+
let flagWorks = false;
|
|
53
|
+
try {
|
|
54
|
+
execSync(`"${runtimeBin}" --experimental-ffi -e "0"`, { stdio: 'ignore' });
|
|
55
|
+
flagWorks = true;
|
|
56
|
+
} catch {}
|
|
57
|
+
|
|
58
|
+
if (flagWorks) {
|
|
59
|
+
nodeArgs.push('--experimental-ffi');
|
|
60
|
+
selfRelaunch = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
33
63
|
}
|
|
34
64
|
|
|
35
|
-
const
|
|
65
|
+
const env = { ...process.env, AURIX_HOME: join(__dirname, '..') };
|
|
66
|
+
if (selfRelaunch) env.AURIX_RELAUNCHED = '1';
|
|
67
|
+
|
|
68
|
+
const child = spawn(runtimeBin, [...nodeArgs, dist, ...process.argv.slice(2)], {
|
|
36
69
|
stdio: 'inherit',
|
|
37
|
-
env
|
|
38
|
-
shell: process.platform === 'win32',
|
|
70
|
+
env,
|
|
39
71
|
});
|
|
40
72
|
|
|
41
73
|
child.on('close', (code) => process.exit(code ?? 0));
|
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,63 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
// Runs automatically after `npm install` (postinstall hook).
|
|
3
|
+
// Fixes the two things that commonly break aurix on Windows:
|
|
4
|
+
// 1. @opentui/core-win32-x64 optional dependency sometimes gets skipped
|
|
5
|
+
// (network glitch, --omit=optional, pnpm strict).
|
|
6
|
+
// 2. Bun runtime (preferred over Node because it has built-in FFI,
|
|
7
|
+
// no --experimental-ffi flag needed).
|
|
8
|
+
// Safe to re-run; idempotent and skips when already satisfied.
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'fs';
|
|
3
11
|
import { join, dirname } from 'path';
|
|
4
12
|
import { fileURLToPath } from 'url';
|
|
13
|
+
import { spawnSync, execSync } from 'child_process';
|
|
5
14
|
|
|
6
15
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const projectRoot = join(__dirname, '..');
|
|
7
17
|
|
|
8
|
-
console.log(
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
function log(msg) { console.log(`[aurix postinstall] ${msg}`); }
|
|
19
|
+
function run(cmd, args, opts = {}) {
|
|
20
|
+
return spawnSync(cmd, args, { stdio: 'inherit', ...opts }).status === 0;
|
|
21
|
+
}
|
|
11
22
|
|
|
12
|
-
|
|
23
|
+
// ─── 1. Ensure native OpenTUI binary is installed (Windows only) ───────────
|
|
24
|
+
if (process.platform === 'win32') {
|
|
25
|
+
const pkgName = process.arch === 'arm64'
|
|
26
|
+
? '@opentui/core-win32-arm64'
|
|
27
|
+
: '@opentui/core-win32-x64';
|
|
28
|
+
const expected = join(projectRoot, 'node_modules', '@opentui', pkgName.replace('@opentui/', ''));
|
|
13
29
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const pkgPath = join(__dirname, '..', 'node_modules', 'react-reconciler', 'package.json');
|
|
17
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
18
|
-
if (!pkg.exports) {
|
|
19
|
-
pkg.exports = {
|
|
20
|
-
'.': './index.js',
|
|
21
|
-
'./constants': './constants.js',
|
|
22
|
-
'./reflection': './reflection.js',
|
|
23
|
-
'./package.json': './package.json',
|
|
24
|
-
};
|
|
25
|
-
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
|
|
26
|
-
console.log(' ✓ React-reconciler patched\n');
|
|
27
|
-
results.push(['React-reconciler patch', 'success']);
|
|
30
|
+
if (existsSync(expected)) {
|
|
31
|
+
log(`✓ ${pkgName} already installed`);
|
|
28
32
|
} else {
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
log(`⚠ ${pkgName} missing — installing (this optionalDependency is sometimes skipped by npm)`);
|
|
34
|
+
// shell:true needed on Windows so `npm` resolves through npm.cmd
|
|
35
|
+
const ok = run('npm', [
|
|
36
|
+
'install', '--no-save', '--no-audit', '--no-fund', `${pkgName}@0.4.1`,
|
|
37
|
+
], { cwd: projectRoot, shell: true });
|
|
38
|
+
if (!ok) log(`⚠ failed to install ${pkgName} — TUI may fail to start`);
|
|
39
|
+
else log(`✓ ${pkgName} installed`);
|
|
31
40
|
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.warn(' ⚠ Could not patch react-reconciler:', e.message, '\n');
|
|
34
|
-
results.push(['React-reconciler patch', 'failed']);
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
// ─── 2. Hint about Bun (don't auto-install on Windows — UAC prompt) ───────
|
|
37
44
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
execSync('bun --version', { stdio: 'ignore' });
|
|
46
|
+
log('✓ Bun already installed');
|
|
47
|
+
} catch {
|
|
48
|
+
if (process.platform === 'win32') {
|
|
49
|
+
log('');
|
|
50
|
+
log('⚠ Bun not found. Bun is RECOMMENDED on Windows because it has');
|
|
51
|
+
log(' built-in FFI (no --experimental-ffi flag needed).');
|
|
52
|
+
log('');
|
|
53
|
+
log(' To install, run in PowerShell:');
|
|
54
|
+
log(' powershell -c "irm bun.sh/install.ps1 | iex"');
|
|
55
|
+
log('');
|
|
56
|
+
log(' Skipping auto-install to avoid UAC prompts in non-interactive mode.');
|
|
57
|
+
} else {
|
|
58
|
+
log('Installing Bun...');
|
|
59
|
+
if (run('bash', ['-c', 'curl -fsSL https://bun.sh/install | bash'])) {
|
|
60
|
+
log('✓ Bun installed');
|
|
61
|
+
} else {
|
|
62
|
+
log('⚠ Bun install failed — aurix will fall back to Node');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
// ─── 3. Node FFI probe (informative) ──────────────────────────────────────
|
|
68
|
+
try {
|
|
69
|
+
execSync(`"${process.execPath}" -e "require(\\"node:ffi\\")"`, { stdio: 'ignore' });
|
|
70
|
+
log('✓ node:ffi available without flag');
|
|
71
|
+
} catch {
|
|
72
|
+
let flagWorks = false;
|
|
73
|
+
try {
|
|
74
|
+
execSync(`"${process.execPath}" --experimental-ffi -e "0"`, { stdio: 'ignore' });
|
|
75
|
+
flagWorks = true;
|
|
76
|
+
} catch {}
|
|
77
|
+
if (flagWorks) {
|
|
78
|
+
log('ℹ node:ffi requires --experimental-ffi (launcher injects it automatically)');
|
|
79
|
+
} else {
|
|
80
|
+
log('⚠ node:ffi not available on this Node build.');
|
|
81
|
+
log(' Install Bun (recommended) or use official Node from nodejs.org.');
|
|
82
|
+
}
|
|
58
83
|
}
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log('║ For issues: https://github.com/DekaPrayoga/AurixAgent ║');
|
|
63
|
-
console.log('╚═══════════════════════════════════════════════════════════╝\n');
|
|
85
|
+
log('');
|
|
86
|
+
log('✓ postinstall complete. Run `aurix` to start.');
|