Merge pull request #8 from benoitvx/feat/runtime-example
Add runtime.example.sh and document global runtime setup
- 作者
- Sylvain Zimmer
- 时间
- 2026/04/04 19:11
- 提交
- a82e54f
这是一个合并提交,下面是和第一个上一提交相比的改动。
Add runtime.example.sh and document global runtime setup
这是一个合并提交,下面是和第一个上一提交相比的改动。
| @@ -141,11 +141,46 @@ pip install pandas numpy | ||
| 141 | 141 | |
| 142 | 142 | ### Per-user runtime: `~/.agent-vm/runtime.sh` |
| 143 | 143 | |
| 144 | 删除:Create this file to run commands inside every VM on each start. Runs before the per-project runtime script: | |
| 144 | 新增:Create this file to run commands inside every VM on each start. It runs **before** the per-project `.agent-vm.runtime.sh` script. | |
| 145 | 新增: | |
| 146 | 新增:Use it for anything that should be available in all your VMs: SSH keys, git config, GitHub CLI auth, Claude Code skills, MCP servers, etc. | |
| 147 | 新增: | |
| 148 | 新增:**Getting started:** | |
| 149 | 新增: | |
| 150 | 新增:```bash | |
| 151 | 新增:cp runtime.example.sh ~/.agent-vm/runtime.sh | |
| 152 | 新增:# Edit with your own values | |
| 153 | 新增:``` | |
| 154 | 新增: | |
| 155 | 新增:See [`runtime.example.sh`](runtime.example.sh) for a fully commented template covering: | |
| 156 | 新增:- SSH key injection for GitHub (base64-encoded private key) | |
| 157 | 新增:- Git identity and SSH-forced remotes (`url.insteadOf`) | |
| 158 | 新增:- GitHub CLI authentication (`gh auth login --with-token`) | |
| 159 | 新增:- Claude Code skills installation (global and per-project) | |
| 160 | 新增:- MCP server registration (`claude mcp add --scope user`) | |
| 161 | 新增:- Status line configuration in `~/.claude/settings.json` | |
| 162 | 新增: | |
| 163 | 新增:**Encoding your SSH key:** | |
| 164 | 新增: | |
| 165 | 新增:```bash | |
| 166 | 新增:cat ~/.ssh/id_ed25519 | base64 | |
| 167 | 新增:``` | |
| 168 | 新增: | |
| 169 | 新增:Paste the output into your `runtime.sh` — the script decodes it at boot and sets up `~/.ssh` with proper permissions. | |
| 170 | 新增: | |
| 171 | 新增:**Global vs per-project runtime:** | |
| 172 | 新增: | |
| 173 | 新增:| File | Scope | Runs when | | |
| 174 | 新增:|------|-------|-----------| | |
| 175 | 新增:| `~/.agent-vm/runtime.sh` | All VMs | Every VM start, first | | |
| 176 | 新增:| `.agent-vm.runtime.sh` | Current project only | Every VM start, after global | | |
| 177 | 新增: | |
| 178 | 新增:**Important:** Always launch `agent-vm` from a path without spaces. macOS iCloud paths contain spaces (`~/Library/Mobile Documents/...`), which can break mounts. Create a symlink instead: | |
| 145 | 179 | |
| 146 | 180 | ```bash |
| 147 | 删除:# ~/.agent-vm/runtime.sh | |
| 148 | 删除:export MY_API_KEY="..." | |
| 181 | 新增:ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/Dev ~/Dev | |
| 182 | 新增:cd ~/Dev/your-project | |
| 183 | 新增:agent-vm claude | |
| 149 | 184 | ``` |
| 150 | 185 | |
| 151 | 186 | ### Per-project: `.agent-vm.runtime.sh` |
| @@ -0,0 +1,104 @@ | ||
| 1 | 新增:#!/bin/bash | |
| 2 | 新增:# ============================================================================= | |
| 3 | 新增:# runtime.example.sh — Template for ~/.agent-vm/runtime.sh | |
| 4 | 新增:# ============================================================================= | |
| 5 | 新增:# | |
| 6 | 新增:# This file runs inside every agent-vm on each start, before the per-project | |
| 7 | 新增:# .agent-vm.runtime.sh script. Copy it to ~/.agent-vm/runtime.sh and uncomment | |
| 8 | 新增:# the sections you need. | |
| 9 | 新增:# | |
| 10 | 新增:# To get started: | |
| 11 | 新增:# cp runtime.example.sh ~/.agent-vm/runtime.sh | |
| 12 | 新增:# # Edit the file with your own values | |
| 13 | 新增:# chmod +x ~/.agent-vm/runtime.sh | |
| 14 | 新增: | |
| 15 | 新增: | |
| 16 | 新增:# ============================================================================= | |
| 17 | 新增:# 1. SSH authentication for GitHub | |
| 18 | 新增:# ============================================================================= | |
| 19 | 新增:# | |
| 20 | 新增:# Embed your SSH private key (base64-encoded) so the VM can push/pull over SSH. | |
| 21 | 新增:# | |
| 22 | 新增:# To encode your key: | |
| 23 | 新增:# cat ~/.ssh/id_ed25519 | base64 | |
| 24 | 新增:# | |
| 25 | 新增:# Paste the output below: | |
| 26 | 新增: | |
| 27 | 新增:# SSH_KEY_B64="<your-base64-encoded-private-key>" | |
| 28 | 新增:# mkdir -p ~/.ssh && chmod 700 ~/.ssh | |
| 29 | 新增:# echo "$SSH_KEY_B64" | base64 -d > ~/.ssh/id_ed25519 | |
| 30 | 新增:# chmod 600 ~/.ssh/id_ed25519 | |
| 31 | 新增:# ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null | |
| 32 | 新增: | |
| 33 | 新增: | |
| 34 | 新增:# ============================================================================= | |
| 35 | 新增:# 2. Git configuration | |
| 36 | 新增:# ============================================================================= | |
| 37 | 新增: | |
| 38 | 新增:# git config --global user.name "Your Name" | |
| 39 | 新增:# git config --global user.email "[email protected]" | |
| 40 | 新增: | |
| 41 | 新增:# Force SSH for all GitHub remotes (avoids HTTPS credential prompts) | |
| 42 | 新增:# git config --global url."[email protected]:".insteadOf "https://github.com/" | |
| 43 | 新增: | |
| 44 | 新增: | |
| 45 | 新增:# ============================================================================= | |
| 46 | 新增:# 3. GitHub CLI authentication | |
| 47 | 新增:# ============================================================================= | |
| 48 | 新增:# | |
| 49 | 新增:# Required for creating PRs, commenting on issues, etc. from inside the VM. | |
| 50 | 新增:# | |
| 51 | 新增:# To create a token: https://github.com/settings/tokens | |
| 52 | 新增:# Scopes needed: repo, read:org | |
| 53 | 新增:# | |
| 54 | 新增:# echo "<your-github-pat>" | gh auth login --with-token | |
| 55 | 新增: | |
| 56 | 新增: | |
| 57 | 新增:# ============================================================================= | |
| 58 | 新增:# 4. Claude Code skills | |
| 59 | 新增:# ============================================================================= | |
| 60 | 新增:# | |
| 61 | 新增:# Clone shared skills into the global skills directory. | |
| 62 | 新增:# These will be available in all projects. | |
| 63 | 新增: | |
| 64 | 新增:# mkdir -p ~/.claude/skills | |
| 65 | 新增:# git clone [email protected]:your-org/claude-skills.git ~/.claude/skills/your-org-skills | |
| 66 | 新增: | |
| 67 | 新增:# You can also install skills into the current project's directory. | |
| 68 | 新增:# These will only be available when working in that project. | |
| 69 | 新增: | |
| 70 | 新增:# PROJECT_DIR="$(pwd)" | |
| 71 | 新增:# mkdir -p "$PROJECT_DIR/.claude/skills" | |
| 72 | 新增:# git clone [email protected]:your-org/project-skills.git "$PROJECT_DIR/.claude/skills/project-skills" | |
| 73 | 新增: | |
| 74 | 新增: | |
| 75 | 新增:# ============================================================================= | |
| 76 | 新增:# 5. MCP servers | |
| 77 | 新增:# ============================================================================= | |
| 78 | 新增:# | |
| 79 | 新增:# Add MCP servers available to Claude Code in all projects (--scope user). | |
| 80 | 新增:# | |
| 81 | 新增:# claude mcp add --scope user my-mcp-server npx -y my-mcp-server@latest | |
| 82 | 新增: | |
| 83 | 新增: | |
| 84 | 新增:# ============================================================================= | |
| 85 | 新增:# 6. Claude Code status line | |
| 86 | 新增:# ============================================================================= | |
| 87 | 新增:# | |
| 88 | 新增:# Install a custom status line command in ~/.claude/settings.json. | |
| 89 | 新增:# The command output is displayed at the bottom of the Claude Code interface. | |
| 90 | 新增:# | |
| 91 | 新增:# For example, to show the current git branch: | |
| 92 | 新增:# | |
| 93 | 新增:# cat > /tmp/statusline-patch.json << 'PATCH' | |
| 94 | 新增:# {"statusLine": {"command": "git branch --show-current 2>/dev/null || echo ''"}} | |
| 95 | 新增:# PATCH | |
| 96 | 新增:# | |
| 97 | 新增:# if [ -f ~/.claude/settings.json ]; then | |
| 98 | 新增:# jq -s '.[0] * .[1]' ~/.claude/settings.json /tmp/statusline-patch.json > /tmp/settings-merged.json | |
| 99 | 新增:# mv /tmp/settings-merged.json ~/.claude/settings.json | |
| 100 | 新增:# else | |
| 101 | 新增:# mkdir -p ~/.claude | |
| 102 | 新增:# cp /tmp/statusline-patch.json ~/.claude/settings.json | |
| 103 | 新增:# fi | |
| 104 | 新增:# rm -f /tmp/statusline-patch.json | |