Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
4 changes: 2 additions & 2 deletions config/cliproxyapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{
# 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;
source = config.lib.file.mkOutOfStoreSymlink ./config.template.yaml;
force = true;
};
# Example config - required by cliproxyapi's object-backed config bootstrap
home.file.".cli-proxy-api/config.example.yaml" = {
source = config.lib.file.mkOutOfStoreSymlink ./config.yaml;
source = config.lib.file.mkOutOfStoreSymlink ./config.template.yaml;
force = true;
};
}
4 changes: 2 additions & 2 deletions home-manager/programs/fish/functions/_ocxe_function.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ function _ocxe_function --description "Run OpenCode with GLM-4.7 via OpenRouter"
# Usage: ocxe [<prompt words...>]

if test (count $argv) -eq 0
opencode -m 'cliproxyapi/glm-4-7'
opencode -m 'cliproxyapi/glm-4.7'
else
set -l prompt (string join " " -- $argv)
opencode run "$prompt" -m 'cliproxyapi/glm-4-7'
opencode run "$prompt" -m 'cliproxyapi/glm-4.7'
end
end
2 changes: 1 addition & 1 deletion home-manager/programs/fish/functions/_ocxeh_function.fish
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ function _ocxeh_function --description "Run OpenCode headlessly with GLM-4.7"
return 1
end

opencode run "$prompt" -m 'cliproxyapi/glm-4-7'
opencode run "$prompt" -m 'cliproxyapi/glm-4.7'
end
29 changes: 29 additions & 0 deletions home-manager/services/cliproxyapi/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ if [ -f "$TEMPLATE" ]; then
fi
fi

# Keep objectstore-backed config in sync for management UI
OBJECTSTORE_CONFIG_DIR="$CONFIG_DIR/objectstore/config"
OBJECTSTORE_CONFIG="$OBJECTSTORE_CONFIG_DIR/config.yaml"
BACKUP_CONFIG_DIR="$CONFIG_DIR/backup/config"
BACKUP_CONFIG="$BACKUP_CONFIG_DIR/config.yaml"
mkdir -p "$OBJECTSTORE_CONFIG_DIR" "$BACKUP_CONFIG_DIR"
rm -f "$OBJECTSTORE_CONFIG" "$BACKUP_CONFIG"

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 rm -f command is redundant because the cp commands on the following lines will overwrite the destination files if they exist. You can safely remove this line to make the script slightly cleaner.

cp "$CONFIG" "$OBJECTSTORE_CONFIG"
cp "$CONFIG" "$BACKUP_CONFIG"

# Push config to objectstore so remote-backed config doesn't revert locally
if [ -n "$OBJECTSTORE_ENDPOINT" ] && [ -n "$OBJECTSTORE_ACCESS_KEY" ] && [ -n "$OBJECTSTORE_SECRET_KEY" ]; then
AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \
@aws@ s3 sync \
--endpoint-url="$OBJECTSTORE_ENDPOINT" \
--no-progress \
"$OBJECTSTORE_CONFIG_DIR/" \
"s3://${OBJECTSTORE_BUCKET}/config/" || true

AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \
@aws@ s3 sync \
--endpoint-url="$OBJECTSTORE_ENDPOINT" \
--no-progress \
"$BACKUP_CONFIG_DIR/" \
"s3://${OBJECTSTORE_BUCKET}/backup/config/" || true
fi
Comment on lines +114 to +130

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 two aws s3 sync blocks are nearly identical and they suppress errors using || true. This is risky because any failure to sync the configuration to S3 will be silently ignored, which could lead to stale configurations on the object store and potential data loss if an old config is pulled later.

I recommend refactoring this logic into a function. This would not only reduce code duplication but also allow for proper error handling, such as logging a warning message on failure. This would make the script more robust and easier to maintain.

Suggested change
if [ -n "$OBJECTSTORE_ENDPOINT" ] && [ -n "$OBJECTSTORE_ACCESS_KEY" ] && [ -n "$OBJECTSTORE_SECRET_KEY" ]; then
AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \
@aws@ s3 sync \
--endpoint-url="$OBJECTSTORE_ENDPOINT" \
--no-progress \
"$OBJECTSTORE_CONFIG_DIR/" \
"s3://${OBJECTSTORE_BUCKET}/config/" || true
AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \
@aws@ s3 sync \
--endpoint-url="$OBJECTSTORE_ENDPOINT" \
--no-progress \
"$BACKUP_CONFIG_DIR/" \
"s3://${OBJECTSTORE_BUCKET}/backup/config/" || true
fi
if [ -n "$OBJECTSTORE_ENDPOINT" ] && [ -n "$OBJECTSTORE_ACCESS_KEY" ] && [ -n "$OBJECTSTORE_SECRET_KEY" ]; then
sync_to_s3() {
local source_dir="$1"
local dest_path="$2"
if ! AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \
@aws@ s3 sync \
--endpoint-url="$OBJECTSTORE_ENDPOINT" \
--no-progress \
"${source_dir}/" \
"s3://${OBJECTSTORE_BUCKET}/${dest_path}/"; then
echo "⚠️ Failed to sync ${source_dir} to S3. Continuing..." >&2
fi
}
sync_to_s3 "$OBJECTSTORE_CONFIG_DIR" "config"
sync_to_s3 "$BACKUP_CONFIG_DIR" "backup/config"
fi

Comment on lines +103 to +130

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

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

The new config synchronization functionality lacks test coverage. The existing test suite in spec/cliproxyapi_spec.sh covers configuration generation and platform-specific handling, but doesn't test the new objectstore config sync operations (directory creation, file copying, and S3 sync behavior). Consider adding tests to verify: 1) directories are created correctly, 2) config files are copied to the objectstore and backup directories, 3) S3 sync is attempted when credentials are present, and 4) the script continues gracefully when S3 sync fails (due to '|| true').

Copilot uses AI. Check for mistakes.

cd "$CONFIG_DIR"

# Linux: Docker
Expand Down
Loading