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.
This commit is contained in:
admin committed 2026-07-28 19:12:19 +05:00
1 parent 0c355c4b9d
commit 54aabcab23
8 files changed
+292 -180

No files matched your search

+26 -3
View File
@@ -9,6 +9,10 @@
# If <job_dir>/prompt.md is non-empty it is always fed via stdin ('-'); codex-flags
# stay positional, so options and a file prompt combine freely.
# Review runs against the git repo at the CURRENT WORKING DIRECTORY (no -C support).
# Review mode: codex CLI forbids combining scope flags (--base/--commit/--uncommitted)
# with a positional [PROMPT] — and stdin '-' counts as PROMPT. So with a non-empty
# prompt.md the scope flag is translated into prompt text and review runs with custom
# instructions only; with an empty prompt.md the native `review <scope>` is used.
#
# Files written to <job_dir>: events.jsonl last.md err.log thread_id status
# status: ok | stalled | error: <reason>. Exit code 0 only on ok.
@@ -23,6 +27,7 @@ JOB_DIR=$1; MODE=$2; shift 2
mkdir -p "$JOB_DIR"
JOB_DIR=$(cd "$JOB_DIR" && pwd)
EV=$JOB_DIR/events.jsonl LAST=$JOB_DIR/last.md ERR=$JOB_DIR/err.log
PF=$JOB_DIR/prompt.md
STALL=${CODEX_STALL_TIMEOUT:-600}
TICK=${CODEX_WATCH_INTERVAL:-15}
BIN=${CODEX_BIN:-codex}
@@ -31,14 +36,32 @@ case $MODE in
exec) CMD=("$BIN" exec --json --skip-git-repo-check -o "$LAST") ;;
resume) TID=$1; shift; printf '%s\n' "$TID" > "$JOB_DIR/thread_id"
CMD=("$BIN" exec resume "$TID" --json --skip-git-repo-check -o "$LAST") ;;
review) CMD=("$BIN" exec review --json -o "$LAST") ;;
review)
if [[ -s $JOB_DIR/prompt.md ]]; then
# scope flags conflict with a prompt at the CLI level — move scope into text
SCOPE_DESC=""; REST=()
while [[ $# -gt 0 ]]; do
case $1 in
--base) SCOPE_DESC="Review the changes on the current branch against base ref '$2' — run \`git diff $2...HEAD\` (merge-base) to see the full change set."; shift 2 ;;
--commit) SCOPE_DESC="Review the changes introduced by commit '$2' — run \`git show $2\` to see them."; shift 2 ;;
--uncommitted) SCOPE_DESC="Review all uncommitted changes (staged, unstaged, untracked) — run \`git status\` and \`git diff HEAD\` to see them."; shift ;;
*) REST+=("$1"); shift ;;
esac
done
if [[ -n $SCOPE_DESC ]]; then
PF=$JOB_DIR/prompt.final.md
{ printf 'This is a code review task. %s\n\n' "$SCOPE_DESC"; cat "$JOB_DIR/prompt.md"; } > "$PF"
fi
set -- ${REST[@]+"${REST[@]}"}
fi
CMD=("$BIN" exec review --json --skip-git-repo-check -o "$LAST") ;;
*) echo "usage: codex-run.sh <job_dir> exec|resume|review ..." >&2; exit 2 ;;
esac
rm -f "$JOB_DIR/status" "$LAST"; : > "$EV"; : > "$ERR"
if [[ -s $JOB_DIR/prompt.md ]]; then
"${CMD[@]}" "$@" - < "$JOB_DIR/prompt.md" > "$EV" 2> "$ERR" &
if [[ -s $PF ]]; then
"${CMD[@]}" "$@" - < "$PF" > "$EV" 2> "$ERR" &
else
"${CMD[@]}" "$@" < /dev/null > "$EV" 2> "$ERR" &
fi