feat(translator): add vision support for commandcode provider

Map OpenAI image_url / Claude-style image blocks to the {type:"image",
image:"<data URI|url>"} shape the command-code CLI sends to /alpha/generate
instead of dropping them to "[image omitted]". Handles data URIs, raw base64
(with media_type / image/png fallback), and remote URLs.

- Promote bugs-gemini-cursor-commandcode "image content is preserved" from
  it.fails to a real assertion (bug fixed)
- Add vision unit tests to openai-to-commandcode.test.js
- Add test-commandcode-vision.sh curl helper for live verification

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
2026-08-03 17:06:32 +07:00
parent 067f18aaa1
commit fcd3dcb409
4 changed files with 637 additions and 323 deletions

41
test-commandcode-vision.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Test vision support for the commandcode provider in 9router.
#
# Usage:
# ./test-commandcode-vision.sh [base_url] [model]
# BASE_URL=http://localhost:20128 ./test-commandcode-vision.sh
#
# Defaults: base_url=http://localhost:20128, model=commandcode/Qwen/Qwen3.6-Max-Preview
set -euo pipefail
BASE_URL="${1:-${BASE_URL:-http://localhost:20128}}"
MODEL="${2:-${MODEL:-commandcode/Qwen/Qwen3.6-Max-Preview}}"
# 1x1 red pixel PNG (base64) — enough to prove the image reaches the model.
PNG_B64="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
echo "==> POST $BASE_URL/v1/chat/completions"
echo "==> model: $MODEL"
echo
curl -sS -N "$BASE_URL/v1/chat/completions" \
-H "Content-Type: application/json" \
-d "$(
cat <<JSON
{
"model": "$MODEL",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What color is this image? Reply with just the color name."},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,$PNG_B64"}}
]
}
],
"stream": false
}
JSON
)"
echo