query

GitHub

提供对语义知识图谱的查询能力,支持内存ContextGraph搜索、RDF三元组库SPARQL查询及LPG后端Cypher查询,涵盖基础检索与高级优化。

plugins/skills/query/SKILL.md semantica-agi/semantica

Trigger Scenarios

需要搜索或查询知识图谱数据 执行SPARQL或Cypher查询语句 分析图数据库中的节点和关系

Install

npx skills add semantica-agi/semantica --skill query -g -y
More Options

Non-standard path

npx skills add https://github.com/semantica-agi/semantica/tree/main/plugins/skills/query -g -y

Use without installing

npx skills use semantica-agi/semantica@query

指定 Agent (Claude Code)

npx skills add semantica-agi/semantica --skill query -a claude-code -g -y

安装 repo 全部 skill

npx skills add semantica-agi/semantica --all -g -y

预览 repo 内 skill

npx skills add semantica-agi/semantica --list

SKILL.md

Frontmatter
{
    "name": "query",
    "description": "Query Semantica knowledge graphs — in-memory ContextGraph search, SPARQL over RDF triple stores, and Cypher over LPG backends."
}

/semantica:query

Query the graph. Usage: /semantica:query <task> [args]

Which API you want depends on where the graph lives.


search "<keywords>" — the in-memory ContextGraph

This is the one that works with no external server.

import os
from semantica.context import ContextGraph

graph = ContextGraph()
graph.load_from_file(os.path.expanduser("~/.semantica/kg.json"))   # load_from_file does not expand ~

results = graph.query("vendor selection", skip=0, limit=20)

Related lookups on the same object:

graph.find_nodes(...)          graph.find_node(...)
graph.find_related_nodes(...)  graph.get_neighbors(node_id)
graph.find_similar_nodes(...)  graph.get_nodes_by_label(label)

Decision-specific queries belong to /semantica:decision.


sparql "<query>" — RDF triple stores

from semantica.triplet_store import TripletStore

store = TripletStore(backend="oxigraph")       # embedded; needs semantica[tripletstore-oxigraph]
# or backend="blazegraph" | "jena" | "rdf4j" with endpoint="http://..."
result = store.execute_query(sparql)

For query planning, optimisation, and caching over a backend:

from semantica.triplet_store import QueryEngine, OxigraphStore

# QueryEngine needs an object exposing execute_sparql() — the raw backend,
# not the TripletStore wrapper above (which only exposes execute_query()).
backend = OxigraphStore()

qe = QueryEngine()
plan   = qe.plan_query(sparql)
tuned  = qe.optimize_query(sparql)
result = qe.execute_query(sparql, store_backend=backend)
stats  = qe.get_query_statistics()

Blazegraph / Jena / RDF4J need no extra — semantica.triplet_store speaks SPARQL over HTTP using the core requests dependency.


cypher "<query>" — labeled property graphs

from semantica.graph_store import Neo4jStore    # needs semantica[graph-neo4j]

store = Neo4jStore(uri=..., user=..., password=...)
result = store.execute_query(query, parameters={...})

Also available: FalkorDBStore, ApacheAgeStore, AmazonNeptuneStore, and GraphManager / GraphStore for backend-agnostic access.

Not installed in this environment — add the backend extra first, e.g. pip install "semantica[graph-neo4j]".

Version History

  • fdf3fd8 Current 2026-09-22 03:21

    修复示例代码中的API调用错误,包括实例化配置、路径展开、方法名修正及执行逻辑补全,确保与v0.7.0 API兼容。

  • 9094f1e 2026-07-05 09:26

Same Skill Collection

.claude/skills/semantica/SKILL.md
plugins/skills/causal/SKILL.md
plugins/skills/change/SKILL.md
plugins/skills/decision/SKILL.md
plugins/skills/deduplicate/SKILL.md
plugins/skills/explain/SKILL.md
plugins/skills/export/SKILL.md
plugins/skills/extract/SKILL.md
plugins/skills/ingest/SKILL.md
plugins/skills/ontology/SKILL.md
plugins/skills/policy/SKILL.md
plugins/skills/provenance/SKILL.md

Metadata

Files
0
Version
7918f71
Hash
52381bbf
Indexed
2026-07-05 09:26

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-28 19:43
浙ICP备14020137号-1