Skip to main content
Glama

🌌 OntoAgent

The All-Knowing Code Brain & Architecture Contract Guard for AI Coding Agents

AI コーディングエージェント向けの全リポジトリ認知ナレッジグラフとアーキテクチャガバナンスエンジン。

CI Python 3.10+ License: Apache-2.0 Embedded Kùzu DB MCP Supported DSH Compatible Benchmark


📖 Why OntoAgent?

現代の Coding Agent が大規模なコードベースに直面するとき、通常3つの構造的な問題に遭遇します:

  1. 群盲象を撫でる:現在のファイルしか見えず、モジュールをまたぐ呼び出し元、API 契約、テスト依存関係が見えません。

  2. 長文脈幻覚:リポジトリ全体を Prompt に「力技で放り込み」、Token コストが高く、S/N 比が低く、モデルが重要な制約を見落としがちです。

  3. 破壊的変更の追跡が困難:コアクラスを変更しても、どの上流モジュール、テスト、インターフェースが一緒に壊れるかを素早く把握できません。

従来のアプローチ:

  • Naive Raw Text:全量をコンテキストに詰め込み、Token が膨大で構造化された位置特定がありません。

  • Vector-Chunk RAG:テキスト類似度でチャンク分割し、Token を圧縮できますが、AST レベルの依存関係、継承関係、契約セマンティクスが失われます。

OntoAgent の選択:

AST 静的解析 + 組み込み型グラフデータベース で全リポジトリの認知グラフを構築し、AI Agent がコードを変更する前に 呼び出し網、契約、テスト、爆発半径 を確認できるようにします。


Related MCP server: code-intel

🏛️ Architecture Flow

graph TD
    subgraph Base["底座层"]
        Kuzu["Kùzu Embedded Graph DB"]
        AST["AST Parsers: Python / TypeScript / Markdown / JSON"]
    end

    subgraph Core["核心引擎"]
        Blast["Blast Radius Analyzer"]
        Context["Smart Context Extractor"]
        Compliance["Architecture Compliance Guard"]
        Scanner["Codebase Scanner & Entity Ingestion"]
    end

    subgraph Ecosystem["交互生态"]
        MCP["MCP Server"]
        DSH["DSH / Cordis Plugin"]
        CLI["onto-agent CLI"]
        Dashboard["React 2D Canvas + Dagre Dashboard"]
    end

    AST --> Scanner
    Scanner --> Kuzu
    Kuzu --> Blast
    Kuzu --> Context
    Kuzu --> Compliance
    Blast --> MCP
    Context --> DSH
    Compliance --> CLI
    Scanner --> Dashboard

📊 Benchmark

ワンクリックで再現:

python benchmark/run_benchmark.py

決定論的なコードフィクスチャに基づき、3つのコンテキスト構築戦略を比較:

Method

Tokens

Token Reduction

Critical Dep Recall

Test & Contract Recall

Blast Precision

Blast Recall

Blast F1

A. Naive Raw Text

1162

0.0%

100.0%

100.0%

50.0%

100.0%

66.7%

B. Vector-Chunk RAG

282

75.7%

0.0%

66.7%

60.0%

60.0%

60.0%

C. OntoAgent AST Graph

120

89.7%

100.0%

100.0%

100.0%

100.0%

100.0%

結論:

  • OntoAgent は Naive Raw Text と比較して約 89.7% の Token 消費を削減します。

  • OntoAgent は Vector-Chunk RAG と比較して、重要依存関係の再現率、テスト/契約の再現率、爆発半径の特定において全面的に優れています。

  • 完全なレポートは benchmark/reports/benchmark_report.md を参照してください。


🚀 Quickstart

1. インストール

pip install -e .[test]

2. 全リポジトリをスキャン

onto-agent scan --path .

3. 可視化ワークベンチを起動

python dashboard/api_server.py
# 打开 http://127.0.0.1:8000

4. MCP を設定

integrations/cursor_mcp.json を .cursor/mcp.json にコピーするか、Claude Desktop でマージします:

{
  "mcpServers": {
    "onto-agent": {
      "command": "python",
      "args": ["-m", "onto_agent.mcp"]
    }
  }
}

5. DSH ネイティブプラグインをインストール

dsh plugin --profile web add ./integrations/dsh/onto-agent-plugin

🧠 Agent Abilities

get_blast_radius(file_path)

任意のファイル/シンボルを変更する前に、以下を返します:

  • 直接の呼び出し元

  • 間接的に影響を受けるモジュール

  • 下流の依存関係

  • 関連する API 契約

  • 実行が必要なテスト

check_architecture_compliance(strict=True)

チェック:

  • 循環 import

  • レイヤーをまたぐ違反呼び出し

  • テストでカバーされていないコアクラス

get_smart_context(query_or_symbol)

リファクタリング/生成前の高 S/N 比コンテキストを生成:

  • 定義、行数、Docstring

  • クラス/関数リスト

  • imports / callers

  • API 契約、関連テスト、関連ドキュメント


🔌 Ecosystem

エントリポイント

方法

MCP

onto_get_blast_radius、onto_check_architecture_compliance、onto_get_smart_context など 10 個のツール

DSH

integrations/dsh/onto-agent-plugin、Cordis ネイティブプラグイン

CLI

onto-agent blast-radius、onto-agent compliance、onto-agent context

REST

/api/blast_radius、/api/architecture/compliance、/api/smart_context

Dashboard

React + Force Graph + Dagre 階層アーキテクチャ図


🗂️ Project Layout

src/onto_agent/
├── engine/          # Scanner, ArchitectureGuard, Context, Steering, Reflection
├── storage/         # Kùzu graph storage adapter
├── mcp/             # MCP Server
├── client/          # Python SDK
└── cli.py           # Unified CLI

dashboard/           # FastAPI + React workbench
benchmark/           # Reproducible Codex-for-Open benchmark
integrations/        # Cursor / Claude / Windsurf / DSH
docs/                # Design docs & tickets
tests/               # 48+ unit / integration tests

📚 Documentation


📄 License

本プロジェクトは Apache-2.0 でオープンソース公開されています。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides semantic code search and code insights via a knowledge graph, enabling AI to understand, navigate, and modify complex projects with deep dependency and architecture analysis.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Supercharges AI coding agents with semantic code intelligence, providing pre-built knowledge graphs for surgical context, faster answers, and fewer tool calls.
    MIT