oc-codex-multi-auth 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/assets/opencode-logo-ornate-dark.svg +18 -0
- package/assets/readme-hero.svg +31 -0
- package/config/README.md +96 -0
- package/config/minimal-opencode.json +13 -0
- package/config/opencode-legacy.json +871 -0
- package/config/opencode-modern.json +358 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5008 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/accounts/rate-limits.d.ts +22 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -0
- package/dist/lib/accounts/rate-limits.js +63 -0
- package/dist/lib/accounts/rate-limits.js.map +1 -0
- package/dist/lib/accounts.d.ts +134 -0
- package/dist/lib/accounts.d.ts.map +1 -0
- package/dist/lib/accounts.js +795 -0
- package/dist/lib/accounts.js.map +1 -0
- package/dist/lib/audit.d.ts +45 -0
- package/dist/lib/audit.d.ts.map +1 -0
- package/dist/lib/audit.js +154 -0
- package/dist/lib/audit.js.map +1 -0
- package/dist/lib/auth/auth.d.ts +51 -0
- package/dist/lib/auth/auth.d.ts.map +1 -0
- package/dist/lib/auth/auth.js +191 -0
- package/dist/lib/auth/auth.js.map +1 -0
- package/dist/lib/auth/browser.d.ts +17 -0
- package/dist/lib/auth/browser.d.ts.map +1 -0
- package/dist/lib/auth/browser.js +90 -0
- package/dist/lib/auth/browser.js.map +1 -0
- package/dist/lib/auth/device-code.d.ts +28 -0
- package/dist/lib/auth/device-code.d.ts.map +1 -0
- package/dist/lib/auth/device-code.js +215 -0
- package/dist/lib/auth/device-code.js.map +1 -0
- package/dist/lib/auth/login-runner.d.ts +55 -0
- package/dist/lib/auth/login-runner.d.ts.map +1 -0
- package/dist/lib/auth/login-runner.js +631 -0
- package/dist/lib/auth/login-runner.js.map +1 -0
- package/dist/lib/auth/server.d.ts +10 -0
- package/dist/lib/auth/server.d.ts.map +1 -0
- package/dist/lib/auth/server.js +98 -0
- package/dist/lib/auth/server.js.map +1 -0
- package/dist/lib/auth/token-utils.d.ts +60 -0
- package/dist/lib/auth/token-utils.d.ts.map +1 -0
- package/dist/lib/auth/token-utils.js +416 -0
- package/dist/lib/auth/token-utils.js.map +1 -0
- package/dist/lib/auth-rate-limit.d.ts +20 -0
- package/dist/lib/auth-rate-limit.d.ts.map +1 -0
- package/dist/lib/auth-rate-limit.js +91 -0
- package/dist/lib/auth-rate-limit.js.map +1 -0
- package/dist/lib/auto-update-checker.d.ts +10 -0
- package/dist/lib/auto-update-checker.d.ts.map +1 -0
- package/dist/lib/auto-update-checker.js +129 -0
- package/dist/lib/auto-update-checker.js.map +1 -0
- package/dist/lib/circuit-breaker.d.ts +34 -0
- package/dist/lib/circuit-breaker.d.ts.map +1 -0
- package/dist/lib/circuit-breaker.js +124 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/cli.d.ts +46 -0
- package/dist/lib/cli.d.ts.map +1 -0
- package/dist/lib/cli.js +192 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/config.d.ts +42 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +314 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +90 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +90 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/context-overflow.d.ts +27 -0
- package/dist/lib/context-overflow.d.ts.map +1 -0
- package/dist/lib/context-overflow.js +124 -0
- package/dist/lib/context-overflow.js.map +1 -0
- package/dist/lib/errors.d.ts +113 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +103 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/health.d.ts +33 -0
- package/dist/lib/health.d.ts.map +1 -0
- package/dist/lib/health.js +70 -0
- package/dist/lib/health.js.map +1 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/logger.d.ts +40 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +337 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/oauth-success.html +712 -0
- package/dist/lib/parallel-probe.d.ts +28 -0
- package/dist/lib/parallel-probe.d.ts.map +1 -0
- package/dist/lib/parallel-probe.js +97 -0
- package/dist/lib/parallel-probe.js.map +1 -0
- package/dist/lib/proactive-refresh.d.ts +67 -0
- package/dist/lib/proactive-refresh.d.ts.map +1 -0
- package/dist/lib/proactive-refresh.js +161 -0
- package/dist/lib/proactive-refresh.js.map +1 -0
- package/dist/lib/prompts/codex-opencode-bridge.d.ts +20 -0
- package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
- package/dist/lib/prompts/codex-opencode-bridge.js +126 -0
- package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
- package/dist/lib/prompts/codex.d.ts +41 -0
- package/dist/lib/prompts/codex.d.ts.map +1 -0
- package/dist/lib/prompts/codex.js +400 -0
- package/dist/lib/prompts/codex.js.map +1 -0
- package/dist/lib/prompts/opencode-codex.d.ts +25 -0
- package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
- package/dist/lib/prompts/opencode-codex.js +223 -0
- package/dist/lib/prompts/opencode-codex.js.map +1 -0
- package/dist/lib/recovery/constants.d.ts +12 -0
- package/dist/lib/recovery/constants.d.ts.map +1 -0
- package/dist/lib/recovery/constants.js +25 -0
- package/dist/lib/recovery/constants.js.map +1 -0
- package/dist/lib/recovery/index.d.ts +12 -0
- package/dist/lib/recovery/index.d.ts.map +1 -0
- package/dist/lib/recovery/index.js +12 -0
- package/dist/lib/recovery/index.js.map +1 -0
- package/dist/lib/recovery/storage.d.ts +24 -0
- package/dist/lib/recovery/storage.d.ts.map +1 -0
- package/dist/lib/recovery/storage.js +362 -0
- package/dist/lib/recovery/storage.js.map +1 -0
- package/dist/lib/recovery/types.d.ts +116 -0
- package/dist/lib/recovery/types.d.ts.map +1 -0
- package/dist/lib/recovery/types.js +7 -0
- package/dist/lib/recovery/types.js.map +1 -0
- package/dist/lib/recovery.d.ts +31 -0
- package/dist/lib/recovery.d.ts.map +1 -0
- package/dist/lib/recovery.js +313 -0
- package/dist/lib/recovery.js.map +1 -0
- package/dist/lib/refresh-queue.d.ts +131 -0
- package/dist/lib/refresh-queue.d.ts.map +1 -0
- package/dist/lib/refresh-queue.js +297 -0
- package/dist/lib/refresh-queue.js.map +1 -0
- package/dist/lib/request/fetch-helpers.d.ts +142 -0
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
- package/dist/lib/request/fetch-helpers.js +749 -0
- package/dist/lib/request/fetch-helpers.js.map +1 -0
- package/dist/lib/request/helpers/input-utils.d.ts +7 -0
- package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
- package/dist/lib/request/helpers/input-utils.js +214 -0
- package/dist/lib/request/helpers/input-utils.js.map +1 -0
- package/dist/lib/request/helpers/model-map.d.ts +22 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
- package/dist/lib/request/helpers/model-map.js +183 -0
- package/dist/lib/request/helpers/model-map.js.map +1 -0
- package/dist/lib/request/helpers/tool-utils.d.ts +29 -0
- package/dist/lib/request/helpers/tool-utils.d.ts.map +1 -0
- package/dist/lib/request/helpers/tool-utils.js +117 -0
- package/dist/lib/request/helpers/tool-utils.js.map +1 -0
- package/dist/lib/request/rate-limit-backoff.d.ts +17 -0
- package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -0
- package/dist/lib/request/rate-limit-backoff.js +83 -0
- package/dist/lib/request/rate-limit-backoff.js.map +1 -0
- package/dist/lib/request/request-transformer.d.ts +107 -0
- package/dist/lib/request/request-transformer.d.ts.map +1 -0
- package/dist/lib/request/request-transformer.js +930 -0
- package/dist/lib/request/request-transformer.js.map +1 -0
- package/dist/lib/request/response-handler.d.ts +23 -0
- package/dist/lib/request/response-handler.d.ts.map +1 -0
- package/dist/lib/request/response-handler.js +245 -0
- package/dist/lib/request/response-handler.js.map +1 -0
- package/dist/lib/request/retry-budget.d.ts +19 -0
- package/dist/lib/request/retry-budget.d.ts.map +1 -0
- package/dist/lib/request/retry-budget.js +99 -0
- package/dist/lib/request/retry-budget.js.map +1 -0
- package/dist/lib/rotation.d.ts +130 -0
- package/dist/lib/rotation.d.ts.map +1 -0
- package/dist/lib/rotation.js +301 -0
- package/dist/lib/rotation.js.map +1 -0
- package/dist/lib/runtime-contracts.d.ts +16 -0
- package/dist/lib/runtime-contracts.d.ts.map +1 -0
- package/dist/lib/runtime-contracts.js +24 -0
- package/dist/lib/runtime-contracts.js.map +1 -0
- package/dist/lib/schemas.d.ts +457 -0
- package/dist/lib/schemas.d.ts.map +1 -0
- package/dist/lib/schemas.js +283 -0
- package/dist/lib/schemas.js.map +1 -0
- package/dist/lib/shutdown.d.ts +7 -0
- package/dist/lib/shutdown.d.ts.map +1 -0
- package/dist/lib/shutdown.js +43 -0
- package/dist/lib/shutdown.js.map +1 -0
- package/dist/lib/storage/migrations.d.ts +65 -0
- package/dist/lib/storage/migrations.d.ts.map +1 -0
- package/dist/lib/storage/migrations.js +44 -0
- package/dist/lib/storage/migrations.js.map +1 -0
- package/dist/lib/storage/paths.d.ts +16 -0
- package/dist/lib/storage/paths.d.ts.map +1 -0
- package/dist/lib/storage/paths.js +92 -0
- package/dist/lib/storage/paths.js.map +1 -0
- package/dist/lib/storage.d.ts +157 -0
- package/dist/lib/storage.d.ts.map +1 -0
- package/dist/lib/storage.js +1169 -0
- package/dist/lib/storage.js.map +1 -0
- package/dist/lib/table-formatter.d.ts +32 -0
- package/dist/lib/table-formatter.d.ts.map +1 -0
- package/dist/lib/table-formatter.js +44 -0
- package/dist/lib/table-formatter.js.map +1 -0
- package/dist/lib/types.d.ts +131 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/ui/ansi.d.ts +22 -0
- package/dist/lib/ui/ansi.d.ts.map +1 -0
- package/dist/lib/ui/ansi.js +38 -0
- package/dist/lib/ui/ansi.js.map +1 -0
- package/dist/lib/ui/auth-menu.d.ts +39 -0
- package/dist/lib/ui/auth-menu.d.ts.map +1 -0
- package/dist/lib/ui/auth-menu.js +186 -0
- package/dist/lib/ui/auth-menu.js.map +1 -0
- package/dist/lib/ui/beginner.d.ts +62 -0
- package/dist/lib/ui/beginner.d.ts.map +1 -0
- package/dist/lib/ui/beginner.js +259 -0
- package/dist/lib/ui/beginner.js.map +1 -0
- package/dist/lib/ui/confirm.d.ts +2 -0
- package/dist/lib/ui/confirm.d.ts.map +1 -0
- package/dist/lib/ui/confirm.js +21 -0
- package/dist/lib/ui/confirm.js.map +1 -0
- package/dist/lib/ui/format.d.ts +9 -0
- package/dist/lib/ui/format.d.ts.map +1 -0
- package/dist/lib/ui/format.js +49 -0
- package/dist/lib/ui/format.js.map +1 -0
- package/dist/lib/ui/runtime.d.ts +11 -0
- package/dist/lib/ui/runtime.d.ts.map +1 -0
- package/dist/lib/ui/runtime.js +31 -0
- package/dist/lib/ui/runtime.js.map +1 -0
- package/dist/lib/ui/select.d.ts +20 -0
- package/dist/lib/ui/select.d.ts.map +1 -0
- package/dist/lib/ui/select.js +343 -0
- package/dist/lib/ui/select.js.map +1 -0
- package/dist/lib/ui/theme.d.ts +34 -0
- package/dist/lib/ui/theme.d.ts.map +1 -0
- package/dist/lib/ui/theme.js +84 -0
- package/dist/lib/ui/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +29 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +54 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +113 -0
- package/scripts/audit-dev-allowlist.js +114 -0
- package/scripts/copy-oauth-success.js +37 -0
- package/scripts/install-oc-codex-multi-auth-core.js +381 -0
- package/scripts/install-oc-codex-multi-auth.js +15 -0
- package/scripts/test-all-models.sh +260 -0
- package/scripts/validate-model-map.sh +97 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Test All Models - Verify API Configuration
|
|
4
|
+
# This script tests all model configurations and verifies the actual API requests
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors for output
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
# Paths
|
|
16
|
+
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
17
|
+
OPENCODE_JSON="${REPO_DIR}/opencode.json"
|
|
18
|
+
LOG_DIR="${HOME}/.opencode/logs/codex-plugin"
|
|
19
|
+
RESULTS_FILE="${REPO_DIR}/test-results.md"
|
|
20
|
+
|
|
21
|
+
# Test counter
|
|
22
|
+
TOTAL_TESTS=0
|
|
23
|
+
PASSED_TESTS=0
|
|
24
|
+
FAILED_TESTS=0
|
|
25
|
+
|
|
26
|
+
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
27
|
+
echo -e "${BLUE} Model Configuration Verification Test Suite${NC}"
|
|
28
|
+
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
29
|
+
echo ""
|
|
30
|
+
|
|
31
|
+
# Kill any running OpenCode server processes to force fresh plugin load
|
|
32
|
+
echo "Killing OpenCode server processes..."
|
|
33
|
+
pkill -f "opencode" 2>/dev/null || true
|
|
34
|
+
sleep 2
|
|
35
|
+
echo "✓ OpenCode servers stopped"
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
# Initialize results file
|
|
39
|
+
cat > "${RESULTS_FILE}" << 'EOF'
|
|
40
|
+
# Model Configuration Verification Results
|
|
41
|
+
|
|
42
|
+
**Test Date:** $(date)
|
|
43
|
+
**Test Directory:** Repository local config
|
|
44
|
+
|
|
45
|
+
## Results Summary
|
|
46
|
+
|
|
47
|
+
| Model | Normalized | Family | Effort | Summary | Verbosity | Include | Status |
|
|
48
|
+
|-------|------------|--------|--------|---------|-----------|---------|--------|
|
|
49
|
+
EOF
|
|
50
|
+
|
|
51
|
+
# Function: Run a test for a specific model
|
|
52
|
+
test_model() {
|
|
53
|
+
local model_name="$1"
|
|
54
|
+
local expected_normalized="$2"
|
|
55
|
+
local expected_family="$3"
|
|
56
|
+
local expected_effort="$4"
|
|
57
|
+
local expected_summary="$5"
|
|
58
|
+
local expected_verbosity="$6"
|
|
59
|
+
|
|
60
|
+
((TOTAL_TESTS++))
|
|
61
|
+
|
|
62
|
+
echo -e "${YELLOW}Testing model: ${model_name}${NC}"
|
|
63
|
+
|
|
64
|
+
# Clear previous logs
|
|
65
|
+
rm -rf "${LOG_DIR}"/*
|
|
66
|
+
|
|
67
|
+
# Run opencode
|
|
68
|
+
cd "${REPO_DIR}"
|
|
69
|
+
if ENABLE_PLUGIN_REQUEST_LOGGING=1 DEBUG_CODEX_PLUGIN=1 opencode run "write hello to test-${TOTAL_TESTS}.txt" --model="openai/${model_name}" > /dev/null 2>&1; then
|
|
70
|
+
echo -e "${GREEN} ✓ Command executed successfully${NC}"
|
|
71
|
+
else
|
|
72
|
+
echo -e "${RED} ✗ Command failed${NC}"
|
|
73
|
+
echo "| ${model_name} | N/A | N/A | N/A | N/A | N/A | ❌ FAILED |" >> "${RESULTS_FILE}"
|
|
74
|
+
((FAILED_TESTS++))
|
|
75
|
+
return 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Find the after-transform log file that matches the expected model
|
|
79
|
+
# (opencode may use multiple models per session - e.g., nano for titles)
|
|
80
|
+
local log_file=""
|
|
81
|
+
for f in $(find "${LOG_DIR}" -name "*-after-transform.json" -type f -print0 | xargs -0 ls -t); do
|
|
82
|
+
local orig_model=$(jq -r '.originalModel // ""' "$f" 2>/dev/null)
|
|
83
|
+
if [ "${orig_model}" = "${model_name}" ]; then
|
|
84
|
+
log_file="$f"
|
|
85
|
+
break
|
|
86
|
+
fi
|
|
87
|
+
done
|
|
88
|
+
|
|
89
|
+
if [ -z "${log_file}" ] || [ ! -f "${log_file}" ]; then
|
|
90
|
+
echo -e "${RED} ✗ Log file not found for model ${model_name}${NC}"
|
|
91
|
+
echo "| ${model_name} | N/A | N/A | N/A | N/A | N/A | ❌ NO LOG |" >> "${RESULTS_FILE}"
|
|
92
|
+
((FAILED_TESTS++))
|
|
93
|
+
return 1
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# Parse log file with jq
|
|
97
|
+
local actual_normalized=$(jq -r '.normalizedModel // "N/A"' "${log_file}")
|
|
98
|
+
local actual_family=$(jq -r '.modelFamily // "N/A"' "${log_file}")
|
|
99
|
+
local actual_effort=$(jq -r '.reasoning.effort // "N/A"' "${log_file}")
|
|
100
|
+
local actual_summary=$(jq -r '.reasoning.summary // "N/A"' "${log_file}")
|
|
101
|
+
local actual_verbosity=$(jq -r '.body.text.verbosity // "N/A"' "${log_file}")
|
|
102
|
+
local actual_include=$(jq -r '.include[0] // "N/A"' "${log_file}")
|
|
103
|
+
|
|
104
|
+
echo " Actual: model=${actual_normalized}, family=${actual_family}, effort=${actual_effort}, summary=${actual_summary}, verbosity=${actual_verbosity}"
|
|
105
|
+
echo " Expected: model=${expected_normalized}, family=${expected_family}, effort=${expected_effort}, summary=${expected_summary}, verbosity=${expected_verbosity}"
|
|
106
|
+
|
|
107
|
+
# Verify values
|
|
108
|
+
local status="✅ PASS"
|
|
109
|
+
if [ "${actual_normalized}" != "${expected_normalized}" ] || \
|
|
110
|
+
[ "${actual_family}" != "${expected_family}" ] || \
|
|
111
|
+
[ "${actual_effort}" != "${expected_effort}" ] || \
|
|
112
|
+
[ "${actual_summary}" != "${expected_summary}" ] || \
|
|
113
|
+
[ "${actual_verbosity}" != "${expected_verbosity}" ]; then
|
|
114
|
+
status="❌ FAIL"
|
|
115
|
+
((FAILED_TESTS++))
|
|
116
|
+
echo -e "${RED} ✗ Verification failed${NC}"
|
|
117
|
+
else
|
|
118
|
+
((PASSED_TESTS++))
|
|
119
|
+
echo -e "${GREEN} ✓ Verification passed${NC}"
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# Add to results
|
|
123
|
+
echo "| ${model_name} | ${actual_normalized} | ${actual_family} | ${actual_effort} | ${actual_summary} | ${actual_verbosity} | ${actual_include} | ${status} |" >> "${RESULTS_FILE}"
|
|
124
|
+
|
|
125
|
+
# Cleanup
|
|
126
|
+
rm -f "${REPO_DIR}/test-${TOTAL_TESTS}.txt"
|
|
127
|
+
|
|
128
|
+
echo ""
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Function: Update opencode.json with config
|
|
132
|
+
update_config() {
|
|
133
|
+
local config_type="$1"
|
|
134
|
+
|
|
135
|
+
echo -e "${BLUE}─────────────────────────────────────────────────────────────────${NC}"
|
|
136
|
+
echo -e "${BLUE}Scenario: ${config_type}${NC}"
|
|
137
|
+
echo -e "${BLUE}─────────────────────────────────────────────────────────────────${NC}"
|
|
138
|
+
echo ""
|
|
139
|
+
|
|
140
|
+
case "${config_type}" in
|
|
141
|
+
"legacy")
|
|
142
|
+
cat "${REPO_DIR}/config/opencode-legacy.json" > "${OPENCODE_JSON}"
|
|
143
|
+
echo "✓ Updated opencode.json with legacy config (GPT 5.x)"
|
|
144
|
+
;;
|
|
145
|
+
"minimal")
|
|
146
|
+
cat "${REPO_DIR}/config/minimal-opencode.json" > "${OPENCODE_JSON}"
|
|
147
|
+
echo "✓ Updated opencode.json with minimal config"
|
|
148
|
+
;;
|
|
149
|
+
esac
|
|
150
|
+
|
|
151
|
+
# Replace npm package with local dist for testing
|
|
152
|
+
sed -i.bak -E 's|"oc-codex-multi-auth(@[^"]*)?"|"file://'"${REPO_DIR}"'/dist"|' "${OPENCODE_JSON}"
|
|
153
|
+
|
|
154
|
+
rm -f "${OPENCODE_JSON}.bak"
|
|
155
|
+
echo "✓ Using local dist for plugin"
|
|
156
|
+
|
|
157
|
+
echo ""
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
# ============================================================================
|
|
161
|
+
# Scenario 1: Legacy Config - GPT 5.x Model Family
|
|
162
|
+
# ============================================================================
|
|
163
|
+
update_config "legacy"
|
|
164
|
+
|
|
165
|
+
# GPT 5.1 Codex presets
|
|
166
|
+
test_model "gpt-5.1-codex-low" "gpt-5.1-codex" "codex" "low" "auto" "medium"
|
|
167
|
+
test_model "gpt-5.1-codex-medium" "gpt-5.1-codex" "codex" "medium" "auto" "medium"
|
|
168
|
+
test_model "gpt-5.1-codex-high" "gpt-5.1-codex" "codex" "high" "detailed" "medium"
|
|
169
|
+
test_model "gpt-5.1-codex-max-low" "gpt-5.1-codex-max" "codex-max" "low" "detailed" "medium"
|
|
170
|
+
test_model "gpt-5.1-codex-max-medium" "gpt-5.1-codex-max" "codex-max" "medium" "detailed" "medium"
|
|
171
|
+
test_model "gpt-5.1-codex-max-high" "gpt-5.1-codex-max" "codex-max" "high" "detailed" "medium"
|
|
172
|
+
test_model "gpt-5.1-codex-max-xhigh" "gpt-5.1-codex-max" "codex-max" "xhigh" "detailed" "medium"
|
|
173
|
+
|
|
174
|
+
# GPT 5.2 presets (supports none/low/medium/high/xhigh per OpenAI API docs)
|
|
175
|
+
test_model "gpt-5.2-none" "gpt-5.2" "gpt-5.2" "none" "auto" "medium"
|
|
176
|
+
test_model "gpt-5.2-low" "gpt-5.2" "gpt-5.2" "low" "auto" "medium"
|
|
177
|
+
test_model "gpt-5.2-medium" "gpt-5.2" "gpt-5.2" "medium" "auto" "medium"
|
|
178
|
+
test_model "gpt-5.2-high" "gpt-5.2" "gpt-5.2" "high" "detailed" "medium"
|
|
179
|
+
test_model "gpt-5.2-xhigh" "gpt-5.2" "gpt-5.2" "xhigh" "detailed" "medium"
|
|
180
|
+
|
|
181
|
+
# GPT 5.2 Codex presets
|
|
182
|
+
test_model "gpt-5.2-codex-low" "gpt-5.2-codex" "gpt-5.2-codex" "low" "auto" "medium"
|
|
183
|
+
test_model "gpt-5.2-codex-medium" "gpt-5.2-codex" "gpt-5.2-codex" "medium" "auto" "medium"
|
|
184
|
+
test_model "gpt-5.2-codex-high" "gpt-5.2-codex" "gpt-5.2-codex" "high" "detailed" "medium"
|
|
185
|
+
test_model "gpt-5.2-codex-xhigh" "gpt-5.2-codex" "gpt-5.2-codex" "xhigh" "detailed" "medium"
|
|
186
|
+
|
|
187
|
+
# GPT 5.1 Codex Mini presets (medium/high only)
|
|
188
|
+
test_model "gpt-5.1-codex-mini-medium" "gpt-5.1-codex-mini" "codex" "medium" "auto" "medium"
|
|
189
|
+
test_model "gpt-5.1-codex-mini-high" "gpt-5.1-codex-mini" "codex" "high" "detailed" "medium"
|
|
190
|
+
|
|
191
|
+
# GPT 5.1 general-purpose presets (supports none/low/medium/high per OpenAI API docs)
|
|
192
|
+
test_model "gpt-5.1-none" "gpt-5.1" "gpt-5.1" "none" "auto" "medium"
|
|
193
|
+
test_model "gpt-5.1-low" "gpt-5.1" "gpt-5.1" "low" "auto" "low"
|
|
194
|
+
test_model "gpt-5.1-medium" "gpt-5.1" "gpt-5.1" "medium" "auto" "medium"
|
|
195
|
+
test_model "gpt-5.1-high" "gpt-5.1" "gpt-5.1" "high" "detailed" "high"
|
|
196
|
+
|
|
197
|
+
# # ============================================================================
|
|
198
|
+
# # Scenario 2: Minimal Config - Default Models (No Custom Config)
|
|
199
|
+
# # ============================================================================
|
|
200
|
+
# update_config "minimal"
|
|
201
|
+
|
|
202
|
+
# test_model "gpt-5" "gpt-5" "medium" "auto" "medium"
|
|
203
|
+
# test_model "gpt-5-codex" "gpt-5-codex" "medium" "auto" "medium"
|
|
204
|
+
# test_model "gpt-5-mini" "gpt-5" "minimal" "auto" "medium"
|
|
205
|
+
# test_model "gpt-5-nano" "gpt-5" "minimal" "auto" "medium"
|
|
206
|
+
|
|
207
|
+
# ============================================================================
|
|
208
|
+
# Scenario 3: Backwards Compatibility
|
|
209
|
+
# ============================================================================
|
|
210
|
+
# update_config "backwards-compat"
|
|
211
|
+
|
|
212
|
+
# # GPT 5 Codex presets
|
|
213
|
+
# test_model "gpt-5-codex-low" "gpt-5-codex" "low" "auto" "medium"
|
|
214
|
+
# test_model "gpt-5-codex-medium" "gpt-5-codex" "medium" "auto" "medium"
|
|
215
|
+
# test_model "gpt-5-codex-high" "gpt-5-codex" "high" "detailed" "medium"
|
|
216
|
+
|
|
217
|
+
# GPT 5 Codex Mini presets
|
|
218
|
+
# test_model "gpt-5-codex-mini" "codex-mini-latest" "medium" "auto" "medium"
|
|
219
|
+
# test_model "gpt-5-codex-mini-medium" "codex-mini-latest" "medium" "auto" "medium"
|
|
220
|
+
# test_model "gpt-5-codex-mini-high" "codex-mini-latest" "high" "detailed" "medium"
|
|
221
|
+
|
|
222
|
+
# GPT 5 general-purpose presets
|
|
223
|
+
# test_model "gpt-5" "gpt-5" "medium" "auto" "medium"
|
|
224
|
+
# test_model "gpt-5-medium" "gpt-5" "medium" "auto" "medium"
|
|
225
|
+
# test_model "gpt-5-high" "gpt-5" "high" "detailed" "high"
|
|
226
|
+
# test_model "gpt-5-mini" "gpt-5" "minimal" "auto" "medium"
|
|
227
|
+
|
|
228
|
+
# ============================================================================
|
|
229
|
+
# Summary
|
|
230
|
+
# ============================================================================
|
|
231
|
+
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
232
|
+
echo -e "${BLUE} Test Results Summary${NC}"
|
|
233
|
+
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
234
|
+
echo ""
|
|
235
|
+
echo -e "Total Tests: ${TOTAL_TESTS}"
|
|
236
|
+
echo -e "${GREEN}Passed: ${PASSED_TESTS}${NC}"
|
|
237
|
+
if [ ${FAILED_TESTS} -gt 0 ]; then
|
|
238
|
+
echo -e "${RED}Failed: ${FAILED_TESTS}${NC}"
|
|
239
|
+
else
|
|
240
|
+
echo -e "Failed: ${FAILED_TESTS}"
|
|
241
|
+
fi
|
|
242
|
+
echo ""
|
|
243
|
+
echo -e "Results saved to: ${RESULTS_FILE} (will be removed)"
|
|
244
|
+
echo ""
|
|
245
|
+
|
|
246
|
+
# Restore original config
|
|
247
|
+
if [ -f "${REPO_DIR}/config/opencode-legacy.json" ]; then
|
|
248
|
+
cat "${REPO_DIR}/config/opencode-legacy.json" > "${OPENCODE_JSON}"
|
|
249
|
+
echo "✓ Restored original legacy config to opencode.json"
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
# Cleanup results file to avoid polluting the repo
|
|
253
|
+
rm -f "${RESULTS_FILE}"
|
|
254
|
+
|
|
255
|
+
# Exit with appropriate code
|
|
256
|
+
if [ ${FAILED_TESTS} -gt 0 ]; then
|
|
257
|
+
exit 1
|
|
258
|
+
else
|
|
259
|
+
exit 0
|
|
260
|
+
fi
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Simple Model Map Validation Script
|
|
4
|
+
# Tests that OpenCode correctly uses models from config
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m'
|
|
14
|
+
|
|
15
|
+
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
16
|
+
LOG_DIR="${HOME}/.opencode/logs/codex-plugin"
|
|
17
|
+
|
|
18
|
+
echo -e "${BLUE}════════════════════════════════════════════${NC}"
|
|
19
|
+
echo -e "${BLUE} Model Map Validation${NC}"
|
|
20
|
+
echo -e "${BLUE}════════════════════════════════════════════${NC}"
|
|
21
|
+
echo ""
|
|
22
|
+
|
|
23
|
+
# Test 1: Model that IS in the config (should work)
|
|
24
|
+
echo -e "${YELLOW}Test 1: Model IN config (gpt-5.1-codex-low)${NC}"
|
|
25
|
+
rm -rf "${LOG_DIR}"/*
|
|
26
|
+
|
|
27
|
+
cd "${REPO_DIR}"
|
|
28
|
+
if ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode run "say hello" --model="openai/gpt-5.1-codex-low" > /dev/null 2>&1; then
|
|
29
|
+
# Check the log - find the one for gpt-5.1-codex-low specifically
|
|
30
|
+
log_file=$(find "${LOG_DIR}" -name "*-after-transform.json" -exec grep -l "gpt-5.1-codex-low" {} \; | head -n 1)
|
|
31
|
+
|
|
32
|
+
if [ -f "${log_file}" ]; then
|
|
33
|
+
original=$(jq -r '.originalModel // "N/A"' "${log_file}")
|
|
34
|
+
normalized=$(jq -r '.normalizedModel // "N/A"' "${log_file}")
|
|
35
|
+
|
|
36
|
+
echo -e " Original: ${original}"
|
|
37
|
+
echo -e " Normalized: ${normalized}"
|
|
38
|
+
|
|
39
|
+
if [ "${normalized}" == "gpt-5.1-codex" ]; then
|
|
40
|
+
echo -e " ${GREEN}✓ PASS - Correctly normalized to gpt-5.1-codex${NC}"
|
|
41
|
+
else
|
|
42
|
+
echo -e " ${RED}✗ FAIL - Expected gpt-5.1-codex, got ${normalized}${NC}"
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
else
|
|
46
|
+
echo -e " ${RED}✗ FAIL - No log file found${NC}"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
else
|
|
50
|
+
echo -e " ${RED}✗ FAIL - Command failed${NC}"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
echo ""
|
|
55
|
+
|
|
56
|
+
# Test 2: Model that is NOT in the config (should error or use fallback)
|
|
57
|
+
echo -e "${YELLOW}Test 2: Model NOT in config (fake-model-xyz)${NC}"
|
|
58
|
+
rm -rf "${LOG_DIR}"/*
|
|
59
|
+
|
|
60
|
+
if ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode run "write test" --model="openai/fake-model-xyz" > /dev/null 2>&1; then
|
|
61
|
+
log_file=$(find "${LOG_DIR}" -name "*-after-transform.json" | head -n 1)
|
|
62
|
+
|
|
63
|
+
if [ -f "${log_file}" ]; then
|
|
64
|
+
original=$(jq -r '.originalModel // "N/A"' "${log_file}")
|
|
65
|
+
normalized=$(jq -r '.normalizedModel // "N/A"' "${log_file}")
|
|
66
|
+
|
|
67
|
+
echo -e " Original: ${original}"
|
|
68
|
+
echo -e " Normalized: ${normalized}"
|
|
69
|
+
echo -e " ${GREEN}✓ Command succeeded (using fallback: ${normalized})${NC}"
|
|
70
|
+
else
|
|
71
|
+
echo -e " ${YELLOW}⚠ No log file (expected - model not in config)${NC}"
|
|
72
|
+
fi
|
|
73
|
+
else
|
|
74
|
+
echo -e " ${YELLOW}⚠ Command failed (expected - model not in config)${NC}"
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
echo ""
|
|
78
|
+
|
|
79
|
+
# Test 3: Verify config location
|
|
80
|
+
echo -e "${YELLOW}Test 3: Verify config file location${NC}"
|
|
81
|
+
if [ -f "${REPO_DIR}/opencode.json" ]; then
|
|
82
|
+
plugin_path=$(jq -r '.plugin[0]' "${REPO_DIR}/opencode.json")
|
|
83
|
+
model_count=$(jq '.provider.openai.models | length' "${REPO_DIR}/opencode.json")
|
|
84
|
+
|
|
85
|
+
echo -e " Config file: ${REPO_DIR}/opencode.json"
|
|
86
|
+
echo -e " Plugin path: ${plugin_path}"
|
|
87
|
+
echo -e " Models defined: ${model_count}"
|
|
88
|
+
echo -e " ${GREEN}✓ Config file found and valid${NC}"
|
|
89
|
+
else
|
|
90
|
+
echo -e " ${RED}✗ No opencode.json in repo directory${NC}"
|
|
91
|
+
exit 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
echo ""
|
|
95
|
+
echo -e "${GREEN}════════════════════════════════════════════${NC}"
|
|
96
|
+
echo -e "${GREEN} All validation tests passed!${NC}"
|
|
97
|
+
echo -e "${GREEN}════════════════════════════════════════════${NC}"
|