Skip to content
Merged

Coder #389

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4224e2f
feat(homebrew): add 'coder' to the list of installed brews
shunkakinoki Dec 2, 2025
05f3692
feat(homebrew): add 'cliproxyapi' to the list of installed brews
shunkakinoki Dec 2, 2025
02d7598
feat(cliproxyapi): add cliproxyapi service configuration and integration
shunkakinoki Dec 2, 2025
a1b5285
feat(cliproxyapi): add configuration files and startup script for cli…
shunkakinoki Dec 2, 2025
c3f5cdf
fix(cliproxyapi): enable logging to file and ensure correct directory…
shunkakinoki Dec 2, 2025
29b913f
feat(config): add CLIProxyAPI provider configuration to codex and ope…
shunkakinoki Dec 2, 2025
40860b7
feat(cliproxyapi): export S3-compatible object storage environment va…
shunkakinoki Dec 2, 2025
c65da1c
fix(config): update remote management settings and clean up config.yaml
shunkakinoki Dec 2, 2025
238b516
feat(cliproxyapi): add GLM-4 model configuration to cliproxyapi and o…
shunkakinoki Dec 2, 2025
3bb7cf7
fix(cliproxyapi): update base URL for CLIProxyAPI to version 1 in con…
shunkakinoki Dec 2, 2025
cba3383
feat(config): update GLM-4 model reference to z-ai/glm-4.6 in config …
shunkakinoki Dec 2, 2025
74b4d3c
refactor(config): remove Kimi K2 model references and streamline GLM-…
shunkakinoki Dec 2, 2025
cf9d27d
fix(cliproxyapi): update GLM-4.6 model reference to z-ai/glm-4.6 in o…
shunkakinoki Dec 2, 2025
c5bf0f3
fix(config): remove alias for glm-4.6 model in cliproxyapi configuration
shunkakinoki Dec 2, 2025
edade9a
fix(opencode): add stream option to GLM-4.6 model configuration
shunkakinoki Dec 2, 2025
f976f17
feat(config): add AMP upstream settings and configuration files
shunkakinoki Dec 2, 2025
949def1
fix(config): update amp-restrict-management-to-localhost setting to f…
shunkakinoki Dec 3, 2025
073da2a
feat(factory): add configuration files and models for factory setup
shunkakinoki Dec 3, 2025
d7d6fce
fix(config): update base URLs in factory models and add o3 model to o…
shunkakinoki Dec 3, 2025
2ae7e0c
fix(config): update gemini models and remove deprecated entries in fa…
shunkakinoki Dec 3, 2025
1629387
fix(config): update models in CLIProxyAPI configuration for opencode
shunkakinoki Dec 3, 2025
58c68d6
fix(config): remove deprecated plugin entry from opencode configuration
shunkakinoki Dec 3, 2025
c1c6c2f
fix(config): update model name from gemini-3.0-pro to gemini-3-pro-pr…
shunkakinoki Dec 3, 2025
bcaf79d
fix(config): update model names for Claude Opus and Haiku in configur…
shunkakinoki Dec 3, 2025
a9f6128
fix(config): correct model version formatting for Claude Opus and Hai…
shunkakinoki Dec 3, 2025
6a6db05
fix(config): update model names for Claude Opus and Haiku with versio…
shunkakinoki Dec 3, 2025
1ef0639
fix(config): add postgresql@18 to the list of brews in homebrew confi…
shunkakinoki Dec 3, 2025
802f2af
fix(config): add postgresql@18 to PATH in bash, fish, and zsh configu…
shunkakinoki Dec 5, 2025
b00bda2
Merge remote-tracking branch 'origin/main' into coder
shunkakinoki Dec 5, 2025
7bfe27e
fix(config): update model version for Claude Opus in configuration files
shunkakinoki Dec 5, 2025
e130484
fix(config): add gpt-5.1-codex and gpt-5.1-codex-max models to config…
shunkakinoki Dec 5, 2025
975c648
fix(config): update AMP upstream settings and restructure configuration
shunkakinoki Dec 5, 2025
c68684c
fix(config): remove commented amp-upstream-api-key from configuration
shunkakinoki Dec 5, 2025
ad39434
fix(config): remove unnecessary whitespace in configuration file
shunkakinoki Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/amp/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ config, ... }:
{
xdg.configFile."amp/settings.json" = {
source = config.lib.file.mkOutOfStoreSymlink ./settings.json;
};
}
3 changes: 3 additions & 0 deletions config/amp/settings.json
Original file line number Diff line number Diff line change
@@ -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

}
93 changes: 93 additions & 0 deletions config/cliproxyapi/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Server port
port: 8317
# Management API settings
remote-management:
# Whether to allow remote (non-localhost) management access.
# When false, only localhost can access management endpoints (a key is still required).
allow-remote: false
# Management key. If a plaintext value is provided here, it will be hashed on startup.
# All management requests (even from localhost) require this key.
# Leave empty to disable the Management API entirely (404 for all /v0/management routes).
secret-key: ""
# Disable the bundled management control panel asset download and HTTP route when true.
disable-control-panel: false
# Authentication directory (supports ~ for home directory). If you use Windows, please set the directory like this: `C:/cli-proxy-api/`
auth-dir: "~/.cli-proxy-api"
# API keys for authentication
# api-keys:
# - "your-api-key-1"
# - "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

