get_dependencies
Return the import graph for a file: direct imports and, optionally, their transitive closure.
Input schema
{
"type": "object",
"required": ["file"],
"properties": {
"file": {
"type": "string",
"description": "Path to the file, relative to repo root."
},
"transitive": {
"type": "boolean",
"default": false,
"description": "If true, return transitive dependencies up to `depth` hops. If false, return direct imports only."
},
"depth": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"default": 3,
"description": "Maximum BFS depth when transitive is true."
},
"repo": {
"type": "string",
"description": "Absolute path to the repository root. Defaults to the daemon's primary repo."
}
}
}
Output schema
{
"type": "object",
"properties": {
"file": { "type": "string" },
"direct": {
"type": "array",
"items": { "$ref": "#/definitions/Dependency" }
},
"transitive": {
"type": "array",
"items": { "$ref": "#/definitions/Dependency" }
},
"error": { "$ref": "#/definitions/Error" }
},
"definitions": {
"Dependency": {
"type": "object",
"properties": {
"path": { "type": "string" },
"kind": { "type": "string", "enum": ["import", "require", "use", "include"] },
"depth": { "type": "integer" },
"external": { "type": "boolean", "description": "True if this is a node_modules / crate dependency" }
}
}
}
}
Example
Request:
{
"file": "src/controllers/PaymentController.ts",
"transitive": true
}
Response:
{
"file": "src/controllers/PaymentController.ts",
"direct": [
{ "path": "src/services/PaymentService.ts", "kind": "import", "depth": 1, "external": false },
{ "path": "src/models/Order.ts", "kind": "import", "depth": 1, "external": false },
{ "path": "express", "kind": "import", "depth": 1, "external": true }
],
"transitive": [
{ "path": "src/services/PaymentService.ts", "kind": "import", "depth": 1, "external": false },
{ "path": "src/db/connection.ts", "kind": "import", "depth": 2, "external": false },
{ "path": "src/config/env.ts", "kind": "import", "depth": 2, "external": false },
{ "path": "src/models/User.ts", "kind": "import", "depth": 3, "external": false }
]
}
When to use
- Before touching a file: understand what you're about to affect.
- Circular dependency detection: look for a file that appears in its own transitive list.
- Bundle analysis: find which external packages a module pulls in.