KnowledgeBaseSkill
A production-grade Knowledge Base Skill for ArkOps-Ai — enables AI to query, manage, and answer player questions using a persistent knowledge base.
Features
- Fuzzy Search — N-gram keyword extraction with stop-word filtering for accurate Chinese/English search
- Weighted Scoring — Results ranked by relevance (tags > title > ID > content)
- Data Persistence — JSON-based storage with atomic writes and debounced saving
- Permission Control — Granular tool-level permissions (PLAYER / ADMIN / SUPER_ADMIN)
- Thread-Safe —
ConcurrentHashMapcache with synchronized file operations - Category Management — Dynamic category grouping without redundant data files
Quick Start
Requirements
- Java 21+
- Maven 3.6+
- ArkOps-Ai plugin installed on your server
- Paper/Spigot 1.21.8+
Build
mvn clean package
The compiled jar will be at target/KnowledgeBaseSkill-1.0.0.jar.
Install
- Copy
KnowledgeBaseSkill-1.0.0.jarto your server'splugins/folder - Restart the server
- The skill auto-registers with ArkOps-Ai
Data Location
Knowledge base data is stored at:
plugins/ArkOps-Ai/skills/knowledge_base/entries.json
Architecture
plugins/ArkOps-Ai/skills/knowledge_base/
└── entries.json # All knowledge entries (single source of truth)
Entry Structure
{
"server_rules": {
"title": "Server Rules",
"content": "1. Be respectful to all players\n2. No cheating...",
"category": "rules",
"tags": ["rules", "guidelines", "behavior"],
"created_at": 1710000000,
"updated_at": 1710000000
}
}
Tools
| Tool | Permission | Description |
|---|---|---|
query_knowledge |
PLAYER | Search knowledge base with fuzzy matching |
add_knowledge |
SUPER_ADMIN | Add a new knowledge entry |
update_knowledge |
SUPER_ADMIN | Update an existing entry |
delete_knowledge |
SUPER_ADMIN | Delete an entry by ID |
list_categories |
PLAYER | List all available categories |
list_knowledge |
PLAYER | List entries, optionally filtered by category |
Search Algorithm
Keyword Extraction
- Stop-word filtering — Removes common words (如何, 怎么, the, is, etc.)
- N-gram generation — Extracts 2-gram and 3-gram substrings
- Word splitting — Splits by whitespace for English terms
Scoring
| Match Location | Weight |
|---|---|
| Tags | +15 |
| Title | +10 |
| ID | +8 |
| Content | +5 |
Results are sorted by score in descending order.
Save Mechanism
| Event | Action |
|---|---|
| Add/Update/Delete | Mark dirty + schedule save (5s debounce) |
| Server shutdown | Force immediate save |
| Multiple rapid edits | Merged into single write |
Atomic writes use a .tmp file + rename pattern to prevent data corruption.
Example Usage
Query Knowledge
Player: 如何查看筑梦点?
AI: [query_knowledge] question="如何查看筑梦点"
Result: Found 1 result(s):
【筑梦点系统指令】
ID: dream_voice_commands
Category: economy
Tags: 筑梦点, dv, balance, pay, 经济, 货币, 转账
筑梦点是服务器的一种货币系统。查看筑梦点余额的指令是 /dv balance...
Add Knowledge
Player: 添加知识库 查看筑梦点到方法是/dv balance
AI: [add_knowledge] id="dream_voice_commands" title="筑梦点系统指令" content="..." category="economy" tags="筑梦点, dv, balance, pay"
Result: Successfully added knowledge entry: dream_voice_commands
Development
Project Structure
KnowledgeBaseSkill/
├── pom.xml
├── SKILL_DEVELOPMENT.md # ArkOps-Ai skill development docs
├── skill-template/ # Reference template
└── src/main/java/com/arkops/
├── knowledgebaseskill/
│ └── KnowledgeBaseSkill.java
└── skill/
├── Skill.java # Skill interface (stub)
└── SkillManager.java # Skill manager (stub)
Dependencies
| Dependency | Scope | Purpose |
|---|---|---|
io.papermc.paper:paper-api |
provided | Bukkit API |
com.google.code.gson:gson |
compile (shaded) | JSON serialization |
Gson is shaded into the final jar to avoid conflicts.
License
This Skill is still in development and internal testing phase, not yet open for use. Thank you for your attention, please wait patiently for the follow-up release. If you are interested in this project, you can contact DreamArkMC@163.com to apply for beta testing.
Author
DreamArk Studio
DreamArk Studio