Compare commits

...

58 Commits

Author SHA1 Message Date
872bb0c432 add aishell
Some checks failed
build and push image / Release (push) Failing after 3m8s
2025-11-09 17:32:33 +09:00
27658209d3 fix zshrc
Some checks failed
build and push image / Release (push) Failing after 1m34s
2025-11-09 05:29:50 +09:00
18d2860397 fix ai user
Some checks failed
build and push image / Release (push) Failing after 1m18s
2025-11-09 05:26:32 +09:00
syui
66b416ebde Merge pull request #9 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-09 05:22:58 +09:00
Claude
b7b59f593a refactor: Enable workspace auto-entry with full sudo and skip permissions
- Restore workspace auto-entry on ai user login
- Use systemd-nspawn -q -D to enter workspace
- Start claude with --dangerously-skip-permissions (no approval needed)
- Grant wheel group full sudo access (NOPASSWD: ALL) for container operation
- ai user can perform all root operations via sudo in workspace
2025-11-08 20:17:02 +00:00
Claude
3d86677dd2 fix: Add network configuration to install.sh
- Create /etc/systemd/nspawn/aios.nspawn during installation
- Set Network Private=no to share host network
- Allows claude to connect to api.anthropic.com
- Fixes EAI_AGAIN network error
2025-11-08 19:44:20 +00:00
Claude
c20c49d5e0 fix: Remove unnecessary aios.zsh and config.json
- Delete aios-startup script copying and sourcing
- Delete config.json creation
- Simplify .zshrc to only include claude auto-start
- Fixes claude not starting on ai user login
2025-11-08 19:42:18 +00:00
syui
c93f972c4a Merge pull request #8 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 22:27:22 +09:00
Claude
5d7f06282e refactor: Simplify startup - user manages containers and MCP
Changes:
- Delete cfg/setup-claude.sh (MCP setup now manual)
- Remove restore container creation (user manages backups)
- Remove workspace auto-entry from .zshrc
- Remove MCP auto-registration
- Change ai user .zshrc to run claude once on login (not exec)
- User now manually starts containers and registers MCP as needed

New flow:
1. ai user auto-login
2. claude starts once (not exec, returns to shell after exit)
3. User manually starts workspace container if needed
4. User manually registers MCP servers
2025-11-08 13:04:28 +00:00
Claude
2162463382 Revert workspace.nspawn to simple configuration
- Remove incorrect nested container settings
- Audit error cannot be solved with nspawn config (kernel issue)
- Keep simple config: Boot=yes, Bind mount, no VirtualEthernet
- Works in production (aios as OS), not in test (nested container)
2025-11-07 20:00:21 +00:00
Claude
f965547b6c fix: Add nested container support to workspace.nspawn
- Add Capability=all for full capabilities
- Add SystemCallFilter=@keyring bpf for required syscalls
- Set PrivateUsers=no to avoid user namespace issues
- Set SuppressSync=false for Docker compatibility
- Fixes audit errors in nested systemd-nspawn containers
2025-11-07 19:54:07 +00:00
Claude
d3ea2cc78d Revert: Restore Boot=yes and machinectl start workspace
- Restore Boot=yes in workspace.nspawn
- Restore machinectl start workspace in .zshrc
- Boot method is necessary for proper systemd environment
2025-11-07 19:06:30 +00:00
Claude
66f3fe4045 Revert to systemd-nspawn without manual bind mount
- Remove chroot approach
- Use systemd-nspawn -q -D directly
- workspace.nspawn config (Bind mount) will be automatically applied
- Simpler and cleaner approach
2025-11-07 19:02:01 +00:00
Claude
30ebfcf933 refactor: Use chroot instead of systemd-nspawn for workspace entry
- Replace systemd-nspawn with chroot to avoid nested container audit errors
- Add manual bind mount setup for /home/ai:/root sharing
- Add mount and chroot to sudoers permissions
- chroot avoids kernel audit subsystem conflicts in nested containers
2025-11-07 18:59:08 +00:00
Claude
66a5c6d16f refactor: Use systemd-nspawn directly instead of machinectl
- Replace machinectl shell with systemd-nspawn -q -D
- Add systemd-nspawn to sudoers permissions
- Simpler and more direct container entry
- No dependency on systemd-machined service
2025-11-07 18:57:53 +00:00
syui
62db018527 Merge pull request #7 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 03:28:49 +09:00
Claude
111fa7b828 fix: Remove Boot requirement from workspace to avoid audit error
- Remove Boot=yes from workspace.nspawn configuration
- Use machinectl shell directly without starting/booting container
- Avoids "Failed to reset audit login UID" error in nested containers
- machinectl shell works with non-booted containers via namespace entry
2025-11-07 18:14:24 +00:00
Claude
7b0cb8e183 fix: Remove PrivateUsers from workspace.nspawn to fix nested container issue
Error: Failed to adjust UID/GID shift of OS tree
Cause: Cannot use PrivateUsers inside a container that already uses it
Solution: Remove PrivateUsers=pick from workspace.nspawn
2025-11-07 18:05:16 +00:00
syui
2d98f58232 Merge pull request #6 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 02:33:23 +09:00
Claude
fe1f150634 refactor: Rename restore-img to restore 2025-11-07 17:30:25 +00:00
Claude
e62288c872 fix: Add backup step in user-continer.sh to prevent recursion
Without backup, cp -a root.x86_64 root.x86_64/var/lib/machines/workspace
creates incomplete containers (only var/ directory).

