From 5d7f06282ed266f2ca949963cd0adad726221b34 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Nov 2025 13:04:28 +0000 Subject: [PATCH] refactor: Simplify startup - user manages containers and MCP Changes: - Delete cfg/setup-claude.sh (MCP setup now manual) - Remove restore container creation (user manages backups) - Remove workspace auto-entry from .zshrc - Remove MCP auto-registration - Change ai user .zshrc to run claude once on login (not exec) - User now manually starts containers and registers MCP as needed New flow: 1. ai user auto-login 2. claude starts once (not exec, returns to shell after exit) 3. User manually starts workspace container if needed 4. User manually registers MCP servers --- build.zsh | 9 +------- cfg/setup-claude.sh | 50 -------------------------------------------- cfg/setup-user.sh | 24 ++++----------------- cfg/user-continer.sh | 10 +++------ 4 files changed, 8 insertions(+), 85 deletions(-) delete mode 100755 cfg/setup-claude.sh diff --git a/build.zsh b/build.zsh index 29d8899..24f71f7 100755 --- a/build.zsh +++ b/build.zsh @@ -86,14 +86,7 @@ bash ./cfg/setup-user.sh echo "" # ============================================ -# 3. Claude & aigpt Setup -# ============================================ - -bash ./cfg/setup-claude.sh -echo "" - -# ============================================ -# 4. Create child containers (after all configuration) +# 3. Create workspace container (after all configuration) # ============================================ bash ./cfg/user-continer.sh diff --git a/cfg/setup-claude.sh b/cfg/setup-claude.sh deleted file mode 100755 index e6ae470..0000000 --- a/cfg/setup-claude.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# Claude Code MCP setup for aios -# Configures MCP, sets up shared memory - -ROOTFS="root.x86_64" - -echo "=== Claude MCP Setup ===" - -# Setup Claude Code MCP configuration (shared via symlink) -echo "Configuring MCP..." -# Create actual config in syui/ai/claude (bind-mounted) -arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude' -cat > $ROOTFS/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF' -{ - "mcpServers": { - "aigpt": { - "command": "aigpt", - "args": ["server", "--enable-layer4"] - } - } -} -EOF - -# Create symlink for root -arch-chroot $ROOTFS /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude' - -# Setup for ai user too -arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude' -arch-chroot $ROOTFS /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/' -arch-chroot $ROOTFS /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude' -arch-chroot $ROOTFS /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui' - -# Create config directory -arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt' - -# Copy MCP and aios configuration -echo "Copying configuration files..." -cp -rf ./cfg/mcp.json $ROOTFS/root/.config/syui/ai/mcp.json -cp -rf ./cfg/config.toml $ROOTFS/root/.config/syui/ai/config.toml - -# Initialize aigpt database with WAL mode -echo "Initializing aigpt database..." -arch-chroot $ROOTFS /bin/sh -c 'aigpt server --enable-layer4 &' -sleep 2 -arch-chroot $ROOTFS /bin/sh -c 'pkill aigpt' -arch-chroot $ROOTFS /bin/sh -c 'if command -v sqlite3 &>/dev/null; then sqlite3 /root/.config/syui/ai/gpt/memory.db "PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL;"; fi' - -# Note: claude auto-start is configured in ai user's .zshrc (shared with workspace root via bind mount) - -echo "✓ Claude MCP setup complete" diff --git a/cfg/setup-user.sh b/cfg/setup-user.sh index bf386f2..68a7bcb 100755 --- a/cfg/setup-user.sh +++ b/cfg/setup-user.sh @@ -61,29 +61,13 @@ cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc # Copy .zshrc for user 'ai' cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc -# Add workspace container auto-start and entry (shared .zshrc for ai user and workspace root) +# Add claude auto-start on login (once, not exec) cat >> $ROOTFS/home/ai/.zshrc <<'EOF' -# MCP auto-setup (run once after .claude.json is created) -if [[ -f ~/.claude.json ]] && ! grep -q '"aigpt"' ~/.claude.json 2>/dev/null; then - if command -v claude &>/dev/null && command -v aigpt &>/dev/null; then - claude mcp add aigpt aigpt server &>/dev/null || true - fi -fi - -# aios concept: container from start (ai user and workspace root share this .zshrc) +# Start claude on login (once) if [[ -o login ]] && [[ -o interactive ]]; then - if [[ -z "$INSIDE_WORKSPACE" ]]; then - # Running as ai user on aios OS - enter workspace container - export INSIDE_WORKSPACE=1 - sudo machinectl start workspace 2>/dev/null || true - sleep 1 - exec sudo machinectl shell workspace - else - # Running as root inside workspace container - start claude - if command -v claude &>/dev/null; then - claude - fi + if command -v claude &>/dev/null; then + claude fi fi EOF diff --git a/cfg/user-continer.sh b/cfg/user-continer.sh index 8f12161..ff74bfc 100644 --- a/cfg/user-continer.sh +++ b/cfg/user-continer.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Create child containers inside aios for ai user +# Create workspace container inside aios for ai user # Backup aios before creating /var/lib/machines to avoid recursion ROOTFS="root.x86_64" -echo "=== Creating child containers ===" +echo "=== Creating workspace container ===" # Backup current aios to temp location (before creating /var/lib/machines) echo "Backing up aios..." @@ -17,11 +17,7 @@ mkdir -p $ROOTFS/var/lib/machines echo "Creating workspace container..." cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace -# Copy backup as restore -echo "Creating restore container..." -cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/restore - # Cleanup temp backup rm -rf /tmp/aios-backup-$$ -echo "✓ Child containers created" +echo "✓ Workspace container created"