From cd7cc2b0476d1487b57c9387c4d4ae659f2519a0 Mon Sep 17 00:00:00 2001 From: sunwrobert Date: Mon, 9 Nov 2026 13:26:03 +1100 Subject: [PATCH 1/5] feat: add Brewfile for machine setup --- setup/Brewfile | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 setup/Brewfile diff --git a/setup/Brewfile b/setup/Brewfile new file mode 100644 index 0000000..d8dd555 --- /dev/null +++ b/setup/Brewfile @@ -0,0 +1,63 @@ +tap "hashicorp/tap" +tap "infisical/get-cli" +tap "oven-sh/bun" +tap "speakeasy-api/tap" +tap "withgraphite/tap" + +# Languages and package managers +brew "fnm" +brew "mise" +brew "oven-sh/bun/bun" +brew "pnpm" +brew "uv" + +# Git +brew "git" +brew "gh" +brew "withgraphite/tap/graphite" +brew "gnupg" + +# Shell utilities +brew "jq" +brew "hurl" +brew "hyperfine" +brew "k6" +brew "ffmpeg" +brew "imagemagick" + +# Infrastructure +brew "tilt" +brew "helm" +brew "argocd" +brew "opentofu" +brew "hashicorp/tap/terraform" +brew "infisical/get-cli/infisical" +brew "stripe-cli" +brew "speakeasy-api/tap/speakeasy" +brew "postgresql@18" + +# Command line casks +cask "1password-cli" +cask "gcloud-cli" +cask "orbstack" + +# Apps +cask "1password" +cask "caffeine" +cask "cap" +cask "chatgpt" +cask "claude" +cask "conductor" +cask "cursor" +cask "discord" +cask "ghostty" +cask "google-chrome" +cask "granola" +cask "linear-linear" +cask "notion" +cask "obsidian" +cask "raycast" +cask "slack" +cask "t3-code@nightly" +cask "yaak" +cask "zed@preview" From 81e814adaa889ecdbe2eb6e6acb74100ebdbcd76 Mon Sep 17 00:00:00 2001 From: sunwrobert Date: Mon, 9 Nov 2026 13:26:04 +1100 Subject: [PATCH 2/5] feat: add dotfiles for machine setup --- setup/dotfiles/gitconfig | 24 +++++++++++++++++++++++ setup/dotfiles/herdr/config.toml | 17 ++++++++++++++++ setup/dotfiles/zed/settings.json | 33 ++++++++++++++++++++++++++++++++ setup/dotfiles/zprofile | 4 ++++ setup/dotfiles/zshrc | 26 +++++++++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 setup/dotfiles/gitconfig create mode 100644 setup/dotfiles/herdr/config.toml create mode 100644 setup/dotfiles/zed/settings.json create mode 100644 setup/dotfiles/zprofile create mode 100644 setup/dotfiles/zshrc diff --git a/setup/dotfiles/gitconfig b/setup/dotfiles/gitconfig new file mode 100644 index 0000000..f9d37a6 --- /dev/null +++ b/setup/dotfiles/gitconfig @@ -0,0 +1,24 @@ +[alias] + co = checkout + cob = checkout -b + sw = switch + swc = switch -c + br = branch + st = status --short --branch + aa = add --all + ap = add --patch + ci = commit + cm = commit -m + ca = commit --amend + df = diff + ds = diff --staged + unstage = reset HEAD -- + last = log -1 HEAD + lg = log --graph --pretty=format:%C(auto)%h%C(reset) %C(auto)%d%C(reset) %s %C(dim white)- %an, %ar%C(reset) --all + rb = rebase + rbi = rebase --interactive + cp = cherry-pick + aliases = !git config --get-regexp \"^alias\\\\.\" +[user] + name = sunwrobert + email = sunwrobert@gmail.com diff --git a/setup/dotfiles/herdr/config.toml b/setup/dotfiles/herdr/config.toml new file mode 100644 index 0000000..1b1c560 --- /dev/null +++ b/setup/dotfiles/herdr/config.toml @@ -0,0 +1,17 @@ +onboarding = false + +[ui.sound] +enabled = true + +[[keys.command]] +key = "prefix+f" +type = "plugin_action" +command = "herdr-file-viewer.open-file-viewer" +description = "open file viewer in split" + +[[keys.command]] +key = "prefix+shift+f" +type = "plugin_action" +command = "herdr-file-viewer.open-file-viewer-tab" +description = "open file viewer in tab" + diff --git a/setup/dotfiles/zed/settings.json b/setup/dotfiles/zed/settings.json new file mode 100644 index 0000000..a3922b0 --- /dev/null +++ b/setup/dotfiles/zed/settings.json @@ -0,0 +1,33 @@ +// Zed settings +// +// For information on how to configure Zed, see the Zed +// documentation: https://zed.dev/docs/configuring-zed +// +// To see all of Zed's default settings without changing your +// custom settings, run `zed: open default settings` from the +// command palette (cmd-shift-p / ctrl-shift-p) +{ + "edit_predictions": { + "provider": "zed" + }, + "project_panel": { + "dock": "left" + }, + "session": { + "trust_all_worktrees": true + }, + "vim_mode": true, + "base_keymap": "Cursor", + "icon_theme": { + "mode": "dark", + "light": "Catppuccin Frappé", + "dark": "Catppuccin Frappé" + }, + "ui_font_size": 16, + "buffer_font_size": 15, + "theme": { + "mode": "dark", + "light": "One Light", + "dark": "Catppuccin Macchiato" + } +} diff --git a/setup/dotfiles/zprofile b/setup/dotfiles/zprofile new file mode 100644 index 0000000..718046d --- /dev/null +++ b/setup/dotfiles/zprofile @@ -0,0 +1,4 @@ +export PATH="$HOME/.local/bin:$PATH" + +# OrbStack command-line tools and integration +source ~/.orbstack/shell/init.zsh 2>/dev/null || : diff --git a/setup/dotfiles/zshrc b/setup/dotfiles/zshrc new file mode 100644 index 0000000..7c373f6 --- /dev/null +++ b/setup/dotfiles/zshrc @@ -0,0 +1,26 @@ +export ZSH="$HOME/.oh-my-zsh" +ZSH_THEME="robbyrussell" +plugins=(git zsh-autosuggestions zsh-syntax-highlighting) +source "$ZSH/oh-my-zsh.sh" + +# fnm +if command -v fnm >/dev/null 2>&1; then + eval "$(fnm env --shell zsh)" +fi + +# bun +export BUN_INSTALL="$HOME/.bun" +export PATH="$BUN_INSTALL/bin:$PATH" +[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun" + +export PATH="$HOME/.local/bin:$HOME/.opencode/bin:$PATH" + +# Secrets and machine-specific settings live outside the repo. +[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local" + +# Route Claude Code through OpenRouter when a key is set in ~/.zshrc.local. +if [ -n "$OPENROUTER_API_KEY" ]; then + export ANTHROPIC_BASE_URL="https://openrouter.ai/api" + export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" + export ANTHROPIC_API_KEY="" # Must be explicitly empty +fi From 65b61302a845ba8911bb23862516387946b8d686 Mon Sep 17 00:00:00 2001 From: sunwrobert Date: Mon, 9 Nov 2026 13:26:05 +1100 Subject: [PATCH 3/5] feat: add one-stop machine setup script --- setup/setup.sh | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 setup/setup.sh diff --git a/setup/setup.sh b/setup/setup.sh new file mode 100755 index 0000000..6c1fb85 --- /dev/null +++ b/setup/setup.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# One-stop setup for a new Mac. Safe to run again. +set -euo pipefail + +SETUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_DIR="$(dirname "$SETUP_DIR")" +DOTFILES="$SETUP_DIR/dotfiles" +NODE_VERSION="24" + +step() { printf '\n==> %s\n' "$1"; } + +# Symlink $1 to $2, moving any existing real file aside first. +link() { + local source="$1" target="$2" + mkdir -p "$(dirname "$target")" + if [ -e "$target" ] && [ ! -L "$target" ]; then + mv "$target" "$target.backup.$(date +%Y%m%d%H%M%S)" + fi + ln -sfn "$source" "$target" + echo "linked $target" +} + +if [ "$(uname)" != "Darwin" ]; then + echo "This script only supports macOS." >&2 + exit 1 +fi + +step "Xcode command line tools" +if ! xcode-select -p >/dev/null 2>&1; then + xcode-select --install + echo "Finish the installer, then run this script again." + exit 0 +fi + +step "Homebrew" +if ! command -v brew >/dev/null 2>&1 && [ ! -x /opt/homebrew/bin/brew ]; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi +if [ -x /opt/homebrew/bin/brew ]; then + eval "$(/opt/homebrew/bin/brew shellenv)" +fi + +step "Apps and command line tools" +brew bundle --file "$SETUP_DIR/Brewfile" + +step "Oh My Zsh" +ZSH_DIR="$HOME/.oh-my-zsh" +if [ ! -d "$ZSH_DIR" ]; then + RUNZSH=no CHSH=no KEEP_ZSHRC=yes \ + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +fi +for plugin in zsh-autosuggestions zsh-syntax-highlighting; do + plugin_dir="$ZSH_DIR/custom/plugins/$plugin" + [ -d "$plugin_dir" ] || + git clone --depth 1 "https://github.com/zsh-users/$plugin" "$plugin_dir" +done + +step "Dotfiles" +link "$DOTFILES/zshrc" "$HOME/.zshrc" +link "$DOTFILES/zprofile" "$HOME/.zprofile" +# Included, not linked, so tools that write to ~/.gitconfig leave the repo clean. +git config --global --get-all include.path | grep -qxF "$DOTFILES/gitconfig" || + git config --global --add include.path "$DOTFILES/gitconfig" +link "$DOTFILES/zed/settings.json" "$HOME/.config/zed/settings.json" +link "$DOTFILES/herdr/config.toml" "$HOME/.config/herdr/config.toml" +if [ ! -f "$HOME/.zshrc.local" ]; then + printf '# Secrets and machine-specific settings. Never commit this file.\n# export OPENROUTER_API_KEY=""\n' >"$HOME/.zshrc.local" + chmod 600 "$HOME/.zshrc.local" + echo "created ~/.zshrc.local" +fi + +step "Node" +eval "$(fnm env --shell bash)" +fnm install "$NODE_VERSION" +fnm default "$NODE_VERSION" +fnm use "$NODE_VERSION" + +step "Global npm and bun packages" +npm install --global \ + @earendil-works/pi-coding-agent \ + @openai/codex \ + agent-browser \ + executor \ + hunkdiff \ + prime-agent +bun add --global @oh-my-pi/pi-coding-agent + +step "Claude Code" +command -v claude >/dev/null 2>&1 || [ -x "$HOME/.local/bin/claude" ] || + curl -fsSL https://claude.ai/install.sh | bash + +step "Agent skills" +mkdir -p "$HOME/.agents/skills" "$HOME/.claude/skills" +for skill_dir in "$REPO_DIR"/skills/*/; do + name="$(basename "$skill_dir")" + [ -e "$HOME/.agents/skills/$name" ] || + ln -s "${skill_dir%/}" "$HOME/.agents/skills/$name" + [ -e "$HOME/.claude/skills/$name" ] || + ln -s "../../.agents/skills/$name" "$HOME/.claude/skills/$name" +done + +step "Done" +echo "Open a new terminal, then follow the manual steps in setup/README.md." +echo "Or hand setup/AGENT_PROMPT.md to a coding agent to finish and verify." From 3f35a4a0fe3e33e7be211c69320beca843e830a9 Mon Sep 17 00:00:00 2001 From: sunwrobert Date: Mon, 9 Nov 2026 13:26:05 +1100 Subject: [PATCH 4/5] docs: document machine setup and add agent prompt --- README.md | 1 + setup/AGENT_PROMPT.md | 29 +++++++++++++++++++++++++++++ setup/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 setup/AGENT_PROMPT.md create mode 100644 setup/README.md diff --git a/README.md b/README.md index 830358a..4fcce76 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ knowledge-base/ ├── AGENTS.md # Shared agent instructions (code philosophy, etc.) ├── CLAUDE.md -> AGENTS.md # Symlink for Claude Code compatibility ├── scripts/ # Utility scripts +├── setup/ # New Mac setup: Brewfile, dotfiles, setup.sh └── skills/ # Portable agent skills ``` diff --git a/setup/AGENT_PROMPT.md b/setup/AGENT_PROMPT.md new file mode 100644 index 0000000..ee2138f --- /dev/null +++ b/setup/AGENT_PROMPT.md @@ -0,0 +1,29 @@ +# Agent Prompt: Set Up This Mac + +Paste everything below into a coding agent running on the new machine. + +--- + +Set up this Mac from my knowledge-base repo. + +## Steps + +1. If `~/Repositories/knowledge-base` does not exist, clone `https://github.com/sunwrobert/knowledge-base.git` there. +2. Read `setup/README.md` and `setup/setup.sh` before running anything. +3. Run `setup/setup.sh`. If it stops for the Xcode command line tools installer, wait for me to finish it, then run the script again. +4. If a step fails, find the cause, fix it and run the script again. It is safe to run more than once. If a Homebrew cask no longer exists, tell me instead of substituting another one. +5. Verify the result: + - `brew bundle check --file setup/Brewfile` passes. + - `git`, `gh`, `gt`, `bun`, `pnpm`, `node`, `uv`, `tilt`, `tofu`, `infisical`, `pi`, `codex`, `claude`, `omp` and `agent-browser` all resolve in a new login shell (`zsh -lic 'command -v '`). + - `~/.zshrc`, `~/.zprofile`, `~/.config/zed/settings.json` and `~/.config/herdr/config.toml` are symlinks into `setup/dotfiles`. + - `git config --global --get-all include.path` lists `setup/dotfiles/gitconfig`. + - `~/.agents/skills` contains the skills from the repo. +6. Report what was installed, what failed, and the manual steps from `setup/README.md` that are still open. + +## Rules + +- Never write a secret, API key or token to any file in the repo. Secrets go in `~/.zshrc.local` only, and I enter them myself. +- Do not log in to any account for me. List the login commands I need to run. +- Do not install or remove employer-managed software such as device management, security or compliance agents. +- Do not commit or push changes to the repo unless I ask. +- Do not delete the `.backup.` files the script creates. diff --git a/setup/README.md b/setup/README.md new file mode 100644 index 0000000..061f13f --- /dev/null +++ b/setup/README.md @@ -0,0 +1,41 @@ +# Machine Setup + +One script sets up a new Mac: apps, command line tools, shell, dotfiles, Node, global packages and agent skills. + +## Run + +```bash +git clone https://github.com/sunwrobert/knowledge-base.git ~/Repositories/knowledge-base +~/Repositories/knowledge-base/setup/setup.sh +``` + +The script is safe to run again. Existing dotfiles are moved to `.backup.` before they are replaced with symlinks into this folder. `~/.gitconfig` is the exception: it stays a real file that includes `dotfiles/gitconfig`. + +## Contents + +- `Brewfile`: Homebrew formulae and casks. +- `dotfiles/`: `zshrc`, `zprofile`, `gitconfig`, Zed settings and Herdr config. +- `setup.sh`: the setup script. +- `AGENT_PROMPT.md`: a prompt that has a coding agent run and verify the setup. + +## Manual Steps + +1. Sign in to 1Password and turn on its SSH agent. +2. Run `gh auth login`, `gh auth setup-git`, `gt auth` and `gcloud auth login`. +3. Put secrets in `~/.zshrc.local`, for example `OPENROUTER_API_KEY`. +4. Install the apps with no Homebrew cask: Devin, Hex, Magnet, Ports, PR Review, Readout, Grok Bot, Rex Beta and Xcode. +5. Install the command line tools with no package: `herdr`, `fx` and `devin`. +6. Import Raycast settings. + +## Not Included + +- Secrets: SSH keys, API keys and auth tokens. +- Apps and agents an employer installs. + +## Updating + +Add a tool to `Brewfile` or the package list in `setup.sh` when you start using it. Edit dotfiles in place; they are symlinks into this repo. + +## With An Agent + +Once a coding agent is installed, paste `AGENT_PROMPT.md` into it. The agent runs the script, fixes failures, checks the result and lists the manual steps that are left. From 7bdee08e4351650b8222a487ab318dd08ec5a2e7 Mon Sep 17 00:00:00 2001 From: sunwrobert Date: Mon, 9 Nov 2026 13:43:34 +1100 Subject: [PATCH 5/5] feat: use ori login for agent credentials in machine setup --- setup/AGENT_PROMPT.md | 1 + setup/README.md | 7 ++++--- setup/dotfiles/zshrc | 7 ------- setup/setup.sh | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/setup/AGENT_PROMPT.md b/setup/AGENT_PROMPT.md index ee2138f..8097629 100644 --- a/setup/AGENT_PROMPT.md +++ b/setup/AGENT_PROMPT.md @@ -24,6 +24,7 @@ Set up this Mac from my knowledge-base repo. - Never write a secret, API key or token to any file in the repo. Secrets go in `~/.zshrc.local` only, and I enter them myself. - Do not log in to any account for me. List the login commands I need to run. +- Do not put an OpenRouter key in any shell file. Agents get their credential from `ori login`. - Do not install or remove employer-managed software such as device management, security or compliance agents. - Do not commit or push changes to the repo unless I ask. - Do not delete the `.backup.` files the script creates. diff --git a/setup/README.md b/setup/README.md index 061f13f..de09a75 100644 --- a/setup/README.md +++ b/setup/README.md @@ -22,10 +22,11 @@ The script is safe to run again. Existing dotfiles are moved to `.backup.< 1. Sign in to 1Password and turn on its SSH agent. 2. Run `gh auth login`, `gh auth setup-git`, `gt auth` and `gcloud auth login`. -3. Put secrets in `~/.zshrc.local`, for example `OPENROUTER_API_KEY`. -4. Install the apps with no Homebrew cask: Devin, Hex, Magnet, Ports, PR Review, Readout, Grok Bot, Rex Beta and Xcode. -5. Install the command line tools with no package: `herdr`, `fx` and `devin`. +3. Install the command line tools with no package: `ori`, `herdr`, `fx` and `devin`. +4. Run `ori login`, then `ori alias` so plain `pi`, `claude`, `codex` and `omp` run through Ori. No OpenRouter key goes in the shell config. +5. Install the apps with no Homebrew cask: Devin, Hex, Magnet, Ports, PR Review, Readout, Grok Bot, Rex Beta and Xcode. 6. Import Raycast settings. +7. Put any other secrets in `~/.zshrc.local`, which the script creates and git never sees. ## Not Included diff --git a/setup/dotfiles/zshrc b/setup/dotfiles/zshrc index 7c373f6..a5232a0 100644 --- a/setup/dotfiles/zshrc +++ b/setup/dotfiles/zshrc @@ -17,10 +17,3 @@ export PATH="$HOME/.local/bin:$HOME/.opencode/bin:$PATH" # Secrets and machine-specific settings live outside the repo. [ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local" - -# Route Claude Code through OpenRouter when a key is set in ~/.zshrc.local. -if [ -n "$OPENROUTER_API_KEY" ]; then - export ANTHROPIC_BASE_URL="https://openrouter.ai/api" - export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" - export ANTHROPIC_API_KEY="" # Must be explicitly empty -fi diff --git a/setup/setup.sh b/setup/setup.sh index 6c1fb85..7758d9c 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -64,7 +64,7 @@ git config --global --get-all include.path | grep -qxF "$DOTFILES/gitconfig" || link "$DOTFILES/zed/settings.json" "$HOME/.config/zed/settings.json" link "$DOTFILES/herdr/config.toml" "$HOME/.config/herdr/config.toml" if [ ! -f "$HOME/.zshrc.local" ]; then - printf '# Secrets and machine-specific settings. Never commit this file.\n# export OPENROUTER_API_KEY=""\n' >"$HOME/.zshrc.local" + printf '# Secrets and machine-specific settings. Never commit this file.\n' >"$HOME/.zshrc.local" chmod 600 "$HOME/.zshrc.local" echo "created ~/.zshrc.local" fi