From 5264e9866cd8d214f96e1e4cd4972ac9c6456add Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 16:35:01 +0000 Subject: [PATCH] feat: Implement aios core concept - start from container with claude MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented the 3 core requirements: 1. Auto-login as ai user (already done) 2. ai user automatically starts workspace container on login 3. Container root automatically starts claude with MCP Flow: aios boot → ai user auto-login → workspace starts → enter workspace as root → claude auto-starts Changes: - ai user .zshrc: auto-start workspace and exec into it - root .zshrc: auto-start claude with MCP - Moved user-continer.sh to after setup-claude.sh to include all configs --- build.zsh | 18 +++++++++--------- cfg/setup-claude.sh | 19 +++++++++++++++++++ cfg/setup-user.sh | 19 +++++++------------ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/build.zsh b/build.zsh index d555cd1..2442524 100755 --- a/build.zsh +++ b/build.zsh @@ -79,26 +79,26 @@ echo "✓ Arch Linux base complete" echo "" # ============================================ -# 2. Create child containers (before user setup) -# ============================================ - -bash ./cfg/user-continer.sh -echo "" - -# ============================================ -# 3. User Setup +# 2. User Setup # ============================================ bash ./cfg/setup-user.sh echo "" # ============================================ -# 4. Claude & aigpt Setup +# 3. Claude & aigpt Setup # ============================================ bash ./cfg/setup-claude.sh echo "" +# ============================================ +# 4. Create child containers (after all configuration) +# ============================================ + +bash ./cfg/user-continer.sh +echo "" + # ============================================ # Finalize # ============================================ diff --git a/cfg/setup-claude.sh b/cfg/setup-claude.sh index a0a2981..20c4367 100755 --- a/cfg/setup-claude.sh +++ b/cfg/setup-claude.sh @@ -45,4 +45,23 @@ 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' +# Add claude auto-start for root user (container concept) +echo "Configuring claude auto-start for root..." +cat >> $ROOTFS/root/.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 + +# Auto-start claude in interactive login shell +if [[ -o login ]] && [[ -o interactive ]]; then + if command -v claude &>/dev/null; then + claude + fi +fi +EOF + echo "✓ Claude MCP setup complete" diff --git a/cfg/setup-user.sh b/cfg/setup-user.sh index d2c0d7d..35c9397 100755 --- a/cfg/setup-user.sh +++ b/cfg/setup-user.sh @@ -46,21 +46,16 @@ cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc # Copy .zshrc for user 'ai' cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc -# Add MCP auto-setup and claude auto-start for ai user (login shell only) +# Add auto container login for ai user 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 - -# Auto-start claude in interactive login shell +# Auto-start workspace container and login (aios concept: start from container) if [[ -o login ]] && [[ -o interactive ]]; then - if command -v claude &>/dev/null; then - claude - fi + # Start workspace container + sudo machinectl start workspace 2>/dev/null || true + sleep 2 + # Enter workspace container as root + exec sudo machinectl shell workspace fi EOF