diff --git a/.gitignore b/.gitignore index e2be789..d03370a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,13 @@ -# map tile cache + server runtime -mock/.tilecache/ -mock/server.log - -# OSM data (downloaded by router/scripts/setup-osrm.sh) -osm/*.osm.pbf -osm/build/ - -# Go +# Compiled binaries (built in place, not committed) router/router -spatial/spatiald router/bench +spatial/spatiald router/scripts/__pycache__/ -# per-trip uploaded documents + chat logs (PII — never commit) -mock/store/ +# Runtime artifacts live OUTSIDE this source tree, in ~/trips: +# ~/trips/osm/ OSM PBF extracts (setup-osrm*.sh, spatial/import.sh) +# ~/trips/tilecache/ mock tile cache (mock/server.js) +# ~/trips/store/mock/ per-trip docs + chats (mock/server.js, PII) +# ~/trips/logs/ server logs +# and the OSRM toolchain + routing graphs live in ~/osm-build (W in the +# setup scripts). Nothing here should be re-added under those names. diff --git a/mock/app.js b/mock/app.js index f6a1049..9afb6fe 100644 --- a/mock/app.js +++ b/mock/app.js @@ -1925,9 +1925,9 @@ let version = 0; let history = []; // [{v, label, at, days, stays}] let hIdx = -1; // pointer into history let tripDocs = {}; // name → {name,kind,chars,text,truncated,at} — attached documents - // (authoritative copy lives on the server: mock/store//docs/) + // (authoritative copy lives on the server: ~/trips/store/mock//docs/) let chatLog = []; // [{role:'user'|'assistant', text}] — conversation turns, persisted - // per trip on the server (mock/store//chat.jsonl) so a + // per trip on the server (~/trips/store/mock//chat.jsonl) so a // follow-up ("yes, do it") can see what the model said earlier, // even after a reload let storeReady = Promise.resolve(); // resolve when this trip's server store has loaded @@ -2407,7 +2407,7 @@ let persistT = 0; function persistTrip(force = false) { clearTimeout(persistT); const hist = history.slice(0, hIdx + 1).slice(-25); // drop the redo tail, cap at 25 - // docs + chat live on the server now (mock/store//) — localStorage + // docs + chat live on the server now (~/trips/store/mock//) — localStorage // only carries the plan state. force: skip the debounce — the re-anchoring // of the whole trip around booked flights is the one edit we must never lose const save = () => tripStore.save(tripId, { days, stays, version, hIdx: hist.length - 1, history: hist, bookings: M.trip.bookings, title: M.trip.title }); diff --git a/mock/scripts/pre-cache-tiles.sh b/mock/scripts/pre-cache-tiles.sh index 733724f..38cf6df 100755 --- a/mock/scripts/pre-cache-tiles.sh +++ b/mock/scripts/pre-cache-tiles.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Pre-cache OSM tiles for the trip's map extent through the local proxy -# (which stores them in mock/.tilecache). Usage: +# (the proxy stores them in ~/trips/tilecache). Usage: # pre-cache-tiles.sh # all trips # pre-cache-tiles.sh colombia z16 # one trip, one zoom set -euo pipefail @@ -60,4 +60,5 @@ for trip in "${TRIPS[@]}"; do fetch "$trip" "$z" | xargs -P 8 -n 1 curl -s -o /dev/null -m 20 --retry 2 > /dev/null done done -echo "done. cache size: $(du -sh .tilecache | cut -f1)" +CACHE_DIR="${TRIPS_HOME:-$HOME/trips}/tilecache" +echo "done. cache size: $(du -sh "$CACHE_DIR" 2>/dev/null | cut -f1)" diff --git a/mock/server.js b/mock/server.js index 9b1482e..f134461 100644 --- a/mock/server.js +++ b/mock/server.js @@ -44,9 +44,13 @@ const SEARXNG = { base: process.env.SEARXNG_BASE || 'http://192.168.3.4:30053' } const SPATIAL = { url: process.env.SPATIAL_URL || 'http://localhost:5005' }; const routerFor = (u) => ROUTERS[u.searchParams.get('router') || 'northeast'] || ROUTERS.northeast; const PROFILE = { foot: 'walking', walk: 'walking', bike: 'cycling', cycle: 'cycling', car: 'driving', drive: 'driving', transit: 'driving' }; -const CACHE = path.join(__dirname, '.tilecache'); +// Runtime artifacts live OUTSIDE the source tree — the repo holds code + +// built binaries only. Home: ~/trips (override with TRIPS_HOME). +const TRIPS_HOME = process.env.TRIPS_HOME || path.join(os.homedir(), 'trips'); +const CACHE = path.join(TRIPS_HOME, 'tilecache'); fs.mkdirSync(CACHE, { recursive: true }); -const STORE = path.join(__dirname, 'store'); // per-trip uploads (originals + parsed) + chat logs +// per-trip uploads (originals + parsed) + chat logs: ~/trips/store/mock// +const STORE = path.join(TRIPS_HOME, 'store', 'mock'); fs.mkdirSync(STORE, { recursive: true }); const mime = { diff --git a/router/scripts/setup-osrm-colombia.sh b/router/scripts/setup-osrm-colombia.sh index ba7f73a..2812e6a 100644 --- a/router/scripts/setup-osrm-colombia.sh +++ b/router/scripts/setup-osrm-colombia.sh @@ -15,7 +15,8 @@ set -euo pipefail cd "$(dirname "$0")" W="${W:-$HOME/osm-build}" -OSM_DIR="$(cd ../.. && pwd)/osm" +OSM_DIR="${OSM_DIR:-$HOME/trips/osm}" # raw PBFs live outside the dev tree +mkdir -p "$OSM_DIR" DATA_DIR="$W/data/colombia" OSRM_BIN="$W/build" OSRM_SRC="$W/osrm-backend-26.4.1" diff --git a/router/scripts/setup-osrm.sh b/router/scripts/setup-osrm.sh index 8144a86..c9d89df 100755 --- a/router/scripts/setup-osrm.sh +++ b/router/scripts/setup-osrm.sh @@ -8,13 +8,15 @@ # scripts/setup-osrm.sh --no-serve # build + extract, don't serve # # Artifacts live in $W (default: $HOME/osm-build — durable; the extract -# is ~8 GB under $W/data). PBFs are in ../../osm/ (~1.1 GB, gitignored). +# is ~8 GB under $W/data). Raw PBFs live in ~/trips/osm (~1.1 GB; the dev +# tree holds source only — override with OSM_DIR). set -euo pipefail cd "$(dirname "$0")" W="${W:-$HOME/osm-build}" P="$W/prefix" -OSM_DIR="$(cd ../.. && pwd)/osm" +OSM_DIR="${OSM_DIR:-$HOME/trips/osm}" # raw PBFs live outside the dev tree +mkdir -p "$OSM_DIR" DATA_DIR="${DATA_DIR:-$W/data}" OSRM_SRC="$W/osrm-backend-26.4.1" OSRM_BIN="$W/build" diff --git a/spatial/README.md b/spatial/README.md index db975d2..94dd78b 100644 --- a/spatial/README.md +++ b/spatial/README.md @@ -18,15 +18,15 @@ nearest, bbox)"). Replaces the flat-file/Overpass approximations. * Docker with the current user in the `docker` group (on this box: one-time `sudo usermod -aG docker $USER`, then re-login). -* PBF extracts in `../osm/` (already present: `nh.osm.pbf`, - `colombia.osm.pbf`, US state extracts). +* PBF extracts in `~/trips/osm` (already present: `nh.osm.pbf`, + `colombia.osm.pbf`, US state extracts; override with `OSM_DIR`). ## Usage ```bash docker compose up -d postgis # first: runs schema.sql -./import.sh ../osm/nh.osm.pbf nh # load New England (default) -./import.sh ../osm/colombia.osm.pbf colombia +./import.sh ~/trips/osm/nh.osm.pbf nh # load New England (default) +./import.sh ~/trips/osm/colombia.osm.pbf colombia docker compose up -d spatiald # query service on :5005 ``` diff --git a/spatial/docker-compose.yml b/spatial/docker-compose.yml index 4d6c220..6fae81f 100644 --- a/spatial/docker-compose.yml +++ b/spatial/docker-compose.yml @@ -1,7 +1,10 @@ # PostGIS spatial stack for the trip planner. # # docker compose up -d postgis # start the DB (schema.sql runs on first boot) -# ./import.sh ../osm/nh.osm.pbf # import an OSM extract (one-shot osm2pgsql) +# ./import.sh # import ~/trips/osm/nh.osm.pbf (one-shot osm2pgsql) +# +# OSM_DIR (default ~/trips/osm) is where the PBF extracts live — outside the +# dev tree. Export it to override. # docker compose run --rm spatiald # start the query service on :5005 # # The PBF extracts live in ../osm (gitignored). osm2pgsql runs as a one-shot @@ -43,7 +46,7 @@ services: --flat-nodes=/tmp/flat.nodes --disable-operations --import-strips=10 volumes: - - ../osm:/data:ro + - ${OSM_DIR:-$HOME/trips/osm}:/data:ro spatiald: build: . diff --git a/spatial/import.sh b/spatial/import.sh index 92e80f4..bccd07b 100755 --- a/spatial/import.sh +++ b/spatial/import.sh @@ -3,7 +3,8 @@ # # ./import.sh [file.osm.pbf] [extract-name] # -# file.osm.pbf default: ../osm/nh.osm.pbf (path may be absolute) +# file.osm.pbf default: $OSM_DIR/nh.osm.pbf (OSM_DIR defaults to +# ~/trips/osm — the PBFs live outside the dev tree) # extract-name default: basename without extension # # The PBF must be readable by uid 1001 (the osm2pgsql image user) — the @@ -12,7 +13,8 @@ set -euo pipefail cd "$(dirname "$0")" -PBF=${1:-../osm/nh.osm.pbf} +OSM_DIR="${OSM_DIR:-$HOME/trips/osm}" +PBF=${1:-$OSM_DIR/nh.osm.pbf} NAME=${2:-$(basename "${PBF%.osm.pbf}")} ABS=$(realpath "$PBF") [[ -f $ABS ]] || { echo "no such PBF: $ABS" >&2; exit 1; }