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).
Schema
Section titled “Schema”| Arg | Type | Required | Description |
|---|---|---|---|
action | string | yes | imports_of / importers_of / related / summary. |
target | string | for non-summary | File path (imports_of, related) or module name (importers_of). |
root | string | no | Workspace root to scan. Defaults to env’s workdir. |
max_results | integer | no | Cap on the returned list. |
Actions
Section titled “Actions”| Action | Returns |
|---|---|
imports_of | Modules imported by target file. |
importers_of | Files that import target module. |
related | Both directions, ranked by edge count. |
summary | Total files, total edges, top hubs. |
Example invocation
Section titled “Example invocation”{"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)Output sample
Section titled “Output sample”imports_of chimera/core/agent.py: chimera.core.context chimera.core.loop chimera.providers.base chimera.typessummary (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.
See also
Section titled “See also”repo_map— structural map (classes, signatures).search,list_files.