Skip to content

import_graph — module dependency queries

import_graph builds an in-memory directed graph of module imports and answers four query shapes. Use it to scope a refactor (who imports chimera.core.agent?) or to verify isolation (does the env layer import the agent layer? It shouldn’t).

ArgTypeRequiredDescription
actionstringyesimports_of / importers_of / related / summary.
targetstringfor non-summaryFile path (imports_of, related) or module name (importers_of).
rootstringnoWorkspace root to scan. Defaults to env’s workdir.
max_resultsintegernoCap on the returned list.
ActionReturns
imports_ofModules imported by target file.
importers_ofFiles that import target module.
relatedBoth directions, ranked by edge count.
summaryTotal files, total edges, top hubs.
{"action": "importers_of", "target": "chimera.core.agent"}
from chimera.tools.import_graph import ImportGraphTool
tool = ImportGraphTool()
result = tool.execute(
{"action": "summary", "root": "chimera"},
env=local_env,
)
print(result.output)
imports_of chimera/core/agent.py:
chimera.core.context
chimera.core.loop
chimera.providers.base
chimera.types
summary (root=chimera):
files: 412
edges: 1,847
top hubs (in-degree):
chimera.types 118
chimera.providers.base 72
chimera.core.tool 58
  • Python only. JavaScript / TypeScript graph support is on the roadmap.
  • Cache is in-memory per tool instance — re-instantiate to pick up new files.