195 lines
16 KiB
Markdown
195 lines
16 KiB
Markdown
The reason you are still seeing command not found is that darwin-rebuild does not exist on your computer yet.When doing a brand-new installation of nix-darwin, the darwin-rebuild tool is not part of the standard Nix installer. You have to bootstrap it using the nix run command first, which will dynamically pull the tool from GitHub and execute the initial build.Run the following command from your terminal inside your ~/.dotfiles directory:zshsudo nix run nix-darwin#darwin-rebuild -- switch --flake ~/.dotfiles#lt-mbp
|
|
|
|
## firstmate + Gitea (one-time per machine, secrets not in nix)
|
|
|
|
The firstmate crew dispatch + Gitea PR helper are wired by `darwin-rebuild`, but two secrets must be set manually per machine (nix cannot manage tokens without exposing them):
|
|
|
|
1. tea login (Gitea CLI auth against unraid):
|
|
zsh
|
|
tea login add --name unraid --url http://unraid.local:3003 --token <GITEA_TOKEN>
|
|
|
|
2. The Gitea token is the one in investor-flow's origin remote URL. After `tea login`, optionally clean the embedded creds from the remote:
|
|
zsh
|
|
cd ~/Documents/investor-flow
|
|
git remote set-url origin http://unraid.local:3003/transnet/investor-flow
|
|
|
|
Verify: `fm` and `fm-oc2` launch OpenCode 2 as the first mate and `fm-pi` is the explicit Pi fallback; `oc2 --version` prints the Homebrew opencode version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works.
|
|
|
|
## firstmate launcher and crew model routing
|
|
|
|
`fm` is the permanent firstmate launcher. `fm-oc2` is the same launcher under its explicit OpenCode 2 name, so both aliases expand to the same command. They change to `~/Documents/firstmate` and execute `~/.local/bin/oc2`, which runs the Homebrew OpenCode build with the isolated `~/.config/opencode2/opencode.json` config. `fm-pi` starts Pi instead and remains only an explicit fallback. Never make Pi the default launcher.
|
|
|
|
The three aliases share one firstmate home. They read the same task records, inbox, and state. Each tool keeps its own chat history, so a conversation in OpenCode 2 does not appear in Pi, and the reverse. Quit the running primary before you start the other one. A single firstmate home serves one primary at a time.
|
|
|
|
`home.nix` owns all three aliases, so a rebuild regenerates them. The installed `~/.zshrc` changes only at the next activation.
|
|
|
|
Worker routing lives in `home/.config/firstmate/crew-dispatch.json`, which is symlinked to `~/Documents/firstmate/config/crew-dispatch.json`:
|
|
|
|
| Task | Harness | Model |
|
|
| --- | --- | --- |
|
|
| Default crewmates and scouts | opencode | opencode-go/deepseek-v4.1-flash |
|
|
| Documentation writing, updating, or review | opencode | opencode-go/beam-free |
|
|
| UI work with image context | opencode | opencode-go/deepseek-v4.1-flash |
|
|
| Design, architecture, and design review (preserved exception) | pi | openai-codex/gpt-6.1-sol at xhigh |
|
|
|
|
Firstmate matches the `when` text with judgment. It then passes concrete `--harness` and `--model` flags to `fm-spawn.sh`. The file has no Pi default.
|
|
|
|
`~/Documents/firstmate/config/crew-harness` stays `opencode`. `home.activation.firstmate` seeds it only when the file is absent, so a captain edit survives a rebuild.
|
|
|
|
The model IDs above were listed from a neutral directory with `OPENCODE_CONFIG=~/.config/opencode2/opencode.json opencode models`. Both `opencode-go/deepseek-v4.1-flash` and `opencode-go/beam-free` are exact IDs.
|
|
|
|
### no-mistakes pipeline models
|
|
|
|
The captain confirmed the split on 2026-11-15. Leave it unchanged:
|
|
|
|
- execution tool: Pi (`agent: [pi]`)
|
|
- general steps and fixers: `opencode-go/deepseek-v4.1-flash`
|
|
- reviewer: `opencode-go/glm-5.3-flash`
|
|
|
|
`home.activation.noMistakes` adds `agent_config` and `review_agents` only when those keys are absent. The live `~/.no-mistakes/config.yaml` also sets `agent_path_override.opencode`, which stays inactive while the execution tool is Pi. This repository has no `.no-mistakes.yaml`, so no repo-level override applies. Firstmate's own `.no-mistakes.yaml` applies only to the firstmate repository. Do not edit the live no-mistakes config by hand.
|
|
|
|
### Checks
|
|
|
|
```bash
|
|
./tests/fm-launcher.sh --live # installed zshrc; fails while it still launches Pi
|
|
./tests/fm-launcher.sh # generated zshrc; must pass
|
|
./tests/crew-dispatch.sh # routing via firstmate, model IDs via opencode models
|
|
./tests/rebuild-update-steps.sh # static audit of rebuild.sh update steps
|
|
./tests/run.sh # all checks
|
|
```
|
|
|
|
The launcher check sources the real generated zshrc in an interactive zsh. A `pi` spy on PATH and an `OPENCODE2_BIN` spy capture the launch of `fm`, `fm-oc2`, and `fm-pi`, record the working directory, and exit at once, so no firstmate session starts.
|
|
|
|
### Install after merge
|
|
|
|
The Nix sources in this repository are the durable record. The live files are generated, so do not edit them.
|
|
|
|
1. Merge the reviewed branch into the default branch.
|
|
2. Confirm `readlink ~/.dotfiles` names the checkout that holds the merged commit.
|
|
3. Run `./rebuild.sh` from that checkout.
|
|
4. Run `./tests/fm-launcher.sh --live` and `./tests/crew-dispatch.sh`.
|
|
5. Open a fresh shell and run `alias fm fm-oc2 fm-pi`. `fm` and `fm-oc2` must show `exec /Users/laptran/.local/bin/oc2`, and `fm-pi` must show `exec pi`.
|
|
|
|
### Checkout topology and safe installation
|
|
|
|
`rebuild.sh` points `~/.dotfiles` at its own directory and then builds `~/.dotfiles#lt-mbp`. On 2026-11-15, `~/.dotfiles` resolved to `/Users/laptran/Documents/firstmate/projects/dotfiles`. A second checkout at `/Users/laptran/Documents/dotfiles` carried an uncommitted `home.nix` that changed `fm` back to `pi` and seeded `crew-harness` as `pi`. A rebuild from that checkout would restore the Pi default. Do not run `rebuild.sh` from a checkout with that edit, and do not repoint `~/.dotfiles` by hand.
|
|
|
|
This follows the NIST SP 800-128 Rev. 1 (2019) Section 3.3 "Controlling Configuration Change" (CM-3) practice: route every change through review and approval, test it, record it in version control, and restrict who can change the operational configuration. The 2011 edition is withdrawn and superseded by Revision 1.
|
|
|
|
## What `rebuild.sh` updates
|
|
|
|
One `./rebuild.sh` run brings every installed component to its latest supported version. Each step is idempotent: a current copy is left alone, and a re-run repeats no install. When a tool or the network is absent, the step prints a warning and the rebuild continues.
|
|
|
|
Before the switch:
|
|
|
|
- Installed npm globals through `/opt/homebrew/bin/npm`, never Nix's npm: `@steipete/bird`, `chrome-devtools-axi`, `defuddle`, `forgejo-axi`, `gh-axi`, `lavish-axi`, `quota-axi`, and `tasks-axi`. The script skips absent packages and compares each installed package with the registry before an update. `tasks-axi` keeps its firstmate floor of 0.2.6 in `home.activation.axiTools`, which now installs only a missing or older copy, so the latest release survives the switch.
|
|
- Retired npm packages are removed only while their evidence still holds: `@opencode-ai/cli`, `opencode-ai`, and the June `pi-cli`/`pi-coding-agent` placeholders. The global `pi-context` is removed only when Pi keeps its own copy under `~/.pi/agent/npm`. If `pi` resolves into npm's global tree, the script warns and leaves those packages in place.
|
|
- `no-mistakes update`, using the binary at `~/.no-mistakes/bin/no-mistakes`.
|
|
- `hermes update --yes`, which pulls the configured channel and restarts the services that run its new code.
|
|
- `nix flake update`, so the switch builds from the newest locked inputs. Commit the resulting `flake.lock` change.
|
|
|
|
During the switch:
|
|
|
|
- nix-darwin updates Homebrew formulae and casks through `configuration.nix`'s `onActivation.autoUpdate` and `onActivation.upgrade` settings.
|
|
- `home.activation.backpass` updates `acpx` and `backpass`. Other activation steps install their declared npm packages when absent.
|
|
|
|
After the switch:
|
|
|
|
- The Skills CLI updates every skill tracked in `~/.agents/.skill-lock.json`. The pinned pstack skills are not in that lock, so they stay on the `home.nix` revision (see [pstack skills](#pstack-skills-pinned-on-every-rebuild)). `security-audit` is excluded on purpose, because `home.nix` freezes it so a rebuild never pulls a new skill mid-session; renew it by hand with the command in [security-audit skill](#security-audit-skill-agent-security-reviews).
|
|
- `pi update --extensions --no-approve`, run after the switch because the Homebrew bundle may have upgraded the `pi` binary.
|
|
|
|
Two tools have no supported updater: `actionlint` and `shellcheck` are standalone binaries in `~/.local/bin`, downloaded from their release pages. The rebuild does not replace them. Both were current on 2026-11-23 (actionlint 1.7.12, shellcheck 0.11.0); fetch a new release by hand when one is published. The pinned pstack tree also stays put; see its section for how to move it.
|
|
|
|
## security-audit skill (agent security reviews)
|
|
|
|
`home.activation.securityAuditSkill` installs Cloudflare's `security-audit` skill from `https://github.com/cloudflare/security-audit-skill` so the coding agents can run a structured vulnerability audit. The exact command:
|
|
|
|
```bash
|
|
/opt/homebrew/bin/npx --yes skills add https://github.com/cloudflare/security-audit-skill \
|
|
--skill security-audit --global \
|
|
--agent claude-code codex pi opencode --yes
|
|
```
|
|
|
|
The install needs Homebrew's `node`, which `configuration.nix` already declares, plus the system Git at `/usr/bin/git` for the clone. Renew or update the skill by hand with:
|
|
|
|
```bash
|
|
/opt/homebrew/bin/npx --yes skills update security-audit --global --yes
|
|
```
|
|
|
|
Agent scope: the Skills CLI installs the bundle once under `~/.agents/skills/security-audit`, the universal user-level directory that Codex, Pi, and OpenCode read, and it links that directory into `~/.claude/skills` for Claude Code. Grok Build is out of scope for this install: its skill directory is `~/.grok/skills`, and the CLI only populates it when `grok` is named in `--agent`. The install leaves `~/.config/opencode/skills` alone because home-manager owns that path with `force = true` and `mkOutOfStoreSymlink` into the mutable dotfiles checkout: a rebuild would clobber the CLI's link, and CLI writes would land in the git checkout. That is why the install uses the shared directory instead.
|
|
|
|
The activation is idempotent and non-interactive: it skips the install when both the canonical copy and the Claude Code link exist, and a failed download only warns so the rebuild still completes. Trigger it in an agent with "security audit this codebase".
|
|
|
|
Sandbox: the skill's README requires an OS-enforced sandbox (no external network, sanitized environment, resource limits, scratch-only writes) before it may run target-controlled builds, tests, browser automation, emulators, fuzzers, or fixtures. `security-audit-sandbox` below provides that sandbox. Run target code only through it; otherwise the workflow keeps such leads as `needs_validation` rather than executing target code.
|
|
|
|
## Security audit sandbox
|
|
|
|
`security-audit-sandbox` (installed as `~/.local/bin/security-audit-sandbox`) runs untrusted target code in a Docker container. It is for target code only: do not run the audit agent or your own tools inside it.
|
|
|
|
```bash
|
|
security-audit-sandbox start ~/code/myapp [--image node:22-bookworm] [--exclude dist]...
|
|
security-audit-sandbox exec ~/code/myapp [--timeout 600] -- npm test
|
|
security-audit-sandbox stop ~/code/myapp [--keep]
|
|
security-audit-sandbox status ~/code/myapp
|
|
```
|
|
|
|
`start` canonicalizes the app path, copies the app to `~/security-audit-runs/<slug>.XXXXXX`, and starts a detached container. The original app directory is never mounted into the container, so the copy is the only thing the target code can see.
|
|
|
|
Image resolution order:
|
|
|
|
1. `--image`
|
|
2. `IMAGE=` in the app's `security-audit.conf`
|
|
3. Inference: `package.json` gives `node:22-bookworm`, `pyproject.toml` or `requirements.txt` gives `python:3.12-slim`, `go.mod` gives `golang:1.24-bookworm`, `Cargo.toml` gives `rust:1-bookworm`, and `Gemfile` gives `ruby:3.3-bookworm`.
|
|
|
|
`start` stops with an error when nothing resolves an image. To support another runtime, add a marker file mapping or pass `--image`.
|
|
|
|
The optional `security-audit.conf` in the app root holds simple `KEY=value` lines. It is parsed, never sourced:
|
|
|
|
```ini
|
|
IMAGE=node:22-bookworm
|
|
EXCLUDE="node_modules dist coverage"
|
|
```
|
|
|
|
`EXCLUDE=` is a whitespace-separated list, and the key may be repeated: every `EXCLUDE=` line applies. CLI `--exclude` patterns are added on top of it. The copy always excludes `.git`, `.env*`, and the top-level `/data` directory, so secrets and live data stay on the host.
|
|
|
|
Container controls:
|
|
|
|
- `--network none`: no external network, only loopback for local tests.
|
|
- `--read-only` root with writes limited to the bind-mounted scratch directory at `/scratch`, plus a 512 MiB tmpfs at `/tmp`.
|
|
- `HOME=/scratch/home`, `TMPDIR=/scratch/tmp`, and `XDG_CACHE_HOME=/scratch/cache`.
|
|
- Runs as your host UID:GID, with `--cap-drop ALL`, `no-new-privileges`, and `--init`.
|
|
- `--memory 4g`, `--cpus 2`, `--pids-limit 256`, and `nofile=1024:1024`.
|
|
- `fsize=104857600` (100 MiB) when the Docker host accepts it. Docker Desktop on macOS may refuse `fsize`; the wrapper then starts without only that cap and prints a warning.
|
|
|
|
`exec` runs the command from `/scratch/app` under `timeout --signal=KILL`, default 600 seconds. It passes no host environment variables. If the image has no `timeout` binary, or its `timeout` does not enforce the `--signal=KILL` wall-clock limit, `exec` refuses to run rather than dropping the limit.
|
|
|
|
`stop` removes the container, the state file, and the run directory. Pass `--keep` to keep the run directory for inspection. State lives under `${XDG_STATE_HOME:-~/.local/state}/security-audit-sandbox` and is keyed by the canonical app path, so `exec`, `stop`, and `status` find the same run.
|
|
|
|
Use dummy data only. The exclusions cover common secrets and the top-level `data` directory, not every possible secret path. Review the copied tree, or add `--exclude` patterns, before you run a target that reads credentials from unexpected places. Audit findings do not belong in this repo or in the run directory.
|
|
|
|
## pstack skills (pinned on every rebuild)
|
|
|
|
`home.activation.pstackSkills` restores the eleven adopted pstack skills into `~/.agents/skills`, the shared user-level skill directory that the security-audit section describes. The source is `https://github.com/cursor/plugins` at a fixed commit (folder `pstack/skills`), pinned by the `pstackSkills` `fetchFromGitHub` in `home.nix`. That pin is the only record of the commit in this repo: to move to newer upstream content, change `rev` and `hash` together, then rerun `./rebuild.sh`.
|
|
|
|
Each run removes and recopies only those eleven directories, so a renamed upstream file never lingers and every other skill in `~/.agents/skills` stays untouched, including an existing tdd skill. `tdd` is skipped on purpose: an existing user-level tdd skill owns that name, so the pstack copy is never installed. The block adds no `~/.claude/skills` link, so Claude Code does not see these eleven skills.
|
|
|
|
Why these eleven skills exist is recorded in firstmate's `docs/adopted-skills.md`, outside this repo.
|
|
|
|
## OpenSuperWhisper (local voice input)
|
|
|
|
Hold a shortcut, speak, release, and the transcript pastes into the focused app. Everything runs on the Mac: no audio or transcript leaves the machine.
|
|
|
|
First run:
|
|
|
|
1. The `opensuperwhisper` cask is installed and `home.activation.openSuperWhisper` pre-downloads the model to `~/Library/Application Support/ru.starmel.OpenSuperWhisper/whisper-models/ggml-large-v3-turbo.bin`. It selects "Whisper V3 Large" only when no model is selected or the selected file is gone, so a model you pick in the app stays selected.
|
|
2. Open the app. Onboarding should already show "Whisper V3 Large" as downloaded.
|
|
3. Grant **Microphone**, **Accessibility**, and **Input Monitoring** when macOS asks. Input Monitoring is needed because the trigger is Right Option, a single modifier key.
|
|
4. Keep the Right Option trigger (or change it in the app's settings). Hold it, speak, release. Auto-paste puts the text into the focused terminal or editor.
|
|
|
|
Notes:
|
|
|
|
- A fresh install starts with Option plus backtick instead of Right Option, and that combination needs no Input Monitoring. The activation never writes the trigger, the language, or the paste settings, so whatever you choose in the app survives the next rebuild.
|
|
- The model is local-only (about 1.6 GB). If the download failed during the rebuild, rerun `./rebuild.sh` or download the large Turbo V3 model ("Turbo V3 large" in the app's Settings) by hand.
|
|
- Voice is for prompts and prose. Type URLs, file paths, and exact identifiers yourself.
|
|
- The first-run steps above are manual on purpose: macOS TCC permissions cannot be granted declaratively.
|