Skip to content

Coder - #389

Merged
shunkakinoki merged 34 commits into
mainfrom
coder
Dec 5, 2025
Merged

Coder#389
shunkakinoki merged 34 commits into
mainfrom
coder

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Dec 5, 2025

Copy link
Copy Markdown
Owner

Summary by cubic

Set up CLIProxyAPI as a local service and wired Codex, OpenCode, AMP, and Factory to use http://localhost:8317/v1 for unified model access. Also added brew packages and Postgres 18 PATH updates needed to run the service.

  • New Features

    • Added a launchd agent for CLIProxyAPI with a start script that injects secrets from .env and exports S3-compatible env vars; logs to files; runs on port 8317.
    • Introduced cliproxyapi config template and YAML; remote management disabled; OpenRouter key substitution supported.
    • Updated Codex and OpenCode to use CLIProxyAPI, exposing models like gemini-3-pro-preview, gpt-5.1 (incl. codex variants), Claude Opus/Haiku 4.5, and GLM-4.6 via OpenRouter.
    • Added AMP settings pointing to the local proxy and Factory custom models targeting the same endpoint.
  • Dependencies

    • Homebrew: added cliproxyapi, coder, and postgresql@18.
    • PATH: appended postgresql@18/bin for bash, fish, and zsh.

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

Copilot AI review requested due to automatic review settings December 5, 2025 07:39
@coderabbitai

coderabbitai Bot commented Dec 5, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features
    • Added CLIProxyAPI local proxy server (localhost:8317) supporting multiple AI models including Gemini, GPT, Claude, and GLM
    • Integrated factory and AMP configuration support for custom model management
    • Added PostgreSQL 18 command-line tools to system PATH across bash, fish, and zsh shells
    • Added cliproxyapi macOS service with automatic startup configuration
    • Installed new Homebrew packages: cliproxyapi, coder, and postgresql@18

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

Walkthrough

This PR introduces CLIProxyAPI integration infrastructure alongside PostgreSQL 18 support. It adds Nix modules for configuration management, a macOS launchd service with startup script, model provider configurations (CLIProxyAPI, AMP, factory), and augments shell PATH variables across bash, fish, and zsh. Homebrew packages for cliproxyapi, coder, and postgresql@18 are added.

Changes

Cohort / File(s) Summary
CLIProxyAPI Configuration & Service
config/cliproxyapi/config.yaml, config/cliproxyapi/default.nix, home-manager/services/cliproxyapi/default.nix, home-manager/services/cliproxyapi/start.sh, home-manager/services/default.nix
Introduces comprehensive CLIProxyAPI server configuration (port 8317, auth, logging, quota handling, AMP integration), Nix module for config symlink management, macOS launchd agent setup with environment and logging, Bash startup script for bootstrap with env var injection and model provider routing, and service registry update.
Shell Environment PATH Updates
home-manager/programs/bash/default.nix, home-manager/programs/fish/default.nix, home-manager/programs/zsh/default.nix
Adds PostgreSQL 18 binary path (/opt/homebrew/opt/postgresql@18/bin) to bashrcExtra, loginShellInit, interactiveShellInit, and zsh initialization respectively.
Model Provider Configuration
config/codex/config.toml, config/opencode/opencode.jsonc, config/factory/config.json, config/factory/default.nix
Adds CLIProxyAPI model provider and kimi-k2 profile to Codex; introduces new CLIProxyAPI provider (OpenAI-compatible) and removes opencode-openai-codex-auth plugin from Opencode; defines six custom model entries (OpenAI and Anthropic) in factory config with Nix module symlink.
AMP Configuration
config/amp/default.nix, config/amp/settings.json
Adds AMP module with symlinked settings.json (amp.url pointing to localhost:8317) and Nix function to expose config via XDG.
Nix Module Registry & Package Management
config/default.nix, nix-darwin/config/homebrew.nix
Adds three new module imports (./amp, ./cliproxyapi, ./factory) to config list; adds three Homebrew packages (cliproxyapi, coder, postgresql@18).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • CLIProxyAPI YAML configuration (config/cliproxyapi/config.yaml): Verify all server settings, authentication paths, provider integrations, and commented example keys are correct and secure.
  • Startup script logic (home-manager/services/cliproxyapi/start.sh): Review environment variable handling, template config generation with OPENROUTER_API_KEY injection, OBJECTSTORE_* mapping logic, and binary discovery fallback.
  • Model provider consistency: Cross-check CLIProxyAPI endpoints, model names, and base URLs across config/codex/config.toml, config/opencode/opencode.jsonc, and config/factory/config.json for consistency.
  • Shell PATH ordering and conflicts: Ensure PostgreSQL 18 PATH additions in bash, fish, and zsh don't conflict with existing Homebrew paths or override unintended binaries.

