Compare commits

..

35 Commits

Author SHA1 Message Date
66a95b912b fix
Some checks failed
build and push image / Release (push) Failing after 1m27s
2025-11-08 02:07:29 +09:00
syui
68817ba8de Merge pull request #4 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 02:07:02 +09:00
Claude
4352a7d0e3 fix: Correct OS structure - root.x86_64 is OS root, not machines/aios
Fixed the fundamental issue:
- root.x86_64/ = aios OS (entire filesystem)
- root.x86_64/var/lib/machines/ = child containers directory

Changes:
- build.zsh: Use root.x86_64 directly as OS root
- setup-user.sh: ROOTFS=root.x86_64
- setup-claude.sh: ROOTFS=root.x86_64
- user-continer.sh: ROOTFS=root.x86_64
- install.sh: mv root.x86_64 /var/lib/machines/aios

Now matches github-actions structure correctly.
2025-11-07 16:55:36 +00:00
Claude
b41052b9a8 feat: Implement user-dir sharing between ai user and workspace root
Perfect solution for aios concept:
- workspace.nspawn: Bind=/home/ai:/root
- ai user and workspace root share the SAME home directory
- Same .zshrc, .claude.json, .config, all data/settings/history
- INSIDE_WORKSPACE env var prevents infinite loop
- Flow: ai login → enter workspace → claude starts
- All configuration and memory perfectly shared
2025-11-07 16:45:12 +00:00
Claude
100471646e fix: Share claude config/memory between ai user and container
ai user now uses workspace container's claude via wrapper function.
This ensures ai user and container root share the same:
- claude configuration
- MCP settings
- conversation history/memory

Flow:
1. ai user login → workspace starts
2. ai user runs 'claude' → calls workspace container's claude
3. Container root runs 'claude' → same claude instance
4. Configuration and memory are shared
2025-11-07 16:40:54 +00:00
Claude
5264e9866c feat: Implement aios core concept - start from container with claude
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
2025-11-07 16:35:01 +00:00
Claude
1ca53c489c fix: Create child containers before user setup
Moved user-continer.sh execution before setup-user.sh.
Child containers are created by root for root to use, not for ai user.
2025-11-07 15:32:45 +00:00
Claude
d1c3ab94cb refactor: Remove unnecessary backup step in container creation
Simplified user-continer.sh by removing temp backup.
Directly copy aios to workspace and restore-img.
2025-11-07 15:30:17 +00:00
Claude
fd25a50395 refactor: Simplify child container creation by copying aios itself
Changed from building new containers to simply copying the aios base:
- Backup current aios to /tmp
- Copy backup as workspace
- Copy backup as restore-img
- Much faster and simpler than pacstrap
- Child containers have same config as parent aios
2025-11-07 15:25:01 +00:00
Claude
642ccb28a6 refactor: Create child containers during build as root, not at ai user login
- Renamed init-containers.sh to user-continer.sh
- Moved container creation from ai user first login to build.zsh
- Removed initialization check from ai user .zshrc
- Child containers (workspace, restore-img) now pre-created by root
- ai user simply uses pre-existing containers
2025-11-07 15:21:14 +00:00
syui
d575a489ce Merge pull request #3 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 00:15:24 +09:00
Claude
e2b0d7a51d refactor: Simplify install.sh and rename arch to aios throughout
- Simplified install.sh to just extract and mv
- Renamed root.x86_64/var/lib/machines/arch to aios
- Updated all references in build.zsh, setup-user.sh, setup-claude.sh
2025-11-07 15:00:01 +00:00
Claude
1aab33cb04 feat: Add automatic workspace container initialization on first login
- Created init-containers.sh to create workspace and restore-img
- Runs automatically on ai user's first login
- Uses ~/.aios-initialized flag to run once
- Updated sudoers to allow pacstrap, arch-chroot commands
2025-11-07 14:54:51 +00:00
Claude
cdf38812fc fix: Add securetty config and enable systemd-machined for container operations
- Added pts/0-9 to /etc/securetty for systemd-nspawn login
- Enabled systemd-machined for ai user to use machinectl
- Added arch-install-scripts package for pacstrap support inside aios
2025-11-07 14:50:03 +00:00
Claude
abdb399552 fix: Remove unused BACKUP variable from install.sh 2025-11-07 14:44:43 +00:00
Claude
49da9ec86a fix: Don't pre-create child containers - let ai user create them as needed
Changed to only prepare /var/lib/machines/ directory inside aios.
ai user will create child containers (workspace, restore-img, etc.) using machinectl as needed.
2025-11-07 14:41:36 +00:00
Claude
e88b241519 fix: Restructure containers - aios contains child containers internally
Changed from 3 separate containers to 1 container with child containers inside:
- /var/lib/machines/aios/ (main container)
  - /var/lib/machines/restore-img/ (child container)
  - /var/lib/machines/workspace/ (child container)

