From ee4b8c052fb39e8d2a4be4e9984afe1dbc5d7ed4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 12:36:50 +0000 Subject: [PATCH 01/16] Implement aios initial direction: AI-managed OS with shared memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit implements the new direction for aios: - AI conversation interface replaces traditional shell - aigpt integration for shared memory across containers - systemd-nspawn for environment isolation Changes: - Added aios-install.sh: Complete installer script - Added cfg/mcp.json: MCP server configuration for aigpt - Added cfg/config.toml: aios configuration with permission system - Added cfg/nspawn/aios.nspawn: systemd-nspawn configuration - Updated build.zsh: Integrated aigpt installation and setup - Updated README.md: Documented new architecture and philosophy Architecture: User → AI Chat → Commands → Execution ↓ aigpt (shared memory) ↓ systemd-nspawn (isolated environment) Philosophy: Simply insert AI into existing flows (shell → AI chat) --- README.md | 262 ++++++++++++++++++++++++++++++----------- aios-install.sh | 151 ++++++++++++++++++++++++ build.zsh | 19 +++ cfg/config.toml | 59 ++++++++++ cfg/mcp.json | 12 ++ cfg/nspawn/aios.nspawn | 16 +++ 6 files changed, 449 insertions(+), 70 deletions(-) create mode 100755 aios-install.sh create mode 100644 cfg/config.toml create mode 100644 cfg/mcp.json create mode 100644 cfg/nspawn/aios.nspawn diff --git a/README.md b/README.md index 4a89543..93f8da2 100644 --- a/README.md +++ b/README.md @@ -1,110 +1,232 @@ -# ai `os` +# ai `os` -`aios` is a simple linux distribution based on `archlinux`. +**aios** = AI-managed OS with shared memory -|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)| +An ArchLinux-based OS where AI conversation interface replaces the traditional shell. -```sh -$ docker run -it git.syui.ai/ai/os ai +``` +User → AI Chat → Commands → Execution + ↓ + aigpt (shared memory) + ↓ + systemd-nspawn (isolated environment) ``` -## 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 +- Traditional: `User → Shell → Commands` +- aios: `User → AI Chat → Commands` + +Simply insert AI layer into the existing workflow. + +## Core Features + +### 1. AI-First Interface + +Default interface is AI conversation, not shell. ```sh -# https://gitlab.archlinux.org/archlinux -$ git clone https://gitlab.archlinux.org/archlinux/archiso +> Install rust development environment +✓ Installing rust, rust-analyzer, neovim +✓ Done + +> What did I install yesterday? +Yesterday you installed Python with poetry. ``` -## docker +### 2. Shared Memory (aigpt) + +All containers share the same memory database. + +``` +Host: ~/.config/syui/ai/gpt/memory.db (shared) + ↓ +aios-dev → bind mount → same DB +aios-prod → bind mount → same DB +``` + +AI learns from all environments and remembers your preferences. + +### 3. Environment Isolation + +Execution environments are isolated using systemd-nspawn. ```sh -# https://git.syui.ai/ai/-/packages/container/os -$ docker run -it git.syui.ai/ai/os ai +# Development environment +$ systemd-nspawn --machine=aios-dev -# 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 +# Production environment +$ systemd-nspawn --machine=aios-prod ``` -## token +Memory is shared, but environments are separated. -|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 +``` +aios (ArchLinux base) +├── aigpt (memory system) +│ ├── SQLite with WAL mode +│ ├── Layer 3: Personality analysis +│ └── Layer 4: Relationship inference +├── MCP (AI connection standard) +│ └── Claude Code / ChatGPT / Custom AI +├── systemd-nspawn (container runtime) +│ └── Shared memory bind mount +└── Permission system + ├── Auto-allow + ├── Notify + ├── Require approval + └── Deny +``` + +## Quick Start + +### Installation ```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 +# Clone repository +$ git clone https://github.com/syui/aios +$ cd aios + +# Run installer +$ sudo ./aios-install.sh ``` +### Usage + ```sh -$ podman pull aios +# Start aios container +$ sudo systemctl start systemd-nspawn@aios + +# Enter aios shell +$ sudo machinectl shell aios + +# Inside aios, AI chat interface starts +[aios] > ``` -> ~/.config/containers/registries.conf.d/ai.conf +## Container Distribution + +Pre-built containers are available: ```sh -# https://github.com/containers/shortnames -# ~/.config/containers/registries.conf.d/ai.conf -unqualified-search-registries = ['git.syui.ai', 'docker.io', 'ghcr.io'] +# Docker +$ docker run -it git.syui.ai/ai/os +$ docker run -it ghcr.io/syui/aios -[aliases] -"aios" = "git.syui.ai/ai/os" +# Podman +$ podman pull aios # using shortname alias ``` +## Configuration + +### Directory Structure + +``` +~/.config/syui/ai/ +├── gpt/ +│ ├── memory.db # Shared memory (SQLite WAL) +│ ├── memory.db-wal +│ └── memory.db-shm +├── mcp.json # MCP server configuration +└── config.toml # aios configuration +``` + +### MCP Configuration + +`~/.config/syui/ai/mcp.json`: + +```json +{ + "mcpServers": { + "aigpt": { + "command": "aigpt", + "args": ["server", "--enable-layer4"] + } + } +} +``` + +### Permission System + +`~/.config/syui/ai/config.toml`: + +```toml +[permissions] +# Auto-allow (no approval) +auto_allow = ["pacman -Q*", "ls", "cat"] + +# Notify (log only) +notify = ["pacman -S*", "git clone*"] + +# Require approval +require_approval = ["rm -rf*", "systemctl stop*"] + +# Deny +deny = ["rm -rf /", "mkfs*"] +``` + +## Building from Source + ```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 +# Install dependencies +$ pacman -S base-devel archiso docker git rust + +# Build bootstrap image +$ ./build.zsh + +# Result: aios-bootstrap.tar.gz ``` -## cron +## Integration with aigpt -stop +aios is designed to work with [aigpt](https://git.syui.ai/ai/gpt) (AI memory system). -```sh - schedule: - - cron: "0 0 * * *" -``` +aigpt provides: +- **Layer 1**: Memory storage +- **Layer 2**: Priority scoring +- **Layer 3**: Personality analysis (Big Five) +- **Layer 4**: Relationship inference -## update action +All memories are shared across containers through bind-mounted SQLite database. -```sh -$ vim build.zszh -$ ./scpt/gh-actions.zsh -``` +## Comparison -## link +| Aspect | Traditional OS | aios | +|--------|---------------|------| +| Interface | Shell (bash/zsh) | AI Chat | +| Command | Memorize syntax | Natural language | +| Configuration | Manual editing | AI executes | +| Learning | No | Yes (aigpt) | +| Memory | No | Shared (SQLite) | +| Isolation | Docker/Podman | systemd-nspawn | -- https://git.syui.ai/ai/os -- https://github.com/syui/aios +## Links +- 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 + +## Philosophy Detail + +From conversation with AI about aigpt: + +> "What is the essence of this design?" +> "Simply insert AI into existing flows" +> +> - aigpt: Insert AI between conversation and memory +> - aios: Insert AI between user and commands +> +> Not building something entirely new. +> Just adding an AI layer to existing workflows. +> And prepare the environment for that. + +This is aios. + +--- + +© syui diff --git a/aios-install.sh b/aios-install.sh new file mode 100755 index 0000000..070f9b9 --- /dev/null +++ b/aios-install.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# aios installer - AI-managed OS with shared memory + +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 "aios = AI-managed OS with shared memory" +echo "- Default interface: AI chat (not shell)" +echo "- Shared memory: aigpt (SQLite)" +echo "- Environment isolation: systemd-nspawn" +echo "" + +# Check if running as root for container creation +if [ "$EUID" -ne 0 ] && [ ! -d "$AIOS_ROOT" ]; then + echo "Note: Container creation requires root privileges" + echo " User config will be created in: $AIOS_CONFIG" +fi + +# 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" < /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 "" + +if command -v aigpt &>/dev/null; then + echo "Next steps:" + echo "" + echo " # Enter aios container:" + echo " $ sudo machinectl shell aios" + echo "" + echo " # Or start AI chat interface:" + echo " $ aios shell" + echo "" +else + echo "To complete installation:" + echo " 1. Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" + echo " 2. Run this installer again: ./aios-install.sh" +fi + +echo "" +echo "Configuration:" +echo " Config dir: ${AIOS_CONFIG}" +echo " Memory DB: ${AIOS_CONFIG}/gpt/memory.db" +echo " MCP config: ${AIOS_CONFIG}/mcp.json" +echo "" diff --git a/build.zsh b/build.zsh index 92bcf60..0139a57 100755 --- a/build.zsh +++ b/build.zsh @@ -18,5 +18,24 @@ arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linu 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' + +# Install aigpt (AI memory system) +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/' + +# Install ai/bot (optional, for backward compatibility) 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' + +# Create config directory +arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt' + +# Copy MCP and aios configuration +cp -rf ./cfg/mcp.json root.x86_64/root/.config/syui/ai/mcp.json +cp -rf ./cfg/config.toml root.x86_64/root/.config/syui/ai/config.toml + +# Initialize aigpt database with WAL mode +arch-chroot root.x86_64 /bin/sh -c 'aigpt server --enable-layer4 &' +sleep 2 +arch-chroot root.x86_64 /bin/sh -c 'pkill aigpt' +arch-chroot root.x86_64 /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' + tar -zcvf aios-bootstrap.tar.gz root.x86_64/ diff --git a/cfg/config.toml b/cfg/config.toml new file mode 100644 index 0000000..d441b89 --- /dev/null +++ b/cfg/config.toml @@ -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 diff --git a/cfg/mcp.json b/cfg/mcp.json new file mode 100644 index 0000000..5753a69 --- /dev/null +++ b/cfg/mcp.json @@ -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" + } + } +} diff --git a/cfg/nspawn/aios.nspawn b/cfg/nspawn/aios.nspawn new file mode 100644 index 0000000..1550bda --- /dev/null +++ b/cfg/nspawn/aios.nspawn @@ -0,0 +1,16 @@ +# 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: ~/.config/syui/ai -> Container: /root/.config/syui/ai +Bind=%h/.config/syui/ai:/root/.config/syui/ai + +[Network] +Private=yes +VirtualEthernet=yes From 80e40a53ec5c1799df7bdd91e7f9871350aab126 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 13:19:48 +0000 Subject: [PATCH 02/16] Refactor aios: Focus on Claude Code + aigpt simplicity Simplified aios to focus on core value: - Pre-configured systemd-nspawn environment - Claude Code + aigpt (MCP) pre-installed - Shared memory across containers Philosophy: Don't build new tools. Use existing ones (Claude Code, systemd-nspawn). Just provide the optimal environment and automation. Changes: - Added cfg/zshrc: Shell config with claude alias - Updated build.zsh: Install Claude Code (npm) + aigpt - Updated aios-install.sh: Simplified installation flow - Updated README.md: Focus on simplicity and practicality Installation: 1. npm i -g @anthropic-ai/claude-code 2. Build aigpt from source 3. Configure .zshrc with aliases 4. Set up systemd-nspawn with bind mounts Usage: $ sudo machinectl shell aios $ claude # or: ai --- README.md | 198 +++++++++++++++++++----------------------------- aios-install.sh | 43 ++++------- build.zsh | 8 +- cfg/zshrc | 40 ++++++++++ 4 files changed, 137 insertions(+), 152 deletions(-) create mode 100644 cfg/zshrc diff --git a/README.md b/README.md index 93f8da2..1ddc2af 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,98 @@ # ai `os` -**aios** = AI-managed OS with shared memory +**aios** = ArchLinux + Claude Code + aigpt in systemd-nspawn -An ArchLinux-based OS where AI conversation interface replaces the traditional shell. +A minimal ArchLinux environment optimized for Claude Code with shared AI memory. ``` -User → AI Chat → Commands → Execution - ↓ - aigpt (shared memory) - ↓ - systemd-nspawn (isolated environment) +systemd-nspawn container +├── Claude Code (AI interface) +├── aigpt (shared memory) +└── zsh (.zshrc configured) + +$ sudo machinectl shell aios +$ claude # Start Claude Code ``` ## Philosophy **Insert AI into existing flows** -- Traditional: `User → Shell → Commands` -- aios: `User → AI Chat → Commands` +Instead of building a new AI chat interface, use **Claude Code** (which already works). -Simply insert AI layer into the existing workflow. +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 -## Core Features +## What's Included -### 1. AI-First Interface +### 1. Claude Code -Default interface is AI conversation, not shell. +Pre-installed and ready to use: ```sh +$ claude +# Claude Code starts, with MCP connection to aigpt > Install rust development environment ✓ Installing rust, rust-analyzer, neovim -✓ Done - -> What did I install yesterday? -Yesterday you installed Python with poetry. ``` -### 2. Shared Memory (aigpt) +### 2. aigpt (Shared Memory) -All containers share the same memory database. +MCP server that provides persistent memory to Claude Code: ``` -Host: ~/.config/syui/ai/gpt/memory.db (shared) - ↓ -aios-dev → bind mount → same DB -aios-prod → bind mount → same DB +~/.config/syui/ai/gpt/memory.db (SQLite, WAL mode) + ↓ bind mount +aios-dev, aios-prod, etc. (all share same DB) ``` -AI learns from all environments and remembers your preferences. +AI remembers your preferences across all containers. -### 3. Environment Isolation +### 3. systemd-nspawn -Execution environments are isolated using systemd-nspawn. +Lightweight container environment: ```sh -# Development environment -$ systemd-nspawn --machine=aios-dev - -# Production environment -$ systemd-nspawn --machine=aios-prod +$ sudo machinectl shell aios +# Inside container with aigpt + Claude Code ``` -Memory is shared, but environments are separated. +Multiple containers can share the same memory. ## Architecture ``` -aios (ArchLinux base) -├── aigpt (memory system) -│ ├── SQLite with WAL mode -│ ├── Layer 3: Personality analysis -│ └── Layer 4: Relationship inference -├── MCP (AI connection standard) -│ └── Claude Code / ChatGPT / Custom AI -├── systemd-nspawn (container runtime) -│ └── Shared memory bind mount -└── Permission system - ├── Auto-allow - ├── Notify - ├── Require approval - └── Deny +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 -### Installation - ```sh -# Clone repository +# 1. Clone repository $ git clone https://github.com/syui/aios $ cd aios -# Run installer +# 2. Run installer (creates systemd-nspawn container) $ sudo ./aios-install.sh -``` -### Usage - -```sh -# Start aios container -$ sudo systemctl start systemd-nspawn@aios - -# Enter aios shell +# 3. Enter container $ sudo machinectl shell aios -# Inside aios, AI chat interface starts -[aios] > +# 4. Start Claude Code +$ claude +# or +$ ai ``` ## Container Distribution @@ -127,17 +114,14 @@ $ podman pull aios # using shortname alias ``` ~/.config/syui/ai/ -├── gpt/ -│ ├── memory.db # Shared memory (SQLite WAL) -│ ├── memory.db-wal -│ └── memory.db-shm -├── mcp.json # MCP server configuration -└── config.toml # aios configuration +├── gpt/memory.db # Shared memory (SQLite WAL) +├── mcp.json # MCP server config +└── config.toml # aios config ``` ### MCP Configuration -`~/.config/syui/ai/mcp.json`: +Claude Code connects to aigpt via MCP: ```json { @@ -150,59 +134,32 @@ $ podman pull aios # using shortname alias } ``` -### Permission System - -`~/.config/syui/ai/config.toml`: - -```toml -[permissions] -# Auto-allow (no approval) -auto_allow = ["pacman -Q*", "ls", "cat"] - -# Notify (log only) -notify = ["pacman -S*", "git clone*"] - -# Require approval -require_approval = ["rm -rf*", "systemctl stop*"] - -# Deny -deny = ["rm -rf /", "mkfs*"] -``` +This enables Claude Code to use aigpt's memory system. ## Building from Source ```sh -# Install dependencies -$ pacman -S base-devel archiso docker git rust - -# Build bootstrap image +$ pacman -S base-devel archiso docker git rust nodejs npm $ ./build.zsh - -# Result: aios-bootstrap.tar.gz +# Creates: aios-bootstrap.tar.gz ``` -## Integration with aigpt +## How It Works -aios is designed to work with [aigpt](https://git.syui.ai/ai/gpt) (AI memory system). +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 -aigpt provides: -- **Layer 1**: Memory storage -- **Layer 2**: Priority scoring -- **Layer 3**: Personality analysis (Big Five) -- **Layer 4**: Relationship inference +**Result:** Claude Code can remember your preferences across all containers. -All memories are shared across containers through bind-mounted SQLite database. +## Why Not Just Use Claude Code? -## Comparison - -| Aspect | Traditional OS | aios | -|--------|---------------|------| -| Interface | Shell (bash/zsh) | AI Chat | -| Command | Memorize syntax | Natural language | -| Configuration | Manual editing | AI executes | -| Learning | No | Yes (aigpt) | -| Memory | No | Shared (SQLite) | -| Isolation | Docker/Podman | systemd-nspawn | +You can! aios just provides: +- Pre-configured environment +- Shared memory (aigpt) pre-installed +- Container isolation +- Easy multi-environment setup ## Links @@ -211,21 +168,20 @@ All memories are shared across containers through bind-mounted SQLite database. - aigpt: https://git.syui.ai/ai/gpt - Container: https://git.syui.ai/ai/-/packages/container/os -## Philosophy Detail +## Philosophy -From conversation with AI about aigpt: +**Insert AI into existing flows** -> "What is the essence of this design?" -> "Simply insert AI into existing flows" -> -> - aigpt: Insert AI between conversation and memory -> - aios: Insert AI between user and commands -> -> Not building something entirely new. -> Just adding an AI layer to existing workflows. -> And prepare the environment for that. +Don't build a new AI chat interface. Use Claude Code (which already works). -This is aios. +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. --- diff --git a/aios-install.sh b/aios-install.sh index 070f9b9..03cc9f5 100755 --- a/aios-install.sh +++ b/aios-install.sh @@ -1,5 +1,5 @@ #!/bin/bash -# aios installer - AI-managed OS with shared memory +# aios installer - systemd-nspawn with aigpt + Claude Code set -e @@ -9,18 +9,9 @@ AIOS_CONFIG="$HOME/.config/syui/ai" echo "=== aios installer v${AIOS_VERSION} ===" echo "" -echo "aios = AI-managed OS with shared memory" -echo "- Default interface: AI chat (not shell)" -echo "- Shared memory: aigpt (SQLite)" -echo "- Environment isolation: systemd-nspawn" +echo "Installing: aigpt + Claude Code in systemd-nspawn" echo "" -# Check if running as root for container creation -if [ "$EUID" -ne 0 ] && [ ! -d "$AIOS_ROOT" ]; then - echo "Note: Container creation requires root privileges" - echo " User config will be created in: $AIOS_CONFIG" -fi - # 1. Create shared memory directory echo "[1/6] Creating shared memory directory..." mkdir -p "${AIOS_CONFIG}/gpt" @@ -127,25 +118,17 @@ echo "================================================" echo "✓ aios installation complete!" echo "================================================" echo "" - -if command -v aigpt &>/dev/null; then - echo "Next steps:" - echo "" - echo " # Enter aios container:" - echo " $ sudo machinectl shell aios" - echo "" - echo " # Or start AI chat interface:" - echo " $ aios shell" - echo "" -else - echo "To complete installation:" - echo " 1. Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" - echo " 2. Run this installer again: ./aios-install.sh" -fi - +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 " Config dir: ${AIOS_CONFIG}" -echo " Memory DB: ${AIOS_CONFIG}/gpt/memory.db" -echo " MCP config: ${AIOS_CONFIG}/mcp.json" +echo " Shared memory: ${AIOS_CONFIG}/gpt/memory.db" +echo " MCP config: ${AIOS_CONFIG}/mcp.json" echo "" diff --git a/build.zsh b/build.zsh index 0139a57..13a5267 100755 --- a/build.zsh +++ b/build.zsh @@ -14,11 +14,17 @@ Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pa 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 '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 /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' +# Install Claude Code +arch-chroot root.x86_64 /bin/sh -c 'npm i -g @anthropic-ai/claude-code' + +# Copy .zshrc +cp -rf ./cfg/zshrc root.x86_64/root/.zshrc + # Install aigpt (AI memory system) 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/' diff --git a/cfg/zshrc b/cfg/zshrc new file mode 100644 index 0000000..21f1cc1 --- /dev/null +++ b/cfg/zshrc @@ -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 "" From f5c5b8395587bdd28eee5b9fd2b898f5d14544ff Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 13:34:31 +0000 Subject: [PATCH 03/16] fix: Change "ai os" to "aios" in cfg files - cfg/os-release: NAME and PRETTY_NAME - cfg/profiledef.sh: iso_publisher and iso_application --- cfg/os-release | 4 ++-- cfg/profiledef.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cfg/os-release b/cfg/os-release index dd2a110..c517e2e 100644 --- a/cfg/os-release +++ b/cfg/os-release @@ -2,8 +2,8 @@ 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 HOME_URL=https://git.syui.ai/ai/os DOCUMENTATION_URL=https://git.syui.ai/ai/os/wiki diff --git a/cfg/profiledef.sh b/cfg/profiledef.sh index 146fddb..cf86495 100644 --- a/cfg/profiledef.sh +++ b/cfg/profiledef.sh @@ -3,8 +3,8 @@ iso_name="aios" iso_label="AI_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m)" -iso_publisher="ai os " -iso_application="ai os Live/Rescue DVD" +iso_publisher="aios " +iso_application="aios Live/Rescue DVD" iso_version="$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y.%m.%d)" install_dir="ai" #buildmodes=('iso') From 34f40e82c1b38e62a702a55ad69de4d9bfeb8373 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 13:35:21 +0000 Subject: [PATCH 04/16] feat: Improve os-release with standard fields - Added ID_LIKE=arch (indicates Arch Linux base) - Added VERSION_ID and VERSION (version information) - Added VERSION_CODENAME=rolling - Reorganized fields in standard order - Updated IMAGE_VERSION to 2024.11.06 --- cfg/os-release | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cfg/os-release b/cfg/os-release index c517e2e..7794c7d 100644 --- a/cfg/os-release +++ b/cfg/os-release @@ -1,10 +1,14 @@ -BUILD_ID=rolling -ANSI_COLOR="38;2;23;147;209" -IMAGE_ID=aios -IMAGE_VERSION=2024.02.11 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 From bf27244544f762711cd6aec3fe031f25def4585a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 14:26:53 +0000 Subject: [PATCH 05/16] fix: Update arch-chroot paths for new archiso structure archiso now creates bootstrap with systemd-nspawn standard structure: root.x86_64/var/lib/machines/arch/ instead of root.x86_64/ Changes: - build.zsh: Updated all arch-chroot paths to root.x86_64/var/lib/machines/arch - build.zsh: Updated file copy paths for .zshrc, mcp.json, config.toml - .github/workflows/release.yml: Same path updates - Added aigpt + Claude Code installation steps to GitHub Actions This aligns with systemd-nspawn's standard container directory structure (/var/lib/machines/). --- .github/workflows/release.yml | 24 ++++++++++++++--------- build.zsh | 36 +++++++++++++++++------------------ 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a44e42..7059824 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,15 +37,21 @@ 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' + 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/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc + 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 '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 tar -zcvf aios-bootstrap.tar.gz root.x86_64/ tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }} echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin diff --git a/build.zsh b/build.zsh index 13a5267..22b7f2d 100755 --- a/build.zsh +++ b/build.zsh @@ -10,38 +10,38 @@ 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 npm docker podman bc sqlite' -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' +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 /bin/sh -c 'npm i -g @anthropic-ai/claude-code' +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai/claude-code' # Copy .zshrc -cp -rf ./cfg/zshrc root.x86_64/root/.zshrc +cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc # Install aigpt (AI memory system) -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/' +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/' # Install ai/bot (optional, for backward compatibility) -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' +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 /bin/sh -c 'mkdir -p /root/.config/syui/ai/gpt' +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/root/.config/syui/ai/mcp.json -cp -rf ./cfg/config.toml root.x86_64/root/.config/syui/ai/config.toml +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 /bin/sh -c 'aigpt server --enable-layer4 &' +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'aigpt server --enable-layer4 &' sleep 2 -arch-chroot root.x86_64 /bin/sh -c 'pkill aigpt' -arch-chroot root.x86_64 /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' +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' tar -zcvf aios-bootstrap.tar.gz root.x86_64/ From 22b1502f58d9a7c9ed51f8a1ba9d3f8ed643d505 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 14:51:31 +0000 Subject: [PATCH 06/16] fix: Add missing os-release copy to build process cfg/os-release was not being copied, causing NAME to remain 'Arch Linux' instead of 'aios'. Added os-release copy to both: - build.zsh - .github/workflows/release.yml --- .github/workflows/release.yml | 1 + build.zsh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7059824..c432aa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,7 @@ jobs: 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 cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc 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 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai' diff --git a/build.zsh b/build.zsh index 22b7f2d..4aa4d44 100755 --- a/build.zsh +++ b/build.zsh @@ -22,6 +22,9 @@ 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 + # Copy .zshrc cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc From b7077becdb499fdf53a4e195c475ae16a233ee07 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:13:03 +0000 Subject: [PATCH 07/16] feat: Auto-register aigpt to Claude MCP during build Added automatic MCP registration: - claude mcp add aigpt $(which aigpt) server This eliminates manual MCP setup after installation. Users can immediately use 'claude' with aigpt memory system. --- build.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.zsh b/build.zsh index 4aa4d44..6adf1ae 100755 --- a/build.zsh +++ b/build.zsh @@ -31,6 +31,9 @@ cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc # 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/' +# Register aigpt to Claude MCP +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'claude mcp add aigpt $(which aigpt) server' + # 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' From a411b361089f0e50c544104f661db48466500199 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:14:42 +0000 Subject: [PATCH 08/16] fix: Create Claude MCP config file directly claude mcp add command does not support args parameter. Changed to directly create claude_desktop_config.json with full config: - command: aigpt - args: ["server", "--enable-layer4"] This ensures aigpt is properly registered with Layer 4 enabled. --- build.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build.zsh b/build.zsh index 6adf1ae..4114da9 100755 --- a/build.zsh +++ b/build.zsh @@ -31,8 +31,18 @@ cp -rf ./cfg/zshrc root.x86_64/var/lib/machines/arch/root/.zshrc # 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/' -# Register aigpt to Claude MCP -arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'claude mcp add aigpt $(which aigpt) server' +# Setup Claude Code MCP configuration +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p ~/.config/claude' +cat > root.x86_64/var/lib/machines/arch/root/.config/claude/claude_desktop_config.json <<'EOF' +{ + "mcpServers": { + "aigpt": { + "command": "aigpt", + "args": ["server", "--enable-layer4"] + } + } +} +EOF # 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' From 69754d9df09667638d1cdc838eed828b40f4f02c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:18:04 +0000 Subject: [PATCH 09/16] feat: Add default user 'ai' with auto-login Added user setup: - Username: ai - Password: root - Shell: zsh - Groups: wheel (sudo enabled) Auto-login configuration: - getty@tty1 with --autologin ai - .zshrc copied for both root and ai user This provides a ready-to-use environment with AI-first user. --- build.zsh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/build.zsh b/build.zsh index 4114da9..00980ee 100755 --- a/build.zsh +++ b/build.zsh @@ -25,9 +25,28 @@ arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'npm i -g @anthropic-ai # Copy os-release cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release -# Copy .zshrc +# 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 +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'sed -i "s/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/" /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' + # 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/' From baece04bba8d85cc13d5e55de23ca7823b2cbe8d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:19:48 +0000 Subject: [PATCH 10/16] fix: Configure sudo for specific commands only Changed sudo configuration to allow NOPASSWD for specific commands only: - pacman -Syu --noconfirm (system update) - rm -rf /var/lib/pacman/db.lck (unlock pacman) - poweroff (shutdown) - reboot (reboot) This is more secure than allowing all commands without password. --- build.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zsh b/build.zsh index 00980ee..9a90421 100755 --- a/build.zsh +++ b/build.zsh @@ -29,8 +29,8 @@ 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' -# Enable wheel group for sudo -arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'sed -i "s/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/" /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" >> /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' From 8e74f906a0b2d9830bd455bf76299bfc528b0800 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:39:47 +0000 Subject: [PATCH 11/16] feat: Add optional auto-startup for claude - Create cfg/aios.zsh startup script with config-based claude launch - Install startup script to /usr/local/bin/aios-startup - Create default config at ~/.config/syui/ai/os/config.json - Source startup script from user 'ai' .zshrc - Enable optional "shell mode" via config {"shell": true} --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ build.zsh | 20 ++++++++++++++++++ cfg/aios.zsh | 28 ++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 cfg/aios.zsh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c432aa9..52a7da3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,12 +47,52 @@ jobs: 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" >> /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 ~/.config/claude' + cat > root.x86_64/var/lib/machines/arch/root/.config/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 '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' tar -zcvf aios-bootstrap.tar.gz root.x86_64/ tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }} echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin diff --git a/build.zsh b/build.zsh index 9a90421..2527618 100755 --- a/build.zsh +++ b/build.zsh @@ -47,6 +47,26 @@ 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' +# 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/' diff --git a/cfg/aios.zsh b/cfg/aios.zsh new file mode 100644 index 0000000..a625888 --- /dev/null +++ b/cfg/aios.zsh @@ -0,0 +1,28 @@ +#!/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 " Shell mode enabled" + echo "" + + # claudeを起動 + if command -v claude &>/dev/null; then + exec claude + fi +fi From a3e1878c14ceba5fa8ebfd13dd8475b84e0b3537 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 15:56:00 +0000 Subject: [PATCH 12/16] feat: Add machinectl management and backup/restore system - Create cfg/aios-ctl.zsh with machinectl control commands - aios-start/stop/shell/login for basic operations - aios-backup to save current state to aiosback - aios-reset to restore from backup (preserves config files) - aios-update to update packages in backup - Create cfg/install.sh for automated installation - Extracts tarball to /var/lib/machines/aios - Creates systemd-nspawn configuration - Automatically creates initial backup image (aiosback) - Include aios-ctl.zsh in container at /opt/aios-ctl.zsh - Include install.sh in tarball for easy deployment - Config files in ~/.config/syui/ai are bind-mounted and preserved across resets --- .github/workflows/release.yml | 5 +- build.zsh | 9 ++- cfg/aios-ctl.zsh | 132 ++++++++++++++++++++++++++++++++++ cfg/install.sh | 82 +++++++++++++++++++++ 4 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 cfg/aios-ctl.zsh create mode 100644 cfg/install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52a7da3..ea0e72e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,10 @@ jobs: 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' - tar -zcvf aios-bootstrap.tar.gz root.x86_64/ + 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 }} diff --git a/build.zsh b/build.zsh index 2527618..9e7afc8 100755 --- a/build.zsh +++ b/build.zsh @@ -99,4 +99,11 @@ 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' -tar -zcvf aios-bootstrap.tar.gz root.x86_64/ +# 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 diff --git a/cfg/aios-ctl.zsh b/cfg/aios-ctl.zsh new file mode 100644 index 0000000..41cfd30 --- /dev/null +++ b/cfg/aios-ctl.zsh @@ -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 " + 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 +} diff --git a/cfg/install.sh b/cfg/install.sh new file mode 100644 index 0000000..c98ef80 --- /dev/null +++ b/cfg/install.sh @@ -0,0 +1,82 @@ +#!/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 +cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF' +[Exec] +Boot=yes +PrivateUsers=pick +ResolvConf=copy-host + +[Files] +Bind=%h/.config/syui/ai:/root/.config/syui/ai + +[Network] +Private=yes +VirtualEthernet=yes +EOF + +# 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 + +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 "" From c2149966ec2182ea11d6ec62deb5862ba318a4be Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 16:00:49 +0000 Subject: [PATCH 13/16] chore: Add build artifacts to .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index f2ba035..592174c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ .config/ai **.DS_Store + +# Build artifacts +aios-bootstrap*.tar.gz +root.x86_64/ +archiso/ +install.sh +build.log From ab50bc29f0d443c422ac828f2ee6d71b6352bbfe Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 17:12:49 +0000 Subject: [PATCH 14/16] fix: Configure Claude Code settings via symlink for sharing - Move MCP config to ~/.config/syui/ai/claude/ (bind-mounted) - Create symlink ~/.config/claude -> ~/.config/syui/ai/claude - Apply to both root and ai user - Settings now shared across containers via bind mount - No need to copy config files, they are automatically shared --- .github/workflows/release.yml | 9 +++++++-- build.zsh | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea0e72e..9eb673e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,8 +74,8 @@ jobs: 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 ~/.config/claude' - cat > root.x86_64/var/lib/machines/arch/root/.config/claude/claude_desktop_config.json <<'EOF' + 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": { @@ -85,6 +85,11 @@ jobs: } } 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 diff --git a/build.zsh b/build.zsh index 9e7afc8..7859ed9 100755 --- a/build.zsh +++ b/build.zsh @@ -70,9 +70,10 @@ 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 -arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'mkdir -p ~/.config/claude' -cat > root.x86_64/var/lib/machines/arch/root/.config/claude/claude_desktop_config.json <<'EOF' +# 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": { @@ -83,6 +84,15 @@ cat > root.x86_64/var/lib/machines/arch/root/.config/claude/claude_desktop_confi } 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' From ff161f84a0ed954624d51d9e5fe8a4e18ccc1d8a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 06:02:40 +0000 Subject: [PATCH 15/16] feat: Add workspace container with claude auto-start - Create cfg/claude.service for systemd auto-start of Claude Code - Enable claude.service on container boot - Update install.sh to automatically create workspace container - Update aios.zsh to start workspace and connect when shell:true - Add machinectl to sudoers NOPASSWD for ai user - Workspace container starts on login, claude.service auto-runs inside --- .github/workflows/release.yml | 4 +++- build.zsh | 6 +++++- cfg/aios.zsh | 18 ++++++++++++++---- cfg/claude.service | 15 +++++++++++++++ cfg/install.sh | 4 ++++ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 cfg/claude.service diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9eb673e..0ed5ea9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,10 +46,12 @@ jobs: 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/claude.service root.x86_64/var/lib/machines/arch/etc/systemd/system/claude.service + arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'systemctl enable claude' 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" >> /etc/sudoers' + 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] diff --git a/build.zsh b/build.zsh index 7859ed9..6a4b50e 100755 --- a/build.zsh +++ b/build.zsh @@ -22,6 +22,10 @@ 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' +# Setup Claude Code systemd service for auto-start +cp -rf ./cfg/claude.service root.x86_64/var/lib/machines/arch/etc/systemd/system/claude.service +arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'systemctl enable claude' + # Copy os-release cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release @@ -30,7 +34,7 @@ arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'useradd -m -G wheel -s 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" >> /etc/sudoers' +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' diff --git a/cfg/aios.zsh b/cfg/aios.zsh index a625888..933d9f6 100644 --- a/cfg/aios.zsh +++ b/cfg/aios.zsh @@ -18,11 +18,21 @@ SHELL_MODE=$(cat "$CONFIG_FILE" | jq -r '.shell // false') if [ "$SHELL_MODE" = "true" ]; then echo "aios - AI-managed OS" - echo " Shell mode enabled" + echo " Starting workspace container..." echo "" - # claudeを起動 - if command -v claude &>/dev/null; then - exec claude + # 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 diff --git a/cfg/claude.service b/cfg/claude.service new file mode 100644 index 0000000..bbcd46c --- /dev/null +++ b/cfg/claude.service @@ -0,0 +1,15 @@ +[Unit] +Description=Claude Code AI Assistant +After=network.target + +[Service] +Type=simple +User=ai +WorkingDirectory=/home/ai +Environment=HOME=/home/ai +ExecStart=/usr/bin/claude +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/cfg/install.sh b/cfg/install.sh index c98ef80..16ead3a 100644 --- a/cfg/install.sh +++ b/cfg/install.sh @@ -58,6 +58,10 @@ systemctl enable --now systemd-machined 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 "" From 7d531c260836343f9a3fc7b43c32a6c1e12679bb Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 07:02:43 +0000 Subject: [PATCH 16/16] fix: Remove claude.service and fix network settings - Remove cfg/claude.service (claude should be run manually, not as systemd service) - Fix bind mount: change %h to /root for proper path resolution - Fix network: change to VirtualEthernet=no for internet access - Update install.sh to create proper nspawn configs for all containers - Create /root/.config/syui/ai directory in install.sh Working flow: - aios OS boot -> ai user login - machinectl login workspace - manually run 'claude' command --- .github/workflows/release.yml | 2 -- build.zsh | 4 ---- cfg/claude.service | 15 -------------- cfg/install.sh | 38 ++++++++++++++++++++++++++++++++--- cfg/nspawn/aios.nspawn | 7 +++---- 5 files changed, 38 insertions(+), 28 deletions(-) delete mode 100644 cfg/claude.service diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ed5ea9..9227c43 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,8 +46,6 @@ jobs: 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/claude.service root.x86_64/var/lib/machines/arch/etc/systemd/system/claude.service - arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'systemctl enable claude' 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' diff --git a/build.zsh b/build.zsh index 6a4b50e..babd919 100755 --- a/build.zsh +++ b/build.zsh @@ -22,10 +22,6 @@ 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' -# Setup Claude Code systemd service for auto-start -cp -rf ./cfg/claude.service root.x86_64/var/lib/machines/arch/etc/systemd/system/claude.service -arch-chroot root.x86_64/var/lib/machines/arch /bin/sh -c 'systemctl enable claude' - # Copy os-release cp -rf ./cfg/os-release root.x86_64/var/lib/machines/arch/etc/os-release diff --git a/cfg/claude.service b/cfg/claude.service deleted file mode 100644 index bbcd46c..0000000 --- a/cfg/claude.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Claude Code AI Assistant -After=network.target - -[Service] -Type=simple -User=ai -WorkingDirectory=/home/ai -Environment=HOME=/home/ai -ExecStart=/usr/bin/claude -Restart=on-failure -RestartSec=5s - -[Install] -WantedBy=multi-user.target diff --git a/cfg/install.sh b/cfg/install.sh index 16ead3a..86703e9 100644 --- a/cfg/install.sh +++ b/cfg/install.sh @@ -36,6 +36,8 @@ 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 @@ -43,13 +45,43 @@ PrivateUsers=pick ResolvConf=copy-host [Files] -Bind=%h/.config/syui/ai:/root/.config/syui/ai +Bind=/root/.config/syui/ai:/root/.config/syui/ai [Network] -Private=yes -VirtualEthernet=yes +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 diff --git a/cfg/nspawn/aios.nspawn b/cfg/nspawn/aios.nspawn index 1550bda..6a07f95 100644 --- a/cfg/nspawn/aios.nspawn +++ b/cfg/nspawn/aios.nspawn @@ -8,9 +8,8 @@ ResolvConf=copy-host [Files] # Bind mount shared memory directory -# Host: ~/.config/syui/ai -> Container: /root/.config/syui/ai -Bind=%h/.config/syui/ai:/root/.config/syui/ai +# Host: /root/.config/syui/ai -> Container: /root/.config/syui/ai +Bind=/root/.config/syui/ai:/root/.config/syui/ai [Network] -Private=yes -VirtualEthernet=yes +VirtualEthernet=no