Compare commits

...
Author SHA1 Message Date
hugocasaandClaude Opus 5 f551c48c2d docs: target the backend pane in the webmux capture-pane cell
Without -t the command dumps the agent's own pane. Matches the form .webmux.yaml already uses in its startup prompt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 17:16:57 +02:00
hugocasaandClaude Opus 5 1fece42e00 docs: correct the .env.local readability claim
The file-read tool denies every .env.* path via .claude/settings.json, .env.local included, so the section points at cat instead of implying the file is readable.

DATABASE_URL carries an export prefix, which the bare 'source .env.local' in .envrc needs to reach cargo and sqlx, and which a ^DATABASE_URL= grep would miss. Documented rather than removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 17:09:48 +02:00
hugocasaandClaude Opus 5 7a8cd3b5c6 chore: narrow the shared helper to .env.local writing
Slot assignment goes back into worktree-env: it had one caller, and the herdr plugin it was extracted for provisions worktrees before the checkout is usable, so it carries its own copy rather than sourcing one whose contents depend on whichever branch the main checkout sits on.

Writing .env.local stays shared - worktree-env and post-create.sh each had the same eleven lines.

Also corrects AGENTS.md: .env.local is a shared format rather than a shared function, and WM_DB_NAME comes from it rather than webmux's runtime.env.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 16:33:31 +02:00
hugocasaandClaude Opus 5 af9dcf4976 docs: point at the herdr plugin setup
Naming the repo left the reader to work out what to do with it. The plugins do
nothing until they are installed and their actions are bound, and Herdr has no
action palette to discover them through.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 16:26:22 +02:00
hugocasaandClaude Opus 5 1caa9adc70 docs: describe both worktree managers in the dev environment section
The section assumed webmux and tmux throughout. Worktree tooling is being
trialled on herdr alongside it, so the detection markers and the pane
inspection commands now appear side by side.

Corrects the pointer for per-worktree values: .env.local is written by both
managers through wm_write_env_local and is readable, so it is the portable
source. webmux's runtime.env stays documented as the place carrying the extras
.env.local lacks.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 16:26:22 +02:00
hugocasaandClaude Opus 5 40ffb08b00 chore: share worktree port assignment across worktree tooling
The slot scan and the .env.local writer existed twice, once inline in
scripts/worktree-env and once in scripts/post-create.sh. Both are now
wm_assign_ports and wm_write_env_local in scripts/worktree-common.sh, so a
third caller cannot drift from the other two.

