From 197207db76226ea8c5ec51c3d71334b6b608da58 Mon Sep 17 00:00:00 2001 From: robcholz <84130577+robcholz@users.noreply.github.com> Date: Fri, 6 Feb 2026 22:12:42 -0500 Subject: [PATCH] feat: removed rust and rename to vibebox --- docs/tasks.md | 4 ++-- src/instance.rs | 51 ++++++++++++++++++++---------------------------- src/lib.rs | 2 +- src/provision.sh | 15 ++------------ src/vm.rs | 10 ++-------- 5 files changed, 28 insertions(+), 54 deletions(-) diff --git a/docs/tasks.md b/docs/tasks.md index b7072f4..78b9bfd 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -36,6 +36,6 @@ ## Integration 1. [x] Wire up the vm and tui. -2. [ ] Use ssh to connect to vm. +2. [x] Use ssh to connect to vm. 3. [ ] wire up SessionManager. -4. [ ] VM should be separated by per-session VM daemon process (only accepts if to shutdown vm and itself). +4. [ ] VM should be separated by a per-session VM daemon process (only accepts if to shut down vm and itself). diff --git a/src/instance.rs b/src/instance.rs index 6b0a1be..04d9bc7 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -1,12 +1,8 @@ use std::{ - env, - fs, + env, fs, io::{self, Write}, net::{SocketAddr, TcpStream}, - os::unix::{ - fs::PermissionsExt, - io::OwnedFd, - }, + os::unix::{fs::PermissionsExt, io::OwnedFd}, path::{Path, PathBuf}, process::{Command, Stdio}, sync::{ @@ -17,8 +13,8 @@ use std::{ }; use serde::{Deserialize, Serialize}; -use uuid::Uuid; use std::sync::mpsc::Sender; +use uuid::Uuid; use crate::{ session_manager::INSTANCE_DIR_NAME, @@ -30,7 +26,7 @@ const INSTANCE_TOML: &str = "instance.toml"; const SSH_KEY_NAME: &str = "ssh_key"; const SERIAL_LOG_NAME: &str = "serial.log"; const SSH_GUEST_DIR: &str = "/root/.vibebox"; -const DEFAULT_SSH_USER: &str = "vibebox"; +const DEFAULT_SSH_USER: &str = "vibecoder"; const SSH_CONNECT_RETRIES: usize = 30; const SSH_CONNECT_DELAY_MS: u64 = 500; const SSH_SETUP_SCRIPT: &str = include_str!("ssh.sh"); @@ -76,12 +72,8 @@ pub fn run_with_ssh( true, )?]; - let extra_login_actions = build_ssh_login_actions( - &config, - &project_name, - SSH_GUEST_DIR, - SSH_KEY_NAME, - ); + let extra_login_actions = + build_ssh_login_actions(&config, &project_name, SSH_GUEST_DIR, SSH_KEY_NAME); vm::run_with_args_and_extras( args, @@ -107,7 +99,9 @@ fn ensure_instance_dir(project_root: &Path) -> Result { Ok(instance_dir) } -fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box> { +fn ensure_ssh_keypair( + instance_dir: &Path, +) -> Result<(PathBuf, PathBuf), Box> { let private_key = instance_dir.join(SSH_KEY_NAME); let public_key = instance_dir.join(format!("{SSH_KEY_NAME}.pub")); @@ -129,12 +123,13 @@ fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box>>> = - Arc::new(Mutex::new(None)); + let input_tx_holder: Arc>>> = Arc::new(Mutex::new(None)); let instance_path = instance_dir.join(INSTANCE_TOML); let config_for_output = config.clone(); @@ -415,9 +409,7 @@ fn spawn_ssh_io( ); break; } - thread::sleep(std::time::Duration::from_millis( - SSH_CONNECT_DELAY_MS, - )); + thread::sleep(std::time::Duration::from_millis(SSH_CONNECT_DELAY_MS)); continue; } @@ -427,9 +419,7 @@ fn spawn_ssh_io( let status = Command::new("ssh") .args([ "-i", - ssh_key_for_thread - .to_str() - .unwrap_or(".vibebox/ssh_key"), + ssh_key_for_thread.to_str().unwrap_or(".vibebox/ssh_key"), "-o", "IdentitiesOnly=yes", "-o", @@ -447,6 +437,9 @@ fn spawn_ssh_io( "-o", "ConnectTimeout=5", ]) + .env_remove("LC_CTYPE") + .env_remove("LC_ALL") + // .env_remove("LANG") .arg(format!("{ssh_user}@{ip}")) .stdin(Stdio::inherit()) .stdout(Stdio::inherit()) @@ -458,8 +451,7 @@ fn spawn_ssh_io( ssh_connected_for_thread.store(false, Ordering::SeqCst); eprintln!("[vibebox] ssh exited with status: {status}"); if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() { - let _ = - tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec())); + let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec())); } break; } @@ -479,8 +471,7 @@ fn spawn_ssh_io( ssh_connected_for_thread.store(false, Ordering::SeqCst); eprintln!("[vibebox] ssh exited with status: {status}"); if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() { - let _ = - tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec())); + let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec())); } break; } diff --git a/src/lib.rs b/src/lib.rs index f0c19a1..d089ae0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ +pub mod instance; pub mod session_manager; pub mod tui; pub mod vm; -pub mod instance; pub use session_manager::{SessionError, SessionManager, SessionRecord}; diff --git a/src/provision.sh b/src/provision.sh index c61d018..9dfa743 100644 --- a/src/provision.sh +++ b/src/provision.sh @@ -15,16 +15,10 @@ apt-get install -y --no-install-recommends \ git \ ripgrep \ openssh-server \ - locales \ sudo -# Set hostname to "vibe" so it's clear that you're inside the VM. -hostnamectl set-hostname vibe - -# Locale (fix: setlocale: LC_CTYPE ... UTF-8) -sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen -locale-gen -update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 +# Set hostname to "vibebox" so it's clear that you're inside the VM. +hostnamectl set-hostname vibebox # SSH: host keys + base config (doesn't depend on runtime user) ssh-keygen -A @@ -54,11 +48,6 @@ systemctl poweroff sleep 100 # sleep here so that we don't see the login screen flash up before the shutdown. EOF - -# Install Rust -curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --component "rustfmt,clippy" - - # Install Mise curl https://mise.run | sh echo 'eval "$(~/.local/bin/mise activate bash)"' >> .bashrc diff --git a/src/vm.rs b/src/vm.rs index f31d9a3..5522136 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -795,12 +795,7 @@ where continue; } - match poll_with_wakeup( - libc::STDIN_FILENO, - wakeup_read.as_raw_fd(), - &mut buf, - -1, - ) { + match poll_with_wakeup(libc::STDIN_FILENO, wakeup_read.as_raw_fd(), &mut buf, -1) { PollResult::Shutdown | PollResult::Error => break, PollResult::Spurious => continue, PollResult::Ready(bytes) => { @@ -858,8 +853,7 @@ where wakeup_read.as_raw_fd(), &mut buf, 100, - ) - { + ) { PollResult::Shutdown | PollResult::Error => break, PollResult::Spurious => continue, PollResult::Ready(bytes) => {