Files
codex-crew/tests/test-run.sh
T
admin 54aabcab23 fix: review mode works with prompts, anti-self-work contract, EN docs
- codex-run.sh review: CLI forbids scope flags + prompt (stdin '-' counts
  as [PROMPT]); translate scope into prompt text, native review only when
  prompt.md is empty. Add --skip-git-repo-check for consistency.
- agents/codex.md: marker contract (=== TASK FOR CODEX === / === END TASK ===,
  legacy RU markers accepted) so wrapper instructions never leak into the
  codex prompt and the wrapper never mistakes the task for its own job;
  self-check against doing the task itself; preamble now states codex is a
  subagent executor and process flows belong to the orchestrator; scope
  flags as separate args; no nohup; Read before rewriting prompt.md.
- skills: wrapper framing line + marker block in prompt templates.
- All instructions and README translated to English (RU trigger phrases
  kept in skill descriptions).
- tests: 3 new review-mode cases, ALL PASS.
- bump 0.1.2.
2026-07-28 19:12:19 +05:00

58 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
RUN=$HERE/../scripts/codex-run.sh
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
# 1. happy path -> status ok, thread_id captured, exit 0
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/ok" exec "hello"
[[ $(cat "$TMP/ok/status") == ok ]]
[[ $(cat "$TMP/ok/thread_id") == test-thread-123 ]]
[[ $(cat "$TMP/ok/last.md") == "stub answer|args="*"hello|" ]]
# 2. stall -> watchdog kills, status stalled, exit nonzero
if CODEX_BIN=$HERE/stub-hang/codex CODEX_STALL_TIMEOUT=4 CODEX_WATCH_INTERVAL=2 \
"$RUN" "$TMP/hang" exec "hello"; then
echo "FAIL: stall run must exit nonzero"; exit 1
fi
[[ $(cat "$TMP/hang/status") == stalled ]]
[[ $(cat "$TMP/hang/thread_id") == hang-thread-456 ]]
# 3. prompt.md via stdin path
mkdir -p "$TMP/stdin"; echo "prompt from file" > "$TMP/stdin/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/stdin" exec
[[ $(cat "$TMP/stdin/status") == ok ]]
[[ $(cat "$TMP/stdin/last.md") == "stub answer|args="*" -|prompt from file" ]]
# 4. prompt.md + codex flags -> stdin still delivered (regression: options ate the prompt)
mkdir -p "$TMP/flags"; echo "prompt with flags" > "$TMP/flags/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/flags" exec -s read-only
[[ $(cat "$TMP/flags/status") == ok ]]
[[ $(cat "$TMP/flags/last.md") == "stub answer|args="*"-s read-only -|prompt with flags" ]]
# 5. review + scope + prompt.md -> scope translated into prompt text, no scope flag in args
mkdir -p "$TMP/rev"; echo "focus: correctness" > "$TMP/rev/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/rev" review --base main
[[ $(cat "$TMP/rev/status") == ok ]]
LAST5=$(cat "$TMP/rev/last.md")
[[ $LAST5 == "stub answer|args=exec review"* ]]
[[ $LAST5 != *"--base"* ]]
[[ $LAST5 == *"against base ref 'main'"* ]]
[[ $LAST5 == *"git diff main...HEAD"* ]]
[[ $LAST5 == *"focus: correctness" ]]
# 6. review + scope, no prompt.md -> native path keeps the scope flag
mkdir -p "$TMP/rev-native"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/rev-native" review --uncommitted
[[ $(cat "$TMP/rev-native/status") == ok ]]
[[ $(cat "$TMP/rev-native/last.md") == "stub answer|args=exec review"*"--uncommitted|" ]]
# 7. review + prompt.md, no scope -> custom instructions pass through untouched
mkdir -p "$TMP/rev-custom"; echo "review whatever you find" > "$TMP/rev-custom/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/rev-custom" review
[[ $(cat "$TMP/rev-custom/status") == ok ]]
[[ $(cat "$TMP/rev-custom/last.md") == "stub answer|args=exec review"*"-|review whatever you find" ]]
echo "ALL PASS"