ai user operates child containers from within aios using machinectl.
2025-11-07 14:40:46 +00:00
Claude
a35a6bc870 feat: Auto-register aigpt MCP server on first login
Add automatic MCP registration in .zshrc that runs after .claude.json is created.
On second login, aigpt server will be automatically registered to Claude Code.
2025-11-07 14:28:58 +00:00
Claude
a447cb98f0 fix: Skip bootstrap_packages validation when not specified in mkarchiso 2025-11-07 13:26:59 +00:00
Claude
a833a60bac fix: Remove set -e from build.zsh to prevent early exit on errors 2025-11-07 13:25:43 +00:00
Claude
7b889fd5a2 revert: Remove bootstrap_packages configuration (not needed with custom mkarchiso) 2025-11-07 13:22:51 +00:00
Claude
87738e1e0b fix: Add bootstrap_packages.x86_64 configuration for mkarchiso 2025-11-07 13:19:33 +00:00
Claude
19337566a9 fix: Handle missing tarball in cleanup gracefully 2025-11-07 13:16:48 +00:00
Claude
fb31108cf7 feat: Add cleanup step to build.zsh before building 2025-11-07 13:15:36 +00:00
Claude
355c3dceb4 fix: Remove exec from claude auto-start to allow manual shell usage
Allow users to exit claude and continue using shell manually.
When claude exits, user returns to zsh instead of logging out.
2025-11-07 13:05:26 +00:00
Claude
511cf960d6 feat: Pre-create containers in build.zsh
Changed container creation from install-time to build-time:

Before:
- build.zsh: create only aios
- install.sh: machinectl clone aios → aiosback, workspace

After:
- build.zsh: create aios + aiosback + workspace (cp -a)
- install.sh: just extract and move to /var/lib/machines/

Benefits:
- Simpler install.sh (no machinectl clone operations)
- Faster installation (no clone overhead)
- All containers included in tarball
- Consistent initial state
2025-11-07 12:53:12 +00:00
Claude
506b93b5f4 refactor: Move core aios packages to build.zsh
Moved essential aios components to build.zsh (base layer):
- sudoers configuration (wheel group permissions)
- aigpt install (aios core package)
- aibot install (aios core package) - renamed from 'ai' to 'aibot'

Updated module responsibilities:
- build.zsh: Arch base + aios core packages (required)
- setup-user.sh: User customization only
- setup-claude.sh: Claude MCP configuration only

Benefits:
- Clear separation: base vs customization
- aigpt/aibot always included (core aios functionality)
- Modules can be optionally skipped for customization
2025-11-07 12:35:19 +00:00
Claude
d65b1242fe refactor: Modularize build.zsh into separate setup scripts
Separated build.zsh into 3 clear parts:

1. build.zsh (Arch Linux base construction)
   - archiso bootstrap
   - pacstrap base system
   - install base packages
   - install Claude Code

2. cfg/setup-user.sh (User setup)
   - Create ai user
   - Configure sudoers
   - Setup auto-login
   - Configure zshrc and auto-start

