gitarsenal-cli 1.0.4 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -2310,45 +2310,95 @@ if __name__ == "__main__":
2310
2310
  )
2311
2311
 
2312
2312
  print("\nā³ Keeping the sandbox alive. Press Ctrl+C to exit (sandbox will continue running)...")
2313
- while True:
2314
- time.sleep(90)
2315
- print(".", end="", flush=True)
2316
- except KeyboardInterrupt:
2317
- print("\nšŸ‘‹ Script exited. The sandbox will continue running.")
2318
- if 'result' in locals() and result:
2319
- container_id = None
2320
- # Try to get container ID from the result dictionary
2321
- if isinstance(result, dict):
2322
- # The container ID might be stored in execution_history or elsewhere
2323
- # Let's try to find it in the current_dir which might contain it
2324
- current_dir = result.get('current_dir', '')
2325
- if 'container_id' in result:
2326
- container_id = result['container_id']
2327
- elif hasattr(result, 'container_id'):
2328
- container_id = result.container_id
2329
-
2330
- # If we still don't have the container ID, try to read it from the file
2331
- if not container_id:
2332
- try:
2333
- with open(os.path.expanduser("~/.modal_last_container_id"), "r") as f:
2334
- container_id = f.read().strip()
2335
- print(f"šŸ“‹ Retrieved container ID from file: {container_id}")
2336
- except Exception as e:
2337
- print(f"āš ļø Could not read container ID from file: {e}")
2313
+ try:
2314
+ while True:
2315
+ time.sleep(90)
2316
+ print(".", end="", flush=True)
2317
+ except KeyboardInterrupt:
2318
+ print("\nšŸ‘‹ Script exited. The sandbox will continue running.")
2319
+ if 'result' in locals() and result:
2320
+ container_id = None
2321
+ # Try to get container ID from the result dictionary
2322
+ if isinstance(result, dict):
2323
+ # The container ID might be stored in execution_history or elsewhere
2324
+ # Let's try to find it in the current_dir which might contain it
2325
+ current_dir = result.get('current_dir', '')
2326
+ if 'container_id' in result:
2327
+ container_id = result['container_id']
2328
+ elif hasattr(result, 'container_id'):
2329
+ container_id = result.container_id
2330
+
2331
+ # If we still don't have the container ID, try to read it from the file
2332
+ if not container_id:
2333
+ try:
2334
+ with open(os.path.expanduser("~/.modal_last_container_id"), "r") as f:
2335
+ container_id = f.read().strip()
2336
+ print(f"šŸ“‹ Retrieved container ID from file: {container_id}")
2337
+ except Exception as e:
2338
+ print(f"āš ļø Could not read container ID from file: {e}")
2339
+
2340
+ if container_id:
2341
+ print(f"šŸš€ Starting shell in container: {container_id}")
2342
+
2343
+ # First try to open a new terminal window
2344
+ terminal_script = f'''
2345
+ tell application "Terminal"
2346
+ do script "modal shell {container_id}"
2347
+ activate
2348
+ end tell
2349
+ '''
2350
+
2351
+ try:
2352
+ # Run osascript to open a new terminal window
2353
+ subprocess.run(['osascript', '-e', terminal_script],
2354
+ capture_output=True, text=True, timeout=30)
2355
+ print("āœ… New terminal window opened successfully")
2356
+ except Exception as e:
2357
+ print(f"āš ļø Failed to open terminal window: {e}")
2358
+
2359
+ # Try alternative approach with iTerm2 if Terminal failed
2360
+ print("šŸ”„ Trying with iTerm2 instead...")
2361
+ iterm_script = f'''
2362
+ tell application "iTerm"
2363
+ create window with default profile
2364
+ tell current session of current window
2365
+ write text "modal shell {container_id}"
2366
+ end tell
2367
+ end tell
2368
+ '''
2369
+
2370
+ try:
2371
+ iterm_result = subprocess.run(['osascript', '-e', iterm_script],
2372
+ capture_output=True, text=True, timeout=30)
2373
+ print("āœ… New iTerm2 window opened successfully")
2374
+ except Exception as e2:
2375
+ # As a last resort, try to run the modal shell command directly
2376
+ print(f"āš ļø Failed to open iTerm2 window: {e2}")
2377
+ print("šŸ”„ Trying direct modal shell command...")
2378
+
2379
+ try:
2380
+ # Execute modal shell command directly without any flags
2381
+ shell_cmd = f"modal shell {container_id}"
2382
+ print(f"šŸ”„ Executing: {shell_cmd}")
2383
+ subprocess.run(shell_cmd, shell=True)
2384
+ print("āœ… Shell session completed")
2385
+ except Exception as e3:
2386
+ print(f"āŒ Error starting shell: {e3}")
2387
+ print("šŸ“ You can manually connect using:")
2388
+ print(f" modal shell {container_id}")
2389
+ else:
2390
+ print("āš ļø Could not determine container ID")
2391
+ print("šŸ“ You can manually connect using:")
2392
+ print(" modal container list")
2393
+ print(" modal shell <CONTAINER_ID>")
2338
2394
 
2339
- if container_id:
2340
- print(f"šŸš€ Starting shell in container: {container_id}")
2341
- try:
2342
- # Execute the modal shell command directly
2343
- shell_cmd = f"modal shell {container_id}"
2344
- print(f"šŸ”„ Executing: {shell_cmd}")
2345
- subprocess.run(shell_cmd, shell=True)
2346
- except Exception as e:
2347
- print(f"āŒ Error starting shell: {e}")
2348
- print(f"šŸ“ You can manually connect using:")
2349
- print(f" modal shell {container_id}")
2350
- else:
2351
- print("āš ļø Could not determine container ID")
2352
- print("šŸ“ You can manually connect using:")
2353
- print(" modal container list")
2354
- print(" modal shell <CONTAINER_ID>")
2395
+ # Exit cleanly
2396
+ sys.exit(0)
2397
+ except KeyboardInterrupt:
2398
+ # Handle Ctrl+C during sandbox creation
2399
+ print("\nšŸ‘‹ Script interrupted during sandbox creation.")
2400
+ print("šŸ“ You may need to check if a sandbox was created with: modal sandbox list")
2401
+ sys.exit(0)
2402
+ except Exception as e:
2403
+ print(f"āŒ Error: {e}")
2404
+ sys.exit(1)
@@ -30,6 +30,10 @@ async function postinstall() {
30
30
  if (stats.size > 5000) {
31
31
  console.log(chalk.green('āœ… Found existing full Python script. Keeping it.'));
32
32
  scriptFound = true;
33
+ // Skip the rest of the script to avoid overwriting the existing file
34
+ console.log(chalk.blue('šŸ“¦ GitArsenal CLI installation complete!'));
35
+ console.log(chalk.blue('šŸš€ Run "gitarsenal" to start using the CLI.'));
36
+ return;
33
37
  } else {
34
38
  console.log(chalk.yellow('āš ļø Existing Python script appears to be minimal. Looking for full version...'));
35
39
  }