Zhihe Legal Research
Connect to the Zhihe AI Legal Large Model Platform to provide professional legal research and analysis services.
⚠️ Asynchronous Task Processing Mechanism
Legal research is an asynchronous long-running task (3-10 minutes). Adopts a user-initiated query mechanism, compatible with all AI Agent platforms (Claude Code, OpenClaw, etc.):
User submission → Obtain task ID → User actively queries later → Get results and archive
Core Principles:
- Do not automatically check results before each message - Avoid contaminating current conversations with old results
- Only query status and results when users actively ask about research results
- Archive immediately after each query - Ensure clean status with no residual data
Workflow
Step 1: Check Login Status
- → Logged in, proceed
- → Need to log in (perform Step 2)
Step 2: Login (if needed)
bash
# Send verification code (omit phone number parameter if phone number is saved)
./scripts/auth.sh send-code [phone number]
# Verify login (automatically save Token and phone number)
./scripts/auth.sh verify <phone number> <6-digit verification code>
Automatic Re-login Process: If
is saved in
, when the token expires, you can directly execute
./scripts/auth.sh send-code
(no need to pass in the phone number), and the system will automatically use the saved phone number to send the verification code. Users only need to provide the verification code to complete re-login.
Step 3: Submit Legal Question
bash
# Submit question
./scripts/research.sh submit "<user's legal question>"
After successful submission, record the task_id and inform the user:
✅ Your legal question has been submitted, and background research and analysis are in progress.
⏱️ It is expected to take 3-4 minutes to complete.
📋 Task ID:
👉 Please reply "Check results" or "Is the research result ready?" after about 4 minutes to get the analysis report.
Step 4: Query Results (only when users actively ask)
Trigger Condition: Users actively ask about research results (e.g., "Check results", "Is the result out?", etc.).
If the user provides a task_id, query directly; if not, first check history to get the latest task:
bash
# If no task_id, check history first
./scripts/research.sh history 1 3
Then query the status:
bash
# Query status
./scripts/research.sh status <task_id>
Process according to status:
| Status | Processing Method |
|---|
| Get results → Get report → Archive → Display to user |
| Inform user to wait another 1-2 minutes before querying |
| Inform user that it is still in queue, check later |
| Inform user of failure reason, suggest resubmission |
| Inform user of timeout, suggest simplifying the question and retrying |
When status is completed, execute in sequence:
bash
# 1. Get text results
./scripts/research.sh result <task_id>
# 2. Get report download link
./scripts/research.sh report <task_id>
# 3. Auto-archive (download report to archive/ directory, including Markdown conversion)
./scripts/research.sh archive <task_id>
After archiving is completed, display the research results and report link to the user.
Claude Code Enhanced Mode (Optional)
Only available in Claude Code environment. Provides a better asynchronous experience without requiring manual queries from users.
After submitting the task, use
tool's
to start background monitoring:
bash
command: "./scripts/monitor.sh monitor <task_id> 600 30"
run_in_background: true
timeout: 600000
Key Notes:
- timeout must be set to 600000 (10 minutes), otherwise the default 2 minutes will cause timeout
- A notification will be automatically received after background monitoring is completed, and the results will be displayed to the user at this time
- The monitoring script will automatically archive to the directory
This enhanced mode is not supported in OpenClaw environment, please use the standard process (Steps 1-4).
Common Commands
Authentication
| Command | Purpose |
|---|
| Check login status |
./scripts/auth.sh send-code [phone]
| Send verification code (use saved phone number when omitted) |
./scripts/auth.sh verify <phone> <code>
| Verify login (automatically save Token and phone number) |
| Clear credentials |
Research Operations
| Command | Purpose |
|---|
./scripts/research.sh submit "<query>"
| Submit question |
./scripts/research.sh status <task_id>
| Query status |
./scripts/research.sh result <task_id>
| Get results |
./scripts/research.sh report <task_id>
| Get report link |
./scripts/research.sh archive <task_id>
| Archive research results |
./scripts/research.sh history [page] [size]
| View historical tasks |
Monitoring Management (Only for Claude Code Enhanced Mode)
| Command | Purpose |
|---|
./scripts/monitor.sh monitor <task_id> [timeout] [interval]
| Blocking monitoring |
./scripts/monitor.sh status
| Check monitoring status |
./scripts/monitor.sh results
| Get completed pending notification results |
./scripts/monitor.sh clear <task_id>
| Mark as notified |
Status Handling
| Status | Description | Processing |
|---|
| In queue | Inform user to wait |
| Processing | Inform user to continue waiting |
| Completed | Get results → Archive → Notify user |
| Failed | Notify user of failure reason |
| Timeout | Notify user of timeout |
Configuration
All configuration files are self-contained within the skill:
| File | Purpose |
|---|
| Token and phone number configuration (added to .gitignore) |
| Pending tasks |
| Completed pending notification |
| Notified history |
Note:
has been added to
, and sensitive information will not be submitted to git.
See assets/.env.example for configuration examples.
Archive Function
Auto-archive
Auto-archive when task is completed: During archiving, the report will be automatically downloaded and saved to the
directory.
Archive Naming Format:
YYMMDD Topic_Legal Research Report
Example:
archive/
├── 260326 美术作品著作权侵权纠纷_法律研究报告/
│ ├── result.md # Research result summary (Markdown)
│ ├── report.docx # Detailed report (auto-downloaded)
│ ├── report.md # Report Markdown version (requires pandoc installation)
│ └── media/ # Images in the report (if any)
└── 260310 劳动合同解除赔偿_法律研究报告/
└── result.md
Manual Archive
bash
# Archive research results (auto-download report and convert to Markdown)
./scripts/research.sh archive <task_id>
# List all archives
./scripts/research.sh list-archive
Markdown Conversion Dependencies
The system will automatically attempt to convert docx reports to Markdown during archiving:
- Dependency: Need to install pandoc
- Format: Uses GitHub Flavored Markdown (GFM), retains original hierarchical structure
- Images: Automatically extracted to subdirectory
bash
# Install pandoc on macOS
brew install pandoc
Detailed Documentation
- API Reference - Complete API description
- Interaction Examples - Complete workflows for various scenarios
Notes
- Membership Requirement: Requires a Zhihe AI platform membership; non-members are directed to https://www.zhiexa.com
- Token Validity: 72 hours, need to re-login after expiration
- Frequency Limit: Only 1 question can be submitted per minute, and only 1 ongoing task is allowed at a time
- Report Link Validity: 7 days; re-calling the interface will automatically refresh it after expiration
- Privacy Protection: Phone numbers are only used for authentication and will be desensitized when displayed
- Cross-Platform Compatibility: The core process only relies on bash scripts, compatible with all Agent platforms (Claude Code, OpenClaw)