3. cfg/setup-claude.sh (Claude/aigpt setup)
   - Install aigpt
   - Configure MCP
   - Setup symlinks
   - Initialize database

Benefits:
- Each file has a single, clear responsibility
- Easier to maintain and modify
- Can skip/customize setup steps if needed
- GitHub Actions simplified to just run build.zsh
2025-11-07 12:25:51 +00:00
Claude
7abf48a8fd feat: Add auto-start claude for ai user in login shell
- Add claude auto-start to ai user's .zshrc
- Only triggers in interactive login shell
- Uses exec to replace shell process with claude
- Enables seamless AI-first experience

Usage: machinectl shell workspace /bin/su - ai
→ Auto-login + Auto-start claude
2025-11-07 12:17:19 +00:00
Claude
4caa0bbbc6 fix: Improve force removal of existing images in install.sh
- Increase sleep time to 2 seconds
- Add SIGKILL as last resort
- Continue with warning if removal fails
2025-11-07 11:47:12 +00:00
syui
a66d080a30 Merge pull request #2 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-07 20:45:46 +09:00
Claude
5f4384d812 feat: Remove existing images before cloning in install.sh
- Check if aiosback and workspace already exist
- Stop, terminate, and remove existing images before clone
- Prevents 'File exists' error on re-installation
2025-11-07 11:29:55 +00:00
Claude
74f6eea1a3 fix: Uncomment install.sh in .gitignore 2025-11-07 11:27:35 +00:00
Claude
ea207bedd5 Merge remote-tracking branch 'origin/main' into claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo 2025-11-07 11:26:27 +00:00
Claude
4cbc1562f5 chore: Remove outdated aios-install.sh 2025-11-07 11:25:35 +00:00
8 changed files with 298 additions and 280 deletions

View File

@@ -2,8 +2,8 @@ name: release
on:
push:
tags:
- 'v*'
branches:
- main
permissions:
contents: write
@@ -24,84 +24,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize
run: |
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
git clone https://gitlab.archlinux.org/archlinux/archiso
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
tar xf aios-bootstrap*.tar.gz
mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/var/lib/machines/arch/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/var/lib/machines/arch/etc/pacman.conf
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "ai:root" | chpasswd'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm, /usr/bin/rm -rf /var/lib/pacman/db.lck, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl" >> /etc/sudoers'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
cat > root.x86_64/var/lib/machines/arch/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
EOF
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/home/ai/.zshrc
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
cp -rf ./cfg/aios.zsh root.x86_64/var/lib/machines/arch/usr/local/bin/aios-startup
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
cat > root.x86_64/var/lib/machines/arch/home/ai/.config/syui/ai/os/config.json <<'EOF'
{
"shell": false
}
EOF
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config'
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
# aios startup
source /usr/local/bin/aios-startup
EOF
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude'
cat > root.x86_64/var/lib/machines/arch/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF'
{
"mcpServers": {
"aigpt": {
"command": "aigpt",
"args": ["server", "--enable-layer4"]
}
}
}
EOF
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt'
cp -rf ./cfg/mcp.json root.x86_64/var/lib/machines/arch/root/.config/syui/ai/mcp.json
cp -rf ./cfg/config.toml root.x86_64/var/lib/machines/arch/root/.config/syui/ai/config.toml
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'aigpt server --enable-layer4 &'
sleep 2
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pkill aigpt'
arch-chroot root.x86_64/var/lib/machines/arch /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'
cp -rf ./cfg/aios-ctl.zsh root.x86_64/var/lib/machines/arch/opt/aios-ctl.zsh
cp -rf ./cfg/install.sh ./install.sh
chmod +x ./install.sh
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh
- name: Build aios
run: bash ./build.zsh
- name: Create Docker images
run: |
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
docker push ${{ env.IMAGE_NAME }}

175
build.zsh
View File

