Skip to content

fix(cliproxyapi): improve legacy service configuration and documentation - #456

Merged
shunkakinoki merged 7 commits into
mainfrom
fix/legacy-cliproxyapi
Dec 27, 2025
Merged

fix(cliproxyapi): improve legacy service configuration and documentation#456
shunkakinoki merged 7 commits into
mainfrom
fix/legacy-cliproxyapi

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Dec 27, 2025

Copy link
Copy Markdown
Owner

Summary

This PR enhances the cliproxyapi service with comprehensive documentation and improves the start script with proper rsync path variable substitution. It refactors the authentication file syncing to remove unnecessary root directory sync while preserving OAuth token functionality.

Changes

  • Documentation: Add comprehensive README for cliproxyapi service configuration and management
  • Start Script: Add rsync path to variable substitution in start.sh for proper environment variable handling
  • Auth Syncing: Remove root auths directory sync to eliminate redundant OAuth token syncing
  • Config Updates: Refactor API key structure and add model mappings to config.yaml
  • Backup Script: Enhance backup script with improved auth file syncing from R2 storage

Files Modified

  • config/cliproxyapi/config.yaml - Enhanced API configuration
  • home-manager/services/cliproxyapi/README.md - New comprehensive documentation
  • home-manager/services/cliproxyapi/default.nix - Updated module configuration
  • home-manager/services/cliproxyapi/scripts/backup-auth.sh - Enhanced backup logic
  • home-manager/services/cliproxyapi/scripts/start.sh - Added rsync path substitution

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Configuration refinement

Note

Strengthens cliproxyapi’s auth handling and docs with objectstore-centric workflows and safer sync.

  • Auth sync overhaul: start.sh now pulls auths from R2 (auths/ + backup/auths/) before launch and bootstraps from dotfiles only if empty; backup script stops reading from dotfiles to avoid loops and still merges CCS tokens
  • File watching: Removes dotfiles from launchd WatchPaths, preventing circular sync; watchers now monitor only objectstore/auths and ~/.ccs/cliproxy/auth
  • Config: Switches provider keys to api-key-entries in config.yaml; adds commented ampcode.model-mappings example
  • Nix module: Injects rsync path for scripts; updates PATHs accordingly
  • Docs: Adds comprehensive README.md describing architecture, flows, and recovery

Written by Cursor Bugbot for commit fe285e8. Configure here.


Summary by cubic

Improves cliproxyapi reliability and docs. Startup now pulls auth files from R2, removes circular sync loops, and keeps OAuth tokens working.

  • Bug Fixes

    • Sync auth files from R2 (auths and backup/auths) before start; bootstrap from dotfiles only if empty.
    • Read auth only from objectstore/auths when object storage is enabled; remove root auths sync.
    • Exclude dotfiles from WatchPaths and disable dotfiles→cache sync to prevent infinite loops.
    • Add rsync path substitution in start.sh for correct env path handling.
  • New Features

    • Add comprehensive README covering setup, OAuth, backups, and recovery.
    • Update config: switch api-keys to api-key-entries and add optional model-mappings example.

Written for commit fe285e8. Summary will update automatically on new commits.

Copilot AI review requested due to automatic review settings December 27, 2025 05:43
@mesa-dot-dev

mesa-dot-dev Bot commented Dec 27, 2025

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Dec 27, 2025

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added automatic authentication file synchronization from object storage before service startup.
    • Added bootstrap fallback mechanism to use local authentication files when object storage is unavailable.
  • Documentation

    • Added comprehensive service configuration and operation documentation.
  • Configuration

    • Restructured API key configuration format in provider blocks for improved organization.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This change restructures CLIProxyAPI's authentication and configuration handling by introducing R2 object storage as the primary auth file source during service startup, disabling dotfiles-based syncing to prevent circular loops, updating API key configuration schema, and establishing comprehensive service documentation.

Changes

