lash-cli 1.0.7 → 1.1.27

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/lash CHANGED
@@ -1,57 +1,84 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- if [ -n "$LASH_BIN_PATH" ]; then
5
- resolved="$LASH_BIN_PATH"
6
- else
7
- # Get the real path of this script
8
- script_path="$0"
9
- while [ -L "$script_path" ]; do
10
- link_target="$(readlink "$script_path")"
11
- case "$link_target" in
12
- /*) script_path="$link_target" ;;
13
- *) script_path="$(dirname "$script_path")/$link_target" ;;
14
- esac
15
- done
16
- script_dir="$(dirname "$script_path")"
17
- script_dir="$(cd "$script_dir" && pwd)"
18
-
19
- # Map platform
20
- case "$(uname -s)" in
21
- Darwin) platform="darwin" ;;
22
- Linux) platform="linux" ;;
23
- MINGW*|CYGWIN*|MSYS*) platform="win32" ;;
24
- *) platform="$(uname -s | tr '[:upper:]' '[:lower:]')" ;;
25
- esac
26
-
27
- # Map arch
28
- case "$(uname -m)" in
29
- x86_64|amd64) arch="x64" ;;
30
- aarch64) arch="arm64" ;;
31
- armv7l) arch="arm" ;;
32
- *) arch="$(uname -m)" ;;
33
- esac
34
-
35
- name="lash-cli-${platform}-${arch}"
36
- binary="lash"
37
- [ "$platform" = "win32" ] && binary="lash.exe"
38
-
39
- resolved=""
40
- current_dir="$script_dir"
41
- while [ "$current_dir" != "/" ]; do
42
- candidate="$current_dir/node_modules/$name/bin/$binary"
43
- if [ -f "$candidate" ]; then
44
- resolved="$candidate"
45
- break
46
- fi
47
- current_dir="$(dirname "$current_dir")"
48
- done
49
-
50
- if [ -z "$resolved" ]; then
51
- printf "It seems that your package manager failed to install the right version of the lash CLI for your platform. You can try manually installing the \"%s\" package\n" "$name" >&2
52
- exit 1
53
- fi
54
- fi
55
-
56
- trap '' INT
57
- exec "$resolved" "$@"
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.LASH_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename)
26
+ const scriptDir = path.dirname(scriptPath)
27
+
28
+ const platformMap = {
29
+ darwin: "darwin",
30
+ linux: "linux",
31
+ win32: "windows",
32
+ }
33
+ const archMap = {
34
+ x64: "x64",
35
+ arm64: "arm64",
36
+ arm: "arm",
37
+ }
38
+
39
+ let platform = platformMap[os.platform()]
40
+ if (!platform) {
41
+ platform = os.platform()
42
+ }
43
+ let arch = archMap[os.arch()]
44
+ if (!arch) {
45
+ arch = os.arch()
46
+ }
47
+ const base = "lash-cli-" + platform + "-" + arch
48
+ const binary = platform === "windows" ? "lash.exe" : "lash"
49
+
50
+ function findBinary(startDir) {
51
+ let current = startDir
52
+ for (;;) {
53
+ const modules = path.join(current, "node_modules")
54
+ if (fs.existsSync(modules)) {
55
+ const entries = fs.readdirSync(modules)
56
+ for (const entry of entries) {
57
+ if (!entry.startsWith(base)) {
58
+ continue
59
+ }
60
+ const candidate = path.join(modules, entry, "bin", binary)
61
+ if (fs.existsSync(candidate)) {
62
+ return candidate
63
+ }
64
+ }
65
+ }
66
+ const parent = path.dirname(current)
67
+ if (parent === current) {
68
+ return
69
+ }
70
+ current = parent
71
+ }
72
+ }
73
+
74
+ const resolved = findBinary(scriptDir)
75
+ if (!resolved) {
76
+ console.error(
77
+ 'It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing the "' +
78
+ base +
79
+ '" package',
80
+ )
81
+ process.exit(1)
82
+ }
83
+
84
+ run(resolved)
package/package.json CHANGED
@@ -1,37 +1,23 @@
1
1
  {
2
2
  "name": "lash-cli",
3
- "version": "1.0.7",
4
- "description": "lash - The AI coding agent built for the terminal",
5
3
  "bin": {
6
4
  "lash": "./bin/lash"
7
5
  },
8
6
  "scripts": {
9
- "postinstall": "node ./postinstall.mjs"
10
- },
11
- "keywords": [
12
- "ai",
13
- "cli",
14
- "coding",
15
- "assistant",
16
- "terminal",
17
- "lash"
18
- ],
19
- "author": "",
20
- "license": "MIT",
21
- "repository": {
22
- "type": "git",
23
- "url": "https://github.com/lacymorrow/lash"
7
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
24
8
  },
9
+ "version": "1.1.27",
25
10
  "optionalDependencies": {
26
- "lash-cli-windows-x64": "1.0.7",
27
- "lash-cli-linux-arm64": "1.0.7",
28
- "lash-cli-linux-x64": "1.0.7",
29
- "lash-cli-linux-x64-baseline": "1.0.7",
30
- "lash-cli-darwin-x64": "1.0.7",
31
- "lash-cli-darwin-x64-baseline": "1.0.7",
32
- "lash-cli-darwin-arm64": "1.0.7"
33
- },
34
- "engines": {
35
- "node": ">=18.0.0"
11
+ "lash-cli-linux-arm64": "1.1.27",
12
+ "lash-cli-linux-x64": "1.1.27",
13
+ "lash-cli-linux-x64-baseline": "1.1.27",
14
+ "lash-cli-linux-arm64-musl": "1.1.27",
15
+ "lash-cli-linux-x64-musl": "1.1.27",
16
+ "lash-cli-linux-x64-baseline-musl": "1.1.27",
17
+ "lash-cli-darwin-arm64": "1.1.27",
18
+ "lash-cli-darwin-x64": "1.1.27",
19
+ "lash-cli-darwin-x64-baseline": "1.1.27",
20
+ "lash-cli-windows-x64": "1.1.27",
21
+ "lash-cli-windows-x64-baseline": "1.1.27"
36
22
  }
37
23
  }
package/postinstall.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  import fs from "fs"
3
4
  import path from "path"
4
5
  import os from "os"
@@ -9,49 +10,124 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
10
  const require = createRequire(import.meta.url)
10
11
 
11
12
  function detectPlatformAndArch() {
13
+ // Map platform names
12
14
  let platform
13
15
  switch (os.platform()) {
14
- case "darwin": platform = "darwin"; break;
15
- case "linux": platform = "linux"; break;
16
- case "win32": platform = "windows"; break;
17
- default: platform = os.platform(); break;
16
+ case "darwin":
17
+ platform = "darwin"
18
+ break
19
+ case "linux":
20
+ platform = "linux"
21
+ break
22
+ case "win32":
23
+ platform = "windows"
24
+ break
25
+ default:
26
+ platform = os.platform()
27
+ break
18
28
  }
29
+
30
+ // Map architecture names
19
31
  let arch
20
32
  switch (os.arch()) {
21
- case "x64": arch = "x64"; break;
22
- case "arm64": arch = "arm64"; break;
23
- case "arm": arch = "arm"; break;
24
- default: arch = os.arch(); break;
33
+ case "x64":
34
+ arch = "x64"
35
+ break
36
+ case "arm64":
37
+ arch = "arm64"
38
+ break
39
+ case "arm":
40
+ arch = "arm"
41
+ break
42
+ default:
43
+ arch = os.arch()
44
+ break
25
45
  }
46
+
26
47
  return { platform, arch }
27
48
  }
28
49
 
29
50
  function findBinary() {
30
51
  const { platform, arch } = detectPlatformAndArch()
31
- const packageName = `lash-cli-${platform}-${arch}`
32
- const binary = platform === "windows" ? "lash.exe" : "lash"
52
+
53
+ // Read package.json to determine naming
54
+ const pkg = require("./package.json")
55
+ const baseName = pkg.name
56
+ const binaryKeys = Object.keys(pkg.bin || {})
57
+ const binName = binaryKeys[0] || (platform === "windows" ? `${baseName}.exe` : baseName)
58
+
59
+ // Determine actual binary naming inside the package
60
+ const packageName = `${baseName}-${platform}-${arch}`
61
+ const binaryName = platform === "windows" ? `${binName}.exe` : binName
33
62
 
34
63
  try {
64
+ // Use require.resolve to find the package
35
65
  const packageJsonPath = require.resolve(`${packageName}/package.json`)
36
66
  const packageDir = path.dirname(packageJsonPath)
37
- const binaryPath = path.join(packageDir, "bin", binary)
38
- if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found`)
39
- return binaryPath
67
+ const binaryPath = path.join(packageDir, "bin", binaryName)
68
+
69
+ if (!fs.existsSync(binaryPath)) {
70
+ throw new Error(`Binary not found at ${binaryPath}`)
71
+ }
72
+
73
+ return { binaryPath, binaryName }
40
74
  } catch (error) {
41
75
  throw new Error(`Could not find package ${packageName}: ${error.message}`)
42
76
  }
43
77
  }
44
78
 
45
- function main() {
79
+ function prepareBinDirectory(binaryName) {
80
+ const binDir = path.join(__dirname, "bin")
81
+ const targetPath = path.join(binDir, binaryName)
82
+
83
+ // Ensure bin directory exists
84
+ if (!fs.existsSync(binDir)) {
85
+ fs.mkdirSync(binDir, { recursive: true })
86
+ }
87
+
88
+ // Remove existing binary/symlink if it exists
89
+ if (fs.existsSync(targetPath)) {
90
+ fs.unlinkSync(targetPath)
91
+ }
92
+
93
+ return { binDir, targetPath }
94
+ }
95
+
96
+ function symlinkBinary(sourcePath, binaryName) {
97
+ const { targetPath } = prepareBinDirectory(binaryName)
98
+
99
+ fs.symlinkSync(sourcePath, targetPath)
100
+ console.log(`opencode binary symlinked: ${targetPath} -> ${sourcePath}`)
101
+
102
+ // Verify the file exists after operation
103
+ if (!fs.existsSync(targetPath)) {
104
+ throw new Error(`Failed to symlink binary to ${targetPath}`)
105
+ }
106
+ }
107
+
108
+ async function main() {
46
109
  try {
47
- const binaryPath = findBinary()
48
- const binScript = path.join(__dirname, "bin", "lash")
49
- if (fs.existsSync(binScript)) fs.unlinkSync(binScript)
50
- fs.symlinkSync(binaryPath, binScript, 'file')
51
- fs.chmodSync(binScript, '755')
110
+ if (os.platform() === "win32") {
111
+ // On Windows, the .exe is already included in the package and bin field points to it
112
+ // No postinstall setup needed
113
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
114
+ return
115
+ }
116
+
117
+ // On non-Windows platforms, just verify the binary package exists
118
+ // Don't replace the wrapper script - it handles binary execution
119
+ const { binaryPath } = findBinary()
120
+ console.log(`Platform binary verified at: ${binaryPath}`)
121
+ console.log("Wrapper script will handle binary execution")
52
122
  } catch (error) {
53
- console.error("Failed to create symlink:", error.message)
54
- // Don't exit 1, let it fail silently as wrapper script exists
123
+ console.error("Failed to setup opencode binary:", error.message)
124
+ process.exit(1)
55
125
  }
56
126
  }
57
- main()
127
+
128
+ try {
129
+ main()
130
+ } catch (error) {
131
+ console.error("Postinstall script error:", error.message)
132
+ process.exit(0)
133
+ }
package/bin/lash.cmd DELETED
@@ -1,7 +0,0 @@
1
- @IF EXIST "%~dp0\node.exe" (
2
- "%~dp0\node.exe" "%~dp0\..\node_modules\lash-cli-windows-x64\bin\lash.exe" %*
3
- ) ELSE (
4
- @SETLOCAL
5
- @SET PATHEXT=%PATHEXT:;.JS;=;%
6
- node "%~dp0\..\node_modules\lash-cli-windows-x64\bin\lash.exe" %*
7
- )