@@ -1,119 +1,122 @@
#!/bin/zsh
# aios build script
# 1. Build minimal Arch Linux base
# 2. Setup user (ai) and shell
# 3. Setup Claude Code and aigpt
echo "=== aios build ==="
echo ""
# Clean up previous build artifacts
echo "Cleaning up previous build..."
rm -rf root.x86_64/ archiso/ install.sh
rm -f aios-bootstrap*.tar.gz 2>/dev/null || true
# ============================================
# 1. Arch Linux Base Construction
# ============================================
echo "=== Step 1: Arch Linux Base ==="
# Install build dependencies
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
# Clone archiso
git clone https://gitlab.archlinux.org/archlinux/archiso
# Copy configuration
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
# Build bootstrap
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
# Extract and prepare
tar xf aios-bootstrap*.tar.gz
mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
mkdir -p root.x86_64
pacstrap -c root.x86_64 base
# Configure pacman
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/var/lib/machines/arch/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/var/lib/machines/arch/etc/pacman.conf
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chsh -s /bin/zsh'
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
# Initialize pacman keys
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
# Install base packages (including systemd-container for machinectl)
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs npm docker podman bc sqlite systemd arch-install-scripts'
# Configure containers
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
# Set default shell
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
# Install Claude Code
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
arch-chroot root.x86_64 /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
# Copy os-release
cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release
cp -rf ./cfg/os-release root.x86_64/etc/os-release
# Create default user 'ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "ai:root" | chpasswd'
# Configure sudoers for wheel group
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'
# Enable wheel group for sudo (specific commands without password)
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm, /usr/bin/rm -rf /var/lib/pacman/db.lck, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/machinectl" >> /etc/sudoers'
# Install aigpt (aios core package)
echo "Installing aigpt..."
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
# Setup auto-login for user 'ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
cat > root.x86_64/var/lib/machines/arch/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
EOF
# Install aibot (aios core package)
echo "Installing aibot..."
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/aibot /bin/ && aibot ai'
# Copy .zshrc for root
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
echo "✓ Arch Linux base complete"
echo ""
# Copy .zshrc for user 'ai'
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/home/ai/.zshrc
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
# ============================================
# 2. User Setup
# ============================================
# Copy aios startup script
cp -rf ./cfg/aios.zsh root.x86_64/var/lib/machines/arch/usr/local/bin/aios-startup
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
bash ./cfg/setup-user.sh
echo ""
# Create default config directory and file for user 'ai'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
cat > root.x86_64/var/lib/machines/arch/home/ai/.config/syui/ai/os/config.json <<'EOF'
{
"shell": false
}
EOF
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config'
# ============================================
# 3. Claude & aigpt Setup
# ============================================
# Update .zshrc to source startup script
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
bash ./cfg/setup-claude.sh
echo ""
# aios startup
source /usr/local/bin/aios-startup
EOF
# ============================================
# 4. Create child containers (after all configuration)
# ============================================
# Install aigpt (AI memory system)
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/gpt && cd gpt && cargo build --release && cp -rf ./target/release/aigpt /bin/'
bash ./cfg/user-continer.sh
echo ""
# Setup Claude Code MCP configuration (shared via symlink)
# Create actual config in syui/ai/claude (bind-mounted)
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/claude'
cat > root.x86_64/var/lib/machines/arch/root/.config/syui/ai/claude/claude_desktop_config.json <<'EOF'
{
"mcpServers": {
"aigpt": {
"command": "aigpt",
"args": ["server", "--enable-layer4"]
}
}
}
EOF
# ============================================
# Finalize
# ============================================
# Create symlink for root
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /root/.config/syui/ai/claude /root/.config/claude'
# Setup for ai user too
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/claude'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'cp /root/.config/syui/ai/claude/claude_desktop_config.json /home/ai/.config/syui/ai/claude/'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'ln -sf /home/ai/.config/syui/ai/claude /home/ai/.config/claude'
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'chown -R ai:ai /home/ai/.config/syui'
# Install ai/bot (optional, for backward compatibility)
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
# Create config directory
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt'
# Copy MCP and aios configuration
cp -rf ./cfg/mcp.json root.x86_64/var/lib/machines/arch/root/.config/syui/ai/mcp.json
cp -rf ./cfg/config.toml root.x86_64/var/lib/machines/arch/root/.config/syui/ai/config.toml
# Initialize aigpt database with WAL mode
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'aigpt server --enable-layer4 &'
sleep 2
arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'pkill aigpt'
arch-chroot root.x86_64/var/lib/machines/arch /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'
echo "=== Finalizing ==="
# Copy aios-ctl.zsh for host machine control
cp -rf ./cfg/aios-ctl.zsh root.x86_64/var/lib/machines/arch/opt/aios-ctl.zsh
cp -rf ./cfg/aios-ctl.zsh root.x86_64/opt/aios-ctl.zsh
# Copy install script to root for easy access
# Copy install script
cp -rf ./cfg/install.sh ./install.sh
chmod +x ./install.sh
# Create tarball with aios (includes child containers)
echo "Creating tarball..."
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh
echo ""
echo "=== Build Complete ==="
echo "Output: aios-bootstrap.tar.gz"
echo ""

