ClaudeMods
☰
JA
● 0 人がオンライン ・閲覧 0 回
スポンサー作品を投稿
GitHub リポジトリ · 投稿者 ruvnet

ruflo-knowledge-graph

ナレッジグラフの構築——エンティティ抽出、関係マッピング、パスファインダーによるグラフ走査。mod(ADR-445)として、秘密情報をグラフから除外し、グラフ削除を確認し、/kg-mod とコンソールが表示するステータスファイルを提供します

ruvnet@ruvnet

ruvnet/ruflo/tree/main/plugins/ruflo-knowledge-graph

翻訳済み

この mod について

ナレッジグラフの構築——エンティティ抽出、関係マッピング、パスファインダーによるグラフ走査。

概要

ソースコードとドキュメントからエンティティ(クラス、関数、モジュール、型、概念)と関係(imports、extends、implements、depends-on、calls)を抽出します。AgentDB に階層ノードと因果エッジを持つ、ナビゲーション可能なナレッジグラフを構築します。パスファインダーアルゴリズムでグラフを走査し、エッジの重みと意味的類似度によってパスを評価します。

インストール

claude --plugin-dir plugins/ruflo-knowledge-graph

Agents

| Agent | モデル | 役割 | |-------|--------|------| | graph-navigator | sonnet | エンティティ抽出、関係マッピング、ナレッジグラフ構築、パスファインダー走査 |

Skills

| Skill | 使い方 | 説明 | |-------|--------|------| | kg-extract | /kg-extract <path> | ソースファイルからエンティティと関係を抽出してナレッジグラフを構築 | | kg-traverse | /kg-traverse <entity> [--depth N] | シードエンティティから開始するパスファインダー走査 |

コマンド(5 サブコマンド)

kg extract <path>            # ソースファイルからエンティティと関係を抽出
kg traverse <entity>         # シードエンティティからパスファインダー走査を開始
kg relations <entity>        # エンティティの直接の関係をすべて一覧表示
kg visualize                 # ナレッジグラフを ASCII で可視化
kg search <query>            # グラフ全体を意味検索

エンティティ型

| 型 | 例 | |------|----------| | class | UserService、AuthController | | function | calculateDiscount、handleRequest | | module | auth、payments、api | | concept | authentication、caching | | type | User、OrderStatus | | config | database、redis、jwt |

互換性

  • CLI: @claude-flow/cli の v3.6 major+minor に固定されています。
  • 検証: bash plugins/ruflo-knowledge-graph/scripts/smoke.sh が契約です。

名前空間の連携

このプラグインは knowledge-graph AgentDB 名前空間を所有します(kebab-case で、ruflo-agentdb ADR-0001 "Namespace convention" の規約に従います)。予約済み名前空間(pattern、claude-memories、default)を上書きしてはいけません。

エンティティノードは agentdb_hierarchical-store、関係エッジは agentdb_causal-edge、意味インデックスは embeddings_generate を使って保存します(embeddings_embed ではありません。このツール名は存在せず、ADR-0001 が以前の参照を修正しています)。

パスファインダーアルゴリズム

  1. Seed —— 対象エンティティノードから開始
  2. Expand —— 因果エッジを外向きにたどる(設定可能な深さ、デフォルト 3)
  3. Score —— relevance = edge_weight * semantic_similarity(query, node)
  4. Prune —— しきい値未満のパスを削除(デフォルト 0.3)
  5. Rank —— 累積関連度の上位 K 件のパスを返す

G7 コントローラー(ruflo 3.6.23+ / 3.6.24 で有効)

