convert_module_to_package
Convert a Python module file into a package by moving it to a subdirectory and updating all imports project-wide.
Instructions
Convert a module file into a package with the same name.
Transforms foo.py into foo/foo.py while updating all imports project-wide.
Example:
views/service_contractor.py becomes views/service_contractor/service_contractor.py
All imports like from views.service_contractor import X
become from views.service_contractor.service_contractor import X
This is a two-step process using Rope:
Move module to a temporary package (different name to trigger import updates)
Rename the temporary package to the original module name
Args: project_path: Root directory of the Python project module_path: Path to module file (relative to project_path), e.g. "app/views/foo.py"
Returns: JSON with success status and list of changed files
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_path": "<project_path>",
"module_path": "<module_path>"
},
"name": "convert_module_to_package"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| module_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |