← 返回 Skills 市场
xnohat

Knowledge Graph

作者 Hong Phuc Nguyen · GitHub ↗ · v1.1.1
cross-platform ⚠ suspicious
931
总下载
2
收藏
7
当前安装
2
版本数
在 OpenClaw 中安装
/install knowledge-graph-skill
功能描述
Embedded knowledge graph for persistent structured knowledge. ALWAYS use proactively — do NOT wait for user to ask. Auto-triggers on: (1) any mention of peop...
使用说明 (SKILL.md)

Knowledge Graph Skill

Personal KG stored as JSON, queried via CLI scripts. Produces a compact KGML summary for session context. Core instructions are in AGENTS.md (auto-injected by install). This file covers setup, advanced usage, and reference only.

First-Time Setup

node scripts/install.mjs [--workspace /path/to/workspace] [--platform openclaw|claude|gemini]

Auto-detects platform and patches the agent instructions file (AGENTS.md, CLAUDE.md, or GEMINI.md) with KG instructions + graph summary. Idempotent.

KGML Format Reference

#KGML v2 | \x3Ccount>e \x3Ccount>r | depth:\x3CN> | \x3Cdate>
[category]
Label(Alias):type — attr1,attr2
  ChildLabel(CA):type — attrs    ← indent = parent>child
%rels
A>verb>B C>verb>D                ← cross-branch relations (aliases)
%vault key1,key2                 ← vault key names (no values)

Advanced Query Commands

Beyond the basics in AGENTS.md (find, traverse, rels):

node scripts/query.mjs children \x3Cid>      # Direct children
node scripts/query.mjs type \x3Ctype>         # All entities of a type
node scripts/query.mjs cat \x3Ccategory>      # All in category
node scripts/query.mjs orphans             # Unlinked entities
node scripts/query.mjs stats               # Graph statistics
node scripts/query.mjs recent [--days 7]   # Created/updated recently
node scripts/query.mjs timeline [--from YYYY-MM-DD] [--to YYYY-MM-DD]
node scripts/query.mjs changed             # Modified after creation
node scripts/query.mjs uncertain           # Confidence \x3C 0.5

Merge

node scripts/merge.mjs --target \x3Cid> --source \x3Cid> --mode absorb|nest

Vault (secrets)

node scripts/vault.mjs set \x3Ckey> \x3Cvalue> --note "description"
node scripts/vault.mjs get \x3Ckey>          # Raw value (for piping)
node scripts/vault.mjs list               # Keys only
node scripts/vault.mjs del \x3Ckey>

Depth Heuristic — How Many Layers to Extract

Before adding a rich knowledge item (article, paper, report, system description), assess complexity first:

# Score text content and get recommended depth + checklist:
node scripts/depth-check.mjs "paste text or summary here"
echo "article text" | node scripts/depth-check.mjs
node scripts/depth-check.mjs --file /path/to/article.txt
node scripts/depth-check.mjs --json    # machine-readable

# Score interpretation:
# 0-1 → 1 layer (root only)
# 2-3 → 2 layers (root + concepts)
# 4-5 → 3 layers (root → domains → mechanisms)
# 6-7 → 4+ layers (full extraction with orgs/events/policies + cross-relations)

Key rule: Never stop at 2 layers for complex content. If score ≥ 4, extract all named orgs, events, policies, and cross-relations — not just the top-level themes.

Visualization

node scripts/visualize.mjs                # → data/kg-viz.html
node scripts/visualize.mjs --output /tmp/graph.html

ALWAYS use this script. Do NOT write custom HTML. Output is self-contained, offline, no CDN.

Parent edges render as blue dashed arrows (60% opacity). Regular edges are red solid arrows.

Configuration

All settings have sensible defaults. Override only what you need — config stores only your changes.

node scripts/config.mjs                       # list all settings with current values
node scripts/config.mjs get \x3Ckey>              # get a value (e.g. summary.tokenBudget)
node scripts/config.mjs set \x3Ckey> \x3Cvalue>      # set a value
node scripts/config.mjs reset \x3Ckey>            # reset single key to default
node scripts/config.mjs reset --all            # reset everything
node scripts/config.mjs --json                 # full config as JSON

