Room entities/DAOs/DB, PocketBase Retrofit client + auth interceptor, SyncEngine (push-then-pull, LWW, tombstones, client-generated ids), SettingsStore, AppContainer. Open Library + Google Books merge, ISBN validation, CameraX + ML Kit scanner plumbing. Verified by orchestrator: assembleDebug exit 0; testDebugUnitTest exit 0, 68 tests, 0 failures, 0 errors. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bThmkmyUUdqQpy3MXFFe5
37 lines
2.0 KiB
Bash
Executable File
37 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# run-resume.sh <task-name> <prompt-file>
|
|
# Like run-task.sh, but resumes an EXISTING session with a SPECIFIC prompt
|
|
# (run-task.sh sends only a generic "continue" message on resume).
|
|
set -u
|
|
NAME="$1"; PROMPT_FILE="$2"
|
|
L="$HOME/bookshelf/logs"; LOG="$L/${NAME}.json"; ERR="$L/${NAME}.err"
|
|
SIDF="$L/${NAME}.sid"; ST="$L/${NAME}.state"
|
|
MAX_WALL="${MAX_WALL:-86400}"; POLL="${POLL:-600}"; MAX_HARD_FAILS="${MAX_HARD_FAILS:-3}"
|
|
export JAVA_HOME="$HOME/toolchain/jdk21"
|
|
export ANDROID_HOME="$HOME/toolchain/android-sdk"; export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
|
export PATH="$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$PATH"
|
|
cd "$HOME/bookshelf" || exit 1
|
|
SID="$(cat "$SIDF")"
|
|
say(){ echo "[$(date -Is)] $NAME: $*" >> "$ST"; }
|
|
say "RESUME-with-prompt sid=$SID file=$PROMPT_FILE"
|
|
deadline=$(( $(date +%s) + MAX_WALL )); attempt=0; hard=0; qw=0
|
|
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
attempt=$((attempt+1)); say "attempt $attempt: resume $SID"
|
|
claude -p --model sonnet --permission-mode bypassPermissions \
|
|
--output-format json --add-dir "$HOME/bookshelf" --resume "$SID" \
|
|
< "$PROMPT_FILE" > "$LOG" 2>"$ERR"
|
|
rc=$?
|
|
blob="$(cat "$LOG" "$ERR" 2>/dev/null | head -c 20000)"
|
|
if printf '%s' "$blob" | grep -qiE 'usage limit|limit will reset|limit resets|rate_limit_error|rate limit exceeded|429|too many requests|overloaded_error'; then
|
|
qw=$((qw+1)); say "QUOTA hit (wait #$qw), sleeping ${POLL}s"; sleep "$POLL"; continue; fi
|
|
isErr="$(jq -r '.is_error // false' "$LOG" 2>/dev/null)"
|
|
if [ "$rc" -eq 0 ] && [ "$isErr" != "true" ]; then say "SUCCESS after $attempt attempt(s)"; break; fi
|
|
hard=$((hard+1)); say "hard failure #$hard (rc=$rc)"
|
|
[ "$hard" -ge "$MAX_HARD_FAILS" ] && { say "GIVING UP"; break; }
|
|
sleep 60
|
|
done
|
|
{ echo "=== $NAME attempts=$attempt quota_waits=$qw hard_fails=$hard ==="
|
|
jq -r '"cost=$" + ((.total_cost_usd//0)|tostring) + " turns=" + ((.num_turns//0)|tostring)' "$LOG" 2>/dev/null
|
|
echo "--- result ---"; jq -r '.result // "no result"' "$LOG" 2>/dev/null | tail -c 1500
|
|
} > "$L/${NAME}.summary"
|