Cohort / File(s) Summary
Configuration Schema Update
config/cliproxyapi/config.yaml
Renamed api-keys to api-key-entries for openai-compatibility and z-ai providers; changed structure from simple string array to object array with nested api-key field. Added commented model-mappings example under ampcode provider.
Auth Synchronization & Service Startup
home-manager/services/cliproxyapi/scripts/start.sh, home-manager/services/cliproxyapi/scripts/backup-auth.sh
Added pre-start R2 object storage sync for auth files with fallback to local git-tracked dotfiles; disabled dotfiles-based synchronization in backup-auth to prevent circular sync loops. Changes control flow to prioritize remote auth storage with optional local bootstrap.
Service Definition & Documentation
home-manager/services/cliproxyapi/default.nix, home-manager/services/cliproxyapi/README.md
Added rsync path to substitution variables and removed dotfiles watch path from Darwin backup list; added comprehensive README documenting architecture, object storage integration, OAuth token management, backup/recovery flows, and operational procedures.

Sequence Diagram

sequenceDiagram
    participant Service as CLIProxyAPI Service
    participant Cache as Local Auth Cache
    participant R2 as R2 Object Storage
    participant Git as Git Dotfiles
    participant Config as Config Generator

    Note over Service,Git: Service Startup Flow (New)
    Service->>R2: Check OBJECTSTORE_ENDPOINT<br/>OBJECTSTORE_ACCESS_KEY
    alt R2 Credentials Present
        R2-->>Cache: Sync from s3://cliproxyapi/auths/
        R2-->>Cache: Sync from s3://cliproxyapi/backup/auths/
        Note over Cache: Auth files synced from R2
    else R2 Unavailable or Empty
        Service->>Git: Check local git-tracked dotfiles
        alt Dotfiles Contain Auth
            Git-->>Cache: Bootstrap auth files
            Note over Cache: Auth files bootstrapped from dotfiles
        end
    end
    
    Note over Service,Config: Config Generation (Existing)
    Service->>Config: Generate config from template
    Config->>R2: Persist config to objectstore
    Note over R2: Config persisted
    
    Service->>Service: Start CLIProxyAPI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 The config now speaks in structured prose,
Auth flows from object storage's repose,
No dotfiles circles spinning 'round and 'round,
With R2 syncing safely to the ground! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective: improving cliproxyapi's legacy service configuration through documentation, start script enhancements, and auth syncing refactors.
Description check ✅ Passed The description comprehensively relates to all changes in the changeset, clearly detailing modifications across all five modified files and their purposes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/legacy-cliproxyapi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the cliproxyapi service by introducing comprehensive documentation, refining its authentication file synchronization mechanisms, and improving its overall robustness. The changes streamline the management of OAuth tokens with R2 storage, prevent potential circular sync issues, and provide clearer guidance for service setup and operation, ultimately making the service more reliable and user-friendly.

Highlights

  • Comprehensive Documentation: A new README.md provides detailed configuration, architecture, auth management, and usage instructions for the cliproxyapi service, significantly improving clarity and ease of use.
  • Improved Auth Syncing Logic: The start.sh script now critically pulls auth files from R2 storage (primary and backup) before service startup and includes bootstrap logic from dotfiles if the object store is empty, ensuring up-to-date authentication.
  • Circular Sync Loop Prevention: The backup-auth.sh script and default.nix configuration have been updated to prevent infinite sync loops by making the dotfiles/objectstore/auths directory write-only and removing it from watched paths.
  • Refined API Key Structure: The config.yaml now uses api-key-entries for OpenAI-compatible providers, allowing for a more structured and consistent API key configuration.
  • Rsync Path Variable Substitution: The start.sh script now correctly substitutes the rsync path variable, ensuring proper environment handling and script execution.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Dec 27, 2025

Copy link
Copy Markdown

Mesa Description

TL;DR

