Agent Skills by ALSEL
汎用LLM・AI開発⭐ リポ 1品質スコア 63/100

knowledge_graph

コード知識グラフとGraph RAG — ソースリポジトリに対するエンティティ抽出、関係性マッピング、および自然言語クエリ

description の原文を見る

Code knowledge graphs and Graph RAG — entity extraction, relationship mapping, and natural-language queries over source repositories

SKILL.md 本文

Knowledge Graph Specialist

概要

knowledge_graph は、コードのエンティティ抽出とグラフ構築のための abhigyanpatwari/GitNexus のパターンと、 Graph RAG 検索のための topoteretes/cognee をラップしています。

ソースアーティファクト(リポジトリ URL、ファイルパス、または生のコード)を入力として、スペシャリストは エンティティと関係性からなる有向ナレッジグラフを構築し、グラフの走査を通じてエンティティと関係性の有向ナレッジグラフを構築し、自然言語の質問に答えます。結果はランク付けされたエンティティリスト、関連性スコア、明示的な関係パスとして返され、下流の推論または引用に利用できます。

スペシャリストはステートレスです。各 :meth:execute 呼び出しは新しいグラフを構築し、独立した結果辞書を返します。グラフ ID は呼び出し間で渡すことができ、グラフを再構築せずに以前構築されたグラフをクエリできます。

機能

  • knowledge_graph: コードまたはドキュメントから構造化されたエンティティ/関係性グラフを構築します。走査深度とエンティティタイプでスコープできます。
  • code_analysis: ソースリポジトリからモジュール、クラス、関数、変数、インポートを抽出し、依存性とコール グラフの構造を明らかにします。
  • entity_linking: ファイルとモジュール全体にわたる名前付きエンティティを統一されたグラフに解決し、安定したエンティティ ID により参照を重複排除します。
  • graph_rag: グラフ走査と関連性ランキングを通じて自然言語クエリに答えます — 構造化されたコード知識に対する Graph Retrieval-Augmented Generation です。

ツール

ツール説明副作用
build_graphソースアーティファクトからナレッジグラフを構築なし(v1 ローカル;将来:ネットワーク/ディスク)
query_graphグラフを自然言語でクエリ;ランク付けされたエンティティとパスを返すなし
find_relationships2 つの名前付きエンティティ間のすべてのパスを検出;タイプと強度を返すなし

パラメータ

リクエストレベル(intent.parameters

キーデフォルト説明
sourcestr(query.user_input)取り込むリポジトリ URL、ファイルパス、または生のコード
graph_typestr"code"エンティティ戦略:codedocument、または mixed
max_depthint3最大ファイル間走査深度
querystr(query.user_input)グラフに対して実行する自然言語の質問
max_resultsint10グラフクエリの結果の上限
entity_astrNone関係性検索の送信元エンティティ(オプション)
entity_bstrNone関係性検索の対象エンティティ(オプション)

グラフタイプ

  • codemoduleclassfunctionvariableimport エンティティを抽出します。 ソースリポジトリ分析とコール グラフの推論に最適です。
  • documentconceptsectionclaimreference エンティティを抽出します。 技術ドキュメントまたは研究論文に適しています。
  • mixed — コードとドキュメントタイプの統合です。実行可能なコードとリッチなインラインドキュメントを含むソースの場合に使用します。

レスポンスの形式

{
    "graph": {
        "graph_id": str,          # このグラフインスタンスの安定した UUID
        "node_count": int,        # 総エンティティノード数
        "edge_count": int,        # 総有向関係エッジ数
        "entity_types": list[str],# グラフに存在するエンティティラベル
        "graph_type": str,        # リクエストされた graph_type のエコー
    },
    "query_results": {
        "results": list[dict],    # ランク付けされたエンティティヒット
        "relevance_scores": list[float],  # 並列の関連性値 0-1
        "paths": list[dict],      # 接続する関係パス
        "total_found": int,       # max_results 上限以前の総マッチ数
    },
    # entity_a と entity_b が提供される場合のみ表示:
    "relationships": {
        "paths": list[dict],      # entity_a から entity_b へのすべてのパス
        "relationship_types": list[str],  # 重複排除されたエッジラベル
        "strength": float,        # カップリング強度 0-1
        "path_count": int,
    },
}

使用方法

Python API

import asyncio
from agents.specialists.knowledge_graph.agent import KnowledgeGraphSpecialist
from oss_agent_lab.contracts import Intent, Query, SpecialistRequest

specialist = KnowledgeGraphSpecialist()

request = SpecialistRequest(
    intent=Intent(
        action="knowledge_graph",
        domain="code_analysis",
        confidence=0.9,
        parameters={
            "source": "https://github.com/abhigyanpatwari/GitNexus",
            "graph_type": "code",
            "max_depth": 3,
        },
    ),
    query=Query(user_input="Which functions call the authentication module?"),
    specialist_name="knowledge_graph",
)

response = asyncio.run(specialist.execute(request))
print(response.result["graph"]["node_count"])
print(response.result["query_results"]["results"][0])

CLI

oss-lab run knowledge_graph "Which functions call the authentication module?"

関係性検索を使用した例

request = SpecialistRequest(
    intent=Intent(
        action="knowledge_graph",
        domain="code_analysis",
        confidence=0.9,
        parameters={
            "source": "./src/",
            "entity_a": "UserService",
            "entity_b": "DatabaseAdapter",
        },
    ),
    query=Query(user_input="How does UserService depend on DatabaseAdapter?"),
    specialist_name="knowledge_graph",
)

パラメータ付き CLI

oss-lab run knowledge_graph "dependency chain for PaymentProcessor" \
  --param source=https://github.com/owner/repo \
  --param graph_type=code \
  --param max_depth=5 \
  --param entity_a=PaymentProcessor \
  --param entity_b=DatabaseClient

ソース

abhigyanpatwari/GitNexustopoteretes/cognee をラップしています。

ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ

詳細情報

作者
jeremylongshore
リポジトリ
jeremylongshore/oss-agent-lab
ライセンス
MIT
最終更新
2026/5/2

Source: https://github.com/jeremylongshore/oss-agent-lab / ライセンス: MIT

本サイトは GitHub 上で公開されているオープンソースの SKILL.md ファイルをクロール・インデックス化したものです。 各スキルの著作権は原作者に帰属します。掲載に問題がある場合は info@alsel.co.jp または /takedown フォームよりご連絡ください。
原作者: jeremylongshore · jeremylongshore/oss-agent-lab · ライセンス: MIT