Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ organized under `desktop/src/features/`. Biome handles linting and formatting.

```bash
just desktop-dev # web-only dev server (faster iteration)
just desktop-app # full Tauri app with native shell
just dev # full Tauri app with native shell
```

### Workspace Switching
Expand Down Expand Up @@ -291,6 +291,12 @@ flutter test

Or from repo root: `just mobile-fmt` (auto-fix), `just mobile-check` (lint + fmt check), `just mobile-test` (tests).

To run the app locally (starts Docker, relay, iOS simulator automatically):

```bash
just mobile-dev
```

### Testing Conventions

- Prefer **widget tests** over unit tests for UI components — test the
Expand Down
11 changes: 4 additions & 7 deletions NOSTR.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ Connect any NIP-29 client straight to the relay.
### Quick Start

```bash
# 1. Start infrastructure
docker compose up -d

# 2. (Optional) Enable pubkey allowlist — must be set BEFORE relay startup
# 1. (Optional) Enable pubkey allowlist — must be set BEFORE relay startup
export SPROUT_PUBKEY_ALLOWLIST=true

# 3. Start the relay (runs migrations automatically)
cargo run -p sprout-relay & # relay on :3000
# 2. Start the relay (auto-starts Docker services and runs migrations)
just relay & # relay on :3000

# 4. Add a pubkey to the allowlist (if enabled)
# 3. Add a pubkey to the allowlist (if enabled)
# Insert directly — there is no CLI command for this yet.
PGPASSWORD=sprout_dev psql -h localhost -U sprout -d sprout -c \
"INSERT INTO pubkey_allowlist (pubkey) VALUES (decode('<64-char-hex-pubkey>', 'hex'))"
Expand Down
4 changes: 2 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ just test # unit + integration (starts Docker if needed)
```

`just test` runs unit tests plus integration tests against Postgres and Redis
(started via `docker compose`). Neither task runs the E2E suites in
(started automatically if not already running). Neither task runs the E2E suites in
`sprout-test-client` — those are marked `#[ignore]` and require a running relay:

```bash
Expand Down Expand Up @@ -264,7 +264,7 @@ Replies are kind:9 in the same channel; `sprout messages thread --channel <id>
## Configuration reference

The relay reads all configuration from environment variables. Defaults work
out of the box with `docker compose up`. Common overrides:
out of the box with `just setup` or `just relay`. Common overrides:

