Skip to content

Commit e337769

Browse files
ai: added warp file
1 parent abc6a6c commit e337769

1 file changed

Lines changed: 192 additions & 0 deletions

File tree

WARP.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# WARP.md
2+
3+
This file provides guidance to WARP (warp.dev) when working with code in this repository.
4+
5+
## Key commands
6+
7+
### Bootstrap entrypoint
8+
9+
The main entrypoint is `bootstrap.sh`, which orchestrates both machine setup and dotfiles installation.
10+
11+
General usage (from `bootstrap.sh -h`):
12+
13+
- Command: `bash bootstrap.sh -b <command> [options]`
14+
- Commands:
15+
- `machine` – bootstrap a macOS/Fedora/ArchLinux machine
16+
- `dotfiles` – bootstrap dotfiles into `$HOME`
17+
- Common options:
18+
- `-d` – enable debug output (passes `-x` to underlying shell scripts)
19+
- `-s <profile>` – profile to install (case sensitive)
20+
- `perso`, `work` (dotfiles profiles)
21+
- `normal`, `admin`, `dev_single`, `dev_multi` (machine profiles)
22+
- `-t <shell>` – default shell (`bash` or `zsh`, default `zsh`)
23+
- `-p <path>` – absolute path to the companion `dotfiles-private` repository
24+
25+
Run `bash bootstrap.sh -h` for full, up‑to‑date usage.
26+
27+
### Bootstrapping a macOS machine
28+
29+
The README describes a two‑step workflow: bootstrap the machine, then bootstrap configuration files.
30+
31+
**Machine bootstrap (macOS):**
32+
33+
- Standard user:
34+
- `git clone --recursive https://github.com/davidandreoletti/dotfiles.git`
35+
- `cd dotfiles`
36+
- `bash -x bootstrap.sh -b machine -s normal -p "$(pwd)/../dotfiles-private"`
37+
- Administrator account:
38+
- Same as above, with `-s admin`
39+
- Primary developer account (single dev machine):
40+
- Same, with `-s dev_single`
41+
- Secondary developer accounts (multi‑dev machine):
42+
- Same, with `-s dev_multi`
43+
44+
**Dotfiles bootstrap (macOS, first install):**
45+
46+
- Install public + private dotfiles into `$HOME`:
47+
- `git clone --recursive https://github.com/davidandreoletti/dotfiles.git`
48+
- `cd dotfiles`
49+
- `bash bootstrap.sh -b dotfiles -s perso -t bash -p "$(pwd)/../dotfiles-private"`
50+
51+
**Dotfiles update (macOS and Linux):**
52+
53+
- Update this repo and re‑stow configuration files into `$HOME`:
54+
- `cd dotfiles`
55+
- `git pull`
56+
- `git submodule update --recursive --remote`
57+
- `bash bootstrap.sh -b dotfiles -s perso`
58+
59+
### Bootstrapping Fedora and ArchLinux machines
60+
61+
The workflows for Fedora and ArchLinux mirror the macOS flow, but rely on the native package manager and a slightly different set of OS‑specific scripts.
62+
63+
**Fedora:**
64+
65+
- Standard user: `bash -x bootstrap.sh -b machine -s normal -p "$(pwd)/../dotfiles-private"`
66+
- Administrator: `bash -x bootstrap.sh -b machine -s admin -p "$(pwd)/../dotfiles-private"`
67+
- Primary developer: `bash -x bootstrap.sh -b machine -s dev_single -p "$(pwd)/../dotfiles-private"`
68+
- Secondary developer: `bash -x bootstrap.sh -b machine -s dev_multi -p "$(pwd)/../dotfiles-private"`
69+
70+
**ArchLinux:**
71+
72+
- Standard user: `bash -x bootstrap.sh -b machine -s normal -p "$(pwd)/../dotfiles-private"`
73+
- Administrator: `bash -x bootstrap.sh -b machine -s admin -p "$(pwd)/../dotfiles-private"`
74+
- Primary developer: `bash -x bootstrap.sh -b machine -s dev_single -p "$(pwd)/../dotfiles-private"`
75+
- Secondary developer: `bash -x bootstrap.sh -b machine -s dev_multi -p "$(pwd)/../dotfiles-private"`
76+
77+
### CI / bootstrap tests
78+
79+
There is no standalone unit‑test suite; CI exercises the end‑to‑end bootstrap flows via GitHub Actions in `.github/workflows/test_bootstrap.yml`.
80+
81+
- The matrix jobs call reusable workflows (`bootstrap_on_macos.yaml`, `bootstrap_on_fedora.yaml`, `bootstrap_on_archlinux.yaml`), which in turn:
82+
- Set `BOOTSTRAP_MODE=noninteractive`.
83+
- Configure various `BOOTSTRAP_SKIP_*` flags to control optional steps.
84+
- Run `bash bootstrap.sh -d -b machine -s <profile>` and, when requested, `bash bootstrap.sh -d -b dotfiles -s <profile>`.
85+
86+
To approximate a single CI scenario locally (for example, macOS `dev_single`):
87+
88+
- `export BOOTSTRAP_MODE=noninteractive`
89+
- Optionally export the same `BOOTSTRAP_SKIP_*` variables as in `bootstrap_on_macos.yaml` to skip interactive steps.
90+
- Run:
91+
- `bash bootstrap.sh -d -b machine -s dev_single`
92+
- `bash bootstrap.sh -d -b dotfiles -s dev_single`
93+
94+
This is effectively the closest thing to a “single test case” in this repository.
95+
96+
## Architecture overview
97+
98+
### Top‑level responsibilities
99+
100+
At a high level, this repository provides:
101+
102+
- **Machine bootstrapping** for macOS, Fedora, and ArchLinux (system packages, user accounts, services, backups, GUI apps, etc.).
103+
- **Dotfiles management** using GNU Stow, including integration with a separate `dotfiles-private` repository for secrets.
104+
- **Shell environment management** via a custom multi‑shell framework (`.oh-my-shell`).
105+
- **Application‑specific configuration and utilities** (e.g., Vim/Neovim upgrade scripts, browser extension installers, cron jobs, small helper binaries).
106+
107+
These concerns are wired together by `bootstrap.sh` and a set of supporting scripts under `install/` and `.oh-my-shell/`.
108+
109+
### `bootstrap.sh`: orchestration layer
110+
111+
`bootstrap.sh` is the main orchestrator and is responsible for:
112+
113+
- Parsing CLI arguments (`-b`, `-s`, `-t`, `-p`, `-d`).
114+
- Canonicalizing the `dotfiles-private` path when possible and warning when `greadlink` is missing.
115+
- Loading reusable helpers from `install/common/shell/os.sh` and `install/common/shell/stow.sh`.
116+
- Dispatching based on the `-b` command:
117+
- `machine` – detects the OS (`is_macos`, `is_fedora`, `is_archl`) and calls `install/bootstrap_macos.sh`, `install/bootstrap_fedora.sh`, or `install/bootstrap_archlinux.sh`.
118+
- `dotfiles` – performs user‑level setup (shell, PATH, symlinks, Vim/Neovim plugins).
119+
120+
Within the `dotfiles` branch it:
121+
122+
- Optionally changes the default shell (guarded by `BOOTSTRAP_SKIP_SHELL_CHANGE`).
123+
- Calls `bootstrap_homebrew_path`, which sources `.oh-my-shell/shellrc/bootstrap/helper*.sh` to locate Homebrew and export its environment.
124+
- Calls `bootstrap_dotfiles`, which stows dotfiles into `$HOME` using `stow_files`.
125+
- Ensures the repository itself is symlinked to `~/.dotfiles` for cron‑based maintenance.
126+
- Integrates the `dotfiles-private` repository via `bootstrap_dotfiles_private`, using its own helper binaries to check lock status and instruct the user to decrypt when necessary.
127+
- Marks `~/.bin/*` as executable so custom scripts are directly invocable from `$PATH`.
128+
- Triggers Vim/Neovim plugin installation via `install/bootstrap_vim_plugins.sh`.
129+
- Finishes by ensuring `.oh-my-shell` is wired into the user’s login shell RC and prints a ready message.
130+
131+
### `install/`: OS‑level bootstrap modules
132+
133+
The `install/` directory contains the bulk of the machine bootstrap logic, factored into reusable, OS‑agnostic modules and OS‑specific layers.
134+
135+
Key pieces:
136+
137+
- **OS dispatch and shared helpers:**
138+
- `install/common/shell/os.sh` – low‑level OS detection for macOS, generic Linux, Fedora, ArchLinux; must stay in sync with `.oh-my-shell/shellrc/bootstrap/helper2.sh`.
139+
- `install/common/shell/stow.sh` – wraps GNU Stow via `stow_files(user, sourceDir, destDir)` and enforces that `stow` is installed.
140+
- `install/common/shell/*.sh` – shared building blocks for package managers (Homebrew, DNF, pacman), language runtimes (Python, Rust, etc.), containers, systemd, tmux, VS Code integration, sudo helpers, and more.
141+
- **Per‑OS bootstrap scripts:**
142+
- `install/bootstrap_macos.sh` – orchestrates macOS setup: reads a profile from `config/config.sh`, manages sudo via an ephemeral RAM disk, ensures Xcode + CLI tools, installs Homebrew, applies system defaults (including Time Machine and SSD tuning), installs GUI and CLI apps (via `bootstrap_apps.sh`), and manages accounts (guest, dedicated admin account, demotion of the primary user when `dev_single`).
143+
- `install/bootstrap_fedora.sh` – similar orchestration for Fedora: seeds DNF, installs Homebrew, enables Flatpak and Snap, applies Fedora defaults, and wires up user/admin accounts.
144+
- `install/bootstrap_archlinux.sh` – equivalent bootstrap for ArchLinux: seeds pacman, installs Homebrew and related tools, configures defaults and backup tooling.
145+
- `install/bootstrap_os.sh` – additional OS‑environment conveniences (e.g., `zram` and `dnf-plugins-core` on Fedora) for admin‑type profiles.
146+
- **Applications / tools:**
147+
- `install/app/{vim,neovim}/upgrade.sh` – upgrade scripts for editor plugins/configuration.
148+
- `install/browsers/{chrome,firefox}/extensions/install.sh` – configure browser extensions; referenced from the macOS bootstrap script via `BOOTSTRAP_SKIP_BROWSER_EXTENSION_SETUP`.
149+
- **Configuration and utilities:**
150+
- `install/config/config.sh` – central configuration file for bootstrap (usernames, passwords, backup destinations, etc.); bootstrap scripts source this and then use helpers from `utils/` and `common/shell/`.
151+
- `install/utils/{debug.sh,message.sh,profile.sh,todolist.sh}` – logging, profiling, and “todolist” helpers used across bootstrap flows.
152+
153+
When extending machine bootstrap logic, new functionality should typically be implemented as a small helper in `install/common/shell/` or the relevant OS subdirectory, then invoked from the appropriate `install/bootstrap_*.sh` script.
154+
155+
### `.oh-my-shell/`: shell environment framework
156+
157+
`.oh-my-shell` is a custom, multi‑shell (bash/zsh) initialization framework that wires in Homebrew, the dotfiles layout, and a large set of pluggable tools.
158+
159+
Core flow:
160+
161+
- `~/.oh-my-shell/oh-my-shellrc` is sourced from the user’s default shell RC (e.g., `~/.bash_profile` or `~/.zshrc`) by `bootstrap_oh_my_shell()` in `bootstrap.sh`.
162+
- `oh-my-shellrc`:
163+
- Short‑circuits when the shell is non‑interactive.
164+
- Defines key paths (`SHELLRC_ROOT_DIR`, `SHELLRC_SHELLRC_DIR`, `SHELLRC_BOOTSTRAP_DIR`, `SHELLRC_PLUGINS_DIR`).
165+
- Resolves the dotfiles repo (`DOTFILES_HOME_LOCAL`) via `realpath`/`readlink`, and a private config root (`DOTFILES_PRIVATE_HOME_LOCAL`).
166+
- Loads the bootstrap helpers `helper.sh`, `helper2.sh`, `helper3.sh`, `helper4.sh`, and `init.sh`.
167+
- Calls `homebrew_init` to export the Homebrew environment, then caches `HOMEBREW_PACKAGES_INSTALL_DIR_PREFIX`.
168+
- Loads shell‑specific plugins (`environment`, `history`, completions, corrections, custom) in phases.
169+
- Iterates over each plugin under `shellrc/plugins/<name>` via `dot_plugin_if_exists`:
170+
- Prepends `bin/` to `PATH` when present.
171+
- Sources `environment.sh`, `functions.sh`, and `aliases.sh` (plus optional `private/*` variants).
172+
- Defers `completions.sh` and `post.sh` to asynchronous/background phases via per‑shell‑session marker files.
173+
- Optionally profiles load times when `SHELLRC_PROFILE_SPEED` is set, using `_timeNow`, `_timeInterval`, and `_reportIfSlowerThan` from `helper.sh`.
174+
175+
The bootstrap helpers in `.oh-my-shell/shellrc/bootstrap/` mirror some of the OS‑detection logic from `install/common/shell/os.sh` and add utilities for:
176+
177+
- Determining OS, shell, and terminal type (`get_os_type`, `get_shell_type`, `get_terminal_app_type`).
178+
- Managing PATH, MANPATH, and Info paths.
179+
- Creating, tearing down, and locking tasks via RAM disks and `flock` (used for more advanced workflows and background jobs).
180+
181+
When adding new environment features or tool integrations, the typical pattern is to create a new plugin directory under `.oh-my-shell/shellrc/plugins/<name>/` with `environment.sh`, `functions.sh`, `aliases.sh`, and optionally `completions.sh` and `post.sh`.
182+
183+
### Other notable directories
184+
185+
- `~/.bin/` (in this repo as `.bin/`) – user‑level CLI utilities made executable by `bootstrap_dotfiles_binaries()`. After dotfiles bootstrap, these are expected to be on `PATH` and used throughout the environment.
186+
- `.cron/` – cron job scaffolding grouped by schedule (e.g., `5min-any`, `daily-morning`, `weekday-any`), containing example scripts and maintenance tasks (such as Vim plugin upgrades). The bootstrap flow symlinks the repository into `~/.dotfiles` so cron jobs can reference a stable path.
187+
- `.config/` – application‑specific configuration, including Git hooks (`.config/git/hooks/`) and mail client helpers (`.config/mutt/`). These are managed via GNU Stow during dotfiles bootstrap.
188+
- `.studio/` – helper wrapper for the external “Studio” binary (download instructions in `.studio/README`).
189+
190+
### Upstream policy
191+
192+
The README notes that the main source of truth is `https://github.com/davidandreoletti/dotfiles` and that "No code contribution [is] accepted." When working locally in this clone, treat upstream as authoritative and keep changes compatible with the documented bootstrap flows and profiles.

0 commit comments

Comments
 (0)