This PR enhances the cliproxyapi service with comprehensive documentation and improves the start script with proper rsync path variable substitution. It refactors the authentication file syncing to remove unnecessary root directory sync while preserving OAuth token functionality.

What changed?

  • Documentation: Add comprehensive README for cliproxyapi service configuration and management
  • Start Script: Add rsync path to variable substitution in start.sh for proper environment variable handling
  • Auth Syncing: Remove root auths directory sync to eliminate redundant OAuth token syncing
  • Config Updates: Refactor API key structure and add model mappings to config.yaml
  • Backup Script: Enhance backup script with improved auth file syncing from R2 storage

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="home-manager/services/cliproxyapi/default.nix">

<violation number="1" location="home-manager/services/cliproxyapi/default.nix:94">
P2: The comment documents that dotfiles is excluded to prevent circular sync loops, but this exclusion was only applied to the macOS launchd configuration. The Linux systemd path watcher (`systemd.user.paths.cliproxyapi-backup`) still includes `%h/dotfiles/objectstore/auths` in its `PathChanged` list, which could cause the same circular sync issue on Linux systems.</violation>
</file>

Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.

}:/opt/homebrew/bin:/usr/local/bin:/usr/bin";
};
# Watch auth directories for changes - triggers sync immediately
# NOTE: dotfiles is excluded to prevent circular sync loops

@cubic-dev-ai cubic-dev-ai Bot Dec 27, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The comment documents that dotfiles is excluded to prevent circular sync loops, but this exclusion was only applied to the macOS launchd configuration. The Linux systemd path watcher (systemd.user.paths.cliproxyapi-backup) still includes %h/dotfiles/objectstore/auths in its PathChanged list, which could cause the same circular sync issue on Linux systems.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/default.nix, line 94:

<comment>The comment documents that dotfiles is excluded to prevent circular sync loops, but this exclusion was only applied to the macOS launchd configuration. The Linux systemd path watcher (`systemd.user.paths.cliproxyapi-backup`) still includes `%h/dotfiles/objectstore/auths` in its `PathChanged` list, which could cause the same circular sync issue on Linux systems.</comment>

<file context>
@@ -90,9 +91,9 @@ in
         }:/opt/homebrew/bin:/usr/local/bin:/usr/bin&quot;;
       };
       # Watch auth directories for changes - triggers sync immediately