Possibly related PRs

  • devenv #369: Modifies config/default.nix and nix-darwin/config/homebrew.nix to alter package and import lists, overlapping file scope.
  • nvim revamp #360: Updates shell initialization files (home-manager/programs/{bash,fish,zsh}/default.nix) with PATH augmentations, directly related PATH modification pattern.
  • feat: add LM Studio integration and update AI tooling #305: Modifies config/codex/config.toml to add model providers and profiles, touching the same configuration file.

Poem

🐰 A proxy server hops into the fold,
PostgreSQL paths and models bold,
CLIProxyAPI channels the way,
While factories craft configs each day,
Homebrewed and launchd, our setup'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 coder

📜 Recent review details

Configuration used: CodeRabbit 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 67c78fd and ad39434.

📒 Files selected for processing (16)
  • config/amp/default.nix (1 hunks)
  • config/amp/settings.json (1 hunks)
  • config/cliproxyapi/config.yaml (1 hunks)
  • config/cliproxyapi/default.nix (1 hunks)
  • config/codex/config.toml (2 hunks)
  • config/default.nix (1 hunks)
  • config/factory/config.json (1 hunks)
  • config/factory/default.nix (1 hunks)
  • config/opencode/opencode.jsonc (1 hunks)
  • home-manager/programs/bash/default.nix (1 hunks)
  • home-manager/programs/fish/default.nix (2 hunks)
  • home-manager/programs/zsh/default.nix (1 hunks)
  • home-manager/services/cliproxyapi/default.nix (1 hunks)
  • home-manager/services/cliproxyapi/start.sh (1 hunks)
  • home-manager/services/default.nix (2 hunks)
  • nix-darwin/config/homebrew.nix (2 hunks)

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 primarily focuses on integrating and configuring cliproxyapi, a local proxy for various AI models, into the system's NixOS and Homebrew setup. It establishes the necessary configurations for cliproxyapi itself, and then updates several AI-related tools (amp, codex, factory, opencode) to leverage this new local proxy for accessing different language models. Additionally, it streamlines the development environment by adding coder and postgresql@18 to Homebrew and ensuring the PostgreSQL 18 binaries are correctly accessible in common shell environments.

Highlights

  • CLIProxyAPI Integration: Introduced and deeply integrated cliproxyapi, a local proxy for various AI models, into the system's NixOS and Homebrew configurations. This includes new NixOS modules, a launchd service for macOS, and a startup script to manage its configuration and API keys.
  • AI Tool Configuration Updates: Configured several AI-related tools, namely amp, codex, factory, and opencode, to utilize the newly integrated cliproxyapi for accessing a range of language models, including Gemini, GPT, and Claude variants.
  • Development Environment Enhancements: Expanded the development environment by adding coder and postgresql@18 to the Homebrew managed packages and updated the PATH environment variable across Bash, Fish, and Zsh shells to ensure PostgreSQL 18 binaries are readily accessible.
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 5, 2025

Copy link
Copy Markdown

Mesa Description

TL;DR

Set up CLIProxyAPI as a local service and wired Codex, OpenCode, AMP, and Factory to use http://localhost:8317/v1 for unified model access. Also added brew packages and Postgres 18 PATH updates needed to run the service.

