replit-tools 1.1.5 → 1.1.7
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.
- package/package.json +1 -1
- package/scripts/setup-claude-code.sh +90 -69
package/package.json
CHANGED
|
@@ -73,7 +73,8 @@ auto_update_scripts() {
|
|
|
73
73
|
return 1
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
if
|
|
76
|
+
# Skip update check if we just re-sourced after an update
|
|
77
|
+
if [[ $- == *i* ]] && [ -z "${_REPLIT_TOOLS_UPDATED}" ]; then
|
|
77
78
|
CURRENT_VERSION=""
|
|
78
79
|
if [ -f "${VERSION_FILE}" ]; then
|
|
79
80
|
CURRENT_VERSION=$(cat "${VERSION_FILE}" 2>/dev/null)
|
|
@@ -89,6 +90,11 @@ if [[ $- == *i* ]]; then
|
|
|
89
90
|
|
|
90
91
|
if auto_update_scripts "${LATEST_VERSION}"; then
|
|
91
92
|
echo " ✅ Updated to v${LATEST_VERSION}"
|
|
93
|
+
# Re-source the updated script so new code runs
|
|
94
|
+
export _REPLIT_TOOLS_UPDATED=1
|
|
95
|
+
source "${SCRIPTS_DIR}/setup-claude-code.sh"
|
|
96
|
+
unset _REPLIT_TOOLS_UPDATED
|
|
97
|
+
return 0 2>/dev/null || exit 0
|
|
92
98
|
else
|
|
93
99
|
echo " ⚠️ Auto-update failed, continuing with v${CURRENT_VERSION}"
|
|
94
100
|
fi
|
|
@@ -96,6 +102,11 @@ if [[ $- == *i* ]]; then
|
|
|
96
102
|
echo "📦 DATA Tools v${CURRENT_VERSION}"
|
|
97
103
|
fi
|
|
98
104
|
fi
|
|
105
|
+
elif [[ $- == *i* ]] && [ -n "${_REPLIT_TOOLS_UPDATED}" ]; then
|
|
106
|
+
# Show version after re-source
|
|
107
|
+
if [ -f "${VERSION_FILE}" ]; then
|
|
108
|
+
echo "📦 DATA Tools v$(cat "${VERSION_FILE}" 2>/dev/null)"
|
|
109
|
+
fi
|
|
99
110
|
fi
|
|
100
111
|
|
|
101
112
|
# =============================================================================
|
|
@@ -229,85 +240,95 @@ if [[ ":$PATH:" != *":${LOCAL_BIN}:"* ]]; then
|
|
|
229
240
|
fi
|
|
230
241
|
|
|
231
242
|
# =============================================================================
|
|
232
|
-
# Step 6: Auto-refresh OAuth token if needed
|
|
243
|
+
# Step 6: Auto-refresh OAuth token if needed (with loop prevention)
|
|
233
244
|
# =============================================================================
|
|
234
245
|
CREDENTIALS_FILE="${CLAUDE_PERSISTENT}/.credentials.json"
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
246
|
+
|
|
247
|
+
# Prevent infinite refresh loops - only try once per shell session
|
|
248
|
+
if [ -z "${_REPLIT_TOOLS_AUTH_CHECKED}" ]; then
|
|
249
|
+
export _REPLIT_TOOLS_AUTH_CHECKED=1
|
|
250
|
+
|
|
251
|
+
if [ -f "${CREDENTIALS_FILE}" ] && [ -f "${AUTH_REFRESH_SCRIPT}" ]; then
|
|
252
|
+
# Source the auth refresh script to get the function
|
|
253
|
+
source "${AUTH_REFRESH_SCRIPT}"
|
|
254
|
+
|
|
255
|
+
# Check and refresh if needed (this handles all the logic)
|
|
256
|
+
if command -v node &> /dev/null; then
|
|
257
|
+
AUTH_INFO=$(node -e "
|
|
258
|
+
try {
|
|
259
|
+
const creds = require('${CREDENTIALS_FILE}');
|
|
260
|
+
const oauth = creds.claudeAiOauth;
|
|
261
|
+
const apiKey = creds.primaryApiKey;
|
|
262
|
+
if (apiKey) {
|
|
263
|
+
console.log('apikey:permanent');
|
|
264
|
+
} else if (oauth && oauth.expiresAt) {
|
|
265
|
+
const now = Date.now();
|
|
266
|
+
const remaining = Math.floor((oauth.expiresAt - now) / 1000 / 60 / 60);
|
|
267
|
+
const hasRefresh = oauth.refreshToken ? 'yes' : 'no';
|
|
268
|
+
console.log('oauth:' + remaining + ':' + hasRefresh);
|
|
269
|
+
} else {
|
|
270
|
+
console.log('none');
|
|
271
|
+
}
|
|
272
|
+
} catch(e) { console.log('error'); }
|
|
273
|
+
" 2>/dev/null)
|
|
274
|
+
|
|
275
|
+
IFS=':' read -r auth_type remaining has_refresh <<< "${AUTH_INFO}"
|
|
276
|
+
|
|
277
|
+
if [ "${auth_type}" = "apikey" ]; then
|
|
278
|
+
log "✅ Claude authentication: API key (permanent)"
|
|
279
|
+
elif [ "${auth_type}" = "oauth" ]; then
|
|
280
|
+
if [ "${remaining}" -le 0 ]; then
|
|
281
|
+
# Token expired - try to refresh once
|
|
282
|
+
if [ "${has_refresh}" = "yes" ]; then
|
|
283
|
+
log "⚠️ Token expired, attempting refresh..."
|
|
284
|
+
if refresh_token 2>/dev/null; then
|
|
285
|
+
NEW_REMAINING=$(node -e "
|
|
286
|
+
try {
|
|
287
|
+
const creds = require('${CREDENTIALS_FILE}');
|
|
288
|
+
const remaining = Math.floor((creds.claudeAiOauth.expiresAt - Date.now()) / 1000 / 60 / 60);
|
|
289
|
+
console.log(remaining);
|
|
290
|
+
} catch(e) { console.log('0'); }
|
|
291
|
+
" 2>/dev/null)
|
|
292
|
+
log "✅ Claude authentication: refreshed (${NEW_REMAINING}h remaining)"
|
|
293
|
+
else
|
|
294
|
+
log "❌ Token refresh failed - will use --dangerously-skip-permissions"
|
|
295
|
+
export CLAUDE_SKIP_AUTH=1
|
|
296
|
+
fi
|
|
276
297
|
else
|
|
277
|
-
log "❌ Token refresh
|
|
298
|
+
log "❌ Token expired (no refresh token) - will use --dangerously-skip-permissions"
|
|
299
|
+
export CLAUDE_SKIP_AUTH=1
|
|
278
300
|
fi
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
301
|
+
elif [ "${remaining}" -lt 2 ]; then
|
|
302
|
+
# Less than 2 hours - refresh proactively
|
|
303
|
+
if [ "${has_refresh}" = "yes" ]; then
|
|
304
|
+
log "🔄 Token expires in ${remaining}h, refreshing..."
|
|
305
|
+
if refresh_token 2>/dev/null; then
|
|
306
|
+
NEW_REMAINING=$(node -e "
|
|
307
|
+
try {
|
|
308
|
+
const creds = require('${CREDENTIALS_FILE}');
|
|
309
|
+
const remaining = Math.floor((creds.claudeAiOauth.expiresAt - Date.now()) / 1000 / 60 / 60);
|
|
310
|
+
console.log(remaining);
|
|
311
|
+
} catch(e) { console.log('0'); }
|
|
312
|
+
" 2>/dev/null)
|
|
313
|
+
log "✅ Claude authentication: refreshed (${NEW_REMAINING}h remaining)"
|
|
314
|
+
else
|
|
315
|
+
log "⚠️ Refresh failed, ${remaining}h remaining"
|
|
316
|
+
fi
|
|
295
317
|
else
|
|
296
|
-
log "⚠️
|
|
318
|
+
log "⚠️ Claude authentication: ${remaining}h remaining (no refresh token)"
|
|
297
319
|
fi
|
|
298
320
|
else
|
|
299
|
-
log "
|
|
321
|
+
log "✅ Claude authentication: valid (${remaining}h remaining)"
|
|
300
322
|
fi
|
|
301
|
-
|
|
302
|
-
log "
|
|
323
|
+
elif [ "${auth_type}" = "none" ] || [ "${auth_type}" = "error" ]; then
|
|
324
|
+
log "⚠️ No valid auth found - will use --dangerously-skip-permissions"
|
|
325
|
+
export CLAUDE_SKIP_AUTH=1
|
|
303
326
|
fi
|
|
304
|
-
elif [ "${auth_type}" = "error" ]; then
|
|
305
|
-
log "⚠️ Could not read credentials"
|
|
306
327
|
fi
|
|
328
|
+
elif [ ! -f "${CREDENTIALS_FILE}" ]; then
|
|
329
|
+
log "⚠️ No credentials - will use --dangerously-skip-permissions"
|
|
330
|
+
export CLAUDE_SKIP_AUTH=1
|
|
307
331
|
fi
|
|
308
|
-
elif [ ! -f "${CREDENTIALS_FILE}" ]; then
|
|
309
|
-
log "⚠️ No Claude credentials found. Run 'claude login' to authenticate"
|
|
310
|
-
log " 💡 Tip: Run 'claude setup-token' for a long-lived token"
|
|
311
332
|
fi
|
|
312
333
|
|
|
313
334
|
# =============================================================================
|