View File

@@ -21,9 +21,9 @@ function aios-shell() {
sudo machinectl shell $NAME
}
# Login to aios container
# Login to aios container as ai user
function aios-login() {
sudo machinectl login $NAME
sudo machinectl shell $NAME /bin/su - ai
}
# Create backup of current aios

View File

@@ -1,118 +1,19 @@
#!/bin/bash
# aios installation script
set -e
NAME="aios"
BACKUP="${NAME}back"
TARBALL="aios-bootstrap.tar.gz"
echo "=== aios installation ==="
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run as root"
exit 1
fi
# Check if tarball exists
if [ ! -f "$TARBALL" ]; then
echo "Error: $TARBALL not found"
echo "Please download aios-bootstrap.tar.gz first"
exit 1
fi
# Extract tarball
echo "1. Extracting $TARBALL..."
# Extract and install
tar xf "$TARBALL"
# Move to /var/lib/machines/
echo "2. Installing to /var/lib/machines/$NAME..."
rm -rf /var/lib/machines/$NAME
mkdir -p /var/lib/machines
mv root.x86_64/var/lib/machines/arch /var/lib/machines/$NAME
mv root.x86_64 /var/lib/machines/$NAME
# Copy nspawn configuration
echo "3. Installing systemd-nspawn configuration..."
mkdir -p /etc/systemd/nspawn
# Create aios.nspawn
cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF'
[Exec]
Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
Bind=/root/.config/syui/ai:/root/.config/syui/ai
[Network]
VirtualEthernet=no
EOF
# Create aiosback.nspawn
cat > /etc/systemd/nspawn/$BACKUP.nspawn <<'EOF'
[Exec]
Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
Bind=/root/.config/syui/ai:/root/.config/syui/ai
[Network]
VirtualEthernet=no
EOF
# Create workspace.nspawn
cat > /etc/systemd/nspawn/workspace.nspawn <<'EOF'
[Exec]
Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
Bind=/root/.config/syui/ai:/root/.config/syui/ai
[Network]
VirtualEthernet=no
EOF
# Create bind mount directory
mkdir -p /root/.config/syui/ai
# Enable systemd-machined
echo "4. Enabling systemd-machined..."
systemctl enable --now systemd-machined
# Create initial backup
echo "5. Creating initial backup image..."
machinectl clone $NAME $BACKUP
# Create workspace container for AI operations
echo "6. Creating workspace container..."
machinectl clone $NAME workspace
echo ""
echo "=== Installation complete ==="
echo ""
echo "Next steps for each user:"
echo " 1. Copy control script to your home:"
echo " cp /var/lib/machines/$NAME/opt/aios-ctl.zsh ~/.aios-ctl.zsh"
echo ""
echo " 2. Add to your .zshrc:"
echo " echo 'source ~/.aios-ctl.zsh' >> ~/.zshrc"
echo " source ~/.zshrc"
echo ""
echo " 3. Start aios:"
echo " aios-start"
echo ""
echo " 4. Login to aios:"
echo " aios-login"
echo ""
echo "Available commands:"
echo " aios-start, aios-stop, aios-shell, aios-login"
echo " aios-backup, aios-reset, aios-update"
echo " aios-help for full list"
echo "Usage:"
echo " sudo machinectl start $NAME"
echo " sudo machinectl shell $NAME /bin/su - ai"
echo ""

