Repository navigation
feat(cliproxyapi): add auth backup recovery from dotfiles #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ BACKUP_DIR="s3://cliproxyapi/backup/auths/" | |||||||||||||||||
| MAIN_DIR="s3://cliproxyapi/auths/" | ||||||||||||||||||
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||||||||||||||||||
| CCS_AUTH_DIR="$HOME/.ccs/cliproxy/auth" | ||||||||||||||||||
| DOTFILES_AUTH_DIR="$HOME/dotfiles/objectstore/auths" | ||||||||||||||||||
|
|
||||||||||||||||||
| # STEP 1: Pull from R2 to local (captures files created by cliproxyapi directly in R2) | ||||||||||||||||||
| mkdir -p "$AUTH_DIR" | ||||||||||||||||||
|
|
@@ -37,6 +38,12 @@ if [ -d "$CCS_AUTH_DIR" ] && [ -n "$(ls -A "$CCS_AUTH_DIR" 2>/dev/null)" ]; then | |||||||||||||||||
| echo "✅ Synced from ccs auth dir to local cache" >&2 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # STEP 3: Recover missing files from git-tracked dotfiles backup (macOS only; Linux relies on R2) | ||||||||||||||||||
| if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||||||||
| @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" | ||||||||||||||||||
| echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2 | ||||||||||||||||||
|
Comment on lines
+43
to
+44
|
||||||||||||||||||
| fi | ||||||||||||||||||
|
Comment on lines
+42
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic block is very similar to the one in Additionally, using
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| # Check if auth directory has files | ||||||||||||||||||
| if [ -d "$AUTH_DIR" ] && [ -n "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||||||||
| echo "Syncing auth files to R2..." >&2 | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ CONFIG_DIR="$HOME/.cli-proxy-api" | |||||||||||
| TEMPLATE="$CONFIG_DIR/config.template.yaml" | ||||||||||||
| CONFIG="$CONFIG_DIR/config.yaml" | ||||||||||||
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||||||||||||
| DOTFILES_AUTH_DIR="$HOME/dotfiles/objectstore/auths" | ||||||||||||
| # Use explicit path since $HOME may not be set correctly in launchd context | ||||||||||||
| ENV_FILE="${HOME:-/Users/shunkakinoki}/dotfiles/.env" | ||||||||||||
|
|
||||||||||||
|
|
@@ -49,6 +50,12 @@ if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ]; t | |||||||||||
| "s3://cliproxyapi/backup/auths/" \ | ||||||||||||
| "$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true | ||||||||||||
|
|
||||||||||||
| # Recover missing files from git-tracked dotfiles backup (macOS only; Linux Docker uses R2) | ||||||||||||
| if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The dotfiles recovery logic is nested inside the objectstore credentials conditional block. This means recovery from dotfiles backup will never run on macOS when Prompt for AI agents |
||||||||||||
| @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" | ||||||||||||
| echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 | ||||||||||||
|
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because the dotfiles recovery block is nested inside the Useful? React with 👍 / 👎.
Comment on lines
+55
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Missing error handling for rsync command. Under Prompt for AI agents
Suggested change
|
||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+55
to
+58
|
||||||||||||
| @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" | |
| echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 | |
| fi | |
| @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" && echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 || echo "⚠️ Failed to bootstrap from dotfiles backup" >&2 || true | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment labels the recovery step as "STEP 3" but the subsequent sync operations (lines 47-77) are not labeled as "STEP 4". For consistency with the existing step numbering scheme (STEP 1 and STEP 2), consider adding a "# STEP 4:" comment before line 47 or removing the step numbering from the new STEP 3 comment.