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.0

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.0
File Size Uploaded Provenance Actions
magatama_core-0.7.0.tar.gz 183.9 kB Without provenance Details for magatama_core-0.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 341.3 kB

Release files / magatama_core-0.7.0.tar.gz

Download URL magatama_core-0.7.0.tar.gz
Size 183.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e6c8d9e28b6faeb18b6f212da63c9831d1aa7abf76db98919ef5d02883b0595f
BLAKE2b-256 checksum
How to use checksums
120ee83384091e3f81cddcc87c263b24b5fe93df6cb6f476ef6a0505a79adc48
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.0-py3-none-any.whl

Download URL magatama_core-0.7.0-py3-none-any.whl
Size 157.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aef6921789b5867165f695494f631b8f28efc9aad006cf52c65c43d5b921fbe9
BLAKE2b-256 checksum
How to use checksums
03acbff2c50fdf98e4842dd4d66b7be6b1d1bb6674e84d7fc0b892632d05ef2b
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.0

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