forgecode 1.3.0 → 1.4.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/install.js CHANGED
@@ -105,6 +105,31 @@ function testBinary(binaryPath) {
105
105
  }
106
106
  }
107
107
 
108
+ // Detect if running on Android (Termux or similar)
109
+ function isAndroid() {
110
+ try {
111
+ // Check for Android-specific environment variables
112
+ if (process.env.ANDROID_ROOT || process.env.ANDROID_DATA) {
113
+ return true;
114
+ }
115
+
116
+ // Check if running in Termux
117
+ if (process.env.PREFIX && process.env.PREFIX.includes('com.termux')) {
118
+ return true;
119
+ }
120
+
121
+ // Check for Android-specific system properties
122
+ const { existsSync } = require('fs');
123
+ if (existsSync('/system/build.prop')) {
124
+ return true;
125
+ }
126
+
127
+ return false;
128
+ } catch (error) {
129
+ return false;
130
+ }
131
+ }
132
+
108
133
  // Map of supported platforms and architectures to binary names
109
134
  const PLATFORMS = {
110
135
  darwin: {
@@ -119,6 +144,7 @@ const PLATFORMS = {
119
144
  arm64: {
120
145
  gnu: 'forge-aarch64-unknown-linux-gnu',
121
146
  musl: 'forge-aarch64-unknown-linux-musl',
147
+ android: 'forge-aarch64-linux-android',
122
148
  },
123
149
  },
124
150
  win32: {
@@ -141,6 +167,10 @@ function printPlatformInfo() {
141
167
  console.log(` - OS: ${os.type()} ${os.release()}`);
142
168
 
143
169
  if (platform === 'linux') {
170
+ if (isAndroid()) {
171
+ console.log(` - Environment: Android`);
172
+ }
173
+
144
174
  const libcInfo = getGlibcVersion();
145
175
  console.log(
146
176
  ` - Libc: ${libcInfo.type}${libcInfo.version ? ` version ${libcInfo.version}` : ''}`
@@ -186,41 +216,49 @@ function install() {
186
216
 
187
217
  // Handle Linux specially for libc type
188
218
  if (platform === 'linux') {
189
- let libcType = detectLibcType();
190
-
191
- // Always try musl first if available (it's more portable)
192
- const muslBinaryName = PLATFORMS[platform][arch]['musl'];
193
- const muslBinaryPath = join(__dirname, 'bin', platform, arch, muslBinaryName);
194
-
195
- // Check if musl binary exists
196
- if (existsSync(muslBinaryPath)) {
197
- console.log('📦 Found musl binary, which should work on most Linux systems');
198
- binaryName = muslBinaryName;
199
- binaryPath = muslBinaryPath;
200
- }
201
- // Fall back to detected libc type
202
- else {
203
- // Check if the detected libc type is supported in our binaries
204
- if (!PLATFORMS[platform][arch][libcType]) {
205
- // If not supported, try the alternative
206
- libcType = libcType === 'gnu' ? 'musl' : 'gnu';
207
- console.warn(`⚠️ Detected libc type is not supported, trying ${libcType} instead`);
219
+ // Check if running on Android first
220
+ if (isAndroid() && arch === 'arm64' && PLATFORMS[platform][arch]['android']) {
221
+ console.log('🤖 Android platform detected');
222
+ binaryName = PLATFORMS[platform][arch]['android'];
223
+ // Android binaries are stored in darwin/arm64 directory as per update-package.sh
224
+ binaryPath = join(__dirname, 'bin', 'darwin', 'arm64', binaryName);
225
+ } else {
226
+ let libcType = detectLibcType();
227
+
228
+ // Always try musl first if available (it's more portable)
229
+ const muslBinaryName = PLATFORMS[platform][arch]['musl'];
230
+ const muslBinaryPath = join(__dirname, 'bin', platform, arch, muslBinaryName);
231
+
232
+ // Check if musl binary exists
233
+ if (existsSync(muslBinaryPath)) {
234
+ console.log('📦 Found musl binary, which should work on most Linux systems');
235
+ binaryName = muslBinaryName;
236
+ binaryPath = muslBinaryPath;
208
237
  }
238
+ // Fall back to detected libc type
239
+ else {
240
+ // Check if the detected libc type is supported in our binaries
241
+ if (!PLATFORMS[platform][arch][libcType]) {
242
+ // If not supported, try the alternative
243
+ libcType = libcType === 'gnu' ? 'musl' : 'gnu';
244
+ console.warn(`⚠️ Detected libc type is not supported, trying ${libcType} instead`);
245
+ }
209
246
 
210
- binaryName = PLATFORMS[platform][arch][libcType];
211
- binaryPath = join(__dirname, 'bin', platform, arch, binaryName);
212
- }
247
+ binaryName = PLATFORMS[platform][arch][libcType];
248
+ binaryPath = join(__dirname, 'bin', platform, arch, binaryName);
249
+ }
213
250
 
214
- // If binary doesn't exist, try the alternative
215
- if (!existsSync(binaryPath)) {
216
- const alternativeLibc = libcType === 'gnu' ? 'musl' : 'gnu';
217
- const alternativeBinaryName = PLATFORMS[platform][arch][alternativeLibc];
218
- const alternativeBinaryPath = join(__dirname, 'bin', platform, arch, alternativeBinaryName);
251
+ // If binary doesn't exist, try the alternative
252
+ if (!existsSync(binaryPath)) {
253
+ const alternativeLibc = libcType === 'gnu' ? 'musl' : 'gnu';
254
+ const alternativeBinaryName = PLATFORMS[platform][arch][alternativeLibc];
255
+ const alternativeBinaryPath = join(__dirname, 'bin', platform, arch, alternativeBinaryName);
219
256
 
220
- if (existsSync(alternativeBinaryPath)) {
221
- console.warn(`⚠️ Binary for ${libcType} not found, trying ${alternativeLibc} instead`);
222
- binaryName = alternativeBinaryName;
223
- binaryPath = alternativeBinaryPath;
257
+ if (existsSync(alternativeBinaryPath)) {
258
+ console.warn(`⚠️ Binary for ${libcType} not found, trying ${alternativeLibc} instead`);
259
+ binaryName = alternativeBinaryName;
260
+ binaryPath = alternativeBinaryPath;
261
+ }
224
262
  }
225
263
  }
226
264
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgecode",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Code Forge CLI - an AI-powered coding assistant",
5
5
  "bin": {
6
6
  "forge": "forge.js"