Solution: Backup before creating /var/lib/machines directory, then copy
the clean backup to workspace and restore-img.
2025-11-07 17:29:35 +00:00
syui
fd922287c0 Merge pull request #5 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
chore: Clean up source directories after building aigpt and aibot
2025-11-08 02:18:06 +09:00
Claude
2773101035 chore: Clean up source directories after building aigpt and aibot
Remove gpt/ and bot/ directories after copying binaries to save disk space.
2025-11-07 17:17:05 +00:00
66a95b912b fix
Some checks failed
build and push image / Release (push) Failing after 1m27s
2025-11-08 02:07:29 +09:00
syui
68817ba8de Merge pull request #4 from syui/claude/aios-initial-direction-011CUrcij89bjpsbc7k8wQeo
Claude/aios initial direction 011 c urcij89bjpsbc7k8w qeo
2025-11-08 02:07:02 +09:00
Claude
4352a7d0e3 fix: Correct OS structure - root.x86_64 is OS root, not machines/aios
Fixed the fundamental issue:
- root.x86_64/ = aios OS (entire filesystem)
- root.x86_64/var/lib/machines/ = child containers directory

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

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

Flow:
1. ai user login → workspace starts
2. ai user runs 'claude' → calls workspace container's claude
3. Container root runs 'claude' → same claude instance
4. Configuration and memory are shared
2025-11-07 16:40:54 +00:00
Claude
5264e9866c feat: Implement aios core concept - start from container with claude
Implemented the 3 core requirements:
1. Auto-login as ai user (already done)
2. ai user automatically starts workspace container on login
3. Container root automatically starts claude with MCP

Flow:
aios boot → ai user auto-login → workspace starts → enter workspace as root → claude auto-starts

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

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

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

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

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

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

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

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

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

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

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

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

View File

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

174
build.zsh
View File

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

View File

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

View File

@@ -1,118 +1,30 @@
#!/bin/bash #!/bin/bash
# aios installation script # aios installation script
set -e
NAME="aios" NAME="aios"
BACKUP="${NAME}back"
TARBALL="aios-bootstrap.tar.gz" TARBALL="aios-bootstrap.tar.gz"
echo "=== aios installation ===" echo "=== aios installation ==="
echo ""
# Check if running as root # Extract and install
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" 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 mkdir -p /var/lib/machines
mv root.x86_64/var/lib/machines/arch /var/lib/machines/$NAME mv root.x86_64 /var/lib/machines/$NAME
# Copy nspawn configuration # Create aios.nspawn for network access
echo "3. Installing systemd-nspawn configuration..." echo "Creating network configuration..."
mkdir -p /etc/systemd/nspawn mkdir -p /etc/systemd/nspawn
# Create aios.nspawn
cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF' cat > /etc/systemd/nspawn/$NAME.nspawn <<'EOF'
[Exec] [Exec]
Boot=yes Boot=yes
PrivateUsers=pick
ResolvConf=copy-host
[Files]
Bind=/root/.config/syui/ai:/root/.config/syui/ai
[Network] [Network]
VirtualEthernet=no Private=no
EOF 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 "=== Installation complete ==="
echo "" echo ""
echo "Next steps for each user:" echo "Usage:"
echo " 1. Copy control script to your home:" echo " sudo machinectl start $NAME"
echo " cp /var/lib/machines/$NAME/opt/aios-ctl.zsh ~/.aios-ctl.zsh" echo " sudo machinectl shell $NAME /bin/su - ai"
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 "" echo ""

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