50
cfg/setup-claude.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/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"

114
cfg/setup-user.sh Executable file
View File

@@ -0,0 +1,114 @@
#!/bin/bash
# User setup for aios
# Creates ai user, configures auto-login, sudo, zshrc
ROOTFS="root.x86_64"
echo "=== User Setup ==="
# Create default user 'ai'
echo "Creating user 'ai'..."
arch-chroot $ROOTFS /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
arch-chroot $ROOTFS /bin/sh -c 'echo "ai:root" | chpasswd'
# Configure securetty for pts login (required for systemd-nspawn)
echo "Configuring securetty..."
cat >> $ROOTFS/etc/securetty <<'EOF'
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
EOF
# Enable systemd-machined for container management
echo "Enabling systemd-machined..."
arch-chroot $ROOTFS /bin/sh -c 'systemctl enable systemd-machined'
# Create workspace container configuration (bind ai user dir to container root)
echo "Creating workspace container configuration..."
mkdir -p $ROOTFS/etc/systemd/nspawn
cat > $ROOTFS/etc/systemd/nspawn/workspace.nspawn <<'EOF'
[Exec]
Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
Bind=/home/ai:/root
[Network]
VirtualEthernet=no
EOF
# Setup auto-login for user 'ai'
echo "Setting up auto-login..."
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
cat > $ROOTFS/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
EOF
# Copy .zshrc for root
echo "Copying zshrc..."
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)
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)
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
fi
fi
EOF
arch-chroot $ROOTFS /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
# Copy aios startup script
cp -rf ./cfg/aios.zsh $ROOTFS/usr/local/bin/aios-startup
arch-chroot $ROOTFS /bin/sh -c 'chmod +x /usr/local/bin/aios-startup'
# Create default config directory and file for user 'ai'
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /home/ai/.config/syui/ai/os'
cat > $ROOTFS/home/ai/.config/syui/ai/os/config.json <<'EOF'
{
"shell": false
}
EOF
arch-chroot $ROOTFS /bin/sh -c 'chown -R ai:ai /home/ai/.config'
# Update .zshrc to source startup script
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
# aios startup
source /usr/local/bin/aios-startup
EOF
echo "✓ User setup complete"

20
cfg/user-continer.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Create child containers inside aios for ai user
# Simply copy the aios itself as child containers
ROOTFS="root.x86_64"
echo "=== Creating child containers ==="
# Create directory for child containers
mkdir -p $ROOTFS/var/lib/machines
# Copy aios as workspace
echo "Creating workspace container..."
cp -a $ROOTFS $ROOTFS/var/lib/machines/workspace
# Copy aios as restore-img
echo "Creating restore-img container..."
cp -a $ROOTFS $ROOTFS/var/lib/machines/restore-img
echo "✓ Child containers created"

View File

@@ -1335,6 +1335,7 @@ _validate_requirements_buildmode_bootstrap() {
local bootstrap_pkg_list_from_file=()
# Check if packages for the bootstrap image are specified
if [[ -n "${bootstrap_packages}" ]]; then
if [[ -e "${bootstrap_packages}" ]]; then
mapfile -t bootstrap_pkg_list_from_file < \
<(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}")
@@ -1347,6 +1348,7 @@ _validate_requirements_buildmode_bootstrap() {
(( validation_error=validation_error+1 ))
_msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
fi
fi
_validate_common_requirements_buildmode_all
if ! command -v bsdtar &>/dev/null; then