@cubic-dev-ai/cli 0.15.1 → 0.16.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/cubic +16 -6
- package/bin/cubic.cmd +12 -0
- package/bin/cubic.wrapper +71 -0
- package/package.json +12 -12
- package/postinstall.mjs +71 -12
package/bin/cubic
CHANGED
|
@@ -15,7 +15,7 @@ else
|
|
|
15
15
|
done
|
|
16
16
|
script_dir="$(dirname "$script_path")"
|
|
17
17
|
script_dir="$(cd "$script_dir" && pwd)"
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
# Map platform names
|
|
20
20
|
case "$(uname -s)" in
|
|
21
21
|
Darwin) platform="darwin" ;;
|
|
@@ -23,19 +23,19 @@ else
|
|
|
23
23
|
MINGW*|CYGWIN*|MSYS*) platform="win32" ;;
|
|
24
24
|
*) platform="$(uname -s | tr '[:upper:]' '[:lower:]')" ;;
|
|
25
25
|
esac
|
|
26
|
-
|
|
27
|
-
# Map architecture names
|
|
26
|
+
|
|
27
|
+
# Map architecture names
|
|
28
28
|
case "$(uname -m)" in
|
|
29
29
|
x86_64|amd64) arch="x64" ;;
|
|
30
30
|
aarch64) arch="arm64" ;;
|
|
31
31
|
armv7l) arch="arm" ;;
|
|
32
32
|
*) arch="$(uname -m)" ;;
|
|
33
33
|
esac
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
name="@cubic-dev-ai/cli-${platform}-${arch}"
|
|
36
36
|
binary="cubic"
|
|
37
37
|
[ "$platform" = "win32" ] && binary="cubic.exe"
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
# Search for the binary starting from real script location
|
|
40
40
|
resolved=""
|
|
41
41
|
current_dir="$script_dir"
|
|
@@ -47,7 +47,7 @@ else
|
|
|
47
47
|
fi
|
|
48
48
|
current_dir="$(dirname "$current_dir")"
|
|
49
49
|
done
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
if [ -z "$resolved" ]; then
|
|
52
52
|
printf "It seems that your package manager failed to install the right version of the cubic CLI for your platform. You can try manually installing the \"%s\" package\n" "$name" >&2
|
|
53
53
|
exit 1
|
|
@@ -57,5 +57,15 @@ fi
|
|
|
57
57
|
# Handle SIGINT gracefully
|
|
58
58
|
trap '' INT
|
|
59
59
|
|
|
60
|
+
# Intercept installer command from npx wrapper context
|
|
61
|
+
if [ "$1" = "install" ]; then
|
|
62
|
+
exec "$resolved" "$@"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# npx with no args should bootstrap setup flow in exec context
|
|
66
|
+
if [ "$#" -eq 0 ] && [ "${npm_command:-}" = "exec" ]; then
|
|
67
|
+
exec "$resolved" setup --mode install
|
|
68
|
+
fi
|
|
69
|
+
|
|
60
70
|
# Execute the binary with all arguments
|
|
61
71
|
exec "$resolved" "$@"
|
package/bin/cubic.cmd
CHANGED
|
@@ -21,6 +21,7 @@ if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
|
|
21
21
|
) else if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
|
22
22
|
set "arch=x86"
|
|
23
23
|
) else (
|
|
24
|
+
echo Warning: Unknown PROCESSOR_ARCHITECTURE "!PROCESSOR_ARCHITECTURE!", defaulting to x64 >&2
|
|
24
25
|
set "arch=x64"
|
|
25
26
|
)
|
|
26
27
|
|
|
@@ -52,6 +53,17 @@ echo It seems that your package manager failed to install the right version of t
|
|
|
52
53
|
exit /b 1
|
|
53
54
|
|
|
54
55
|
:execute
|
|
56
|
+
rem Intercept installer command from npx wrapper context
|
|
57
|
+
if "%~1"=="install" (
|
|
58
|
+
start /b /wait "" "%resolved%" %*
|
|
59
|
+
exit /b !ERRORLEVEL!
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
if "%~1"=="" if /i "%npm_command%"=="exec" (
|
|
63
|
+
start /b /wait "" "%resolved%" setup --mode install
|
|
64
|
+
exit /b !ERRORLEVEL!
|
|
65
|
+
)
|
|
66
|
+
|
|
55
67
|
rem Execute the binary with all arguments in the same console window
|
|
56
68
|
rem Use start /b /wait to ensure it runs in the current shell context for all shells
|
|
57
69
|
start /b /wait "" "%resolved%" %*
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
if [ -n "$CUBIC_BIN_PATH" ]; then
|
|
5
|
+
resolved="$CUBIC_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="@cubic-dev-ai/cli-${platform}-${arch}"
|
|
36
|
+
binary="cubic"
|
|
37
|
+
[ "$platform" = "win32" ] && binary="cubic.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 cubic 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
|
+
# Intercept installer command from npx wrapper context
|
|
61
|
+
if [ "$1" = "install" ]; then
|
|
62
|
+
exec "$resolved" "$@"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# npx with no args should bootstrap setup flow in exec context
|
|
66
|
+
if [ "$#" -eq 0 ] && [ "${npm_command:-}" = "exec" ]; then
|
|
67
|
+
exec "$resolved" setup --mode install
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Execute the binary with all arguments
|
|
71
|
+
exec "$resolved" "$@"
|
package/package.json
CHANGED
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
"preinstall": "bun ./preinstall.mjs || node ./preinstall.mjs",
|
|
8
8
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.16.1",
|
|
11
11
|
"optionalDependencies": {
|
|
12
|
-
"@cubic-dev-ai/cli-linux-arm64": "0.
|
|
13
|
-
"@cubic-dev-ai/cli-linux-x64": "0.
|
|
14
|
-
"@cubic-dev-ai/cli-linux-x64-baseline": "0.
|
|
15
|
-
"@cubic-dev-ai/cli-linux-arm64-musl": "0.
|
|
16
|
-
"@cubic-dev-ai/cli-linux-x64-musl": "0.
|
|
17
|
-
"@cubic-dev-ai/cli-linux-x64-baseline-musl": "0.
|
|
18
|
-
"@cubic-dev-ai/cli-darwin-arm64": "0.
|
|
19
|
-
"@cubic-dev-ai/cli-darwin-x64": "0.
|
|
20
|
-
"@cubic-dev-ai/cli-darwin-x64-baseline": "0.
|
|
21
|
-
"@cubic-dev-ai/cli-windows-x64": "0.
|
|
22
|
-
"@cubic-dev-ai/cli-windows-x64-baseline": "0.
|
|
12
|
+
"@cubic-dev-ai/cli-linux-arm64": "0.16.1",
|
|
13
|
+
"@cubic-dev-ai/cli-linux-x64": "0.16.1",
|
|
14
|
+
"@cubic-dev-ai/cli-linux-x64-baseline": "0.16.1",
|
|
15
|
+
"@cubic-dev-ai/cli-linux-arm64-musl": "0.16.1",
|
|
16
|
+
"@cubic-dev-ai/cli-linux-x64-musl": "0.16.1",
|
|
17
|
+
"@cubic-dev-ai/cli-linux-x64-baseline-musl": "0.16.1",
|
|
18
|
+
"@cubic-dev-ai/cli-darwin-arm64": "0.16.1",
|
|
19
|
+
"@cubic-dev-ai/cli-darwin-x64": "0.16.1",
|
|
20
|
+
"@cubic-dev-ai/cli-darwin-x64-baseline": "0.16.1",
|
|
21
|
+
"@cubic-dev-ai/cli-windows-x64": "0.16.1",
|
|
22
|
+
"@cubic-dev-ai/cli-windows-x64-baseline": "0.16.1"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -5,7 +5,13 @@ import path from "path"
|
|
|
5
5
|
import os from "os"
|
|
6
6
|
import { fileURLToPath } from "url"
|
|
7
7
|
import { createRequire } from "module"
|
|
8
|
-
import { execSync } from "child_process"
|
|
8
|
+
import { execFileSync, execSync } from "child_process"
|
|
9
|
+
|
|
10
|
+
const CUBIC_WRAPPER_MODE = process.env.CUBIC_WRAPPER_MODE !== "0"
|
|
11
|
+
|
|
12
|
+
function packagePrefix() {
|
|
13
|
+
return process.env.CUBIC_PACKAGE_PREFIX || "@cubic-dev-ai/cli-"
|
|
14
|
+
}
|
|
9
15
|
|
|
10
16
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
17
|
const require = createRequire(import.meta.url)
|
|
@@ -26,9 +32,9 @@ try {
|
|
|
26
32
|
// Use fallback
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
// Validate version format to prevent command injection (must be
|
|
35
|
+
// Validate version format to prevent command injection (must be [v]X.Y.Z format)
|
|
30
36
|
function isValidVersion(version) {
|
|
31
|
-
return /^v
|
|
37
|
+
return /^v?\d+\.\d+\.\d+$/.test(version)
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
if (!isValidVersion(GIT_AI_VERSION)) {
|
|
@@ -36,6 +42,20 @@ if (!isValidVersion(GIT_AI_VERSION)) {
|
|
|
36
42
|
GIT_AI_VERSION = "v1.1.2"
|
|
37
43
|
}
|
|
38
44
|
|
|
45
|
+
function shouldRunInstallWizard() {
|
|
46
|
+
if (process.env.CUBIC_DISABLE_INSTALL_WIZARD === "true") return false
|
|
47
|
+
if (process.env.npm_config_ignore_scripts === "true") return false
|
|
48
|
+
if (process.env.CI && process.env.CI !== "false") return false
|
|
49
|
+
if (process.env.npm_config_yes === "true") return false
|
|
50
|
+
if (process.env.TERM === "dumb") return false
|
|
51
|
+
if (!process.stdin.isTTY) return false
|
|
52
|
+
if (!process.stdout.isTTY) return false
|
|
53
|
+
if (!process.stderr.isTTY) return false
|
|
54
|
+
if (process.platform === "win32") return false
|
|
55
|
+
if (!fs.existsSync("/dev/tty")) return false
|
|
56
|
+
return true
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
function detectPlatformAndArch() {
|
|
40
60
|
// Map platform names
|
|
41
61
|
let platform
|
|
@@ -76,7 +96,7 @@ function detectPlatformAndArch() {
|
|
|
76
96
|
|
|
77
97
|
function findBinary() {
|
|
78
98
|
const { platform, arch } = detectPlatformAndArch()
|
|
79
|
-
const packageName =
|
|
99
|
+
const packageName = `${packagePrefix()}${platform}-${arch}`
|
|
80
100
|
const binary = platform === "windows" ? "cubic.exe" : "cubic"
|
|
81
101
|
|
|
82
102
|
try {
|
|
@@ -197,6 +217,8 @@ function setupGitAi() {
|
|
|
197
217
|
} catch {
|
|
198
218
|
// Ignore if config fails - git-ai will work without quiet mode
|
|
199
219
|
}
|
|
220
|
+
|
|
221
|
+
console.log("Close and reopen your IDE and terminal sessions in order to use AI attribution stats.")
|
|
200
222
|
} catch (error) {
|
|
201
223
|
console.warn(
|
|
202
224
|
"cubic AI stats use git-ai under the hood. git-ai failed to install. " +
|
|
@@ -207,6 +229,7 @@ function setupGitAi() {
|
|
|
207
229
|
}
|
|
208
230
|
|
|
209
231
|
async function main() {
|
|
232
|
+
let binaryPath = ""
|
|
210
233
|
try {
|
|
211
234
|
if (os.platform() === "win32") {
|
|
212
235
|
// NPM eg format - npm/11.4.2 node/v24.4.1 win32 x64
|
|
@@ -217,17 +240,53 @@ async function main() {
|
|
|
217
240
|
console.log("Windows detected but not npm, skipping binary symlink")
|
|
218
241
|
}
|
|
219
242
|
} else {
|
|
220
|
-
|
|
243
|
+
try {
|
|
244
|
+
binaryPath = findBinary()
|
|
245
|
+
} catch (error) {
|
|
246
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
247
|
+
console.log(`cubic: setup skipped (${message}) - run \`npm i -g @cubic-dev-ai/cli\` again in a minute`)
|
|
248
|
+
return
|
|
249
|
+
}
|
|
221
250
|
const binScript = path.join(__dirname, "bin", "cubic")
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (fs.existsSync(
|
|
225
|
-
fs.
|
|
251
|
+
const wrapperPath = path.join(__dirname, "bin", "cubic.wrapper")
|
|
252
|
+
|
|
253
|
+
if (CUBIC_WRAPPER_MODE && fs.existsSync(wrapperPath)) {
|
|
254
|
+
if (fs.existsSync(binScript)) {
|
|
255
|
+
fs.unlinkSync(binScript)
|
|
256
|
+
}
|
|
257
|
+
fs.copyFileSync(wrapperPath, binScript)
|
|
258
|
+
fs.chmodSync(binScript, 0o755)
|
|
259
|
+
process.env.CUBIC_BIN_PATH = binaryPath
|
|
260
|
+
console.log(`cubic wrapper configured: ${binScript} -> ${binaryPath}`)
|
|
261
|
+
} else {
|
|
262
|
+
// Remove existing bin script if it exists
|
|
263
|
+
if (fs.existsSync(binScript)) {
|
|
264
|
+
fs.unlinkSync(binScript)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Create symlink to the actual binary
|
|
268
|
+
fs.symlinkSync(binaryPath, binScript)
|
|
269
|
+
console.log(`cubic binary symlinked: ${binScript} -> ${binaryPath}`)
|
|
226
270
|
}
|
|
271
|
+
}
|
|
227
272
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
console.log(
|
|
273
|
+
// Install-time wizard (opt-in)
|
|
274
|
+
if (shouldRunInstallWizard()) {
|
|
275
|
+
console.log("\n◆ Optional: connect cubic to your coding agent")
|
|
276
|
+
try {
|
|
277
|
+
execFileSync(binaryPath, ["setup", "--mode", "install-time"], {
|
|
278
|
+
stdio: "inherit",
|
|
279
|
+
timeout: 300000,
|
|
280
|
+
env: {
|
|
281
|
+
...process.env,
|
|
282
|
+
},
|
|
283
|
+
})
|
|
284
|
+
} catch (error) {
|
|
285
|
+
const m = error instanceof Error ? error.message : String(error)
|
|
286
|
+
console.log(`cubic: setup skipped (${m}) - run \`cubic setup\` later`)
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
console.log("cubic: Run `cubic setup` to connect your coding agent")
|
|
231
290
|
}
|
|
232
291
|
} catch (error) {
|
|
233
292
|
console.error("Failed to create cubic binary symlink:", error.message)
|