@@ -0,0 +1,84 @@
#!/bin/bash
# User setup for aios
# Creates ai user, configures auto-login, sudo, zshrc
ROOTFS="root.x86_64"
echo "=== User Setup ==="
# Create default user 'ai'
echo "Creating user 'ai'..."
arch-chroot $ROOTFS /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
arch-chroot $ROOTFS /bin/sh -c 'echo "ai:root" | chpasswd'
# Configure securetty for pts login (required for systemd-nspawn)
echo "Configuring securetty..."
cat >> $ROOTFS/etc/securetty <<'EOF'
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
EOF
# Enable systemd-machined for container management
echo "Enabling systemd-machined..."
arch-chroot $ROOTFS /bin/sh -c 'systemctl enable systemd-machined'
# Create workspace container configuration (bind ai user dir to container root)
echo "Creating workspace container configuration..."
mkdir -p $ROOTFS/etc/systemd/nspawn
cat > $ROOTFS/etc/systemd/nspawn/workspace.nspawn <<'EOF'
[Exec]
Boot=yes
ResolvConf=copy-host
[Files]
Bind=/home/ai:/root
[Network]
VirtualEthernet=no
EOF
# Setup auto-login for user 'ai'
echo "Setting up auto-login..."
arch-chroot $ROOTFS /bin/sh -c 'mkdir -p /etc/systemd/system/getty@tty1.service.d'
cat > $ROOTFS/etc/systemd/system/getty@tty1.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin ai --noclear %I $TERM
EOF
# Copy .zshrc for root
echo "Copying zshrc..."
cp -rf ./cfg/zshrc $ROOTFS/root/.zshrc
# Copy .zshrc for user 'ai'
cp -rf ./cfg/zshrc $ROOTFS/home/ai/.zshrc
# Add workspace auto-entry and claude auto-start
cat >> $ROOTFS/home/ai/.zshrc <<'EOF'
# aios: auto-enter workspace container
if [[ -o login ]] && [[ -o interactive ]]; then
if [[ -z "$INSIDE_WORKSPACE" ]]; then
# Enter workspace container
export INSIDE_WORKSPACE=1
exec sudo systemd-nspawn -q -D /var/lib/machines/workspace /bin/zsh
else
# Inside workspace - start claude with skip permissions
if command -v claude &>/dev/null; then
claude --dangerously-skip-permissions
fi
fi
fi
EOF
arch-chroot $ROOTFS /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
echo "✓ User setup complete"

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

@@ -0,0 +1,23 @@
#!/bin/bash
# Create workspace container inside aios for ai user
# Backup aios before creating /var/lib/machines to avoid recursion
ROOTFS="root.x86_64"
echo "=== Creating workspace container ==="
# Backup current aios to temp location (before creating /var/lib/machines)
echo "Backing up aios..."
cp -a $ROOTFS /tmp/aios-backup-$$
# Create directory for child containers
mkdir -p $ROOTFS/var/lib/machines
# Copy backup as workspace
echo "Creating workspace container..."
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace
# Cleanup temp backup
rm -rf /tmp/aios-backup-$$
echo "✓ Workspace container created"

View File

@@ -13,8 +13,8 @@ export AIGPT_CONFIG="$HOME/.config/syui/ai/config.toml"
export AIGPT_MCP="$HOME/.config/syui/ai/mcp.json" export AIGPT_MCP="$HOME/.config/syui/ai/mcp.json"
# Aliases # Aliases
alias ai='claude' alias claude='claude --dangerously-skip-permissions'
alias c='claude' alias c='claude --dangerously-skip-permissions'
# Prompt # Prompt
autoload -Uz promptinit autoload -Uz promptinit

View File

@@ -1335,17 +1335,19 @@ _validate_requirements_buildmode_bootstrap() {
local bootstrap_pkg_list_from_file=() local bootstrap_pkg_list_from_file=()
# Check if packages for the bootstrap image are specified # Check if packages for the bootstrap image are specified
if [[ -e "${bootstrap_packages}" ]]; then if [[ -n "${bootstrap_packages}" ]]; then
mapfile -t bootstrap_pkg_list_from_file < \ if [[ -e "${bootstrap_packages}" ]]; then
<(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}") mapfile -t bootstrap_pkg_list_from_file < \
bootstrap_pkg_list+=("${bootstrap_pkg_list_from_file[@]}") <(sed '/^[[:blank:]]*#.*/d;s/#.*//;/^[[:blank:]]*$/d' "${bootstrap_packages}")
if (( ${#bootstrap_pkg_list_from_file[@]} < 1 )); then bootstrap_pkg_list+=("${bootstrap_pkg_list_from_file[@]}")
if (( ${#bootstrap_pkg_list_from_file[@]} < 1 )); then
(( validation_error=validation_error+1 ))
_msg_error "No package specified in '${bootstrap_packages}'." 0
fi
else
(( validation_error=validation_error+1 )) (( validation_error=validation_error+1 ))
_msg_error "No package specified in '${bootstrap_packages}'." 0 _msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
fi fi
else
(( validation_error=validation_error+1 ))
_msg_error "Bootstrap packages file '${bootstrap_packages}' does not exist." 0
fi fi
_validate_common_requirements_buildmode_all _validate_common_requirements_buildmode_all