This skill provides unified, schema-adaptive query access to the safety-review knowledge base (SQLite database). It eliminates the need to manually write connection scripts, guess field names, or handle encoding issues every time.
Database location: ~/.openclaw-autoclaw/skills/safety-review/db/knowledge.db
safety-review SQLite database
Trigger phrases (Chinese): 查知识库、搜法规、标准有没有、对比标准、查条款、数据质量、法规检索
```bash
python --version
```
Use python or python3 based on availability.
```
C:\Users\13503\.openclaw-autoclaw\skills\safety-review\db\knowledge.db
```
Override via environment variable KB_PATH if needed.
All commands are executed via scripts/kb_query.py. Output is JSON for programmatic consumption.
search)
Find regulations matching a keyword across multiple fields.
python scripts/kb_query.py search <keyword> [--mode fuzzy|exact] [--limit N]
| Parameter | Description | Default |
|-----------|-------------|---------|
| keyword | Search term (standard number, title fragment, etc.) | Required |
| --mode | fuzzy (LIKE match) or exact (equality) | fuzzy |
| --limit | Maximum results | 20 |
Example scenarios:
search GB16423
search 紧急避险
search "AQ/T 2033-2023" --mode exact
check) ⭐ Most Useful
Given a list of standards, report which exist and which are missing — the primary gap analysis tool.
python scripts/kb_query.py check <standard1> <standard2> <standard3> ...
Output fields per result:
found: boolean
id: regulation ID (if found)
document_number: stored document number
title: regulation title (truncated)
status: current status
text_length: character count of full_text
clause_count: number of associated clauses
Example:
python scripts/kb_query.py check "GB 16423" "AQ/T 2033" "AQ 2034" "国发[2010]23号"
info)
Get comprehensive info about a specific regulation by ID.
python scripts/kb_query.py info <regulation_id>
Returns all columns from regulations table + clause count + linked std_registry entry (if any).
clauses)
Retrieve clauses of a regulation, with optional filtering.
python scripts/kb_query.py clauses <regulation_id> [--filter <keyword>]
stats)
Overview of knowledge base contents.
python scripts/kb_query.py stats
Returns: total regulations, total clauses, total books, status breakdown, domain distribution.
schema)
Auto-detect and print table structures (useful when DB schema changes).
python scripts/kb_query.py schema
conflicts) ⭐ Important
Detect potential data quality issues:
python scripts/kb_query.py conflicts
When user provides a document that references standards and asks "which ones are missing":
check command with the extracted list
conflicts for deeper analysis
safety-kb-import)
search with user's keywords
info to get details on relevant entries
clauses
safety-kb-import for writing
--mode exact when possible
clauses command truncates content to 200 chars for readability; use info to get full text
| Skill | Role |
|-------|------|
| safety-kb-query (this one) | Query/read operations only |
| safety-kb-import | Import/write new regulations into the database |
| standard-update-courseware | Update training courseware based on standard changes |
| Error | Cause | Solution |
|-------|-------|----------|
| Database not found | Wrong path or DB moved | Check DEFAULT_DB_PATH or set KB_PATH env var |
| no such column | DB schema changed | Run schema command to see actual columns |
| Empty search results | Keyword too specific or not in DB | Try --mode fuzzy with shorter keywords |
| Garbled output | Terminal encoding issue | Pipe output through chcp 65001 (Windows) or redirect to file |
共 1 个版本