處理 AI review findings 並改寫 Node.js entrypoint #1

Merged
jiantw83 merged 58 commits from ai-review-resolve/20260624102518 into develop 2026-06-24 14:09:27 +00:00
2 changed files with 49 additions and 0 deletions
Showing only changes of commit a01dbe5e2c - Show all commits
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
IMAGE_NAME="codex-action-smoke:local"
if ! command -v docker >/dev/null 2>&1; then
echo "SKIP: docker is not available"
exit 0
fi
if ! docker info >/dev/null 2>&1; then
echo "SKIP: docker daemon is not available"
exit 0
fi
docker build -t "$IMAGE_NAME" "$ROOT_DIR"
docker run --rm --entrypoint codex "$IMAGE_NAME" --version
Ghost marked this conversation as resolved
Review

嚴重等級🔵 建議
審查員:Maya
問題:目前的 Docker 冒煙測試僅驗證了 CLI 二進位檔是否存在,但尚未驗證其在容器內執行時是否能正常存取與寫入 CODEX_HOME 環境設定的目錄。
建議:建議在 docker_image_test.sh 中增加一個測試案例,執行 codex --version 之外的指令,驗證容器權限與目錄環境變數設定是否正確。

**嚴重等級**:🔵 建議 **審查員**:Maya **問題**:目前的 Docker 冒煙測試僅驗證了 CLI 二進位檔是否存在,但尚未驗證其在容器內執行時是否能正常存取與寫入 `CODEX_HOME` 環境設定的目錄。 **建議**:建議在 `docker_image_test.sh` 中增加一個測試案例,執行 `codex --version` 之外的指令,驗證容器權限與目錄環境變數設定是否正確。
docker run --rm --entrypoint codex "$IMAGE_NAME" plugin list | grep -q "jsc@doc"
docker run --rm --entrypoint codex "$IMAGE_NAME" plugin list | grep -q "jsc@code-review"
+27
View File
@@ -16,6 +16,7 @@ make_fake_codex() {
cat > "$dir/codex" <<SH cat > "$dir/codex" <<SH
Ghost marked this conversation as resolved
Review

嚴重等級🟡 警告
審查員:Bard
問題:在測試中建立 codex 指令時,Here-document 與命令混雜,可讀性較低。
建議:建議使用更整齊的縮排格式,或將其抽離為獨立的測試輔助檔案。

**嚴重等級**:🟡 警告 **審查員**:Bard **問題**:在測試中建立 `codex` 指令時,Here-document 與命令混雜,可讀性較低。 **建議**:建議使用更整齊的縮排格式,或將其抽離為獨立的測試輔助檔案。
#!/bin/sh #!/bin/sh
printf '%s\n' "\$*" > "\${CODEX_FAKE_ARGS:-/dev/null}"
echo "$message" echo "$message"
exit $exit_code exit $exit_code
SH SH
1
@@ -118,6 +119,30 @@ test_success_output() {
rm -rf "$tmpdir" rm -rf "$tmpdir"
} }
test_empty_prompt() {
local tmpdir
tmpdir="$(mktemp -d)"
make_fake_codex "$tmpdir" 0 "codex ok"
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT=""
grep -q "codex ok" "$tmpdir/github-output" || die "empty prompt output"
rm -rf "$tmpdir"
}
test_prompt_with_shell_characters() {
local tmpdir
local prompt
tmpdir="$(mktemp -d)"
prompt='hello; rm -rf / $(echo bad) "quoted"'
make_fake_codex "$tmpdir" 0 "codex ok"
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="$prompt" CODEX_FAKE_ARGS="$tmpdir/codex-args"
grep -qF "$prompt" "$tmpdir/codex-args" || die "prompt was not passed as one argument"
rm -rf "$tmpdir"
}
test_failure_output() { test_failure_output() {
local tmpdir local tmpdir
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
@@ -140,6 +165,8 @@ test_missing_model
test_invalid_base64 test_invalid_base64
test_non_object_json test_non_object_json
test_success_output test_success_output
test_empty_prompt
test_prompt_with_shell_characters
test_failure_output test_failure_output
echo "entrypoint tests passed" echo "entrypoint tests passed"