# ClaudeVM [doesnt work yet]

A command-line tool for macOS that opens the current directory in a virtual machine with copy-on-write file access.

## Features

- Creates a lightweight macOS VM using Apple's Virtualization framework
- Mounts the current directory with copy-on-write access
- Changes to files in the VM don't affect the host system
- Provides access to host system programs while keeping files isolated
- Manages VM lifecycle (start, stop, installation)
- Supports automatic macOS installation from Apple's restore images

## What Is ClaudeVM?

ClaudeVM is a developer tool that creates a safe sandbox environment on macOS by:

1. Opening a directory in a macOS virtual machine
2. Setting up copy-on-write file access so changes in the VM don't affect the host
3. Allowing you to use host system programs while keeping files isolated
4. Providing a lightweight solution that shares resources with the host

This gives developers a safe environment to experiment with code, test potentially risky operations, or isolate development work.

## Requirements

- macOS 13 or later
- Apple Silicon Mac
- Swift 5.8 or later

## Installation

```bash
# Clone the repository
git clone https://github.com/yourusername/claudevm.git
cd claudevm

# The script will build automatically on first run
chmod +x claudevm

# Run the tool
./claudevm
```

## Usage

```bash
# Open current directory in VM
./claudevm

# Open specific directory in VM
./claudevm /path/to/directory

# Configure VM resources
./claudevm --memory 8 --cpu-count 4

# Install macOS in the VM (requires sudo)
sudo ./claudevm --install

# Force recreation of VM resources
./claudevm --force

# Show verbose output
./claudevm --verbose
```

## Accessing Shared Directory in VM

Once the VM is running, you can access the shared directory by:

1. Opening Terminal in the VM
2. Creating a mount point: `mkdir -p ~/shared`
3. Mounting the shared directory: `mount -t virtiofs claudevm-shared ~/shared`
4. Your shared directory is now available at `~/shared`

All changes made to files in this directory inside the VM will not affect the original files on your host system.

## How It Works

ClaudeVM uses Apple's Virtualization framework to:

1. Create a macOS virtual machine with the same version as your host
2. Set up directory sharing with VirtioFS for efficient file access
3. Configure the shared directory with copy-on-write functionality
4. Manage the VM lifecycle including installation and graceful shutdown
5. Provide console and graphical access to the VM

## Technical Implementation

The tool leverages several key technologies:

- `VZVirtualMachine` for VM creation and management
- `VZVirtioFileSystemDeviceConfiguration` for directory sharing
- `VZMacOSRestoreImage` for macOS installation
- `VZSharedDirectory` with read-write access for copy-on-write functionality
- Swift Argument Parser for command-line interface
- Signal handling for graceful VM shutdown

## Contributing

Contributions are welcome! To contribute:

1. Fork the repository
2. Make your changes
3. Submit a pull request

## License

MIT
