@mars_ai/marscli 0.0.0-stage → 1.18.36

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/bin/mars.cjs +133 -0
  4. package/package.json +35 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,46 @@
1
- # Temporary Holding Version
1
+ # Mars CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Mars CLI is the command-line client for the MarsAI coding agent.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --global @mars_ai/marscli
9
+ ```
10
+
11
+ This installs the `mars` command. The package selects the matching native binary for the host operating system and CPU architecture.
12
+
13
+ ## Start
14
+
15
+ ```bash
16
+ mars
17
+ mars --help
18
+ mars serve
19
+ ```
20
+
21
+ Sign in to MarsAI with the CLI's account flow, or configure the server URL with `MARSAI_URL` when using a compatible self-hosted gateway.
22
+
23
+ ## Supported targets
24
+
25
+ The release pipeline publishes native optional packages for:
26
+
27
+ - Linux: x64 and arm64, glibc and musl variants where supported
28
+ - macOS: x64 and arm64
29
+ - Windows: x64 and arm64
30
+
31
+ The launcher falls back to a baseline x64 binary when AVX2 is unavailable.
32
+
33
+ ## Configuration
34
+
35
+ Useful environment variables include:
36
+
37
+ - `MARSAI_URL` — MarsAI account/API base URL
38
+ - `MARSAI_BIN_PATH` — explicit path to a native binary, useful for local testing
39
+
40
+ ## Troubleshooting
41
+
42
+ If npm reports that the platform package is missing, reinstall `@mars_ai/marscli` and verify that optional dependencies are enabled. For an offline or restricted installation, set `MARSAI_BIN_PATH` to a compatible native binary.
43
+
44
+ ## License
45
+
46
+ MIT
package/bin/mars.cjs ADDED
@@ -0,0 +1,133 @@
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
+ const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
9
+
10
+ function run(target) {
11
+ const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit" })
12
+ child.on("error", (error) => {
13
+ console.error(error.message)
14
+ process.exit(1)
15
+ })
16
+ const forwarders = {}
17
+ for (const signal of forwardedSignals) {
18
+ forwarders[signal] = () => {
19
+ try {
20
+ child.kill(signal)
21
+ } catch {}
22
+ }
23
+ process.on(signal, forwarders[signal])
24
+ }
25
+ child.on("exit", (code, signal) => {
26
+ for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal])
27
+ if (signal) {
28
+ process.kill(process.pid, signal)
29
+ return
30
+ }
31
+ process.exit(typeof code === "number" ? code : 0)
32
+ })
33
+ }
34
+
35
+ const envPath = process.env.MARSAI_BIN_PATH
36
+ const scriptDir = path.dirname(fs.realpathSync(__filename))
37
+ const cached = path.join(scriptDir, ".marscli")
38
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] || os.platform()
39
+ const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] || os.arch()
40
+ const base = "@mars_ai/marscli-" + platform + "-" + arch
41
+ const binary = platform === "windows" ? "mars.exe" : "mars"
42
+
43
+ function supportsAvx2() {
44
+ if (arch !== "x64") return false
45
+ if (platform === "linux") {
46
+ try {
47
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
48
+ } catch {
49
+ return false
50
+ }
51
+ }
52
+ if (platform === "darwin") {
53
+ try {
54
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
55
+ return result.status === 0 && (result.stdout || "").trim() === "1"
56
+ } catch {
57
+ return false
58
+ }
59
+ }
60
+ if (platform === "windows") {
61
+ const command =
62
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
63
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
64
+ try {
65
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
66
+ encoding: "utf8",
67
+ timeout: 3000,
68
+ windowsHide: true,
69
+ })
70
+ if (result.status !== 0) continue
71
+ const output = (result.stdout || "").trim().toLowerCase()
72
+ if (output === "true" || output === "1") return true
73
+ if (output === "false" || output === "0") return false
74
+ } catch {
75
+ continue
76
+ }
77
+ }
78
+ }
79
+ return false
80
+ }
81
+
82
+ const names = (() => {
83
+ const baseline = arch === "x64" && !supportsAvx2()
84
+ if (platform === "linux") {
85
+ const musl = (() => {
86
+ try {
87
+ if (fs.existsSync("/etc/alpine-release")) return true
88
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
89
+ return ((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")
90
+ } catch {
91
+ return false
92
+ }
93
+ })()
94
+ if (musl)
95
+ return arch === "x64"
96
+ ? baseline
97
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
98
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
99
+ : [`${base}-musl`, base]
100
+ return arch === "x64"
101
+ ? baseline
102
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
103
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
104
+ : [base, `${base}-musl`]
105
+ }
106
+ return arch === "x64" ? (baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]) : [base]
107
+ })()
108
+
109
+ function findBinary(startDir) {
110
+ let current = startDir
111
+ for (;;) {
112
+ const modules = path.join(current, "node_modules")
113
+ if (fs.existsSync(modules))
114
+ for (const name of names) {
115
+ const candidate = path.join(modules, name, "bin", binary)
116
+ if (fs.existsSync(candidate)) return candidate
117
+ }
118
+ const parent = path.dirname(current)
119
+ if (parent === current) return undefined
120
+ current = parent
121
+ }
122
+ }
123
+
124
+ const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
125
+ if (!resolved) {
126
+ console.error(
127
+ "Mars CLI could not find its platform binary. Try manually installing " +
128
+ names.map((name) => `"${name}"`).join(" or ") +
129
+ " package",
130
+ )
131
+ process.exit(1)
132
+ }
133
+ run(resolved)
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@mars_ai/marscli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "bin": {
4
+ "mars": "./bin/mars.cjs"
5
+ },
6
+ "files": [
7
+ "bin",
8
+ "README.md",
9
+ "LICENSE"
10
+ ],
11
+ "version": "1.18.36",
12
+ "description": "MarsAI command-line coding agent",
13
+ "license": "MIT",
14
+ "homepage": "https://marsai.click",
15
+ "os": [
16
+ "darwin",
17
+ "linux",
18
+ "win32"
19
+ ],
20
+ "cpu": [
21
+ "arm64",
22
+ "x64"
23
+ ],
24
+ "optionalDependencies": {
25
+ "@mars_ai/marscli-windows-x64-baseline": "1.18.36",
26
+ "@mars_ai/marscli-windows-x64": "1.18.36",
27
+ "@mars_ai/marscli-windows-arm64": "1.18.36",
28
+ "@mars_ai/marscli-linux-x64-musl": "1.18.36",
29
+ "@mars_ai/marscli-linux-x64-baseline-musl": "1.18.36",
30
+ "@mars_ai/marscli-linux-x64-baseline": "1.18.36",
31
+ "@mars_ai/marscli-linux-x64": "1.18.36",
32
+ "@mars_ai/marscli-linux-arm64-musl": "1.18.36",
33
+ "@mars_ai/marscli-linux-arm64": "1.18.36",
34
+ "@mars_ai/marscli-darwin-x64-baseline": "1.18.36",
35
+ "@mars_ai/marscli-darwin-x64": "1.18.36",
36
+ "@mars_ai/marscli-darwin-arm64": "1.18.36"
37
+ }
6
38
  }