# When true, write application logs to rotating files instead of stdout
logging-to-file: true
# When false, disable in-memory usage statistics aggregation
usage-statistics-enabled: true
# Proxy URL. Supports socks5/http/https protocols. Example: socks5://user:pass@192.168.1.1:1080/
proxy-url: ""
# Number of times to retry a request. Retries will occur if the HTTP response code is 403, 408, 500, 502, 503, or 504.
request-retry: 3
# Quota exceeded behavior
quota-exceeded:
switch-project: true # Whether to automatically switch to another project when a quota is exceeded
switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded
# When true, enable authentication for the WebSocket API (/v1/ws).
ws-auth: false
# AMP
ampcode:
upstream-url: "https://ampcode.com"
restrict-management-to-localhost: true
# amp-upstream-api-key: "" # Optional - use AMP_API_KEY env var or ~/.local/share/amp/secrets.json

# Gemini API keys (preferred)
# gemini-api-key:
# - api-key: "AIzaSy...01"
# base-url: "https://generativelanguage.googleapis.com"
# headers:
# X-Custom-Header: "custom-value"
# proxy-url: "socks5://proxy.example.com:1080"
# - api-key: "AIzaSy...02"

# Codex API keys
# codex-api-key:
# - api-key: "sk-atSM..."
# base-url: "https://www.example.com" # use the custom codex API endpoint
# headers:
# X-Custom-Header: "custom-value"
# proxy-url: "socks5://proxy.example.com:1080" # optional: per-key proxy override

# Claude API keys
# claude-api-key:
# - api-key: "sk-atSM..." # use the official claude API key, no need to set the base url
# - api-key: "sk-atSM..."
# base-url: "https://www.example.com" # use the custom claude API endpoint
# headers:
# X-Custom-Header: "custom-value"
# proxy-url: "socks5://proxy.example.com:1080" # optional: per-key proxy override
# models:
# - name: "claude-3-5-sonnet-20241022" # upstream model name
# alias: "claude-sonnet-latest" # client alias mapped to the upstream model

# OpenAI compatibility providers
openai-compatibility:
- name: "openrouter"
base-url: "https://openrouter.ai/api/v1"
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


# payload: # Optional payload configuration
# default: # Default rules only set parameters when they are missing in the payload.
# - models:
# - name: "gemini-2.5-pro" # Supports wildcards (e.g., "gemini-*")
# protocol: "gemini" # restricts the rule to a specific protocol, options: openai, gemini, claude, codex
# params: # JSON path (gjson/sjson syntax) -> value
# "generationConfig.thinkingConfig.thinkingBudget": 32768
# override: # Override rules always set parameters, overwriting any existing values.
# - models:
# - name: "gpt-*" # Supports wildcards (e.g., "gpt-*")
# protocol: "codex" # restricts the rule to a specific protocol, options: openai, gemini, claude, codex
# params: # JSON path (gjson/sjson syntax) -> value
# "reasoning.effort": "high"
7 changes: 7 additions & 0 deletions config/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ config, ... }:
{
# Template config - the service wrapper injects secrets and writes to config.yaml
home.file.".cli-proxy-api/config.template.yaml" = {
source = config.lib.file.mkOutOfStoreSymlink ./config.yaml;
};
}
8 changes: 8 additions & 0 deletions config/codex/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ notify = [
[features]
web_search_request = true

[model_providers.cliproxyapi]
name = "CLIProxyAPI"
base_url = "http://localhost:8317/v1"

[model_providers.lmstudio]
name = "LMStudio"
base_url = "http://127.0.0.1:1234/v1"
Expand All @@ -32,3 +36,7 @@ model_provider = "lmstudio"
[profiles.qwen3-coder-30b]
model = "qwen/qwen3-coder-30b"
model_provider = "lmstudio"

[profiles.kimi-k2]
model = "kimi-k2"
model_provider = "cliproxyapi"
3 changes: 3 additions & 0 deletions config/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[
./amp
./cliproxyapi
./codex
./crush
./claude
./direnv
./factory
./ghostty
./hammerspoon
./karabiner
Expand Down
40 changes: 40 additions & 0 deletions config/factory/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"custom_models": [
{
"model": "gemini-3-pro-preview",
"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",
Comment on lines +5 to +35

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.
"api_key": "sk-dummy",
"provider": "anthropic"
}
]
}
6 changes: 6 additions & 0 deletions config/factory/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ config, ... }:
{
home.file.".factory/config.json" = {
source = config.lib.file.mkOutOfStoreSymlink ./config.json;
};
}
34 changes: 33 additions & 1 deletion config/opencode/opencode.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,39 @@
}
},
"provider": {
"cliproxyapi": {
"npm": "@ai-sdk/openai-compatible",
"name": "CLIProxyAPI (local)",
"options": {
"baseURL": "http://localhost:8317/v1"
},
"models": {
"gemini-3-pro-preview": {
"name": "Gemini 3.0 Pro (via CLIProxyAPI)"
},
"gpt-5.1": {
"name": "GPT-5.1 (via CLIProxyAPI)"
},
"gpt-5.1-codex": {
"name": "GPT-5.1 Codex (via CLIProxyAPI)"
},
"gpt-5.1-codex-max": {
"name": "GPT-5.1 Codex Max (via CLIProxyAPI)"
},
"claude-opus-4-5-20251101": {
"name": "Claude Opus 4.5 (via CLIProxyAPI)"
},
"claude-haiku-4-5-20251001": {
"name": "Claude Haiku 4.5 (via CLIProxyAPI)"
},
"z-ai/glm-4.6": {
"name": "GLM-4.6 (via OpenRouter)",
"options": {
"stream": false
}
}
}
},
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio (local)",
Expand Down Expand Up @@ -158,7 +191,6 @@
}
}
},
"plugin": ["opencode-openai-codex-auth"],
"tui": {
"scroll_speed": 3
}
Expand Down
1 change: 1 addition & 0 deletions home-manager/programs/bash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
export PATH="$HOME/.nix-profile/bin:$PATH"
export PATH="/nix/var/nix/profiles/default/bin:$PATH"
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/opt/postgresql@18/bin:$PATH"
'';

