Merge pull request #8 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo

Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
This commit is contained in:
syui
2025-11-08 22:27:22 +09:00
committed by GitHub
4 changed files with 10 additions and 84 deletions

View File

@@ -65,7 +65,7 @@ cp -rf ./cfg/os-release root.x86_64/etc/os-release
# Configure sudoers for wheel group # Configure sudoers for wheel group
echo "Configuring sudoers..." echo "Configuring sudoers..."
arch-chroot root.x86_64 /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/pacstrap, /usr/bin/arch-chroot, /usr/bin/rm, /usr/bin/mkdir, /usr/bin/mv, /usr/bin/cp, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl, /bin/bash" >> /etc/sudoers' arch-chroot root.x86_64 /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/pacstrap, /usr/bin/arch-chroot, /usr/bin/rm, /usr/bin/mkdir, /usr/bin/mv, /usr/bin/cp, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl, /usr/bin/systemd-nspawn, /usr/bin/mount, /usr/bin/chroot, /bin/bash" >> /etc/sudoers'
# Install aigpt (aios core package) # Install aigpt (aios core package)
echo "Installing aigpt..." echo "Installing aigpt..."
@@ -86,14 +86,7 @@ bash ./cfg/setup-user.sh
echo "" echo ""
# ============================================ # ============================================
# 3. Claude & aigpt Setup # 3. Create workspace container (after all configuration)
# ============================================
bash ./cfg/setup-claude.sh
echo ""
# ============================================
# 4. Create child containers (after all configuration)
# ============================================ # ============================================
bash ./cfg/user-continer.sh bash ./cfg/user-continer.sh

View File

@@ -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"

View File

@@ -35,6 +35,7 @@ echo "Creating workspace container configuration..."
mkdir -p $ROOTFS/etc/systemd/nspawn mkdir -p $ROOTFS/etc/systemd/nspawn
cat > $ROOTFS/etc/systemd/nspawn/workspace.nspawn <<'EOF' cat > $ROOTFS/etc/systemd/nspawn/workspace.nspawn <<'EOF'
[Exec] [Exec]
Boot=yes
ResolvConf=copy-host ResolvConf=copy-host
[Files] [Files]
@@ -60,27 +61,13 @@ cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc
# Copy .zshrc for user 'ai' # Copy .zshrc for user 'ai'
cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc 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' cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
# MCP auto-setup (run once after .claude.json is created) # Start claude on login (once)
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)
if [[ -o login ]] && [[ -o interactive ]]; then if [[ -o login ]] && [[ -o interactive ]]; then
if [[ -z "$INSIDE_WORKSPACE" ]]; then if command -v claude &>/dev/null; then
# Running as ai user on aios OS - enter workspace container claude
export INSIDE_WORKSPACE=1
exec sudo machinectl shell workspace
else
# Running as root inside workspace container - start claude
if command -v claude &>/dev/null; then
claude
fi
fi fi
fi fi
EOF EOF

View File

@@ -1,10 +1,10 @@
#!/bin/bash #!/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 # Backup aios before creating /var/lib/machines to avoid recursion
ROOTFS="root.x86_64" ROOTFS="root.x86_64"
echo "=== Creating child containers ===" echo "=== Creating workspace container ==="
# Backup current aios to temp location (before creating /var/lib/machines) # Backup current aios to temp location (before creating /var/lib/machines)
echo "Backing up aios..." echo "Backing up aios..."
@@ -17,11 +17,7 @@ mkdir -p $ROOTFS/var/lib/machines
echo "Creating workspace container..." echo "Creating workspace container..."
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace 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 # Cleanup temp backup
rm -rf /tmp/aios-backup-$$ rm -rf /tmp/aios-backup-$$
echo "✓ Child containers created" echo "✓ Workspace container created"