thrivekit 2.0.9 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/ralph/init.sh +62 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thrivekit",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "Tools to thrive with agentic coding - RALPH autonomous loop, Claude Code hooks, PRD-driven development",
5
5
  "author": "Allie Jones <allie@allthrive.ai>",
6
6
  "license": "MIT",
package/ralph/init.sh CHANGED
@@ -188,16 +188,38 @@ auto_configure_project() {
188
188
 
189
189
  # 2. Detect testUrlBase from common patterns
190
190
  local base_url=""
191
- # Check package.json scripts for dev server port
192
- if [[ -f "package.json" ]]; then
191
+
192
+ # Check for Vite config (uses port 5173 by default)
193
+ for vite_config in "vite.config.ts" "vite.config.js" "apps/web/vite.config.ts" "apps/web/vite.config.js" \
194
+ "apps/frontend/vite.config.ts" "frontend/vite.config.ts"; do
195
+ if [[ -f "$vite_config" ]]; then
196
+ base_url="http://localhost:5173"
197
+ break
198
+ fi
199
+ done
200
+
201
+ # Check for Next.js (uses port 3000 by default)
202
+ if [[ -z "$base_url" ]]; then
203
+ for next_config in "next.config.js" "next.config.ts" "next.config.mjs" \
204
+ "apps/web/next.config.js" "apps/web/next.config.mjs"; do
205
+ if [[ -f "$next_config" ]]; then
206
+ base_url="http://localhost:3000"
207
+ break
208
+ fi
209
+ done
210
+ fi
211
+
212
+ # Fallback: Check package.json scripts for dev server port
213
+ if [[ -z "$base_url" && -f "package.json" ]]; then
193
214
  if grep -q '"dev".*:3000' package.json 2>/dev/null; then
194
215
  base_url="http://localhost:3000"
195
216
  elif grep -q '"dev".*:5173' package.json 2>/dev/null; then
196
- base_url="http://localhost:5173" # Vite default
217
+ base_url="http://localhost:5173"
197
218
  elif grep -q '"dev".*:8080' package.json 2>/dev/null; then
198
219
  base_url="http://localhost:8080"
199
220
  fi
200
221
  fi
222
+
201
223
  # Check for monorepo frontend
202
224
  for fe_pkg in "apps/web/package.json" "apps/frontend/package.json" "frontend/package.json"; do
203
225
  if [[ -f "$fe_pkg" && -z "$base_url" ]]; then
@@ -254,7 +276,43 @@ auto_configure_project() {
254
276
  fi
255
277
  fi
256
278
 
257
- # 4. Detect package manager
279
+ # 4. Detect API baseUrl based on backend type
280
+ local api_url=""
281
+ if [[ -n "$backend_dir" ]]; then
282
+ # Check Dockerfile for EXPOSE directive
283
+ if [[ -f "$backend_dir/Dockerfile" ]]; then
284
+ local docker_port
285
+ docker_port=$(grep -i "^EXPOSE" "$backend_dir/Dockerfile" 2>/dev/null | head -1 | grep -oE '[0-9]+' | head -1)
286
+ if [[ -n "$docker_port" ]]; then
287
+ api_url="http://localhost:$docker_port"
288
+ fi
289
+ fi
290
+ # Python backends (FastAPI/Django) typically use port 8000
291
+ if [[ -z "$api_url" ]] && { [[ -f "$backend_dir/pyproject.toml" ]] || [[ -f "$backend_dir/requirements.txt" ]] || [[ -f "$backend_dir/main.py" ]]; }; then
292
+ api_url="http://localhost:8000"
293
+ # Node backends - check for port in package.json or default to 3001
294
+ elif [[ -z "$api_url" && -f "$backend_dir/package.json" ]]; then
295
+ if grep -q ':3001' "$backend_dir/package.json" 2>/dev/null; then
296
+ api_url="http://localhost:3001"
297
+ elif grep -q ':4000' "$backend_dir/package.json" 2>/dev/null; then
298
+ api_url="http://localhost:4000"
299
+ else
300
+ api_url="http://localhost:3001"
301
+ fi
302
+ fi
303
+ fi
304
+
305
+ if [[ -n "$api_url" ]]; then
306
+ if jq -e '.api.baseUrl' "$tmpfile" >/dev/null 2>&1 && [[ "$(jq -r '.api.baseUrl' "$tmpfile")" != "" ]]; then
307
+ : # Already set
308
+ else
309
+ jq --arg url "$api_url" '.api.baseUrl = $url' "$tmpfile" > "${tmpfile}.new" && mv "${tmpfile}.new" "$tmpfile"
310
+ echo " Auto-detected api.baseUrl: $api_url"
311
+ updated=true
312
+ fi
313
+ fi
314
+
315
+ # 5. Detect package manager
258
316
  local pkg_manager="npm"
259
317
  if [[ -f "pnpm-lock.yaml" ]]; then
260
318
  pkg_manager="pnpm"