refactor: migrate claude_gpt and claude_kimi to native CLIs with auto-install

claude_gpt:
- Replace proxy orchestration with direct codex binary launch
- Auto-install via curl -fsSL https://chatgpt.com/codex/install.sh | sh

claude_kimi:
- Remove openai-anthropic-proxy.py (~450 lines)
- Replace Artemox API key flow with native kimi CLI
- Auto-install via curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash

tests/test_fixes.sh:
- Remove obsolete proxy-specific tests (trap, readiness loops, etc.)
- Add tests for auto-install URLs and absence of proxy logic
This commit is contained in:
2026-05-31 18:49:38 +07:00
parent 1e15e4b6e8
commit 47e0f5e58d
2 changed files with 47 additions and 588 deletions

View File

@@ -12,54 +12,42 @@ fail() { echo "[FAIL] $1"; FAIL=$((FAIL+1)); }
# Extract sections
GPT_SECTION=$(awk '/^cat > "\$BIN_DIR\/claude_gpt"/,/^GPTEOF/' "$SCRIPT")
KIMI_SECTION=$(awk '/^cat > "\$BIN_DIR\/claude_kimi"/,/^KIMIEOF/' "$SCRIPT")
GEMINI_SECTION=$(awk '/^cat > "\$BIN_DIR\/claude_gemini"/,/^GEMINIEOF/' "$SCRIPT")
OPENAI_PROXY_SECTION=$(awk '/^cat > "\$OPENAI_ANTHROPIC_PROXY_BIN"/,/^PYEOF/' "$SCRIPT")
# ── Fix 2: trap EXIT kills proxy ──────────────────────────────────────────────
test_fix2_trap_exit() {
if echo "$GPT_SECTION" | grep -q "trap .* EXIT"; then
ok "Fix2: trap EXIT for proxy cleanup present in claude_gpt"
# ── claude_gpt: auto-install codex ────────────────────────────────────────────
test_gpt_autoinstall() {
if echo "$GPT_SECTION" | grep -q 'curl -fsSL https://chatgpt.com/codex/install.sh'; then
ok "claude_gpt: auto-installs codex via official install script"
else
fail "Fix2: trap EXIT for proxy cleanup missing in claude_gpt"
fail "claude_gpt: missing codex auto-install"
fi
}
# ── Fix 3: readiness loop replaces bare sleep 1 ──────────────────────────────
test_fix3_readiness_loop() {
if echo "$GPT_SECTION" | grep -q 'while \[ \$_i -lt'; then
ok "Fix3: readiness poll loop present in claude_gpt proxy start"
# ── claude_gpt: no proxy logic (simplified launcher) ──────────────────────────
test_gpt_no_proxy() {
if echo "$GPT_SECTION" | grep -q 'ANTHROPIC_BASE_URL'; then
fail "claude_gpt: still contains proxy logic (ANTHROPIC_BASE_URL)"
else
fail "Fix3: readiness poll loop missing in claude_gpt"
fi
if echo "$GPT_SECTION" | grep -qP 'proxy_pid=\$!\n\s+sleep 1\n\s+fi'; then
fail "Fix3: bare 'sleep 1' still present right after proxy_pid=\$!"
else
ok "Fix3: bare 'sleep 1; fi' pattern removed"
ok "claude_gpt: proxy logic removed (no ANTHROPIC_BASE_URL)"
fi
}
# ── Fix 3b: curl exit-7 logic correct ────────────────────────────────────────
test_fix3b_exit7_logic() {
if echo "$GPT_SECTION" | grep -q 'exit 7 = connection refused'; then
ok "Fix3b: exit-7 comment present (connection refused check documented)"
# ── claude_kimi: auto-install kimi ────────────────────────────────────────────
test_kimi_autoinstall() {
if echo "$KIMI_SECTION" | grep -q 'curl -fsSL https://code.kimi.com/kimi-code/install.sh'; then
ok "claude_kimi: auto-installs kimi via official install script"
else
fail "Fix3b: exit-7 comment missing"
fi
if echo "$GPT_SECTION" | grep -q '\[ "\$?" -ne 7 \]'; then
ok "Fix3b: [ \$? -ne 7 ] break condition present"
else
fail "Fix3b: exit-7 break condition missing"
fail "claude_kimi: missing kimi auto-install"
fi
}
# ── Fix 4: re-validate after claude_gpt reauth ───────────────────────────────
test_fix4_gpt_revalidate() {
if echo "$GPT_SECTION" | grep -q '_claude_test_api.*http://localhost:18765'; then
ok "Fix4: _claude_test_api called in claude_gpt"
# ── claude_kimi: no proxy logic (simplified launcher) ─────────────────────────
test_kimi_no_proxy() {
if echo "$KIMI_SECTION" | grep -q 'ANTHROPIC_BASE_URL'; then
fail "claude_kimi: still contains proxy logic (ANTHROPIC_BASE_URL)"
else
fail "Fix4: _claude_test_api missing in claude_gpt"
ok "claude_kimi: proxy logic removed (no ANTHROPIC_BASE_URL)"
fi
}
@@ -83,15 +71,6 @@ test_fix7_trap_tmp() {
fi
}
# ── Kimi/OpenAI proxy: Claude Code sends /v1/messages?beta=true ─────────────
test_kimi_proxy_accepts_query_string() {
if echo "$OPENAI_PROXY_SECTION" | grep -q 'urlparse(self.path).path'; then
ok "Kimi proxy: strips query string before routing /messages"
else
fail "Kimi proxy: does not handle /v1/messages?beta=true"
fi
}
# ── bash syntax of the whole script ─────────────────────────────────────────
test_script_syntax() {
if bash -n "$SCRIPT" 2>&1; then
@@ -103,13 +82,12 @@ test_script_syntax() {
# ── run all tests ─────────────────────────────────────────────────────────────
test_script_syntax
test_fix2_trap_exit
test_fix3_readiness_loop
test_fix3b_exit7_logic
test_fix4_gpt_revalidate
test_gpt_autoinstall
test_gpt_no_proxy
test_kimi_autoinstall
test_kimi_no_proxy
test_fix5_gemini_revalidate
test_fix7_trap_tmp
test_kimi_proxy_accepts_query_string
echo ""
echo "Results: $PASS passed, $FAIL failed"