zidane-tui 6.0.1 → 6.1.1
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/postinstall.mjs +88 -0
- package/bin/zidane.mjs +10 -5
- package/package.json +7 -7
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Post-install launch-time optimization: replace the Node launcher shim
|
|
3
|
+
// (`bin/zidane.mjs`) with the platform binary itself.
|
|
4
|
+
//
|
|
5
|
+
// Without this, every `zidane` invocation boots a Node process (~40-80ms)
|
|
6
|
+
// that resolves and spawns the real Bun binary, then stays resident for
|
|
7
|
+
// the whole session just to forward signals. After the swap, the bin path
|
|
8
|
+
// IS the native executable — zero wrapper overhead, one process.
|
|
9
|
+
//
|
|
10
|
+
// Fully best-effort and layered:
|
|
11
|
+
// - Package managers that skip lifecycle scripts (`--ignore-scripts`,
|
|
12
|
+
// pnpm/bun script gating) simply keep the shim, which works fine.
|
|
13
|
+
// - Any failure below leaves the shim untouched.
|
|
14
|
+
// - A hardlink is preferred (no extra disk); copy is the fallback
|
|
15
|
+
// (e.g. pnpm's store on another device).
|
|
16
|
+
//
|
|
17
|
+
// Keep this file dependency-free — it runs before anything else from
|
|
18
|
+
// node_modules is guaranteed to exist.
|
|
19
|
+
|
|
20
|
+
import { execSync } from 'node:child_process'
|
|
21
|
+
import { chmodSync, copyFileSync, existsSync, linkSync, renameSync, unlinkSync } from 'node:fs'
|
|
22
|
+
import { createRequire } from 'node:module'
|
|
23
|
+
import { dirname, join } from 'node:path'
|
|
24
|
+
import { fileURLToPath } from 'node:url'
|
|
25
|
+
|
|
26
|
+
/** glibc vs musl detection. `ldd --version` mentions "musl" on Alpine and similar. */
|
|
27
|
+
function detectLibc() {
|
|
28
|
+
try {
|
|
29
|
+
const out = execSync('ldd --version 2>&1', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })
|
|
30
|
+
return out.toLowerCase().includes('musl') ? 'musl' : 'glibc'
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return 'musl'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Returns the platform key matching one of the `zidane-tui-<key>` packages, or `null` when unsupported. */
|
|
38
|
+
function platformKey() {
|
|
39
|
+
const { platform, arch } = process
|
|
40
|
+
if (platform === 'darwin')
|
|
41
|
+
return arch === 'arm64' ? 'darwin-arm64' : arch === 'x64' ? 'darwin-x64' : null
|
|
42
|
+
if (platform === 'linux') {
|
|
43
|
+
if (detectLibc() !== 'glibc')
|
|
44
|
+
return null
|
|
45
|
+
return arch === 'arm64' ? 'linux-arm64' : arch === 'x64' ? 'linux-x64' : null
|
|
46
|
+
}
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
52
|
+
|
|
53
|
+
// Never run inside the zidane monorepo checkout: there the platform
|
|
54
|
+
// packages resolve to workspace stubs and the swap would clobber the
|
|
55
|
+
// source tree's `bin/zidane.mjs` with a compiled binary. The published
|
|
56
|
+
// package ships only `bin/` — `src/cli.ts` existing means dev checkout.
|
|
57
|
+
if (existsSync(join(here, '..', 'src', 'cli.ts')))
|
|
58
|
+
process.exit(0)
|
|
59
|
+
|
|
60
|
+
const key = platformKey()
|
|
61
|
+
if (!key)
|
|
62
|
+
process.exit(0)
|
|
63
|
+
|
|
64
|
+
const require = createRequire(import.meta.url)
|
|
65
|
+
const binary = require.resolve(`zidane-tui-${key}/bin/zidane`)
|
|
66
|
+
const shim = join(here, 'zidane.mjs')
|
|
67
|
+
|
|
68
|
+
// Stage next to the shim, then rename over it — the shim is never in a
|
|
69
|
+
// half-written or missing state, even if the process dies mid-swap.
|
|
70
|
+
const staged = join(here, '.zidane.mjs.staged')
|
|
71
|
+
try {
|
|
72
|
+
unlinkSync(staged)
|
|
73
|
+
}
|
|
74
|
+
catch {}
|
|
75
|
+
try {
|
|
76
|
+
linkSync(binary, staged)
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
copyFileSync(binary, staged)
|
|
80
|
+
}
|
|
81
|
+
chmodSync(staged, 0o755)
|
|
82
|
+
renameSync(staged, shim)
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Leave the shim in place — it keeps working, just with the extra
|
|
86
|
+
// Node hop. Never fail the install over an optimization.
|
|
87
|
+
process.exit(0)
|
|
88
|
+
}
|
package/bin/zidane.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// `zidane-tui` CLI launcher.
|
|
2
|
+
// `zidane-tui` CLI launcher — fallback path.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// (
|
|
4
|
+
// On a normal install this file gets REPLACED by the platform binary
|
|
5
|
+
// itself (see `bin/postinstall.mjs`), so launches skip the Node hop
|
|
6
|
+
// entirely. This shim only executes when lifecycle scripts were skipped
|
|
7
|
+
// (`--ignore-scripts`, pnpm/bun script gating) or the swap failed.
|
|
8
|
+
//
|
|
9
|
+
// It runs under Node (any Node ≥18) so the package installs cleanly on
|
|
10
|
+
// any machine that already has npm. It detects the host triple, resolves
|
|
11
|
+
// the platform-specific binary from the matching optional dependency
|
|
12
|
+
// (`zidane-tui-darwin-arm64`, …), and spawns it. The binary itself is a
|
|
8
13
|
// self-contained Bun executable — end users do NOT need Bun installed.
|
|
9
14
|
//
|
|
10
15
|
// Keep this file dependency-free: it has to run before anything from
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zidane-tui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "Terminal UI for the zidane agent. Ships as a self-contained binary — install globally and run `zidane`.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yaël GUILLOUX <yael.guilloux@gmail.com>",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"node": ">=18"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
+
"postinstall": "node ./bin/postinstall.mjs",
|
|
37
38
|
"prestart": "bun run ../scripts/bundle-parser-worker.ts",
|
|
38
39
|
"start": "bun run src/cli.ts",
|
|
39
40
|
"predev": "bun run ../scripts/bundle-parser-worker.ts",
|
|
@@ -43,10 +44,10 @@
|
|
|
43
44
|
"typecheck": "tsc --noEmit"
|
|
44
45
|
},
|
|
45
46
|
"optionalDependencies": {
|
|
46
|
-
"zidane-tui-darwin-arm64": "6.
|
|
47
|
-
"zidane-tui-darwin-x64": "6.
|
|
48
|
-
"zidane-tui-linux-x64": "6.
|
|
49
|
-
"zidane-tui-linux-arm64": "6.
|
|
47
|
+
"zidane-tui-darwin-arm64": "6.1.1",
|
|
48
|
+
"zidane-tui-darwin-x64": "6.1.1",
|
|
49
|
+
"zidane-tui-linux-x64": "6.1.1",
|
|
50
|
+
"zidane-tui-linux-arm64": "6.1.1"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
@@ -55,7 +56,6 @@
|
|
|
55
56
|
"@types/bun": "^1.3.14",
|
|
56
57
|
"@types/react": "^19.2.17",
|
|
57
58
|
"react": "^19.2.0",
|
|
58
|
-
"typescript": "~6.0.3"
|
|
59
|
-
"zidane": "file:.."
|
|
59
|
+
"typescript": "~6.0.3"
|
|
60
60
|
}
|
|
61
61
|
}
|