Interactive CLI client and custom hooks framework extending the core AI Coding Agent loops.
This repository features the development of the standalone console execution loop and authorization gates simulating real-world secure terminal workflows.
+-----------------------------+
| User Command Input |
+--------------+--------------+
|
v
+--------------v--------------+
| ReAct Engine Core | <---+
+--------------+--------------+ |
| |
Tool Call |
| Loop Cycles
v |
+--------------v--------------+ |
| Permission Hook (Y/N Gate) | |
+-------+--------------+------+ |
| | |
[Approved] [Denied] |
| | |
v v |
+-------v------+ +-----v------+ |
| Run Terminal | | Feed Deny | ────┘
| Subprocess | | Error Msg |
+--------------+ +------------+
- Interactive Console Client (
claude-code-cli.py): An offline-first terminal client wrapping the ReAct executor. Provides colorful logging, interactive shell prompting, and step-by-step thinking loop inspection. - Permission Hook Gate:
Secures critical tool executions (such as running shell subprocesses via bash). Intercepts execution requests and triggers a manual validation prompt:
👉 是否批准该操作?[y/N]:If the user denies authorization, a clean permission error payload is fed back to the LLM agent's context, maintaining loop integrity without crashing the service thread. - High-Fidelity Mock Mode:
Allows developers to debug agent reasoning sequences locally and offline without triggering API charges, switching to mock states when
ANTHROPIC_API_KEYis not detected.
├── agents/ # Multi-agent coordination helpers
├── s01_agent_loop/ # Basic ReAct iteration scripts
├── s02_tool_use/ # Tool definition & schemas
├── s03_permission/ # Permission intercepts
├── s04_hooks/ # Lifecycle hook orchestrator
├── s20_comprehensive/ # Composite Agent engine build
├── claude-code-cli.py # Standalone interactive CLI app (Production wrapper)
└── README.md # Project documentation
- Python 3.10+
# Start CLI client (Auto-detects API keys in environment)
python3 claude-code-cli.py- Generate files: "Create a simple Python utility that parses arguments"
- Run Shell Checks: "Run ruff check on this directory" (Intercepted by Permission Gate)