@cubic-dev-ai/cli 0.12.7 → 0.13.0

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/git-ai.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "v1.1.2"
3
+ }
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.12.7",
10
+ "version": "0.13.0",
11
11
  "optionalDependencies": {
12
- "@cubic-dev-ai/cli-linux-arm64": "0.12.7",
13
- "@cubic-dev-ai/cli-linux-x64": "0.12.7",
14
- "@cubic-dev-ai/cli-linux-x64-baseline": "0.12.7",
15
- "@cubic-dev-ai/cli-linux-arm64-musl": "0.12.7",
16
- "@cubic-dev-ai/cli-linux-x64-musl": "0.12.7",
17
- "@cubic-dev-ai/cli-linux-x64-baseline-musl": "0.12.7",
18
- "@cubic-dev-ai/cli-darwin-arm64": "0.12.7",
19
- "@cubic-dev-ai/cli-darwin-x64": "0.12.7",
20
- "@cubic-dev-ai/cli-darwin-x64-baseline": "0.12.7",
21
- "@cubic-dev-ai/cli-windows-x64": "0.12.7",
22
- "@cubic-dev-ai/cli-windows-x64-baseline": "0.12.7"
12
+ "@cubic-dev-ai/cli-linux-arm64": "0.13.0",
13
+ "@cubic-dev-ai/cli-linux-x64": "0.13.0",
14
+ "@cubic-dev-ai/cli-linux-x64-baseline": "0.13.0",
15
+ "@cubic-dev-ai/cli-linux-arm64-musl": "0.13.0",
16
+ "@cubic-dev-ai/cli-linux-x64-musl": "0.13.0",
17
+ "@cubic-dev-ai/cli-linux-x64-baseline-musl": "0.13.0",
18
+ "@cubic-dev-ai/cli-darwin-arm64": "0.13.0",
19
+ "@cubic-dev-ai/cli-darwin-x64": "0.13.0",
20
+ "@cubic-dev-ai/cli-darwin-x64-baseline": "0.13.0",
21
+ "@cubic-dev-ai/cli-windows-x64": "0.13.0",
22
+ "@cubic-dev-ai/cli-windows-x64-baseline": "0.13.0"
23
23
  }
24
24
  }
package/postinstall.mjs CHANGED
@@ -5,10 +5,37 @@ 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
9
 
9
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
11
  const require = createRequire(import.meta.url)
11
12
 
