SuperAPI AI Directory

zhihe-legal-research

Writing & research

View repository

Updated 10-15 20:10

About this skill

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 anasynchronous long task(3-10 minutes). It adopts auser-initiated querymechanism, compatible with all AI Agent platforms (Claude Code, OpenClaw, etc.):

用户提交 → 获得任务 ID → 用户稍后主动查询 → 获取结果并归档

Core principles:

  • Do not automatically check results before every message— to avoid old results contaminating the current conversation
  • Only when the user actively asks about the research resultsshould the status and results be queried
  • Archive immediately after each query— to ensure a clean state with no residual data

Workflow

Step 1: Check login status

./scripts/auth.sh check
  • is_vip: true → Already logged in, continue
  • code: 401 → Login required (proceed to Step 2)

Step 2: Log in (if needed)

# 发送验证码(如果已保存手机号,可省略手机号参数)
./scripts/auth.sh send-code [手机号]

# 验证登录(自动保存 Token 和手机号)
./scripts/auth.sh verify <手机号> <6位验证码>

Automatic re-login process: If config has saved LEGAL_RESEARCH_PHONE, when the token expires you can directly execute ./scripts/auth.sh send-code(no need to pass in the phone number); the system will automatically use the saved phone number to send the verification code. The user only needs to provide the verification code to complete re-login.

Step 3: Submit the legal question

# 提交问题
./scripts/research.sh submit "<用户的法律问题>"

After successful submission, record the task_id and inform the user:

✅ Your legal question has been submitted, and research and analysis is underway in the background. ⏱️ It is expected to take 3-4 minutes to complete. 📋 Task ID:{task_id}

👉 Please reply "view results" or "are the research results ready" in about 4 minutes to obtain the analysis report.

Step 4: Query results (only when the user actively asks)

Trigger conditions: The user actively asks about the research results (such as "view results", "are the results out yet", etc.).

If the user provides a task_id, query directly; if not provided, first check the history to obtain the most recent task:

# 如果没有 task_id,先查历史
./scripts/research.sh history 1 3

Then query the status:

# 查询状态
./scripts/research.sh status <task_id>

Handle according to status:

Status Handling method
completed Get results → get report → archive → display to user
running Tell the user to continue waiting 1-2 minutes and then query again
pending Tell the user it is still in the queue and to check again later
failed Tell the user the reason for the failure and suggest resubmitting
timeout Tell the user it timed out and suggest simplifying the question and retrying

When the status is completed, execute in sequence:

# 1. 获取文字结果
./scripts/research.sh result <task_id>

# 2. 获取报告下载链接
./scripts/research.sh report <task_id>

# 3. 自动归档(下载报告到 archive/ 目录,含 Markdown 转换)
./scripts/research.sh archive <task_id>

After archiving is complete, display the research results and report link to the user.


Claude Code Enhanced Mode (optional)

Only available in the Claude Code environment. It provides a better asynchronous experience, with no need for the user to query manually.

After submitting the task, use Bash the tool's run_in_background: true to start background monitoring:

command: "./scripts/monitor.sh monitor <task_id> 600 30"
run_in_background: true
timeout: 600000

Key considerations:

  1. timeout must be set to 600000(10 minutes), otherwise the default 2 minutes will time out
  2. After background monitoring is complete, a notification will be received automatically, and at that point the results should be shown to the user
  3. The monitoring script will automatically archive to archive/ Directory

The OpenClaw environment does not support this enhanced mode, please use the standard process (steps 1-4).


Common Commands

Authentication

Command Purpose
./scripts/auth.sh check Check login status
./scripts/auth.sh send-code [phone] Send verification code (uses the saved phone number when the phone number is omitted)
./scripts/auth.sh verify <phone> <code> Verify login (automatically saves the Token and phone number)
./scripts/auth.sh logout Clear credentials

Research Operations

Command Purpose
./scripts/research.sh submit "<query>" Submit a question
./scripts/research.sh status <task_id> Check 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 (Claude Code enhanced mode only)

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 results pending notification
./scripts/monitor.sh clear <task_id> Mark as notified

Status Handling

Status Description Handling
pending Queued Tell the user to wait
running Processing Tell the user to continue waiting
completed Completed Get results → archive → notify the user
failed Failed Notify the user of the failure reason
timeout Timed out Notify the user of the timeout

Configuration

All configuration files are self-contained within the skill:assets/

File Purpose
.env Token and phone number configuration (added to .gitignore)
pending.json Pending tasks
completed.json Completed pending notification
notified.json Notification history

Note:assets/.env has been added to .gitignore, sensitive information will not be committed to git.

For configuration examples, see assets/.env.example


Archive Function

Automatic Archiving

Automatically archive when a task is completed: during archiving, the report is automatically downloaded and saved to the archive/ directory.

Archive Naming Format:YYMMDD 主题_法律研究报告

Example:

archive/
├── 260326 美术作品著作权侵权纠纷_法律研究报告/
│   ├── result.md       # 研究结果摘要(Markdown)
│   ├── report.docx     # 详细报告(自动下载)
│   ├── report.md       # 报告 Markdown 版本(需安装 pandoc)
│   └── media/          # 报告中的图片(如有)
└── 260310 劳动合同解除赔偿_法律研究报告/
    └── result.md

Manual Archiving

# 归档研究结果(自动下载报告并转换为 Markdown)
./scripts/research.sh archive <task_id>

# 列出所有归档
./scripts/research.sh list-archive

Markdown Conversion Dependency

During archiving, it automatically attempts to convert the docx report to Markdown:

  • Dependency: requires installing pandoc
  • Format: uses GitHub Flavored Markdown (GFM), preserving the original hierarchical structure
  • Images: automatically extracted to the media/ subdirectory
# macOS 安装 pandoc
brew install pandoc

Detailed Documentation


Notes

  1. Membership Requirement: requires a Zhihe AI platform membership; non-members are directed to https://www.zhiexa.com
  2. Token Validity Period: 72 hours; re-login is required after expiration
  3. Rate Limit: only 1 question can be submitted per minute, and only 1 task can be in progress at a time
  4. Report link: Valid for 7 days; after expiration, calling the API again will automatically refresh it
  5. Privacy Protection: The phone number is used only for authentication and is masked when displayed
  6. Cross-Platform Compatibility: The core process relies only on bash scripts and is compatible with all Agent platforms (Claude Code, OpenClaw)