What changed?

  • config/amp/default.nix: New NixOS module for amp/settings.json, creating a symlink.
  • config/amp/settings.json: New config file setting amp.url to http://localhost:8317.
  • config/cliproxyapi/config.yaml: New comprehensive configuration for the CLI proxy API, including server port, remote management, authentication, LLM API keys, debugging, logging, usage statistics, proxy behavior, WebSocket authentication, AMP integration, and OpenAI compatibility providers.
  • config/cliproxyapi/default.nix: New Nix configuration for cliproxyapi, symlinking ~/.cli-proxy-api/config.template.yaml to ./config.yaml.
  • config/codex/config.toml: Introduced "CLIProxyAPI" model provider (http://localhost:8317/v1) and a new "kimi-k2" profile using it.
  • config/default.nix: Added new configuration paths: ./amp, ./cliproxyapi, and ./factory.
  • config/factory/config.json: New config file defining custom GPT, Gemini, and Claude models using openai and anthropic providers, all targeting http://127.0.0.1:8317/v1.
  • config/factory/default.nix: New NixOS module creating a symbolic link for ~/.factory/config.json.
  • config/opencode/opencode.jsonc: Introduced a new "cliproxyapi" provider configuration for local proxy access (http://localhost:8317/v1) with various AI models; removed "opencode-openai-codex-auth" plugin entry.
  • home-manager/programs/bash/default.nix: Updated bash PATH to include /opt/homebrew/opt/postgresql@18/bin.
  • home-manager/programs/fish/default.nix: Updated Fish shell PATH to include /opt/homebrew/opt/postgresql@18/bin.
  • home-manager/programs/zsh/default.nix: Updated Zsh PATH to include /opt/homebrew/opt/postgresql@18/bin.
  • home-manager/services/cliproxyapi/default.nix: New NixOS module defining a launchd agent for macOS that runs a start.sh script with specific PATH and redirects logs.
  • home-manager/services/cliproxyapi/start.sh: New script for cliproxyapi to automate setup and execution, including sourcing .env, dynamically generating config.yaml, setting S3-compatible environment variables, and executing the cliproxyapi binary.
  • home-manager/services/default.nix: Introduced and enabled the new cliproxyapi home-manager service.
  • nix-darwin/config/homebrew.nix: Added new Homebrew packages: "cliproxyapi", "coder", and "postgresql@18".

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki merged commit 52e0242 into main Dec 5, 2025
5 checks passed
@shunkakinoki
shunkakinoki deleted the coder branch December 5, 2025 07:40

@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 configurations for several new tools, including amp, cliproxyapi, and factory, and sets up cliproxyapi as a local service on macOS. It also updates existing tool configurations (codex, opencode) to use the new proxy service. The changes are well-structured, but I have a few suggestions to improve robustness and maintainability, particularly regarding the new cliproxyapi service and shell configurations. My feedback includes suggestions for improving the service logging, simplifying the startup script, and avoiding redundancy in shell setup.

# - "your-api-key-2"

# Enable debug logging
debug: 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.

medium

debug: true is enabled, which can lead to verbose logging and might expose sensitive information in logs. For a long-running service, it's generally recommended to set this to false and only enable it when actively troubleshooting.

debug: false

fish_add_path -p /nix/var/nix/profiles/default/bin
fish_add_path -p ~/.foundry/bin
fish_add_path -p /opt/homebrew/bin
fish_add_path -p /opt/homebrew/opt/postgresql@18/bin

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

This path is already added on line 20 within loginShellInit. Since fish_add_path typically modifies fish_user_paths, which is a universal variable that persists across shell sessions, adding the path again in interactiveShellInit is redundant. You can safely remove this line.

Comment on lines +15 to +16
StandardOutPath = "/tmp/cliproxyapi.log";
StandardErrorPath = "/tmp/cliproxyapi.error.log";

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

Log files are being written to /tmp, which is an ephemeral directory. Its contents may be cleared on system reboot. For persistent logging, consider using a more permanent location, such as ~/Library/Logs/cliproxyapi/ on macOS. Note that you would need to provide an absolute path in the launchd configuration as it does not expand ~.

Comment on lines +33 to +40
if [ -x /opt/homebrew/bin/cliproxyapi ]; then
exec /opt/homebrew/bin/cliproxyapi -config "$CONFIG" "$@"
elif [ -x /usr/local/bin/cliproxyapi ]; then
exec /usr/local/bin/cliproxyapi -config "$CONFIG" "$@"
else
echo 'cliproxyapi binary not found; install it with "brew install cliproxyapi"' >&2
exit 1
fi

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 script hardcodes paths to find the cliproxyapi binary. A more robust approach is to rely on the PATH environment variable, which is already set in the launchd service definition. You can use command -v to check if the binary exists in the PATH and then execute it directly.

Suggested change
if [ -x /opt/homebrew/bin/cliproxyapi ]; then
exec /opt/homebrew/bin/cliproxyapi -config "$CONFIG" "$@"
elif [ -x /usr/local/bin/cliproxyapi ]; then
exec /usr/local/bin/cliproxyapi -config "$CONFIG" "$@"
else
echo 'cliproxyapi binary not found; install it with "brew install cliproxyapi"' >&2
exit 1
fi
if command -v cliproxyapi >/dev/null; then
exec cliproxyapi -config "$CONFIG" "$@"
else
echo 'cliproxyapi binary not found; install it with "brew install cliproxyapi"' >&2
exit 1
fi

@mesa-dot-dev mesa-dot-dev 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.

Performed full review of 67c78fd...c68684c

Analysis

  1. Insecure Secrets Management - The implementation uses plain .env files and sed-based template substitution instead of the repository's established agenix secret management system, creating security vulnerabilities and inconsistent patterns.

  2. Configuration Fragmentation - "localhost:8317" is hardcoded across 5 different config files, creating maintenance challenges when ports need to change. A centralized configuration approach is missing.

  3. Platform Limitations - The cliproxyapi service is Darwin/macOS-only with no Linux/NixOS equivalent, limiting cross-platform compatibility despite the repository supporting multiple platforms.

  4. PostgreSQL Version Conflict Risk - Both "postgresql" and "postgresql@18" are installed via Homebrew without clear documentation about which should be used, potentially causing version conflicts or PATH ordering issues.

  5. Missing Service Dependencies - There's no declaration that tools depend on cliproxyapi being running, which could lead to cryptic connection errors if the proxy service fails.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

16 files reviewed | 6 comments | Edit Agent SettingsRead Docs

Comment thread config/amp/settings.json
@@ -0,0 +1,3 @@
{
"amp.url": "http://localhost:8317"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Hardcoded localhost:8317. If cliproxyapi port changes, this and 4 other config files need manual updates (codex/config.toml, factory/config.json, opencode/opencode.jsonc). Consider extracting this to a shared Nix variable to maintain DRY principles: proxyPort = 8317; then reference it across configs.
Agent: 🏛 Architecture

@@ -0,0 +1,19 @@
{ pkgs, ... }:
{
launchd.agents.cliproxyapi = pkgs.lib.mkIf pkgs.stdenv.isDarwin {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Service is Darwin-only (mkIf pkgs.stdenv.isDarwin) but the repository supports multiple platforms (hosts/darwin, hosts/linux, hosts/nixos). Consider adding a Linux systemd equivalent or documenting why this service is macOS-exclusive.
Agent: 🏛 Architecture

api-keys:
- "__OPENROUTER_API_KEY__"
models:
- name: "z-ai/glm-4.6"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Placeholder syntax OPENROUTER_API_KEY gets replaced by sed in start.sh, but if replacement fails, this literal string remains in the config. Consider using cliproxyapi's native environment variable support (if available) or the agenix secret management system already established in this repository for more robust secret injection.
Agent: 🏛 Architecture

"pinentry-mac"
"pnpm"
"postgresql"
"postgresql@18"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Both "postgresql" (line 37) and "postgresql@18" are now installed. This could cause version conflicts or PATH ordering issues. Document which version should be used, and consider removing the older "postgresql" if version 18 supersedes it.
Agent: 🏛 Architecture

CONFIG_DIR="$HOME/.cli-proxy-api"
TEMPLATE="$CONFIG_DIR/config.template.yaml"
CONFIG="$CONFIG_DIR/config.yaml"
ENV_FILE="$HOME/dotfiles/.env"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Hardcoded path assumes 'dotfiles' directory exists in $HOME, which may not be true on all systems. This repository uses agenix for secret management (see named-hosts/galactica/secrets.nix). Consider migrating to agenix: age.secrets.openrouter-api-key.file = ./keys/openrouter.age; for consistent secret handling across the codebase.
Agent: 🏛 Architecture


# Generate config from template with secrets injected
if [ -f "$TEMPLATE" ]; then
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Silent failure risk: If OPENROUTER_API_KEY is unset or empty, sed creates a config with an empty string, leading to subtle runtime failures. Add validation before sed replacement: if [ -z "${OPENROUTER_API_KEY:-}" ]; then echo "Error: OPENROUTER_API_KEY not set" >&2; exit 1; fi
Agent: 🏛 Architecture

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 adds integration for CLIProxyAPI, a local proxy service for AI model APIs, along with configurations for multiple AI coding tools. It also updates PostgreSQL to version 18 and adds support for various AI models including hypothetical future versions.

Key changes:

  • Adds cliproxyapi as a new launchd service with automatic startup and configuration templating
  • Integrates cliproxyapi with multiple coding tools (opencode, factory, codex, amp)
  • Updates PostgreSQL from default version to version 18 with PATH configurations across all shells

Reviewed changes

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

Show a summary per file
File Description
nix-darwin/config/homebrew.nix Adds cliproxyapi, coder, and postgresql@18 brew packages
home-manager/services/default.nix Registers cliproxyapi service module
home-manager/services/cliproxyapi/start.sh Service startup script that handles config templating and environment setup
home-manager/services/cliproxyapi/default.nix Launchd agent configuration for cliproxyapi service
home-manager/programs/zsh/default.nix Adds postgresql@18 to PATH
home-manager/programs/fish/default.nix Adds postgresql@18 to PATH in both login and interactive shells
home-manager/programs/bash/default.nix Adds postgresql@18 to PATH
config/opencode/opencode.jsonc Adds cliproxyapi provider with model configurations, removes plugin
config/factory/default.nix Creates symlink for factory config
config/factory/config.json Configures custom models pointing to cliproxyapi endpoint
config/default.nix Registers amp, cliproxyapi, and factory config modules
config/codex/config.toml Adds cliproxyapi model provider and kimi-k2 profile
config/cliproxyapi/default.nix Creates symlink for cliproxyapi config template
config/cliproxyapi/config.yaml Main configuration for cliproxyapi service with API settings
config/amp/settings.json Configures amp URL to use cliproxyapi
config/amp/default.nix Creates symlink for amp settings
Comments suppressed due to low confidence (1)

config/default.nix:14

  • The module imports are not in alphabetical order. The list has "./amp" and "./cliproxyapi" before "./codex", "./crush", and "./claude", but then "./claude" appears after "./crush". Consider sorting the entire list alphabetically: amp, claude, cliproxyapi, codex, crush, direnv, factory, ghostty, hammerspoon, karabiner, opencode, serena, starship.
  ./amp
  ./cliproxyapi
  ./codex
  ./crush
  ./claude
  ./direnv
  ./factory
  ./ghostty
  ./hammerspoon
  ./karabiner
  ./opencode
  ./serena
  ./starship

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

Comment on lines +5 to +35
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex-max",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "claude-opus-4-5-20251101",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "anthropic"
},
{
"model": "claude-haiku-4-5-20251001",
"base_url": "http://127.0.0.1:8317/v1",

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

The base_url uses http://127.0.0.1:8317/v1 while other configuration files (opencode.jsonc, codex/config.toml) use http://localhost:8317/v1. For consistency, consider using localhost instead of 127.0.0.1 across all configuration files.

Suggested change
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex-max",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "claude-opus-4-5-20251101",
"base_url": "http://127.0.0.1:8317/v1",
"api_key": "sk-dummy",
"provider": "anthropic"
},
{
"model": "claude-haiku-4-5-20251001",
"base_url": "http://127.0.0.1:8317/v1",
"base_url": "http://localhost:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1",
"base_url": "http://localhost:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex",
"base_url": "http://localhost:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "gpt-5.1-codex-max",
"base_url": "http://localhost:8317/v1",
"api_key": "sk-dummy",
"provider": "openai"
},
{
"model": "claude-opus-4-5-20251101",
"base_url": "http://localhost:8317/v1",
"api_key": "sk-dummy",
"provider": "anthropic"
},
{
"model": "claude-haiku-4-5-20251001",
"base_url": "http://localhost:8317/v1",

Copilot uses AI. Check for mistakes.
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"
fi

# Change to config dir so logs are created there

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

The script attempts to cd "$CONFIG_DIR" without first verifying the directory exists. If ~/.cli-proxy-api doesn't exist, the script will fail. Consider adding a check: mkdir -p "$CONFIG_DIR" before line 24, or add error handling to verify the directory exists.

Suggested change
# Change to config dir so logs are created there
# Change to config dir so logs are created there
mkdir -p "$CONFIG_DIR"

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +21
if [ -f "$TEMPLATE" ]; then
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"
fi

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

The config generation on line 19-21 only runs if $TEMPLATE exists, but the cliproxyapi command on lines 34 and 36 always passes -config "$CONFIG". If the template doesn't exist, the config file won't be created, potentially causing cliproxyapi to fail. Consider either: 1) Making template generation mandatory with error handling, or 2) Only passing -config flag if the config file was successfully generated.

Suggested change
if [ -f "$TEMPLATE" ]; then
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"
fi
if [ ! -f "$TEMPLATE" ]; then
echo "Config template '$TEMPLATE' not found. Cannot generate config file." >&2
exit 1
fi
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"

Copilot uses AI. Check for mistakes.

# Generate config from template with secrets injected
if [ -f "$TEMPLATE" ]; then
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

The sed substitution doesn't escape the OPENROUTER_API_KEY value, which could cause issues if the API key contains special characters like |, &, or /. Consider using a more robust method like envsubst or escaping the value before substitution. For example: envsubst < "$TEMPLATE" > "$CONFIG" with export OPENROUTER_API_KEY set before calling it.

Suggested change
sed "s|__OPENROUTER_API_KEY__|${OPENROUTER_API_KEY:-}|g" "$TEMPLATE" >"$CONFIG"
export OPENROUTER_API_KEY
envsubst < "$TEMPLATE" > "$CONFIG"

Copilot uses AI. Check for mistakes.
"${./start.sh}"
];
Environment = {
PATH = "${pkgs.lib.makeBinPath [ pkgs.gnused ]}:/opt/homebrew/bin:/usr/local/bin";

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

The PATH includes hardcoded /opt/homebrew/bin:/usr/local/bin, but the script itself already checks both locations for the binary (lines 33-36 in start.sh). Since the script uses absolute paths when exec'ing cliproxyapi, these hardcoded PATH entries may be unnecessary. Consider whether they're needed for other commands in the script (like sed).

Suggested change
PATH = "${pkgs.lib.makeBinPath [ pkgs.gnused ]}:/opt/homebrew/bin:/usr/local/bin";
PATH = "${pkgs.lib.makeBinPath [ pkgs.gnused ]}";

Copilot uses AI. Check for mistakes.

@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.

No issues found across 16 files

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