13
+ // Read git-ai version from JSON (single source of truth for JS/TS)
14
+ let GIT_AI_VERSION = "v1.1.2" // fallback
15
+ try {
16
+ // In published package, git-ai.json is a sibling file
17
+ // In development, it's at src/constants/git-ai.json relative to script/
18
+ const publishedPath = path.join(__dirname, "git-ai.json")
19
+ const devPath = path.join(__dirname, "..", "src", "constants", "git-ai.json")
20
+ const configPath = fs.existsSync(publishedPath) ? publishedPath : devPath
21
+ if (fs.existsSync(configPath)) {
22
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"))
23
+ GIT_AI_VERSION = config.version
24
+ }
25
+ } catch {
26
+ // Use fallback
27
+ }
28
+
29
+ // Validate version format to prevent command injection (must be vX.Y.Z format)
30
+ function isValidVersion(version) {
31
+ return /^v\d+\.\d+\.\d+$/.test(version)
32
+ }
33
+
34
+ if (!isValidVersion(GIT_AI_VERSION)) {
35
+ console.warn(`Invalid git-ai version format: ${GIT_AI_VERSION}, using fallback`)
36
+ GIT_AI_VERSION = "v1.1.2"
37
+ }
38
+
12
39
  function detectPlatformAndArch() {
13
40
  // Map platform names
14
41
  let platform
@@ -72,7 +99,6 @@ async function regenerateWindowsCmdWrappers() {
72
99
  console.log("Windows + npm detected: Forcing npm to rebuild bin links")
73
100
 
74
101
  try {
75
- const { execSync } = require("child_process")
76
102
  const pkgPath = path.join(__dirname, "..")
77
103
 
78
104
  // npm_config_global is string | undefined
@@ -97,16 +123,63 @@ async function regenerateWindowsCmdWrappers() {
97
123
  }
98
124
  }
99
125
 
126
+ // Install git-ai using official installer
127
+ // 2 minute timeout to prevent indefinite hangs during npm install
128
+ const GIT_AI_INSTALL_TIMEOUT = 120000
129
+
130
+ function setupGitAi() {
131
+ // Allow users to opt-out of automatic git-ai installation
132
+ if (process.env.CUBIC_DISABLE_GIT_AI === "true") {
133
+ console.log("Skipping git-ai installation (CUBIC_DISABLE_GIT_AI=true)")
134
+ console.log("You can install it later with: cubic stats enable")
135
+ return
136
+ }
137
+
138
+ console.log(`Installing git-ai ${GIT_AI_VERSION} for AI code tracking...`)
139
+
140
+ try {
141
+ if (os.platform() === "win32") {
142
+ // PowerShell installer for Windows
143
+ execSync(
144
+ `powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:GIT_AI_RELEASE_TAG='${GIT_AI_VERSION}'; irm https://usegitai.com/install.ps1 | iex"`,
145
+ { stdio: "inherit", shell: true, timeout: GIT_AI_INSTALL_TIMEOUT },
146
+ )
147
+ } else {
148
+ // Bash installer for macOS/Linux
149
+ execSync(`export GIT_AI_RELEASE_TAG="${GIT_AI_VERSION}" && curl -sSL https://usegitai.com/install.sh | bash`, {
150
+ stdio: "inherit",
151
+ shell: "/bin/bash",
152
+ timeout: GIT_AI_INSTALL_TIMEOUT,
153
+ })
154
+ }
155
+
156
+ console.log("git-ai installed successfully")
157
+
158
+ // Configure git-ai to run in quiet mode (suppress chart output after commits)
159
+ const gitAiBinary = path.join(os.homedir(), ".git-ai", "bin", os.platform() === "win32" ? "git-ai.exe" : "git-ai")
160
+ try {
161
+ execSync(`"${gitAiBinary}" config set quiet true`, { stdio: "ignore", timeout: 5000 })
162
+ } catch {
163
+ // Ignore if config fails - git-ai will work without quiet mode
164
+ }
165
+ } catch (error) {
166
+ console.warn("git-ai installation failed, continuing without it:", error.message)
167
+ console.log("You can install it later with: cubic stats enable")
168
+ }
169
+ }
170
+
100
171
  async function main() {
101
172
  try {
102
173
  if (os.platform() === "win32") {
103
174
  // NPM eg format - npm/11.4.2 node/v24.4.1 win32 x64
104
175
  // Bun eg format - bun/1.2.19 npm/? node/v24.3.0 win32 x64
105
- if (process.env.npm_config_user_agent.startsWith("npm")) {
176
+ if (process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith("npm")) {
106
177
  await regenerateWindowsCmdWrappers()
107
178
  } else {
108
- console.log("Windows detected but not npm, skipping postinstall")
179
+ console.log("Windows detected but not npm, skipping binary symlink")
109
180
  }
181
+ // Install git-ai on Windows too
182
+ setupGitAi()
110
183
  return
111
184
  }
112
185
 
@@ -121,6 +194,9 @@ async function main() {
121
194
  // Create symlink to the actual binary
122
195
  fs.symlinkSync(binaryPath, binScript)
123
196
  console.log(`cubic binary symlinked: ${binScript} -> ${binaryPath}`)
197
+
198
+ // Install git-ai
199
+ setupGitAi()
124
200
  } catch (error) {
125
201
  console.error("Failed to create cubic binary symlink:", error.message)
126
202
  process.exit(1)