lash-cli 0.1.0 → 1.1.26

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,61 +1,84 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- if [ -n "$OPENCODE_BIN_PATH" ]; then
5
- resolved="$OPENCODE_BIN_PATH"
6
- else
7
- # Get the real path of this script, resolving any symlinks
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 names
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 architecture names
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
- # Search for the binary starting from real script location
40
- resolved=""
41
- current_dir="$script_dir"
42
- while [ "$current_dir" != "/" ]; do
43
- candidate="$current_dir/node_modules/$name/bin/$binary"
44
- if [ -f "$candidate" ]; then
45
- resolved="$candidate"
46
- break
47
- fi
48
- current_dir="$(dirname "$current_dir")"
49
- done
50
-
51
- if [ -z "$resolved" ]; then
52
- 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
53
- exit 1
54
- fi
55
- fi
56
-
57
- # Handle SIGINT gracefully
58
- trap '' INT
59
-
60
- # Execute the binary with all arguments
61
- 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,24 +1,23 @@
1
1
  {
2
2
  "name": "lash-cli",
3
- "version": "0.1.0",
4
- "description": "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
- "author": "",
12
- "license": "MIT",
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/lacymorrow/opencode"
7
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
16
8
  },
9
+ "version": "1.1.26",
17
10
  "optionalDependencies": {
18
- "lash-cli-darwin-arm64": "0.1.0",
19
- "lash-cli-darwin-x64": "0.1.0",
20
- "lash-cli-linux-arm64": "0.1.0",
21
- "lash-cli-linux-x64": "0.1.0",
22
- "lash-cli-windows-x64": "0.1.0"
11
+ "lash-cli-linux-arm64": "1.1.26",
12
+ "lash-cli-linux-x64": "1.1.26",
13
+ "lash-cli-linux-x64-baseline": "1.1.26",
14
+ "lash-cli-linux-arm64-musl": "1.1.26",
15
+ "lash-cli-linux-x64-musl": "1.1.26",
16
+ "lash-cli-linux-x64-baseline-musl": "1.1.26",
17
+ "lash-cli-darwin-arm64": "1.1.26",
18
+ "lash-cli-darwin-x64": "1.1.26",
19
+ "lash-cli-darwin-x64-baseline": "1.1.26",
20
+ "lash-cli-windows-x64": "1.1.26",
21
+ "lash-cli-windows-x64-baseline": "1.1.26"
23
22
  }
24
23
  }
package/postinstall.mjs CHANGED
@@ -49,42 +49,85 @@ function detectPlatformAndArch() {
49
49
 
50
50
  function findBinary() {
51
51
  const { platform, arch } = detectPlatformAndArch()
52
- const packageName = `opencode-${platform}-${arch}`
53
- const binary = platform === "windows" ? "opencode.exe" : "opencode"
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
54
62
 
55
63
  try {
56
64
  // Use require.resolve to find the package
57
65
  const packageJsonPath = require.resolve(`${packageName}/package.json`)
58
66
  const packageDir = path.dirname(packageJsonPath)
59
- const binaryPath = path.join(packageDir, "bin", binary)
67
+ const binaryPath = path.join(packageDir, "bin", binaryName)
60
68
 
61
69
  if (!fs.existsSync(binaryPath)) {
62
70
  throw new Error(`Binary not found at ${binaryPath}`)
63
71
  }
64
72
 
65
- return binaryPath
73
+ return { binaryPath, binaryName }
66
74
  } catch (error) {
67
75
  throw new Error(`Could not find package ${packageName}: ${error.message}`)
68
76
  }
69
77
  }
70
78
 
71
- function main() {
72
- try {
73
- const binaryPath = findBinary()
74
- const binScript = path.join(__dirname, "bin", "opencode")
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
+ }
75
107
 
76
- // Remove existing bin script if it exists
77
- if (fs.existsSync(binScript)) {
78
- fs.unlinkSync(binScript)
108
+ async function main() {
109
+ try {
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
79
115
  }
80
116
 
81
- // Create symlink to the actual binary
82
- fs.symlinkSync(binaryPath, binScript)
83
- console.log(`opencode binary symlinked: ${binScript} -> ${binaryPath}`)
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")
84
122
  } catch (error) {
85
- console.error("Failed to create opencode binary symlink:", error.message)
123
+ console.error("Failed to setup opencode binary:", error.message)
86
124
  process.exit(1)
87
125
  }
88
126
  }
89
127
 
90
- main()
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,56 +0,0 @@
1
- @echo off
2
- setlocal enabledelayedexpansion
3
-
4
- if defined OPENCODE_BIN_PATH (
5
- set "resolved=%OPENCODE_BIN_PATH%"
6
- goto :execute
7
- )
8
-
9
- rem Get the directory of this script
10
- set "script_dir=%~dp0"
11
- set "script_dir=%script_dir:~0,-1%"
12
-
13
- rem Detect platform and architecture
14
- set "platform=windows"
15
-
16
- rem Detect architecture
17
- if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
18
- set "arch=x64"
19
- ) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
20
- set "arch=arm64"
21
- ) else if "%PROCESSOR_ARCHITECTURE%"=="x86" (
22
- set "arch=x86"
23
- ) else (
24
- set "arch=x64"
25
- )
26
-
27
- set "name=opencode-!platform!-!arch!"
28
- set "binary=opencode.exe"
29
-
30
- rem Search for the binary starting from script location
31
- set "resolved="
32
- set "current_dir=%script_dir%"
33
-
34
- :search_loop
35
- set "candidate=%current_dir%\node_modules\%name%\bin\%binary%"
36
- if exist "%candidate%" (
37
- set "resolved=%candidate%"
38
- goto :execute
39
- )
40
-
41
- rem Move up one directory
42
- for %%i in ("%current_dir%") do set "parent_dir=%%~dpi"
43
- set "parent_dir=%parent_dir:~0,-1%"
44
-
45
- rem Check if we've reached the root
46
- if "%current_dir%"=="%parent_dir%" goto :not_found
47
- set "current_dir=%parent_dir%"
48
- goto :search_loop
49
-
50
- :not_found
51
- echo 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 "%name%" package >&2
52
- exit /b 1
53
-
54
- :execute
55
- rem Execute the binary with all arguments
56
- "%resolved%" %*