+      # NOTE: dotfiles is excluded to prevent circular sync loops
       WatchPaths = [
         &quot;${homeDir}/.cli-proxy-api/objectstore/auths&quot;
</file context>
Fix with Cubic

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the cliproxyapi service by adding comprehensive documentation and refining the authentication file syncing logic. The changes to prevent circular sync loops are well-implemented. My review focuses on enhancing the clarity and consistency of the new documentation and improving the robustness of the shell scripts. I've suggested fixes for a broken diagram in the README, recommended using configuration variables instead of hardcoded values in the start script, and pointed out opportunities to simplify shell script logic.

Comment on lines +36 to +50
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true

AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/backup/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The S3 bucket name cliproxyapi is hardcoded in the s3 sync commands. The script already exports the OBJECTSTORE_BUCKET environment variable, which should be used here to make the script more configurable and consistent. This will allow users to change the bucket name via the .env file without modifying the script.

Suggested change
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/backup/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://${OBJECTSTORE_BUCKET}/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 auths/" >&2 || true
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://${OBJECTSTORE_BUCKET}/backup/auths/" \
"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true

│ ┌────────────┐ │ │ ┌────────────────────────┐ │
│ │ backup/ │◄─┼──────┤ │ OAuth tokens stored │ │
│ └────────────┘ │ │ │ - claude-*.json │ │
└──────────────────┘ │ │ - codex-*.json │ │

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ASCII art diagram for the data flow appears to be broken on this line, which harms readability. The R2 Storage box closing └──────────────────┘ is misaligned with the rest of the diagram, causing a visual glitch.

Additionally, the diagram might be slightly misleading:

  • The arrow from backup/ on line 75 seems to point to OAuth tokens stored instead of objectstore/auths/. According to the description, both primary and backup R2 locations sync to objectstore/auths/.

Please review and fix the diagram's formatting and arrows to accurately reflect the data flow described in the text.

- Runs on service start
- Pulls auth files from R2
- Bootstraps from dotfiles if needed
- Syncs to OAuth directory

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The term "OAuth directory" is used here, but the rest of the documentation consistently refers to objectstore/auths/. For consistency and clarity, it would be better to use the actual directory name.

Suggested change
- Syncs to OAuth directory
- Syncs to objectstore/auths


## Notes

- **Auth file naming:** Must match pattern `*-shunkakinoki@gmail.com.json` or `*-shunkakinoki_gmail_com.json`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The example auth file name includes a specific email address (shunkakinoki@gmail.com). This should be generalized to be more useful for other users of this documentation. Using a placeholder like <user> or <user_identifier> would be more appropriate.

Suggested change
- **Auth file naming:** Must match pattern `*-shunkakinoki@gmail.com.json` or `*-shunkakinoki_gmail_com.json`
- **Auth file naming:** Must match pattern `*-<user>@gmail.com.json` or `*-<user>_gmail_com.json`

"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true

# Bootstrap from git-tracked dotfiles if objectstore is empty
if [ ! -d "$AUTH_DIR" ] || [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check for whether the auth directory is empty can be simplified. Since mkdir -p "$AUTH_DIR" is executed on line 33, the directory is guaranteed to exist. Therefore, the [ ! -d "$AUTH_DIR" ] part of the condition is redundant. Simplifying the check will make the script cleaner.

Suggested change
if [ ! -d "$AUTH_DIR" ] || [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then
if [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 75 to +78
- name: "openrouter"
base-url: "https://openrouter.ai/api/v1"
api-keys:
- "__OPENROUTER_API_KEY__"
api-key-entries:
- api-key: "__OPENROUTER_API_KEY__"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use api-keys for openai-compatibility auth

The openai-compatibility provider config previously used api-keys (list of strings), but this change switches to api-key-entries objects. If CLIProxyAPI only recognizes api-keys (as the earlier config did), it will ignore these entries and load no API keys for OpenRouter/Z-AI, causing all requests to those providers to be unauthenticated and fail (401/403). This only impacts environments using those providers; consider reverting to api-keys or confirming that api-key-entries is actually supported by the cliproxyapi config schema.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the cliproxyapi service configuration with comprehensive documentation, fixes rsync path substitution, and prevents circular sync loops by refactoring the authentication file synchronization flow.

  • Adds rsync path to Nix variable substitution in start.sh for proper environment variable handling
  • Removes dotfiles directory from WatchPaths to prevent circular sync loops during auth file monitoring
  • Refactors OpenAI compatibility provider configuration from simple api-keys list to structured api-key-entries format
  • Adds comprehensive README documentation covering architecture, auth management flow, and troubleshooting

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
home-manager/services/cliproxyapi/scripts/start.sh Adds AUTH_DIR variable and R2 auth file sync logic with bootstrap fallback to dotfiles; adds rsync placeholder for proper path substitution
home-manager/services/cliproxyapi/scripts/backup-auth.sh Comments out dotfiles-to-cache sync to prevent circular loops while maintaining dotfiles as write-only backup destination
home-manager/services/cliproxyapi/default.nix Adds rsync path substitution to startScript and removes dotfiles path from WatchPaths to prevent circular sync loops
home-manager/services/cliproxyapi/README.md New comprehensive documentation covering service architecture, auth file management flow, directory structure, environment variables, usage examples, and recovery scenarios
config/cliproxyapi/config.yaml Refactors openrouter and z-ai providers from api-keys list format to api-key-entries object format for consistency; adds commented model-mappings example for ampcode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/auths/" \

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bucket name is hardcoded as "cliproxyapi" in the S3 URIs, but OBJECTSTORE_BUCKET is exported on line 25. This creates an inconsistency where changing the bucket name via environment variable would not affect the actual bucket being accessed. Consider using the OBJECTSTORE_BUCKET variable in the S3 URIs instead of hardcoding, like "s3://${OBJECTSTORE_BUCKET}/auths/".

Copilot uses AI. Check for mistakes.
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT}" \
--no-progress \
"s3://cliproxyapi/backup/auths/" \

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bucket name is hardcoded as "cliproxyapi" in the S3 URI, but OBJECTSTORE_BUCKET is set in the environment (line 25 of start.sh). This creates an inconsistency where changing the bucket name via environment variable would not affect the actual bucket being accessed. Consider using the OBJECTSTORE_BUCKET variable instead of hardcoding, like "s3://${OBJECTSTORE_BUCKET}/backup/auths/".

Copilot uses AI. Check for mistakes.
- Runs on service start
- Pulls auth files from R2
- Bootstraps from dotfiles if needed
- Syncs to OAuth directory

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states "Syncs to OAuth directory" but the actual start.sh script does not perform any sync to a separate OAuth directory. The script pulls from R2 (lines 36-50), bootstraps from dotfiles if needed (lines 52-58), generates config (lines 63-93), and starts the cliproxyapi binary (lines 95-106). There is no OAuth directory sync step.

Suggested change
- Syncs to OAuth directory
- Generates config

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
home-manager/services/cliproxyapi/default.nix (1)

105-116: Add same dotfiles exclusion to Linux systemd configuration.

The Darwin launchd configuration (line 94-98) explicitly excludes dotfiles/objectstore/auths from WatchPaths with a comment noting this prevents circular sync loops. The Linux systemd PathChanged (lines 108-112) still includes %h/dotfiles/objectstore/auths, which contradicts this decision. The README documents that watching and writing to dotfiles simultaneously previously caused infinite sync loops. Remove %h/dotfiles/objectstore/auths from the systemd PathChanged list to match the Darwin implementation and prevent circular sync loops on Linux.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97cf0ca and fe285e8.

📒 Files selected for processing (5)
  • config/cliproxyapi/config.yaml
  • home-manager/services/cliproxyapi/README.md
  • home-manager/services/cliproxyapi/default.nix
  • home-manager/services/cliproxyapi/scripts/backup-auth.sh
  • home-manager/services/cliproxyapi/scripts/start.sh
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx,json,jsonc,md}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Use Biome for code formatting as configured in biome.json

Files:

  • home-manager/services/cliproxyapi/README.md
**/*.nix

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.nix: Use nixfmt for formatting all Nix files
Document complex configurations with comments in Nix files

**/*.nix: Use 2 spaces for indentation in Nix files
Keep line length under 100 characters in Nix files
Sort attribute sets alphabetically in Nix files
Use consistent spacing around operators in Nix files
Format lists and sets consistently in Nix files

Use treefmt.toml for formatting Nix files

**/*.nix: Use mkOption for configurable options in Nix modules
Implement proper typing for all options in Nix modules
Follow the Nix expression language style guide

Files:

  • home-manager/services/cliproxyapi/default.nix
**/default.nix

📄 CodeRabbit inference engine (CLAUDE.md)

Use default.nix files for module exports

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/*/default.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

Service configurations should be located in home-manager/services/<name>/ with proper service definitions and correct dependency handling

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/**/default.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/**/*.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

home-manager/**/*.nix: Use typed options whenever possible in Nix configurations
Document all configuration options in Nix modules and programs
Follow home-manager's module structure and keep configurations modular
Use proper indentation and formatting in Nix configuration files

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/**/*.nix

📄 CodeRabbit inference engine (.cursor/rules/nix.mdc)

Service configurations in home-manager/services/ should follow systemd service conventions, include proper service dependencies, and have clear documentation for service parameters

Files:

  • home-manager/services/cliproxyapi/default.nix
**/*.{sh,bash}

📄 CodeRabbit inference engine (CLAUDE.md)

Use shfmt with 2-space indentation for shell scripts

**/*.{sh,bash}: Use 2 spaces for indentation in shell scripts
Add proper shebang lines to shell scripts
Follow shellcheck recommendations in shell scripts
Document complex commands in shell scripts
Use consistent variable naming in shell scripts

Files:

  • home-manager/services/cliproxyapi/scripts/start.sh
  • home-manager/services/cliproxyapi/scripts/backup-auth.sh
**/*.{json,yaml,yml,toml}

📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)

**/*.{json,yaml,yml,toml}: Use consistent indentation (2 spaces) in configuration files
Sort keys alphabetically when possible in configuration files
Use clear, descriptive names in configuration files

Files:

  • config/cliproxyapi/config.yaml
**/*.{yaml,yml,toml}

📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)

Add comments for complex configurations

Files:

  • config/cliproxyapi/config.yaml
🧠 Learnings (6)
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Document all major changes in Nix configurations

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/programs/**/*.nix : Follow program-specific best practices in program configuration files

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/services/**/default.nix : Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Keep configurations modular across home-manager, hosts, and nix-darwin directories

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Follow home-manager's module structure and keep configurations modular

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Document all configuration options in Nix modules and programs

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
🪛 LanguageTool
home-manager/services/cliproxyapi/README.md

[grammar] ~238-~238: Ensure spelling is correct
Context: ...tion Files ### default.nix - Defines launchd agents (macOS) or systemd services (Lin...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
home-manager/services/cliproxyapi/README.md

18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


68-68: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Agent
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Cursor Bugbot
  • GitHub Check: shellcheck
  • GitHub Check: shellspec
  • GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
  • GitHub Check: e2e-run (NixOS, ubuntu-latest)
  • GitHub Check: nix-linux
  • GitHub Check: nix-darwin
  • GitHub Check: e2e-run (MacOS, macos-latest)
  • GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
  • GitHub Check: lua-neovim
  • GitHub Check: nix-nixos
  • GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
  • GitHub Check: lua-hammerspoon
  • GitHub Check: lua-neovim-test
🔇 Additional comments (7)
home-manager/services/cliproxyapi/README.md (1)

1-270: Excellent comprehensive documentation!

The README provides clear, thorough documentation of the service architecture, data flow, auth management, and operational procedures. The inclusion of recovery scenarios, troubleshooting steps, and detailed workflow explanations will significantly help with service maintenance and debugging.

home-manager/services/cliproxyapi/scripts/backup-auth.sh (1)

35-40: LGTM! Circular sync loop prevention implemented correctly.

Disabling the dotfiles-to-cache sync in the backup script and documenting it as bootstrap-only is the right approach to prevent circular sync loops. This aligns with the architecture where dotfiles serves as write-only storage (except during initial bootstrap in start.sh).

home-manager/services/cliproxyapi/scripts/start.sh (1)

29-61: LGTM! Auth sync and bootstrap logic is well-implemented.

The pre-start authentication sync flow is correctly structured:

  • Pulls from primary and backup R2 locations
  • Provides bootstrap fallback from dotfiles when objectstore is empty
  • Uses non-fatal error handling (|| true) appropriately
  • Includes clear user warnings for missing credentials

This implementation aligns well with the documented architecture in the README.

home-manager/services/cliproxyapi/default.nix (2)

11-11: LGTM! rsync path substitution added correctly.

The rsync binary path is now properly substituted in the start script, enabling the bootstrap sync logic from dotfiles to AUTH_DIR.


94-98: LGTM! Clear documentation of circular sync prevention.

The comment and removal of dotfiles from Darwin WatchPaths correctly prevents circular sync loops on macOS.

config/cliproxyapi/config.yaml (2)

41-43: LGTM! Model mappings example added.

The commented model-mappings example provides helpful documentation for ampcode configuration.


77-78: No action needed. The api-key-entries schema is the correct and current format for cliproxyapi's openai-compatibility providers. The legacy api-keys format (bare strings) is deprecated and automatically converted to api-key-entries by cliproxyapi on load. This is not a breaking change—it's the preferred configuration format.

Likely an incorrect or invalid review comment.

Comment on lines +18 to +37
```
~/.cli-proxy-api/
├── config.yaml # Generated config (from template)
├── config.template.yaml # Template with placeholders (symlink)
└── objectstore/
├── config/
│ └── config.yaml # Cloud-synced config
└── auths/ # Auth files (cliproxyapi reads from here)
├── claude-*.json # OAuth tokens for Claude
├── codex-*.json # OAuth tokens for Codex
└── antigravity-*.json # OAuth tokens for other services

~/dotfiles/objectstore/auths/ # Git-tracked backup (write-only)
~/.ccs/cliproxy/auth/ # CCS auth directory (two-way sync)

R2 Storage (Cloudflare):
├── s3://cliproxyapi/auths/ # Primary cloud storage
├── s3://cliproxyapi/backup/auths/ # Redundant backup
└── s3://cliproxyapi/config/ # Config backup
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add language specifier to fenced code block.

Add a language identifier (e.g., text or leave empty) to improve Markdown rendering consistency.

🔎 Proposed fix
-```
+```text
 ~/.cli-proxy-api/
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In home-manager/services/cliproxyapi/README.md around lines 18 to 37, the fenced
code block showing the directory tree lacks a language specifier which can
affect Markdown rendering; edit the opening fence to include a language
identifier such as "text" (i.e., change ``` to ```text) so the block is
consistently rendered, then save the file.

Comment on lines +68 to +86
```
┌──────────────────┐
│ R2 Storage │
│ ┌────────────┐ │ ┌──────────────────────────────┐
│ │ auths/ │◄─┼──────┤ objectstore/auths/ │
│ └────────────┘ │ │ (cliproxyapi reads here) │
│ ┌────────────┐ │ │ ┌────────────────────────┐ │
│ │ backup/ │◄─┼──────┤ │ OAuth tokens stored │ │
│ └────────────┘ │ │ │ - claude-*.json │ │
└──────────────────┘ │ │ - codex-*.json │ │
│ │ - antigravity-*.json │ │
│ └────────────────────────┘ │
└──────────────────────────────┘
├─────► ccs/auth/
└─────► dotfiles/ (git backup)
└─► Bootstrap only
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add language specifier to fenced code block.

Add a language identifier (e.g., text or leave empty) for the ASCII diagram.

🔎 Proposed fix
-```
+```text
 ┌──────────────────┐
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
┌──────────────────┐
│ R2 Storage │
│ ┌────────────┐ │ ┌──────────────────────────────┐
│ │ auths/ │◄─┼──────┤ objectstore/auths/ │
│ └────────────┘ │ │ (cliproxyapi reads here) │
│ ┌────────────┐ │ │ ┌────────────────────────┐ │
│ │ backup/ │◄─┼──────┤ │ OAuth tokens stored │ │
│ └────────────┘ │ │ │ - claude-*.json │ │
└──────────────────┘ │ │ - codex-*.json │ │
│ │ - antigravity-*.json │ │
│ └────────────────────────┘ │
└──────────────────────────────┘
├─────► ccs/auth/
└─────► dotfiles/ (git backup)
└─► Bootstrap only
```
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

68-68: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
home-manager/services/cliproxyapi/README.md around lines 68 to 86: the fenced
code block containing the ASCII diagram lacks a language specifier; update the
opening fence from ``` to ```text (or another appropriate identifier like ```)
so the block is marked as plain text, leaving the diagram contents unchanged and
keeping the closing fence as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants