Skip to main content

magatama-core - Knowledge Graph Engine

PyPI version Python 3.11+ License: MIT

MAGATAMA(YATA のフォーク)の コアライブラリパッケージです(パッケージ名 magatama-core / import 名 magatama_core)。

独立したライブラリとして、コード解析と知識グラフ構築機能を提供します。

特徴

  • 🔍 マルチ言語解析: Python, TypeScript, Rust, Go, Java, C# ほか 24 言語
  • 🕸️ 知識グラフ: NetworkX によるエンティティ・関係性グラフ
  • 🔗 関係性検出: CALLS, IMPORTS, CONTAINS, INHERITS
  • 💾 永続化: JSON / SQLite ストレージ

インストール

pip install magatama-core

オプション言語サポート

# Rust サポート
pip install magatama-core[rust]

# Go サポート
pip install magatama-core[go]

# 全言語サポート
pip install magatama-core[all-languages]

使用方法

基本的な使い方

from magatama_core.infrastructure.parsers import PythonParser
from magatama_core.infrastructure.storage import NetworkXKnowledgeGraph
from magatama_core.application.usecases import ParseFileUseCase

# パーサーとグラフを作成
parser = PythonParser()
graph = NetworkXKnowledgeGraph()

# ユースケースを設定
parse_file = ParseFileUseCase(
    parsers={".py": parser},
    knowledge_graph=graph,
)

# ファイルを解析
from pathlib import Path
result = parse_file.execute(Path("your_file.py"))

print(f"Entities: {result.entity_count}")
print(f"Relationships: {result.relationship_count}")

エンティティの検索

from magatama_core.domain.entities import EntityType

# 関数をすべて取得
functions = list(graph.entities.get_by_type(EntityType.FUNCTION))

# 名前で検索
all_entities = list(graph.entities.all())
matches = [e for e in all_entities if "process" in e.name.lower()]

グラフの永続化

from magatama_core.infrastructure.storage import JSONGraphSerializer

serializer = JSONGraphSerializer()

# 保存
serializer.save(graph, Path("graph.json"))

# 読み込み
loaded_graph = serializer.load(Path("graph.json"))

アーキテクチャ

magatama-core は Clean Architecture に基づいて設計されています:

magatama_core/
├── domain/          # ドメイン層
│   ├── entities/    # FunctionEntity, ClassEntity, etc.
│   ├── value_objects/ # EntityId, Location
│   └── repositories/ # インターフェース
├── application/     # アプリケーション層
│   ├── usecases/    # ParseFileUseCase, etc.
│   └── services/    # Benchmark, etc.
└── infrastructure/  # インフラ層
    ├── parsers/     # PythonParser, TypeScriptParser, etc.
    └── storage/     # NetworkXKnowledgeGraph, SQLiteKnowledgeGraph

対応言語

合計 24 言語に対応しています(主要なものを抜粋)。全一覧は ルート README を参照。

言語 拡張子 パーサー
Python .py PythonParser
TypeScript .ts, .tsx TypeScriptParser
JavaScript .js, .jsx JavaScriptParser
Rust .rs RustParser
Go .go GoParser
Java / C# / C / C++ / Ruby / PHP ほか — (計 24 言語)

ライセンス

MIT License - 詳細は LICENSE を参照してください。

関連プロジェクト

Metadata

Release files for magatama-core 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magatama-core 0.7.3
File Size Uploaded Provenance Actions
magatama_core-0.7.3.tar.gz 185.8 kB Without provenance Details for magatama_core-0.7.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magatama-core 0.7.3
File Interpreter ABI Platform Actions
magatama_core-0.7.3-py3-none-any.whl Python 3 none any Details for magatama_core-0.7.3-py3-none-any.whl

Total release size: 344.4 kB

Release files / magatama_core-0.7.3.tar.gz

Download URL magatama_core-0.7.3.tar.gz
Size 185.8 kB
Tags Source
SHA-256 checksum
How to use checksums
436baefce4ca9b5914ef8eb27b8fac1b3d8c6b4c4075e163ab88f4b48fdd7dc2
BLAKE2b-256 checksum
How to use checksums
03916cdda30a98aeb5f06acec5d6f21500646bb863bcce4d9d68bcf4f1382960
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / magatama_core-0.7.3-py3-none-any.whl

Download URL magatama_core-0.7.3-py3-none-any.whl
Size 158.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4af417a6c3f39fb3d0b3a541ae9f7962d04a82382696d9f6b5df8f85a63db5c0
BLAKE2b-256 checksum
How to use checksums
ee4c0d892a19b7c45a14bf107d12c9733ffaa63b5485e1d545a3813368b1c18a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for magatama-core 0.7.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page