Turn capability definitions from JSON and historical Foundry blueprint text into one inspectable graph plan. It is useful when the same package information lives in different formats and you need to see what would become nodes and relationships, and where it came from, before any database import.
This is a clean continuation of the Foundry importer. It writes a plan, not a Neo4j database. Origin
Python 3.11+, from this checkout:
python -m pip install -e .
python -m examples.walkthrough
python -m examples.conflict
capability-graph-importer examples/normalize.package.json examples/format.blueprint.txt --source-label "Synthetic Packages" --output output/plan.json
python -m unittest discover -s tests -vThe first walkthrough loads a JSON package and a text blueprint. Its captured plan has two packages, ten nodes and eight edges. Read a package:... node, follow its HAS_LOGIC edge, and then find that package in provenance: the source filename and SHA-256 are retained.
The conflict example makes a second definition of the same package. Its result shows default rejection, explicit JSON preference, selected logic and both original source hashes.
from capability_graph_importer import build_graph_plan, merge_package_records
records, conflicts = merge_package_records([{"name": "Greeting", "logic": "return hello"}])
plan = build_graph_plan(records, source_label="Authored example")
assert plan["edges"][0]["type"] == "HAS_LOGIC"
assert not any(plan["provenance"]["package:Greeting"])Direct dictionaries have no invented provenance. Use load_json_package(path) or load_blueprint_package(path) to hash actual source files. core.py contains loading, normalization, merging and projection; cli.py selects the loader by the .json suffix and writes the plan.
Same-name disagreements fail unless you choose --prefer json or --prefer blueprint. Preference selects the first matching source type; if none exists, it falls back to the first input. It is not a field-level merge or a vote. Conflicts and every input's evidence remain recorded.
The text loader reads the older dash-list blueprint dialect. It does not parse the JSON-bodied seven-fence format from Agent Foundry Blueprint Compiler. For that compiler's output, pass its runtime["package"] dictionary to this library after reviewing the field mapping.
Graph projection includes packages, logic, arguments, returns and recognitions. Replacement lists are normalized but not projected. Argument/return names use each object's name field, falling back to positional names; other original properties remain in its record. Repeated item names can produce duplicate node IDs, so a downstream writer must validate uniqueness.
Source hashes identify input bytes, not correctness. Logic is stored as text and never executed. A useful next component would validate the plan against a database schema and apply it with a separate reviewed transaction; connecting that writer is intentionally outside this utility.