Skip to content

feat(ccs): add CCS configuration with dynamic secret hydration - #597

Merged
shunkakinoki merged 2 commits into
mainfrom
feat/ccs-accounts-config
Jan 17, 2026
Merged

feat(ccs): add CCS configuration with dynamic secret hydration#597
shunkakinoki merged 2 commits into
mainfrom
feat/ccs-accounts-config

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jan 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add CCS accounts registry configuration for cliproxy providers (agy, gemini, codex)
  • Add template-based settings hydration with CLIPROXY_API_KEY substitution
  • Add model-mappings for antigravity provider to work on both Linux and macOS
  • Fix cliproxyapi auth-dir to avoid duplicate scanning
  • Add cliproxyapi to make switch restart targets

Changes

  • config/ccs/accounts.json - CCS account registry for OAuth providers
  • config/ccs/config.template.yaml - CCS config with auth_token placeholder
  • config/ccs/*.settings.template.json - Provider settings templates (agy, codex, gemini)
  • config/ccs/hydrate.sh - Script to substitute secrets from .env
  • config/cliproxyapi/config.yaml - Add model-mappings for antigravity provider
  • home-manager/services/cliproxyapi/scripts/start.sh - Disable AMP on Linux, comment model-mappings

How it works

  • On make switch, hydration script runs during home-manager activation
  • Reads CLIPROXY_API_KEY from ~/dotfiles/.env
  • Generates ~/.ccs/config.yaml and ~/.ccs/*.settings.json with actual API key
  • On Linux: AMP disabled, non-prefixed model names work directly
  • On macOS: AMP enabled with model-mappings to route to antigravity provider

Test plan

  • make shell-check passes
  • make shell-test passes (359 examples, 0 failures)
  • make build succeeds
  • make switch hydrates settings correctly
  • ccs agy -p "say hi" works on Linux

🤖 Generated with Claude Code


Summary by cubic

Add CCS config with dynamic secret hydration and an accounts registry for cliproxy providers (agy, gemini, codex). Fix auth directory scanning and model routing, and make switch now hydrates settings and restarts cliproxyapi for reliable ccs commands on Linux and macOS.

  • New Features

    • Hydrates ~/.ccs/config.yaml and provider settings from templates using CLIPROXY_API_KEY.
    • Symlinks CCS accounts registry to ~/.ccs/cliproxy/accounts.json.
    • Adds systemctl-cliproxyapi to pull latest image and restart; included in systemctl.
  • Bug Fixes

    • Sets cliproxyapi auth-dir to ~/.cli-proxy-api/objectstore/auths to avoid duplicate scans.
    • Linux: disables AMP to prevent antigravity routing issues.
    • macOS: adds model-mappings to route non-prefixed models to gemini-prefixed equivalents.

Written for commit d276723. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 17, 2026 20:35
@mesa-dot-dev

mesa-dot-dev Bot commented Jan 17, 2026

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 Jan 17, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated account activity tracking timestamp.
    • Enabled support for additional AI model mappings in proxy configuration.
    • Modified configuration script generation for Linux environments.

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

Walkthrough

This PR updates account metadata, enables three Claude model mappings in the cliproxyapi configuration, and adds sed rules to the startup script to comment out specific YAML keys during config templating.

Changes

Cohort / File(s) Summary
Account Metadata
config/ccs/accounts.json
Updated lastUsedAt timestamp for the shunkakinoki@gmail.com account under theagy provider from 2026-01-17T19:28:18.251Z to 2026-01-17T20:19:49.880Z
Model Mappings Configuration
config/cliproxyapi/config.yaml
Enabled three previously commented model-mappings: claude-opus-4-5-thinking, claude-sonnet-4-5, and claude-sonnet-4-5-thinking with corresponding Gemini mappings
Config Templating Script
home-manager/services/cliproxyapi/scripts/start.sh
Added four sed expressions to comment out YAML keys (Map non-prefixed, model-mappings, and nested from/to entries) during config generation on Linux

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 A rabbit hops through configs deep,
Timestamps updated, mappings sweep,
Claude models dance with Gemini's grace,
While sed comments mark their place!
Hopping along, the changes are neat,
Configuration's done—this task's complete! 🎉

✨ 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 feat/ccs-accounts-config

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 ccs (Claude Code Switcher) setup by integrating cliproxy providers and automating the management of API keys. It introduces a robust system for dynamically injecting secrets into configuration files, ensuring secure and flexible deployment across different operating systems, particularly addressing model routing for the Antigravity provider on Linux and macOS. The changes streamline the configuration process and improve the overall maintainability of the ccs and cliproxyapi services.

Highlights

  • CCS Configuration: Added comprehensive configuration for CCS (Claude Code Switcher) to support cliproxy providers like Antigravity (agy), Gemini, and Codex.
  • Dynamic Secret Hydration: Implemented a mechanism to dynamically hydrate CCS configuration and provider settings with CLIPROXY_API_KEY from the user's .env file during home-manager activation.
  • Cross-Platform Model Mappings: Introduced specific model mappings for the Antigravity provider within cliproxyapi to ensure consistent model routing on both Linux (AMP disabled) and macOS (AMP enabled).
  • cliproxyapi Improvements: Fixed the cliproxyapi authentication directory to prevent redundant scanning and integrated cliproxyapi into the make switch command for easier service management.
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 Jan 17, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added CCS configuration with dynamic secret hydration and an accounts registry for cliproxy providers (agy, gemini, codex). Fixed auth directory scanning and model routing, and integrated make switch to hydrate settings and restart cliproxyapi for reliable ccs commands on Linux and macOS.

What changed?

  • Makefile: Introduced systemctl-cliproxyapi target to pull the latest eceasy/cli-proxy-api Docker image and restart the cliproxyapi.service, integrating it into the main systemctl target.
  • config/ccs/accounts.json: Updated, added, or removed account-specific configurations within the CCS system's accounts.json file.
  • config/ccs/agy.settings.template.json: Added a new configuration file defining environment variables for Anthropic API integration, including a local proxy base URL, auth token placeholder, and default model names.
  • config/ccs/codex.settings.template.json: Added a new configuration file defining environment variables for an Anthropic service, configuring requests to a local codex proxy and setting default Anthropic models with an auth token placeholder.
  • config/ccs/config.template.yaml: Added a new configuration template file for CCS Unified Configuration, defining settings for accounts, API-based profiles, various CLIProxy providers, CLIProxy server connections, user preferences, web search, GitHub Copilot API proxy settings, and global environment variables.
  • config/ccs/default.nix: Introduced a new Home Manager configuration for the 'CCS (Claude Code Switcher)' utility, establishing a symbolic link for accounts.json and adding an activation script using hydrate.sh to populate CCS settings templates.
  • config/ccs/gemini.settings.template.json: Added a new configuration file defining environment variables for Gemini model integration, including a local proxy base URL, auth token placeholder, and default Gemini model names mapped to Anthropic model types.
  • config/ccs/hydrate.sh: Added a new script to automate the setup of CCS configuration by loading CLIPROXY_API_KEY from the .env file, creating the ~/.ccs directory, and processing template files to replace the __CLIPROXY_API_KEY__ placeholder.
  • config/cliproxyapi/config.yaml: Updated auth-dir path to ~/.cli-proxy-api/objectstore/auths to prevent duplicate scanning and uncommented/configured ampcode.model-mappings to map claude models to gemini-prefixed equivalents.
  • config/default.nix: Integrated the ./ccs configuration module into the default configuration.
  • home-manager/services/cliproxyapi/scripts/start.sh: Modified the cliproxyapi start script to disable AMP functionality on Linux systems by commenting out AMP-related configuration lines.
  • spec/coverage_spec.sh: Included config/ccs/hydrate.sh in the list of covered_scripts to ensure test coverage.

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki force-pushed the feat/ccs-accounts-config branch from 08158d8 to d276723 Compare January 17, 2026 20:37

@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 introduces configuration for CCS, including dynamic secret hydration. The changes are generally good, but there are a few important issues to address. I've found a potential security risk with committed personal information in a configuration file. There's also a bug in a shell script that could cause it to fail if an API key contains special characters. Finally, there's an issue with incorrect indentation in another script that modifies a YAML file. I've provided suggestions to fix these issues.

I am having trouble creating individual review comments. Click here to see my feedback.

config/ccs/accounts.json (5-9)

high

This configuration file appears to contain a personal email address and nickname. It's a security risk to commit personal data into a version control system. Please replace these with placeholder values, for example: user@example.com and example-user. This applies to all providers in this file.

      "default": "user@example.com",
      "accounts": {
        "user@example.com": {
          "email": "user@example.com",
          "nickname": "example-user",

config/ccs/hydrate.sh (20-51)

high

The script could fail if the CLIPROXY_API_KEY contains special characters used by sed in the replacement string (like &, \, or the delimiter |). It's much safer to escape the API key value before using it in the sed substitution command.

if [ -z "${CLIPROXY_API_KEY:-}" ]; then
  echo "Warning: CLIPROXY_API_KEY not set in .env, skipping CCS hydration" >&2
  exit 0
fi

# Escape special characters in the API key to prevent issues with sed.
# The sed delimiter is '|', so we need to escape '|', '\', and '&'.
escaped_api_key=$(printf '%s' "${CLIPROXY_API_KEY}" | @sed@ -e 's/[&\\|]/\\&/g')

mkdir -p "$CCS_DIR"

# Hydrate config.yaml
CONFIG_TEMPLATE="${TEMPLATE_DIR}/config.template.yaml"
if [ -f "$CONFIG_TEMPLATE" ]; then
  @sed@ \
    -e "s|__CLIPROXY_API_KEY__|${escaped_api_key}|g" \
    "$CONFIG_TEMPLATE" >"${CCS_DIR}/config.yaml"
  echo "Hydrated CCS config.yaml" >&2
fi

# Process all provider settings templates
for template in "$TEMPLATE_DIR"/*.settings.template.json; do
  [ -f "$template" ] || continue

  # Extract provider name: foo.settings.template.json -> foo
  filename=$(basename "$template")
  provider="${filename%.settings.template.json}"
  output="${CCS_DIR}/${provider}.settings.json"

  # Substitute placeholder and write output
  @sed@ \
    -e "s|__CLIPROXY_API_KEY__|${escaped_api_key}|g" \
    "$template" >"$output"

  echo "Hydrated CCS ${provider}.settings.json" >&2
done

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

medium

The sed commands to comment out the ampcode block are adding extra spaces, which results in incorrect indentation for the commented-out block. This makes the resulting YAML file harder to read and could potentially cause issues with strict parsers. The replacement string should prepend # to the original line, preserving the indentation.

Also, this approach is quite brittle. A small change to the config.template.yaml could break this script. Consider using a YAML-aware tool like yq in the future for more robust modifications (e.g., yq -i 'del(.ampcode)' "$CONFIG").

For now, let's fix the indentation.

    @sed@ -i \
      -e 's|^ampcode:|#ampcode:|' \
      -e 's|^  upstream-url:|#  upstream-url:|' \
      -e 's|^  upstream-api-key:|#  upstream-api-key:|' \
      -e 's|^  restrict-management-to-localhost:|#  restrict-management-to-localhost:|' \
      -e 's|^  # Map non-prefixed|#  # Map non-prefixed|' \
      -e 's|^  model-mappings:|#  model-mappings:|' \
      -e 's|^    - from:|#    - from:|' \
      -e 's|^      to:|#      to:|' \
      "$CONFIG"

shunkakinoki and others added 2 commits January 17, 2026 20:37
The antigravity provider requires `gemini-` prefix on model names:
- gemini-claude-opus-4-5-thinking
- gemini-claude-sonnet-4-5

Without this prefix, requests get routed to ampcode.com and fail with 404.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use non-prefixed model names (claude-opus-4-5-thinking) in templates
- Add model-mappings in ampcode section to map to gemini- prefixed names
- On Linux: AMP disabled, non-prefixed names work directly
- On macOS: AMP enabled, model-mappings route to antigravity provider
- Update start.sh to comment out model-mappings on Linux too

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@shunkakinoki
shunkakinoki merged commit a581c52 into main Jan 17, 2026
20 checks passed
@shunkakinoki
shunkakinoki deleted the feat/ccs-accounts-config branch January 17, 2026 20:38
@shunkakinoki
shunkakinoki removed the request for review from Copilot March 23, 2026 22:11
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.

1 participant