wm_assign_ports takes the worktree root instead of reading the process cwd,
which lets it run from outside the worktree, and prints its slot line to stderr
so stdout carries only the port pair.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 16:26:22 +02:00
4 changed files with 55 additions and 40 deletions
+33 -17
View File
@@ -51,13 +51,22 @@ Open-source platform for internal tools, workflows, API integrations, background
> defaults in this section apply only to a plain single checkout. **Discover the real
> values before running anything** — see "Per-worktree ports and database" below.
**Check whether they are already running before starting anything.** In a webmux worktree
(`$WEBMUX_WORKTREE_PATH` is set) the backend and frontend are already up in sibling tmux panes —
use those, don't spawn your own. `tmux list-panes -t "$(tmux display-message -p -t "$TMUX_PANE"
'#{window_id}')" -F '#{pane_index} #{pane_current_command}'` shows what is running; read its log
with `tmux capture-pane`, and see `backend/AGENTS.md` to restart it with different cargo features.
A second server started in your own shell fights the first one for the port. The commands below
are for a plain checkout with nothing running.
**Check whether they are already running before starting anything.** In a managed worktree the
backend and frontend are already up in sibling panes — use those, don't spawn your own. A second
server started in your own shell fights the first one for the port. Two managers are in use, and
they set disjoint environment variables, so check which one you are in:
| | webmux | herdr |
| --- | --- | --- |
| marker | `$WEBMUX_WORKTREE_PATH` is set | `$HERDR_ENV=1` |
| what is running | `tmux list-panes -t "$(tmux display-message -p -t "$TMUX_PANE" '#{window_id}')" -F '#{pane_index} #{pane_current_command}'` | `herdr pane list --workspace "$HERDR_WORKSPACE_ID"` |
| read a pane's log | `tmux capture-pane -t "$(tmux display-message -p -t "$TMUX_PANE" '#{session_name}:#{window_name}').1" -p -S -50` (`.1` backend, `.2` frontend) | `herdr pane read <pane_id> --source recent-unwrapped --lines 50` |
See `backend/AGENTS.md` to restart the backend with different cargo features. Under herdr, `herdr
--skill` prints a full reference for inspecting and driving panes and agents, and the plugins that
provision worktrees live in the private `windmill-labs/windmill-herdr` — clone it and run
`./setup.sh` to install them and the keybindings they need. The commands below are for a plain
checkout with nothing running.
- **Backend**: `cargo run` from `backend/` (API at http://localhost:8000)
- **Frontend**: `REMOTE=http://localhost:8000 npm run dev` from `frontend/` (port 3000+)
@@ -68,10 +77,15 @@ are for a plain checkout with nothing running.
### Per-worktree ports and database
In a webmux worktree the authoritative values live in
`$(git rev-parse --git-dir)/webmux/runtime.env``BACKEND_PORT`, `FRONTEND_PORT`,
`DATABASE_URL`, `CARGO_FEATURES`, `WM_DB_NAME`. Every pane sources it at startup. Read that
first: it is not a `.env*` file, so the repo's secret-file read rules don't stand in the way.
**`.env.local` in the worktree root is the portable answer** — `BACKEND_PORT`,
`FRONTEND_PORT`, `REMOTE`, `DATABASE_URL`, `CARGO_FEATURES`, `WM_DB_NAME`. Both managers write
those fields, so it is correct whichever one you are in. Read it with `cat .env.local` from a
shell: the file-read tool denies every `.env.*` path, and `DATABASE_URL` is written with an
`export` prefix that a `^DATABASE_URL=` grep misses.
webmux additionally writes `$(git rev-parse --git-dir)/webmux/runtime.env`, which every pane
sources at startup and which carries the extras `.env.local` lacks: `WEBMUX_*`, `WM_CLONE_DB`,
`USE_RUST_PLUGIN`. herdr has no equivalent file; its plugin hooks read `.env.local`.
In a plain checkout, fall back to `.env` / `.env.local` (repo root) and `backend/.env`.
@@ -80,15 +94,17 @@ hook. It is not a copy of the main dev instance: you get the `admins` workspace,
`admin@windmill.dev` superadmin, the license key copied from the base database, and whatever the
migrations seed — and none of your own workspaces, scripts, flows or apps. Create whatever a test
needs. Cloning the base `windmill` database instead is
opt-in per project via `WM_CLONE_DB` in `.webmux.yaml`; read the note there before turning it on.
opt-in via `WM_CLONE_DB` (in `.webmux.yaml` under webmux, or the `windmill.worktree` plugin's
`config.env` under herdr); read the note in `.webmux.yaml` before turning it on.
The database is named after the **worktree directory, not the branch** (`scripts/worktree-common.sh`):
`windmill_` + the directory basename with `-``_`, which Postgres then truncates at 63
characters. Branch `hugo/win-2340-ai-agent-evals-standalone-agent-runs-and-eval-datasets` sits in
a worktree directory named `win-2340-…`, so its database is
`windmill_win_2340_ai_agent_evals_standalone_agent_runs_and_eval` — no `hugo_`, and the tail
chopped. Take `WM_DB_NAME` from `runtime.env` instead of reconstructing the name. Read those, or
discover from what is already running:
characters. The two managers lay worktrees out differently, so the same branch lands in different
directories and therefore different databases: under webmux, branch
`hugo/win-2340-ai-agent-evals-standalone-agent-runs-and-eval-datasets` sits in a directory named
`win-2340-…`, so its database is `windmill_win_2340_ai_agent_evals_standalone_agent_runs_and_eval`
— no `hugo_`, and the tail chopped. Take `WM_DB_NAME` from `.env.local` instead of reconstructing
the name. Read that, or discover from what is already running:
```bash
psql postgres://postgres:changeme@localhost:5432/postgres -tAc \
+1 -11
View File
@@ -11,15 +11,5 @@ if [[ -z "$backend_port" || -z "$frontend_port" ]]; then
exit 1
fi
cat > .env.local <<EOF
BACKEND_PORT=$backend_port
FRONTEND_PORT=$frontend_port
REMOTE=http://localhost:$backend_port
EOF
if [[ -n "${CARGO_FEATURES:-}" ]]; then
echo "CARGO_FEATURES=$CARGO_FEATURES" >> .env.local
fi
echo "Created .env.local with ports: backend=$backend_port, frontend=$frontend_port"
wm_write_env_local "$(pwd)" "$backend_port" "$frontend_port"
wm_shared_post_create "$(pwd)"
+20
View File
@@ -13,6 +13,26 @@ wm_main_repo_root() {
cd "$(git -C "$repo_root" rev-parse --git-common-dir 2>/dev/null)/.." && pwd
}
# These field names are documented in AGENTS.md as how an agent finds its own ports and database.
wm_write_env_local() {
local repo_root=$1
local backend_port=$2
local frontend_port=$3
local env_file="${repo_root}/.env.local"
cat > "$env_file" <<EOF
BACKEND_PORT=$backend_port
FRONTEND_PORT=$frontend_port
REMOTE=http://localhost:$backend_port
EOF
if [[ -n "${CARGO_FEATURES:-}" ]]; then
echo "CARGO_FEATURES=$CARGO_FEATURES" >> "$env_file"
fi
echo "Created .env.local with ports: backend=$backend_port, frontend=$frontend_port"
}
wm_setup_database() {
local repo_root=$1
local env_file=$2
+1 -12
View File
@@ -41,16 +41,5 @@ if port_in_use "$backend_port" || port_in_use "$frontend_port"; then
echo "WARNING: Slot $WM_SLOT ports ($backend_port/$frontend_port) already in use" >&2
fi
# Generate .env.local with port overrides
cat > .env.local <<EOF
BACKEND_PORT=$backend_port
FRONTEND_PORT=$frontend_port
REMOTE=http://localhost:$backend_port
EOF
if [[ -n "${CARGO_FEATURES:-}" ]]; then
echo "CARGO_FEATURES=$CARGO_FEATURES" >> .env.local
fi
echo "Created .env.local with ports: backend=$backend_port, frontend=$frontend_port"
wm_write_env_local "$(pwd)" "$backend_port" "$frontend_port"
wm_shared_post_create "$(pwd)"