Merge pull request #1 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Some checks failed
build and push image / Release (push) Failing after 1m24s

Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
This commit is contained in:
syui
2025-11-07 16:14:43 +09:00
committed by GitHub
14 changed files with 891 additions and 102 deletions

View File

@@ -37,16 +37,71 @@ jobs:
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/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman bc'
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'
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
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
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 }}

7
.gitignore vendored
View File

@@ -1,2 +1,9 @@
.config/ai
**.DS_Store
# Build artifacts
aios-bootstrap*.tar.gz
root.x86_64/
archiso/
install.sh
build.log

226
README.md
View File

@@ -1,110 +1,188 @@
# <img src="./icon/ai.png" width="30"> ai `os`
# <img src="./icon/ai.png" width="30"> ai `os`
`aios` is a simple linux distribution based on `archlinux`.
**aios** = ArchLinux + Claude Code + aigpt in systemd-nspawn
|rule|var|
|---|---|
|name|ai os|
|code|aios|
|id|ai|
|container|[git.syui.ai/ai/os](https://git.syui.ai/ai/-/packages/container/os/latest)|
|image|[aios-bootstrap.tar.gz](https://github.com/syui/aios/releases/download/latest/aios-bootstrap.tar.gz)|
A minimal ArchLinux environment optimized for Claude Code with shared AI memory.
```sh
$ docker run -it git.syui.ai/ai/os ai
```
systemd-nspawn container
├── Claude Code (AI interface)
├── aigpt (shared memory)
└── zsh (.zshrc configured)
$ sudo machinectl shell aios
$ claude # Start Claude Code
```
## link
## Philosophy
|host|command|url|
|---|---|---|
|docker|syui/aios|https://hub.docker.com/r/syui/aios|
|github|ghcr.io/syui/aios|https://github.com/users/syui/packages/container/package/aios|
|syui|git.syui.ai/ai/os|https://git.syui.ai/ai/-/packages/container/os|
**Insert AI into existing flows**
## base
Instead of building a new AI chat interface, use **Claude Code** (which already works).
aios provides:
1. Pre-installed **aigpt** (MCP server for shared memory)
2. Pre-installed **Claude Code** (`npm i -g @anthropic-ai/claude-code`)
3. Environment isolation with **systemd-nspawn**
4. Shared memory across containers
## What's Included
### 1. Claude Code
Pre-installed and ready to use:
```sh
# https://gitlab.archlinux.org/archlinux
$ git clone https://gitlab.archlinux.org/archlinux/archiso
$ claude
# Claude Code starts, with MCP connection to aigpt
> Install rust development environment
✓ Installing rust, rust-analyzer, neovim
```
## docker
### 2. aigpt (Shared Memory)
MCP server that provides persistent memory to Claude Code:
```
~/.config/syui/ai/gpt/memory.db (SQLite, WAL mode)
↓ bind mount
aios-dev, aios-prod, etc. (all share same DB)
```
AI remembers your preferences across all containers.
### 3. systemd-nspawn
Lightweight container environment:
```sh
# https://git.syui.ai/ai/-/packages/container/os
$ docker run -it git.syui.ai/ai/os ai
# https://hub.docker.com/r/syui/aios
$ docekr run -it syui/aios ai
# https://github.com/users/syui/packages/container/package/aios
$ docker run -it ghcr.io/syui/aios ai
$ sudo machinectl shell aios
# Inside container with aigpt + Claude Code
```
## token
Multiple containers can share the same memory.
|env|body|
|---|---|
|${{ github.repository }}|syui/aios|
|${{ secrets.DOCKER_USERNAME }}|syui|
|${{ secrets.DOCKER_TOKEN }}|[token](https://matsuand.github.io/docs.docker.jp.onthefly/docker-hub/access-tokens/)|
|${{ secrets.APP_TOKEN }}|[token](https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), pacakge|
## Architecture
## podman
```
Host
├── ~/.config/syui/ai/gpt/memory.db (shared)
└── /var/lib/machines/aios/ (container)
├── ArchLinux base
├── aigpt (MCP server)
├── Claude Code
├── .zshrc (aliases: ai=claude)
└── Bind mount → shared memory
```
## Quick Start
```sh
if [ ! -d ~/ai/os/.git ];then
mkdir -p ~/ai
git clone https://git.syui.ai/ai/os ~/ai/os
fi
if [ ! -d ~/.config/containers/registries.conf.d ];then
mkdir -p ~/.config/containers/registries.conf.d
fi
ln -s ~/ai/os/.config/containers/registries.conf.d/ai.conf ~/.config/containers/registries.conf.d/ai.conf
# 1. Clone repository
$ git clone https://github.com/syui/aios
$ cd aios
# 2. Run installer (creates systemd-nspawn container)
$ sudo ./aios-install.sh
# 3. Enter container
$ sudo machinectl shell aios
# 4. Start Claude Code
$ claude
# or
$ ai
```
## Container Distribution
Pre-built containers are available:
```sh
$ podman pull aios
# Docker
$ docker run -it git.syui.ai/ai/os
$ docker run -it ghcr.io/syui/aios
# Podman
$ podman pull aios # using shortname alias
```
> ~/.config/containers/registries.conf.d/ai.conf
## Configuration
### Directory Structure
```
~/.config/syui/ai/
├── gpt/memory.db # Shared memory (SQLite WAL)
├── mcp.json # MCP server config
└── config.toml # aios config
```
### MCP Configuration
Claude Code connects to aigpt via MCP:
```json
{
"mcpServers": {
"aigpt": {
"command": "aigpt",
"args": ["server", "--enable-layer4"]
}
}
}
```
This enables Claude Code to use aigpt's memory system.
## Building from Source
```sh
# https://github.com/containers/shortnames
# ~/.config/containers/registries.conf.d/ai.conf
unqualified-search-registries = ['git.syui.ai', 'docker.io', 'ghcr.io']
[aliases]
"aios" = "git.syui.ai/ai/os"
$ pacman -S base-devel archiso docker git rust nodejs npm
$ ./build.zsh
# Creates: aios-bootstrap.tar.gz
```
```sh
$ podman pull aios
Resolved "aios" as an alias (/etc/containers/registries.conf.d/ai.conf)
Trying to pull git.syui.ai/ai/os:latest...
Getting image source signatures
Copying blob c7e55fecf0be [====================>-----------------] 917.4MiB / 1.7GiB
```
## How It Works
## cron
1. **systemd-nspawn** provides lightweight containers
2. **aigpt** runs as MCP server, stores memories in SQLite
3. **Claude Code** connects to aigpt via MCP
4. Shared memory (`~/.config/syui/ai/gpt/memory.db`) is bind-mounted
stop
**Result:** Claude Code can remember your preferences across all containers.
```sh
schedule:
- cron: "0 0 * * *"
```
## Why Not Just Use Claude Code?
## update action
You can! aios just provides:
- Pre-configured environment
- Shared memory (aigpt) pre-installed
- Container isolation
- Easy multi-environment setup
```sh
$ vim build.zszh
$ ./scpt/gh-actions.zsh
```
## Links
## link
- Repository: https://github.com/syui/aios
- Git: https://git.syui.ai/ai/os
- aigpt: https://git.syui.ai/ai/gpt
- Container: https://git.syui.ai/ai/-/packages/container/os
- https://git.syui.ai/ai/os
- https://github.com/syui/aios
## Philosophy
**Insert AI into existing flows**
Don't build a new AI chat interface. Use Claude Code (which already works).
Don't create a new container system. Use systemd-nspawn (lightweight, standard).
Just provide:
1. aigpt for shared memory
2. Pre-configured environment
3. Automation scripts
Simple. Minimal. Effective.
---
© syui

134
aios-install.sh Executable file
View File

@@ -0,0 +1,134 @@
#!/bin/bash
# aios installer - systemd-nspawn with aigpt + Claude Code
set -e
AIOS_VERSION="0.1.0"
AIOS_ROOT="/var/lib/machines/aios"
AIOS_CONFIG="$HOME/.config/syui/ai"
echo "=== aios installer v${AIOS_VERSION} ==="
echo ""
echo "Installing: aigpt + Claude Code in systemd-nspawn"
echo ""
# 1. Create shared memory directory
echo "[1/6] Creating shared memory directory..."
mkdir -p "${AIOS_CONFIG}/gpt"
chmod 700 "${AIOS_CONFIG}"
echo "✓ Created: ${AIOS_CONFIG}"
# 2. Download bootstrap container (if not exists)
if [ ! -d "$AIOS_ROOT" ]; then
echo "[2/6] Downloading aios bootstrap container..."
if [ "$EUID" -eq 0 ]; then
mkdir -p /var/lib/machines
cd /var/lib/machines
curl -sL https://github.com/syui/aios/releases/download/latest/aios-bootstrap.tar.gz | tar xz
echo "✓ Bootstrap container extracted to: $AIOS_ROOT"
else
echo "⚠ Skipping (requires root)"
fi
else
echo "[2/6] Bootstrap container already exists"
fi
# 3. Install aigpt (if not installed)
if ! command -v aigpt &>/dev/null; then
echo "[3/6] Installing aigpt..."
if command -v cargo &>/dev/null; then
cd /tmp
git clone https://git.syui.ai/ai/gpt || git clone https://github.com/syui/aigpt
cd gpt 2>/dev/null || cd aigpt
cargo build --release
if [ "$EUID" -eq 0 ]; then
cp target/release/aigpt /usr/bin/
else
mkdir -p ~/.local/bin
cp target/release/aigpt ~/.local/bin/
echo " Add to PATH: export PATH=\$HOME/.local/bin:\$PATH"
fi
echo "✓ aigpt installed"
else
echo "⚠ cargo not found. Install rust first:"
echo " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
fi
else
echo "[3/6] aigpt already installed"
fi
# 4. Initialize aigpt database
if [ ! -f "${AIOS_CONFIG}/gpt/memory.db" ]; then
echo "[4/6] Initializing aigpt database..."
# Start aigpt server temporarily to create DB
if command -v aigpt &>/dev/null; then
aigpt server --enable-layer4 &
AIGPT_PID=$!
sleep 2
kill $AIGPT_PID 2>/dev/null || true
# Enable WAL mode for concurrent access
if command -v sqlite3 &>/dev/null; then
sqlite3 "${AIOS_CONFIG}/gpt/memory.db" <<EOF
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
PRAGMA cache_size=-64000;
EOF
echo "✓ Database initialized with WAL mode"
else
echo "⚠ sqlite3 not found, skipping WAL mode setup"
fi
else
echo "⚠ aigpt not available, skipping database init"
fi
else
echo "[4/6] Database already exists"
fi
# 5. Install MCP configuration
echo "[5/6] Installing MCP configuration..."
cp cfg/mcp.json "${AIOS_CONFIG}/mcp.json"
cp cfg/config.toml "${AIOS_CONFIG}/config.toml"
echo "✓ Configuration files installed"
# 6. Install systemd-nspawn configuration
if [ "$EUID" -eq 0 ]; then
echo "[6/6] Installing systemd-nspawn configuration..."
mkdir -p /etc/systemd/nspawn
# Replace %h with actual home directory
sed "s|%h|$HOME|g" cfg/nspawn/aios.nspawn > /etc/systemd/nspawn/aios.nspawn
echo "✓ systemd-nspawn configuration installed"
# Enable and start container
echo ""
echo "Starting aios container..."
systemctl enable systemd-nspawn@aios
systemctl start systemd-nspawn@aios
echo "✓ aios container started"
else
echo "[6/6] Skipping systemd setup (requires root)"
fi
echo ""
echo "================================================"
echo "✓ aios installation complete!"
echo "================================================"
echo ""
echo "Next steps:"
echo ""
echo " # Enter aios container:"
echo " $ sudo machinectl shell aios"
echo ""
echo " # Inside container, start Claude Code:"
echo " $ claude"
echo " # or"
echo " $ ai"
echo ""
echo "Configuration:"
echo " Shared memory: ${AIOS_CONFIG}/gpt/memory.db"
echo " MCP config: ${AIOS_CONFIG}/mcp.json"
echo ""

117
build.zsh
View File

@@ -10,13 +10,110 @@ 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/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman bc'
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'
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
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'
# Install Claude Code
arch-chroot root.x86_64/var/lib/machines/arch /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
# 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'
# 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'
# 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
# Copy .zshrc for root
cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc
# 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'
# 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'
# 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'
# Update .zshrc to source startup script
cat >> root.x86_64/var/lib/machines/arch/home/ai/.zshrc <<'EOF'
# aios startup
source /usr/local/bin/aios-startup
EOF
# 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/'
# 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
# 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'
# 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
# Copy install script to root for easy access
cp -rf ./cfg/install.sh ./install.sh
chmod +x ./install.sh
tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh

132
cfg/aios-ctl.zsh Normal file
View File

@@ -0,0 +1,132 @@
#!/bin/zsh
# aios machine control commands
NAME="aios"
BACKUP="${NAME}back"
# Start aios container
function aios-start() {
sudo machinectl start $NAME
}
# Stop aios container
function aios-stop() {
sudo machinectl poweroff $NAME > /dev/null 2>&1
sleep 2
sudo machinectl terminate $NAME > /dev/null 2>&1
}
# Shell into aios container
function aios-shell() {
sudo machinectl shell $NAME
}
# Login to aios container
function aios-login() {
sudo machinectl login $NAME
}
# Create backup of current aios
function aios-backup() {
echo "Creating backup: $BACKUP"
sudo machinectl poweroff $BACKUP > /dev/null 2>&1
sleep 2
sudo machinectl terminate $BACKUP > /dev/null 2>&1
sleep 2
sudo machinectl remove $BACKUP > /dev/null 2>&1
sleep 2
sudo machinectl clone $NAME $BACKUP
echo "Backup created: $BACKUP"
}
# Reset aios from backup
function aios-reset() {
if ! sudo machinectl list-images | grep -q $BACKUP; then
echo "Error: No backup found. Run 'aios-backup' first."
return 1
fi
echo "Resetting $NAME from $BACKUP..."
sudo machinectl poweroff $NAME > /dev/null 2>&1
sleep 2
sudo machinectl terminate $NAME > /dev/null 2>&1
sleep 2
sudo machinectl remove $NAME
sleep 2
sudo machinectl clone $BACKUP $NAME
sleep 2
sudo machinectl start $NAME
echo "Reset complete"
}
# Update packages in backup
function aios-update() {
if ! sudo machinectl list-images | grep -q $BACKUP; then
echo "Error: No backup found. Run 'aios-backup' first."
return 1
fi
echo "Updating $BACKUP..."
sudo machinectl start $BACKUP
sleep 5
sudo machinectl shell $BACKUP /bin/sh -c 'pacman -Syu --noconfirm'
sleep 2
sudo machinectl poweroff $BACKUP
echo "Update complete"
}
# Remove aios container
function aios-remove() {
echo "Removing $NAME..."
sudo machinectl poweroff $NAME > /dev/null 2>&1
sleep 2
sudo machinectl terminate $NAME > /dev/null 2>&1
sleep 2
sudo machinectl remove $NAME
echo "Removed $NAME"
}
# List all machines
function aios-list() {
sudo machinectl list-images
}
# Show status
function aios-status() {
sudo machinectl status $NAME
}
# Execute command in aios
function aios-exec() {
if [ -z "$1" ]; then
echo "Usage: aios-exec <command>"
return 1
fi
sudo machinectl shell $NAME /bin/sh -c "$*"
}
# Show help
function aios-help() {
cat <<'EOF'
aios machine control commands:
aios-start Start aios container
aios-stop Stop aios container
aios-shell Open shell in aios container
aios-login Login to aios container console
aios-backup Create backup snapshot (aiosback)
aios-reset Reset aios from backup
aios-update Update packages in backup
aios-remove Remove aios container
aios-list List all machine images
aios-status Show aios status
aios-exec Execute command in aios
aios-help Show this help
Example workflow:
1. aios-start # Start container
2. aios-login # Login and use
3. aios-backup # Create backup before major changes
4. aios-reset # Restore if something breaks
EOF
}

38
cfg/aios.zsh Normal file
View File

@@ -0,0 +1,38 @@
#!/bin/zsh
# aios startup script
CONFIG_DIR="$HOME/.config/syui/ai/os"
CONFIG_FILE="$CONFIG_DIR/config.json"
# 設定ファイルが存在しない場合は何もしない
if [ ! -f "$CONFIG_FILE" ]; then
return
fi
# jqで設定読み込み
if ! command -v jq &>/dev/null; then
return
fi
SHELL_MODE=$(cat "$CONFIG_FILE" | jq -r '.shell // false')
if [ "$SHELL_MODE" = "true" ]; then
echo "aios - AI-managed OS"
echo " Starting workspace container..."
echo ""
# Check if workspace exists
if ! sudo machinectl list-images | grep -q "^workspace"; then
echo "Error: workspace container not found"
echo "Please run install.sh first to create workspace container"
return
fi
# Start workspace container
sudo machinectl start workspace 2>/dev/null || true
sleep 2
# Login to workspace (claude.service will auto-start inside)
echo "Connecting to workspace container..."
exec sudo machinectl login workspace
fi

59
cfg/config.toml Normal file
View File

@@ -0,0 +1,59 @@
# aios configuration
[general]
version = "0.1.0"
name = "aios"
description = "AI-managed OS with shared memory"
[paths]
config_dir = "~/.config/syui/ai"
memory_db = "~/.config/syui/ai/gpt/memory.db"
mcp_config = "~/.config/syui/ai/mcp.json"
[permissions]
# Level 0: Auto-allow (no approval required)
auto_allow = [
"pacman -Q*",
"pacman -Ss*",
"systemctl status*",
"ls", "cat", "grep", "find",
"ps", "top", "htop",
"df", "free", "uname"
]
# Level 1: Notify (log only, no approval)
notify = [
"pacman -S*",
"pacman -Sy*",
"git clone*",
"cargo install*",
"systemctl start*",
"systemctl enable*"
]
# Level 2: Require approval
require_approval = [
"pacman -R*",
"rm -rf*",
"systemctl stop*",
"systemctl disable*",
"dd*"
]
# Level 3: Deny
deny = [
"rm -rf /",
"rm -rf /*",
"mkfs*",
":(){ :|:& };:"
]
[aigpt]
enable_layer4 = true
wal_mode = true
cache_size_mb = 64
[container]
runtime = "systemd-nspawn"
private_users = true
virtual_ethernet = true

118
cfg/install.sh Normal file
View File

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

12
cfg/mcp.json Normal file
View File

@@ -0,0 +1,12 @@
{
"mcpServers": {
"aigpt": {
"command": "aigpt",
"args": ["server", "--enable-layer4"],
"env": {
"AIGPT_DB": "/root/.config/syui/ai/gpt/memory.db"
},
"description": "AI memory and personality system"
}
}
}

15
cfg/nspawn/aios.nspawn Normal file
View File

@@ -0,0 +1,15 @@
# systemd-nspawn configuration for aios
# Place this file in /etc/systemd/nspawn/aios.nspawn
[Exec]
Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
# Bind mount shared memory directory
# Host: /root/.config/syui/ai -> Container: /root/.config/syui/ai
Bind=/root/.config/syui/ai:/root/.config/syui/ai
[Network]
VirtualEthernet=no

View File

@@ -1,10 +1,14 @@
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
IMAGE_ID=aios
IMAGE_VERSION=2024.02.11
NAME=ai os
PRETTY_NAME=ai os
NAME=aios
PRETTY_NAME=aios
ID=ai
ID_LIKE=arch
VERSION_ID=2024.11
VERSION="2024.11 (Rolling)"
VERSION_CODENAME=rolling
BUILD_ID=rolling
IMAGE_ID=aios
IMAGE_VERSION=2024.11.06
ANSI_COLOR="38;2;23;147;209"
HOME_URL=https://git.syui.ai/ai/os
DOCUMENTATION_URL=https://git.syui.ai/ai/os/wiki
SUPPORT_URL=https://git.syui.ai/ai/os/issues

View File

@@ -3,8 +3,8 @@
iso_name="aios"
iso_label="AI_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m)"
iso_publisher="ai os <https://git.syui.ai/ai/os>"
iso_application="ai os Live/Rescue DVD"
iso_publisher="aios <https://git.syui.ai/ai/os>"
iso_application="aios Live/Rescue DVD"
iso_version="$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y.%m.%d)"
install_dir="ai"
#buildmodes=('iso')

40
cfg/zshrc Normal file
View File

@@ -0,0 +1,40 @@
# aios .zshrc
# AI-managed OS with Claude Code + aigpt
# Environment
export EDITOR=vim
export LANG=en_US.UTF-8
# Path
export PATH=$HOME/.local/bin:$PATH
# aigpt MCP configuration
export AIGPT_CONFIG="$HOME/.config/syui/ai/config.toml"
export AIGPT_MCP="$HOME/.config/syui/ai/mcp.json"
# Aliases
alias ai='claude'
alias c='claude'
# Prompt
autoload -Uz promptinit
promptinit
prompt adam1
# History
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt SHARE_HISTORY
# Completion
autoload -Uz compinit
compinit
# Welcome message
echo "aios - AI-managed OS"
echo " aigpt: MCP server for shared memory"
echo " claude: AI conversation interface"
echo ""
echo "Type 'claude' or 'ai' to start"
echo ""