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

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.2
File Size Uploaded Provenance Actions
magatama_core-0.7.2.tar.gz 184.1 kB Without provenance Details for magatama_core-0.7.2.tar.gz

Built distribution (wheel)

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

Total release size: 341.7 kB

Release files / magatama_core-0.7.2.tar.gz

Download URL magatama_core-0.7.2.tar.gz
Size 184.1 kB
Tags Source
SHA-256 checksum
How to use checksums
103c217bd60d9b57ef3632f2b1617b5b940d93a9641c36cc81b6025088493d9b
BLAKE2b-256 checksum
How to use checksums
8d53b89dbf4db887bf85940aef6286c16ca131e54ad33f3c2d2007e36a79f2ad
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.2-py3-none-any.whl

Download URL magatama_core-0.7.2-py3-none-any.whl
Size 157.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b185ae5865d73dc64077c83782f8999f68e85ec60d238b383232def93c69d358
BLAKE2b-256 checksum
How to use checksums
50434d24383ac46291ed1397ad81488d265e625ed8c58585633ed435d98d2537
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.2

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