Available Settings

Section Key Default Description
summary tokenBudget 5000 Max tokens for kg-summary.md
maxChildDepth auto Tree depth (null=auto: 3/\x3C100, 2/100-400, 1/>400)
maxAttrLen 40 Max characters for attribute values
maxPerRoot 4 Max relations shown per root subtree
compactThreshold 400 Entity count for compact mode
mediumThreshold 200 Entity count for medium depth
validation minEntities 30 Min entities for extraction PASS
minRelationRatio 0.5 Relations per entity ratio
minDepth 3 Min hierarchy depth for PASS
minEvents 3 Min event nodes for PASS
depthCheck entityCapForEstimate 50 Cap NER count for target estimation
minEntitiesMultiplier 1.0 Named entities → min target multiplier
extraEntities 30 Added to min for max entity range
consolidation autoNest true Auto-nest single-relation orphans
mergeSuggestions true Suggest merges for similar labels
pruneEmptyAttrs true Remove empty/null attrs
levenshteinThreshold 2 Max edit distance for merge suggestions
visualization repulsion 5000 Physics repulsion force
edgeRestLength 160 Default edge rest length
overlapPenalty 3 Overlap repulsion multiplier
simulationSteps 500 Physics simulation iterations
initialSpread 1.5 Initial node spread multiplier
zoomAnimationMs 400 Zoom-to-node animation duration

Config file: data/kg-config.json (per-agent, gitignored).

Cross-Agent Access (read-only)

import { createReader } from '\x3Cpath-to-skill>/lib/reader.mjs';
const kg = createReader();
kg.search("query"); kg.traverse("id", { depth: 2 }); kg.stats();

Or CLI: node scripts/export.mjs --format json --target /path/to/output.json

Memory Import

node scripts/import-memory.mjs            # dry-run
node scripts/import-memory.mjs --apply    # add with confidence 0.5

Then: node scripts/query.mjs uncertain to review auto-imported entities.

Knowledge Entity Guide

The knowledge type covers both declarative and procedural knowledge. Use attrs and tags to differentiate:

Kind Tags Key attrs Example
Fact/finding #fact, #til source, field, summary "LLMs use ~4 chars per token"
Research/paper #paper, #research source, field, summary, author AI alignment paper findings
Idea #idea summary, status "Build a CLI for KG queries"
How-to/procedure #howto, #procedure steps, context, summary "How to deploy on Pi"
Mental model #mental-model, #framework steps, context, summary "Debug network: ping→DNS→firewall"
Workflow #workflow steps, context, summary "Code review: tests first, then impl"

Attrs for procedural knowledge:

  • steps: ordered procedure as string (use or numbered: "1. Check logs → 2. Reproduce → 3. Fix → 4. Test")
  • context: when/where to apply this knowledge (e.g. "when network is down", "during code review")
  • summary: short description of what this knowledge is about

Consolidation

Run node scripts/consolidate.mjs weekly or when entity count > 80. Then summarize.mjs.

Security

  • NEVER print vault values in chat or log to memory/ files
  • vault.enc.json and .vault-key must never be in context
  • Other agents: read-only via reader.mjs, NO write access