ADR-095 によって、プラグインのグラフ走査が利用できる AgentDB コントローラー 5 つが完成しました。

  • gnnService —— AgentDB の因果グラフ上で GNN 埋め込みと関係スコアリングを行います。パスファインダーの semantic_similarity(query, node) 項に構造を考慮したスコアを加え、関連性が確認されたノードのグラフ近傍ノードを押し上げます。
  • rvfOptimizer —— 永続化前にベクトルブロックを量子化して重複排除します。ナレッジグラフのインデックスには、複数モジュールから再エクスポートされた同一クラスのような、ほぼ重複するエンティティベクトルが多数含まれがちです。rvfOptimizer が透過的にまとめます。
  • mutationGuard + attestationLog + GuardedVectorBackend —— 基盤のベクトルストアへの書き込みを証明でゲートします。グラフが信頼境界をまたぐ場合(フェデレーテッドなナレッジインポート)に有効で、.swarm/attestation.db の証明チェーンがすべての変更を事後監査用に記録します。

保留中の graphAdapter コントローラーは、このプラグインに本格的なグラフ DB バックエンドを提供します(AgentDB のフラットな causal-edge テーブルの上にグラフビューを構築する方式から変更)。ADR-095 で追跡されています。

agentdb_controllers または agentdb_health MCP ツールでランタイムの状態を確認できます。

検証

bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# 期待値:"10 passed, 0 failed"

アーキテクチャ決定

関連プラグイン

  • ruflo-agentdb —— 上記の G7 コントローラーはこのプラグインのランタイムから提供されます。完全なグラフと走査のカバレッジには両方をインストールしてください。名前空間規約の所有者です
  • ruflo-ruvector —— グラフノードを高速に意味検索する HNSW インデックス
  • ruflo-adr —— ADR の依存関係グラフは同じ因果エッジモデルを共有

ライセンス

MIT

mod として

このプラグインは関数フック mod(ADR-445、hooks/register.ts)を同梱します。ネットワーク呼び出し、プロセスの起動、モデル呼び出しは行いません。

  • Guard(締め付けのみ、デフォルトで有効):キー、トークン、パスワードを含むグラフ書き込み(agentdb_causal-edge、agentdb_hierarchical-store、agentdb_pattern-store)を拒否します。また、confirm: true を伴わない agentdb_causal-edge-delete / agentdb_causal-node-delete も拒否します。拒否時に秘密情報をエコーしません。
  • /kg-mod:status、recent、tools(このプラグインのどのツールが接続されているか)、scan <text>(Guard が拒否するか)を提供します。ローカルで応答します。
  • ステータスファイル: .claude-flow/kg-mod/status.json({version: 1, updatedMs, guard, calls, total, blocked, recent}。カウンターのみで、ツール入力は保存しません)をセッション開始時と、このプラグインのツールを呼び出すたびに書き込みます。

オプション(userConfig):guard(オン)、confirmDeletes(オン)。

テスト:claude plugin validate plugins/ruflo-knowledge-graph、claude plugin test plugins/ruflo-knowledge-graph、bash plugins/ruflo-knowledge-graph/scripts/smoke.sh。

インストール

まず作者の README で marketplace とプラグイン名を確認してください。コマンドはリポジトリの構成によって変わる場合があります。

claude plugin marketplace add ruvnet/ruflo
claude plugin install ruflo-knowledge-graph
原文 / README

ruflo-knowledge-graph

Knowledge graph construction -- entity extraction, relation mapping, and pathfinder graph traversal.

Overview

Extracts entities (classes, functions, modules, types, concepts) and relations (imports, extends, implements, depends-on, calls) from source code and documentation. Builds a navigable knowledge graph stored in AgentDB with hierarchical nodes and causal edges. Traverses the graph using a pathfinder algorithm that scores paths by edge weight and semantic similarity.

Installation

claude --plugin-dir plugins/ruflo-knowledge-graph

Agents

| Agent | Model | Role | |-------|-------|------| | graph-navigator | sonnet | Entity extraction, relation mapping, knowledge graph construction, pathfinder traversal |

Skills

| Skill | Usage | Description | |-------|-------|-------------| | kg-extract | /kg-extract <path> | Extract entities and relations from source files to build a knowledge graph | | kg-traverse | /kg-traverse <entity> [--depth N] | Pathfinder traversal starting from a seed entity |

Commands (5 subcommands)

