globs: alwaysApply: true
This is an advanced, experimental rule. It instructs the AI Agent to check for, potentially create, and then execute a Python script (final_review_gate.py) in your project's root directory to facilitate an interactive review loop. By using this rule, you acknowledge that the AI will attempt file system operations (read, write, execute) as directed. Ensure the AI's execution environment has appropriate permissions if you expect script auto-creation to work, and be aware of the security implications.
Your primary task processing includes a mandatory final interactive review stage driven by user input through a specific Python script (final_review_gate.py). You are NOT to consider your overall task complete until this review stage explicitly signals completion. This protocol leverages your known capability to run commands in a sub-terminal (displayed within the chat interface) and read their output.
final_review_gate.py Script Exists(This phase is executed ONCE per user request that triggers this overall protocol, or if the script is missing or its content is incorrect.)
Define Script Details:
Script Name: final_review_gate.py
Target Location: Directly in the root of the current project/workspace.
Python Script Content (ensure this exact content is used):
# final_review_gate.py
import sys
import os
if __name__ == "__main__":
# Try to make stdout unbuffered for more responsive interaction.
# This might not work on all platforms or if stdout is not a TTY,
# but it's a good practice for this kind of interactive script.
try:
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1)
except Exception:
pass # Ignore if unbuffering fails, e.g., in certain environments
try:
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', buffering=1)
except Exception:
pass # Ignore
print("--- FINAL REVIEW GATE ACTIVE ---", flush=True)
print("AI has completed its primary actions. Awaiting your review or further sub-prompts.", flush=True)
print("Type your sub-prompt, or one of: 'TASK_COMPLETE', 'Done', 'Quit', 'q' to signal completion.", flush=True) # MODIFIED
active_session = True
while active_session:
try:
# Signal that the script is ready for input.
# The AI doesn't need to parse this, but it's good for user visibility.
print("REVIEW_GATE_AWAITING_INPUT:", end="", flush=True)
line = sys.stdin.readline()
if not line: # EOF
print("--- REVIEW GATE: STDIN CLOSED (EOF), EXITING SCRIPT ---", flush=True)
active_session = False
break
user_input = line.strip()
# Check for exit conditions
if user_input.upper() in ['TASK_COMPLETE', 'DONE', 'QUIT', 'Q']: # MODIFIED: Empty string no longer exits
print(f"--- REVIEW GATE: USER SIGNALED COMPLETION WITH '{user_input.upper()}' ---", flush=True)
active_session = False
break
elif user_input: # If there's any other non-empty input (and not a completion command)
# This is the critical line the AI will "listen" for.
print(f"USER_REVIEW_SUB_PROMPT: {user_input}", flush=True)
# If user_input was empty (and not a completion command),
# the loop simply continues, and "REVIEW_GATE_AWAITING_INPUT:" will be printed again.
except KeyboardInterrupt:
print("--- REVIEW GATE: SESSION INTERRUPTED BY USER (KeyboardInterrupt) ---", flush=True)
active_session = False
break
except Exception as e:
print(f"--- REVIEW GATE SCRIPT ERROR: {e} ---", flush=True)
active_session = False
break
print("--- FINAL REVIEW GATE SCRIPT EXITED ---", flush=True)
Ensure Script Existence and Correctness:
a. Use your file system tools to check if the file final_review_gate.py exists in the project root.
b. If the file final_review_gate.py does NOT exist OR if its content does not EXACTLY match the Python script provided in section "Phase 0.1.Python Script Content" (you may need to read the existing file and compare):
i. You MUST create or overwrite the final_review_gate.py file in the project root.
ii. The content of this file MUST be exactly the Python script content provided above. Ensure all indentation, comments, and lines are preserved perfectly. Use your "create file" or "edit file" tool.
iii. After creating/overwriting it, announce: "The final_review_gate.py script has been created/updated in the project root with the latest interaction enhancements."
c. If the file final_review_gate.py already exists and its content is correct: You may skip announcing its creation.
d. If you encounter any errors checking for, reading, or creating/writing the file (e.g., permission issues), you MUST report this to the user. State clearly: "Error managing final_review_gate.py: [specific error]. Cannot proceed with interactive review." and then conclude the interaction for the main task as best as you can without this interactive step.
final_review_gate.py script (which you ensured exists and is correct in Phase 0) from the project root.
python, python3) available in the execution environment. A robust command attempt would be python3 ./final_review_gate.py and if that fails, try python ./final_review_gate.py../final_review_gate.py. The review terminal is now active in this chat window, and its output will be displayed live. Please provide any sub-prompts directly into that script's input area, or type 'TASK_COMPLETE', 'Done', 'Quit', or 'q' when satisfied." (MODIFIED: Removed "or simply press Enter")final_review_gate.py script as it appears live in the chat window. Ensure the user sees all script output, including the REVIEW_GATE_AWAITING_INPUT: prompt. You will "read" its output using the same capability that allows you to read terminal logs or error messages. The script will loop and re-prompt if an empty input is given.