通过 GraphQL API 操作 ai-reins.com 知识库。
| 操作 | 说明 |
|---|---|
| search_wiki(query) | 全文搜索 |
| get_page(path) | 读取文章内容 |
| list_pages(tags?) | 列出所有文章 |
| create_page(...) | 新建文章 |
| update_page(id,...) | 更新文章 |
| delete_page(id) | 删除文章 |
正确: skills/agent-browser
错误: /skills/agent-browser
enwiki-ai-reins---
name: wiki-agent
description: >
Manage and interact with the ai-reins.com Wiki knowledge base via GraphQL API.
Use when the user wants to search, read, create, update, or delete wiki articles.
Triggers: "search wiki", "read wiki", "create article", "update wiki",
"publish to wiki", "find in wiki", "list articles", "delete page".
user-invocable: true
allowed-tools: Bash(python*)
env:
WIKI_URL: https://ai-reins.com
WIKI_TOKEN: $WIKI_TOKEN # 从 Administration → API Access 获取,勿提交到公开仓库
---
# Wiki Agent Skill
通过 GraphQL API 操作 ai-reins.com 知识库。所有写入操作使用 locale `en`。
## Python 调用模板
```python
import httpx, json
WIKI_URL = "https://ai-reins.com"
WIKI_TOKEN = "<见 env.WIKI_TOKEN>"
HEADERS = {"Authorization": f"Bearer {WIKI_TOKEN}", "Content-Type": "application/json"}
def gql(query, variables={}):
r = httpx.post(f"{WIKI_URL}/graphql",
json={"query": query, "variables": variables},
headers=HEADERS, timeout=20)
return r.json()
data = gql("""
query($q: String!) { pages { search(query: $q) { results { id title path description } } } }
""", {"q": "关键词"})
results = data["data"]["pages"]["search"]["results"]
data = gql("{ pages { list(orderBy: UPDATED_ON) { id title path tags updatedAt } } }")
pages = data["data"]["pages"]["list"]
data = gql("""
query($path: String!) { pages { singleByPath(path: $path, locale: "en") { id title content tags { tag } updatedAt } } }
""", {"path": "skills/agent-browser"})
page = data["data"]["pages"]["singleByPath"]
data = gql("""
mutation($path:String!,$title:String!,$content:String!,$tags:[String]!) {
pages { create(path:$path, title:$title, content:$content, tags:$tags,
locale:"en", isPublished:true, editor:"markdown", description:"") {
responseResult { succeeded message } page { id path }
}}
}
""", {"path": "category/page-name", "title": "文章标题", "content": "# Markdown内容", "tags": ["tag1"]})
data = gql("""
mutation($id:Int!,$content:String!,$title:String) {
pages { update(id:$id, content:$content, title:$title) {
responseResult { succeeded message }
}}
}
""", {"id": 3, "content": "# 新内容", "title": "新标题"})
data = gql("""
mutation($id: Int!) { pages { delete(id: $id) { responseResult { succeeded message } } } }
""", {"id": 3})
path 不带前导斜杠,例如 skills/ppt-writinglocale 固定用 "en"(Wiki 仅安装了英文语言包)id