kg extract <path>            # Extract entities and relations from source files
kg traverse <entity>         # Pathfinder traversal from a seed entity
kg relations <entity>        # List all direct relations for an entity
kg visualize                 # ASCII visualization of the knowledge graph
kg search <query>            # Semantic search across the graph

Entity Types

| Type | Examples | |------|----------| | class | UserService, AuthController | | function | calculateDiscount, handleRequest | | module | auth, payments, api | | concept | authentication, caching | | type | User, OrderStatus | | config | database, redis, jwt |

Compatibility

  • CLI: pinned to @claude-flow/cli v3.6 major+minor.
  • Verification: bash plugins/ruflo-knowledge-graph/scripts/smoke.sh is the contract.

Namespace coordination

This plugin owns the knowledge-graph AgentDB namespace (kebab-case, follows the convention from ruflo-agentdb ADR-0001 §"Namespace convention"). Reserved namespaces (pattern, claude-memories, default) MUST NOT be shadowed.

Entity nodes are stored via agentdb_hierarchical-store; relation edges via agentdb_causal-edge; semantic indexing via embeddings_generate (NOT embeddings_embed — that tool name doesn't exist; ADR-0001 fixes prior references).

Pathfinder Algorithm

  1. Seed -- start from the target entity node
  2. Expand -- follow causal edges outward (configurable depth, default 3)
  3. Score -- relevance = edge_weight * semantic_similarity(query, node)
  4. Prune -- remove paths below threshold (default 0.3)
  5. Rank -- return top-K paths by cumulative relevance

G7 controllers (activated in ruflo 3.6.23+ / 3.6.24)

ADR-095 closed five AgentDB controllers that this plugin's graph traversal can leverage:

  • gnnService — GNN embeddings + relational scoring over the AgentDB causal graph. Augments the pathfinder's semantic_similarity(query, node) term with structurally-aware scoring; nodes that are graph-neighbors of confirmed-relevant nodes get a boost.
  • rvfOptimizer — Quantizes + dedupes vector blocks before persistence. Knowledge-graph indexes commonly have many near-duplicate entity vectors (same class re-exported from multiple modules); rvfOptimizer collapses them transparently.
  • mutationGuard + attestationLog + GuardedVectorBackend — Proof-gated writes to the underlying vector store. Relevant when the graph spans trust boundaries (federated knowledge import) — the attestation chain at .swarm/attestation.db records every mutation for after-the-fact audit.

The yet-pending graphAdapter controller will give this plugin a first-class graph-DB backend (instead of building the graph view on top of AgentDB's flat causal-edge table). Tracked in ADR-095.

Inspect runtime status via the agentdb_controllers or agentdb_health MCP tools.

Verification

bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# Expected: "10 passed, 0 failed"

Architecture Decisions

Related Plugins

  • ruflo-agentdb -- The G7 controllers above ship via this plugin's runtime; install both for full graph + traversal coverage; namespace convention owner
  • ruflo-ruvector -- HNSW indexing for fast semantic search across graph nodes
  • ruflo-adr -- ADR dependency graphs share the same causal edge model

License

MIT

As a mod

This plugin ships a function-hook mod (ADR-445, hooks/register.ts). It makes no network call, spawns no process and makes no model call.

  • Guard (tighten-only, on by default): Refuses graph writes (agentdb_causal-edge, agentdb_hierarchical-store, agentdb_pattern-store) that hold a key, token or password, and agentdb_causal-edge-delete / agentdb_causal-node-delete unless the call carries confirm: true. A refusal never echoes the secret.
  • /kg-mod: status, recent, tools (which of this plugin's tools are connected) and scan <text> (would the guard refuse it). Answered locally.
  • Status file: .claude-flow/kg-mod/status.json ({version: 1, updatedMs, guard, calls, total, blocked, recent}, counters only, never tool input), written at session start and after every call to this plugin's tools.

Options (userConfig): guard (on), confirmDeletes (on).

Test it: claude plugin validate plugins/ruflo-knowledge-graph, claude plugin test plugins/ruflo-knowledge-graph, bash plugins/ruflo-knowledge-graph/scripts/smoke.sh.

関連作品