安全使用建议
This skill appears to implement the advertised local knowledge graph and secret vault, but it also (1) patches your agent instruction file at install time to cause proactive use, (2) encourages saving many sensitive data types (people, locations, routines, credentials), and (3) stores the vault key and an encrypted vault inside the skill folder for portability. Before installing: review scripts/install.mjs to see exactly what files it will modify; back up your AGENTS.md/CLAUDE.md/GEMINI.md; inspect scripts/serialize.mjs and vault.mjs to confirm vault behavior (what metadata is emitted into kg-summary.md); ensure data/ is in .gitignore and that .vault-key and vault.enc.json are created with strict permissions; consider keeping high-risk secrets in a separate, audited vault (not the skill folder); and consider disabling the proactive injection behavior or limiting the auto-trigger rules so the skill doesn't automatically capture broad personal data. If you want additional assurance, provide the install.mjs and serialize.mjs contents and I can highlight the exact lines that modify agent files or emit vault key names.
功能分析
Type: OpenClaw Skill Name: knowledge-graph-skill Version: 1.1.1 The skill is generally well-designed for its stated purpose, with strong security instructions to the agent (e.g., 'NEVER print vault values in chat or log to memory/ files' in SKILL.md). However, the `lib/vault.mjs` script's `vaultGet` function outputs raw decrypted secrets to standard output, which is a necessary capability for its intended use (e.g., piping to environment variables). This capability, if misused by an agent compromised via prompt injection, could lead to sensitive data exposure. While the skill explicitly warns the agent against this, the inherent risk of raw secret output makes it suspicious, as it represents a critical vulnerability if the agent's security instructions are bypassed.
能力评估
Purpose & Capability
Name/description align with the included code (graph CRUD, search, KGML summary, visualization, a vault). One minor mismatch: the human-readable description demands the KG be used “ALWAYS” and to auto-trigger proactively, but registry flags show always:false (the skill expects to patch agent instruction files at install time to cause proactive use rather than being force-included by the platform).
Instruction Scope
Runtime instructions and scripts instruct the agent to proactively add many types of personal data (people, locations, routines, credentials) and to run the install script which patches agent instruction files. The skill also instructs storing credentials in an encrypted vault and the serializer will include vault key NAMES in the KGML summary (not values). The combination of proactive capture of sensitive categories and auto-injection into agent prompts increases risk of unintended collection/exposure.
Install Mechanism
No external install downloads; code is local JS (node scripts). That reduces supply-chain risk. However install.mjs will modify workspace agent instruction files (AGENTS.md/CLAUDE.md/GEMINI.md) and create data/ files under the skill — this is intrusive but described in the docs. Review the install script before running.
Credentials
The skill requests no environment variables (good), but it stores an encrypted vault and places the vault key file inside the skill folder for portability. The design intentionally keeps vault keys next to the skill (documented trade-off). The serializer exposes vault key NAMES in the KG summary — while values are encrypted, key names may leak sensitive metadata when the KG summary is loaded into an LLM context or shared.
Persistence & Privilege
The skill is not set always:true, but the installer patches the agent's instruction file so the agent will be instructed to consult/add the KG proactively. That gives the skill persistent influence over agent behavior (via modified instructions) even without platform-level always:true; this is explained in docs but is a material privilege and should be reviewed.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install knowledge-graph-skill
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /knowledge-graph-skill 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.1
- Added quotes around the SKILL.md description field for improved formatting and compatibility. - No functional or behavioral changes; update is documentation-only.
v1.1.0
- Adds SKILL.md with comprehensive setup, usage, and configuration documentation. - Details auto-trigger criteria for knowledge graph usage and strict exclusions for ephemeral/transient data. - Documents KGML format, advanced query/merge/vault commands, configuration keys, and visualization process. - Introduces depth scoring for extraction and entity structuring, with a detailed heuristic. - Outlines cross-agent access, memory import, and structured guidance for various knowledge types. - Version 1.1.0 is a major documentation and usage reference update; code changes not detailed.
元数据
Slug knowledge-graph-skill
版本 1.1.1
许可证
累计安装 7
当前安装数 7
历史版本数 2
常见问题

Knowledge Graph 是什么?

Embedded knowledge graph for persistent structured knowledge. ALWAYS use proactively — do NOT wait for user to ask. Auto-triggers on: (1) any mention of peop... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 931 次。

如何安装 Knowledge Graph?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install knowledge-graph-skill」即可一键安装,无需额外配置。

Knowledge Graph 是免费的吗?

是的,Knowledge Graph 完全免费(开源免费),可自由下载、安装和使用。

Knowledge Graph 支持哪些平台?

Knowledge Graph 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Knowledge Graph?

由 Hong Phuc Nguyen(@xnohat)开发并维护,当前版本 v1.1.1。

💬 留言讨论