| Variable | Default | Notes |
|-----------------------------------|-----------------------------|-------|
Expand Down
3 changes: 1 addition & 2 deletions crates/sprout-acp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Supports any agent that speaks [ACP](https://agentclientprotocol.com/) over stdi

## Prerequisites

- A running Sprout relay (`just relay` or a hosted instance)
- Docker services up (`docker compose up -d`) if running locally
- A running Sprout relay (`just relay` starts Docker services automatically, or use a hosted instance)
- A Nostr keypair for the agent (see [Generating Keys](#generating-keys))

Build:
Expand Down
2 changes: 1 addition & 1 deletion crates/sprout-cli/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ docker compose ps
# sprout-typesense healthy
```

If not running: `./scripts/dev-setup.sh` from the repo root.
If not running: `just setup` from the repo root.

Tools: `jq`, `curl`, Rust toolchain.

Expand Down
3 changes: 1 addition & 2 deletions crates/sprout-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Client (NIP-28) ←→ sprout-proxy :4869 ←→ sprout-relay :3000
### 1. Start infrastructure and relay

```bash
just setup # Docker: Postgres + Redis
just relay # Relay on :3000
just relay # starts Docker services + migrations automatically
```

### 2. Mint a proxy API token
Expand Down
92 changes: 73 additions & 19 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,40 @@ _ensure-sidecar-stubs:
touch "desktop/src-tauri/binaries/${bin}-${TARGET}"
done

# Ensure Docker dev services (Postgres, Redis, etc.) are running and healthy
_ensure-services:
#!/usr/bin/env bash
set -euo pipefail
pg=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-postgres 2>/dev/null || echo "not_found")
redis=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-redis 2>/dev/null || echo "not_found")
if [[ "$pg" == "healthy" && "$redis" == "healthy" ]]; then
echo "Services already healthy"
exit 0
fi
echo "Starting services..."
docker compose up -d || true
echo -n "Waiting for services"
for i in $(seq 1 40); do
pg=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-postgres 2>/dev/null || echo "not_found")
redis=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-redis 2>/dev/null || echo "not_found")
if [[ "$pg" == "healthy" && "$redis" == "healthy" ]]; then
echo " ready"
exit 0
fi
echo -n "."
sleep 3
done
echo " timed out"
exit 1

# Apply database migrations if pgschema is available
_ensure-migrations: _ensure-services
#!/usr/bin/env bash
set -euo pipefail
if [[ -x bin/pgschema && -f schema/schema.sql ]]; then
bin/pgschema apply --file schema/schema.sql --auto-approve || true
fi

# Run clippy on the desktop Tauri Rust crate
desktop-tauri-clippy: _ensure-sidecar-stubs
cargo clippy --manifest-path {{desktop_tauri_manifest}} --all-targets -- -D warnings
Expand Down Expand Up @@ -153,15 +187,15 @@ desktop-release-build target="aarch64-apple-darwin":
desktop-ci: desktop-check desktop-test desktop-tauri-fmt-check desktop-build desktop-tauri-check desktop-tauri-test

# Seed deterministic channel data for desktop Playwright tests
desktop-e2e-seed:
desktop-e2e-seed: _ensure-migrations
./scripts/setup-desktop-test-data.sh

# Run desktop browser smoke tests
desktop-e2e-smoke:
cd {{desktop_dir}} && pnpm test:e2e:smoke

# Run desktop relay-backed e2e tests
desktop-e2e-integration:
desktop-e2e-integration: _ensure-migrations
cd {{desktop_dir}} && pnpm test:e2e:integration

# Run all checks suitable for CI / pre-push (no infra needed)
Expand All @@ -188,20 +222,20 @@ test-integration:

# ─── Run ──────────────────────────────────────────────────────────────────────

# Start the relay server
relay:
# Start the relay server (auto-starts Docker services if needed)
relay: _ensure-migrations
cargo run -p sprout-relay

# Start the relay with the built web UI served from it
relay-web:
relay-web: _ensure-migrations
#!/usr/bin/env bash
set -euo pipefail
[[ -d node_modules ]] || pnpm install
pnpm -C web build
SPROUT_WEB_DIR=./web/dist cargo run -p sprout-relay

# Start the relay server in release mode
relay-release:
relay-release: _ensure-migrations
cargo run -p sprout-relay --release

# Start sprout-proxy (dev mode)
Expand Down Expand Up @@ -248,10 +282,6 @@ desktop-dev:
echo "Starting frontend dev server on Vite port ${SPROUT_VITE_PORT}, relay ${SPROUT_RELAY_URL}"
pnpm exec vite --port "${SPROUT_VITE_PORT}" --strictPort

# Run the desktop Tauri app (alias for dev)
desktop-app *ARGS:
just dev {{ARGS}}

# ─── Web ─────────────────────────────────────────────────────────────────────

# Run the web frontend dev server (port derived from worktree to avoid collisions)
Expand All @@ -266,14 +296,6 @@ web:
cd {{web_dir}}
pnpm exec vite --port "${VITE_PORT}" --strictPort

# Install web JS dependencies (pnpm workspace — installs all packages from root)
web-install:
pnpm install

# Install web JS dependencies reproducibly for CI (pnpm workspace)
web-install-ci:
pnpm install --frozen-lockfile

# Run web lint and format checks
web-check:
cd {{web_dir}} && pnpm check
Expand Down Expand Up @@ -318,10 +340,42 @@ mobile-check:
mobile-test:
unset GIT_DIR GIT_WORK_TREE; cd {{mobile_dir}} && flutter test

# Run the mobile app on iOS simulator (starts infra + relay automatically)
mobile-dev:
#!/usr/bin/env bash
set -euo pipefail
just _ensure-migrations
# Start relay in background if not already running
RELAY_PID=""
if ! lsof -i :3000 -sTCP:LISTEN -t &>/dev/null; then
echo "Starting relay in background (log: /tmp/sprout-relay.log)..."
cargo run -p sprout-relay &>/tmp/sprout-relay.log &
RELAY_PID=$!
trap 'if [[ -n "$RELAY_PID" ]]; then kill "$RELAY_PID" 2>/dev/null || true; fi' EXIT
echo -n "Waiting for relay"
for _ in $(seq 1 30); do
lsof -i :3000 -sTCP:LISTEN -t &>/dev/null && break
echo -n "."
sleep 3
done
echo " ready"
else
echo "Relay already running on :3000"
fi
# Open iOS simulator if not already running
if ! pgrep -x Simulator &>/dev/null; then
open -a Simulator
sleep 3
fi
# Run Flutter
cd {{mobile_dir}}
unset GIT_DIR GIT_WORK_TREE
flutter run

# ─── Database ─────────────────────────────────────────────────────────────────

# Apply schema migrations via pgschema
migrate:
migrate: _ensure-services
./bin/pgschema apply --file schema/schema.sql --auto-approve

# ─── Utilities ────────────────────────────────────────────────────────────────
Expand Down
6 changes: 5 additions & 1 deletion mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ flutter pub get
## Run

```bash
flutter run
# From repo root (recommended — starts Docker, relay, and simulator):
just mobile-dev

# Direct (requires services and relay already running):
cd mobile && flutter run
```

## Checks
Expand Down
52 changes: 3 additions & 49 deletions scripts/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
TIMEOUT=120 # seconds to wait for services to become healthy

# Colors
RED='\033[0;31m'
Expand Down Expand Up @@ -71,53 +70,8 @@ load_env

# ---- Start services ---------------------------------------------------------

log "Starting services..."
docker compose up -d

# ---- Wait for healthy -------------------------------------------------------

wait_healthy() {
local service="$1"
local container="$2"
local elapsed=0
local interval=3

log "Waiting for ${service} to be healthy..."
while true; do
local status
status=$(docker inspect --format='{{.State.Health.Status}}' "${container}" 2>/dev/null || echo "not_found")

case "${status}" in
healthy)
success "${service} is healthy"
return 0
;;
unhealthy)
error "${service} is unhealthy. Check logs: docker logs ${container}"
return 1
;;
not_found)
error "Container ${container} not found"
return 1
;;
esac

if [[ ${elapsed} -ge ${TIMEOUT} ]]; then
error "Timed out waiting for ${service} (${TIMEOUT}s). Check: docker logs ${container}"
return 1
fi

sleep "${interval}"
elapsed=$((elapsed + interval))
echo -n "."
done
}

echo ""
wait_healthy "Postgres" "sprout-postgres"
wait_healthy "Redis" "sprout-redis"
wait_healthy "Typesense" "sprout-typesense"
echo ""
log "Starting services and waiting for health..."
"${REPO_ROOT}/bin/just" _ensure-services

# ---- Run migrations ---------------------------------------------------------

Expand Down Expand Up @@ -204,7 +158,7 @@ if [[ -d "${WEB_DIR}" ]]; then
success "Web dependencies installed"
else
warn "pnpm not found — skipping web dependency install."
warn "Run '. ./bin/activate-hermit' to get pnpm, then 'just web-install'."
warn "Run '. ./bin/activate-hermit' to get pnpm, then 'just desktop-install'."
fi
else
warn "Web directory not found at ${WEB_DIR} — skipping."
Expand Down
Loading