|
| 1 | +# Working on sesh |
| 2 | + |
| 3 | +For anyone changing sesh, person or coding agent. If you use sesh day to day |
| 4 | +as well, the first thing is keeping the sesh you use apart from the one you're |
| 5 | +working on. |
| 6 | + |
| 7 | +## Two seshes: the one in use, and the one being built |
| 8 | + |
| 9 | +- **The daily sesh** is an installed release (`brew install bashhack/sesh/sesh`, |
| 10 | + so `/opt/homebrew/bin/sesh`). Its vault, config, agent and Touch ID key are in |
| 11 | + the default places: `~/Library/Application Support/sesh/` (on Linux |
| 12 | + `~/.local/share/sesh/`), `~/.config/sesh/config.toml`, and the agent's socket |
| 13 | + under the user cache folder. |
| 14 | +- **The dev sesh** is this checkout, run with `scripts/sesh-dev`. It builds the |
| 15 | + working tree to `build/sesh-dev` and runs it on a vault, config and agent of |
| 16 | + its own, in `SESH_DEV_DIR` (an absolute path; default |
| 17 | + `~/.local/share/sesh-dev`): |
| 18 | + |
| 19 | + ```bash |
| 20 | + scripts/sesh-dev add password github --username alice |
| 21 | + scripts/sesh-dev ui |
| 22 | + ``` |
| 23 | + |
| 24 | +Don't run a development build against the daily sesh's vault, config or agent. |
| 25 | +The two would also replace each other's agent on every switch (an agent from |
| 26 | +another build is replaced), so the daily sesh would keep asking to unlock. |
| 27 | + |
| 28 | +### For coding agents |
| 29 | + |
| 30 | +- **Use a throwaway folder for every run,** never the person's dev vault or the |
| 31 | + daily one, and give the master password in the environment, with a small key |
| 32 | + setting so it's quick: |
| 33 | + |
| 34 | + ```bash |
| 35 | + export SESH_DEV_DIR=$(mktemp -d) SESH_MASTER_PASSWORD=throwaway-test-1 SESH_KDF_MEMORY=19MiB |
| 36 | + printf 'pw\n' | scripts/sesh-dev add password demo --username me |
| 37 | + scripts/sesh-dev list |
| 38 | + ``` |
| 39 | + |
| 40 | + `mktemp -d` gives a short enough path: an agent socket's path can be at most |
| 41 | + 103 characters on macOS. Delete the folder when you're done. |
| 42 | +- **Don't touch:** the daily vault, `~/.config/sesh`, the running agent, |
| 43 | + `~/.aws`, or the person's tmux sessions. Use a separate tmux server |
| 44 | + (`tmux -L <name>`) to drive `sesh ui`. |
| 45 | +- **Don't copy:** these use the real clipboard: `sesh copy`, `--clip`, |
| 46 | + `add --generate` and `generate --copy` (they copy the new password), |
| 47 | + `history --clip`, and `sesh aws` while it signs in (it puts the MFA code |
| 48 | + there). In `sesh ui`: Enter and Ctrl-Y, the copy actions, the password |
| 49 | + generator, and saving a generated password. Read the code instead, or use |
| 50 | + `sesh get`. |
| 51 | +- **Don't run `sesh touchid enable` or `sesh browser install`** unless asked: |
| 52 | + the first makes a key in the Mac's secure chip, tied to the person's |
| 53 | + fingerprints; the second repoints their browsers (below). And don't accept |
| 54 | + `sesh sync init`'s offer of an iCloud Drive folder: iCloud copies it to the |
| 55 | + person's other computers. |
| 56 | +- Stop every agent and process you start (`scripts/sesh-dev agent stop`), and |
| 57 | + put a time limit on every test run, so nothing is left behind. |
| 58 | + |
| 59 | +### What the two still share |
| 60 | + |
| 61 | +- **The browser extension.** The browser starts whatever sesh the script in the |
| 62 | + daily data folder (`browser-host`) names, without `scripts/sesh-dev`'s |
| 63 | + settings, so it always runs on the daily vault and agent. |
| 64 | + `scripts/sesh-dev browser …` refuses for that reason; to try the extension |
| 65 | + against a dev build, try the build as the daily sesh (below). |
| 66 | +- **The agent's log**, `agent.log` in the user cache folder: both agents write |
| 67 | + to it. |
| 68 | +- **The clipboard**, and the AWS CLI's own files: `scripts/sesh-dev aws` uses |
| 69 | + the real `~/.aws`. For AWS work without AWS, see `scripts/README.md` (a mock |
| 70 | + AWS CLI). |
| 71 | +- **What the dev sesh starts** keeps its settings: in `sesh run`'s command, |
| 72 | + `sesh aws`'s shell and the notes editor, `SESH_DB_PATH`, `SESH_AUTH_SOCK` |
| 73 | + and `XDG_CONFIG_HOME` point at the dev folder, so a `sesh` run there uses |
| 74 | + the dev vault, and other programs (git, an editor) look for their config in |
| 75 | + it. The other way round, a `scripts/sesh-dev aws` run inside the daily |
| 76 | + sesh's AWS shell refuses ("already in a sesh environment"), except for a |
| 77 | + profile that signs in with `aws login` or SSO whose session has ended: the |
| 78 | + dev build signs it in again. |
| 79 | +- **`sesh init`:** it offers the default vault location, not the dev one; |
| 80 | + `scripts/sesh-dev init` gives it the dev vault's. |
| 81 | + |
| 82 | +### Trying a dev build as the daily sesh |
| 83 | + |
| 84 | +Rarely, a change needs trying for real before it's released: |
| 85 | + |
| 86 | +```bash |
| 87 | +go build -o ~/go/bin/sesh ./sesh/cmd/sesh # a folder on PATH after Homebrew's |
| 88 | +brew unlink sesh && hash -r # now `sesh` is the dev build |
| 89 | +~/go/bin/sesh browser install # the extension too, if needed |
| 90 | +# … and back: |
| 91 | +rm ~/go/bin/sesh && brew link sesh && hash -r |
| 92 | +sesh browser install # the extension back to Homebrew's |
| 93 | +``` |
| 94 | + |
| 95 | +While it's unlinked, a `browser-host` script naming Homebrew's sesh points at |
| 96 | +nothing, so the extension only works after the `browser install` above. |
| 97 | + |
| 98 | +## Building and testing |
| 99 | + |
| 100 | +- Go 1.27+, and on macOS Xcode's command line tools: Touch ID and the screen |
| 101 | + lock check are built with cgo. |
| 102 | +- `go build ./...`, then test only the packages you changed while you work |
| 103 | + (`go test ./internal/tui/`). CI runs everything, and the race detector in |
| 104 | + three parts. It leaves Argon2id uninstrumented, for speed, which needs a Go |
| 105 | + experiment turned off too, or it reports false races: |
| 106 | + |
| 107 | + ```bash |
| 108 | + GOEXPERIMENT=nosizespecializedmalloc go test -race -gcflags='golang.org/x/crypto/argon2=-race=false' ./internal/... |
| 109 | + ``` |
| 110 | + |
| 111 | + A plain `go test -race` works as well, more slowly. |
| 112 | +- `make dev/setup/hooks` installs the pre-commit hook: goimports and |
| 113 | + `go build ./...`, then go vet and golangci-lint on the packages a commit |
| 114 | + touches. `make audit` tidies, formats, vets, lints and tests everything, and |
| 115 | + rewrites files as it goes. |
| 116 | +- `make agent-smoke` runs the agent end to end. |
| 117 | + |
| 118 | +## Changes |
| 119 | + |
| 120 | +- **One pull request per change**, each on its own branch (a git worktree per |
| 121 | + branch keeps them apart). Each is reviewed before it's merged, and CI must |
| 122 | + pass. |
| 123 | +- **Commit messages are one line,** saying what the change does. |
| 124 | +- **Stage files by name,** not `git add -A`: a checkout can hold notes and |
| 125 | + scratch files that aren't meant for the repo. |
| 126 | +- **Comments and docs say how things are,** not how they came to be. |
| 127 | + `docs/USAGE_AND_CONFIGURATION.md`, `docs/SECURITY_MODEL.md` and |
| 128 | + `docs/ARCHITECTURE.md` are checked against the code; change them with it. |
| 129 | + |
| 130 | +## Releasing |
| 131 | + |
| 132 | +Tag `vX.Y.Z` on `main` and push the tag. The release job tests it again, |
| 133 | +builds, signs and notarizes the macOS binaries, publishes the GitHub release, |
| 134 | +and updates the Homebrew formula in `bashhack/homebrew-sesh`. A tag with |
| 135 | +`.github/release-notes/<tag>.md` is released with those notes; otherwise, with |
| 136 | +the commits since the last tag. Then `brew upgrade sesh` updates the daily sesh. |
0 commit comments