profileExtra = ''
Expand Down
2 changes: 2 additions & 0 deletions home-manager/programs/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
fish_add_path -p /etc/profiles/per-user/${config.home.username}/bin
'';
interactiveShellInit = ''
Expand All @@ -30,6 +31,7 @@
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.

fish_add_path -p /etc/profiles/per-user/${config.home.username}/bin
set -a fish_complete_path ~/.nix-profile/share/fish/completions/ ~/.nix-profile/share/fish/vendor_completions.d/
set -x FISH_HISTFILE fish
Expand Down
1 change: 1 addition & 0 deletions home-manager/programs/zsh/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
export PATH="$HOME/.nix-profile/bin:$PATH"
export PATH="/nix/var/nix/profiles/default/bin:$PATH"
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/opt/postgresql@18/bin:$PATH"

# FNM (Fast Node Manager) configuration
export FNM_DIR="$HOME/Library/Application Support/fnm"
Expand Down
19 changes: 19 additions & 0 deletions home-manager/services/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
@@ -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

enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"${./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.
};
KeepAlive = true;
RunAtLoad = true;
StandardOutPath = "/tmp/cliproxyapi.log";
StandardErrorPath = "/tmp/cliproxyapi.error.log";
Comment on lines +15 to +16

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

};
};
}
40 changes: 40 additions & 0 deletions home-manager/services/cliproxyapi/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -euo pipefail

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


# Source .env file to get API keys
if [ -f "$ENV_FILE" ]; then
set -a
# shellcheck source=/dev/null
source "$ENV_FILE"
set +a
fi

# 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 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.
fi
Comment on lines +19 to +21

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.

# 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.
cd "$CONFIG_DIR"

# Export S3-compatible object storage env vars (for R2 or any S3-compatible storage)
export OBJECTSTORE_ENDPOINT="${OBJECTSTORE_ENDPOINT:-${AWS_S3_ENDPOINT:-}}"
export OBJECTSTORE_BUCKET="${OBJECTSTORE_BUCKET:-${AWS_S3_BUCKET:-}}"
export OBJECTSTORE_ACCESS_KEY="${OBJECTSTORE_ACCESS_KEY:-${AWS_ACCESS_KEY_ID:-}}"
export OBJECTSTORE_SECRET_KEY="${OBJECTSTORE_SECRET_KEY:-${AWS_SECRET_ACCESS_KEY:-}}"

# Find and exec cliproxyapi with config file
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
Comment on lines +33 to +40

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

2 changes: 2 additions & 0 deletions home-manager/services/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ pkgs }:
let
cliproxyapi = import ./cliproxyapi { inherit pkgs; };
codeSyncer = import ./code-syncer { inherit pkgs; };
dotfilesUpdater = import ./dotfiles-updater { inherit pkgs; };
neversslKeepalive = import ./neverssl-keepalive { inherit pkgs; };
Expand All @@ -8,6 +9,7 @@ let
in
[
brewUpgrader
cliproxyapi
codeSyncer
dotfilesUpdater
neversslKeepalive
Expand Down
3 changes: 3 additions & 0 deletions nix-darwin/config/homebrew.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
brews = [
"bun"
"claude-squad"
"cliproxyapi"
"cmake"
"coder"
"colima"
"coreutils"
"ffmpeg"
Expand All @@ -35,6 +37,7 @@
"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

"protobuf"
"reth"
"sheldon"
Expand Down
Loading