gitarsenal-cli 1.0.2 ā 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 +1 -1
- package/python/test_modalSandboxScript.py +91 -41
- package/scripts/postinstall.js +4 -0
- package/test_modalSandboxScript.py +2354 -0
package/package.json
CHANGED
@@ -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
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
container_id
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
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
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
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)
|
package/scripts/postinstall.js
CHANGED
@@ -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
|
}
|