Observed since 21 Oct, 10:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI Editor MCP server: universal file preview, open, edit, write, and close
A comprehensive Python code analysis and refactoring tool that generates code maps, detects issues, and provides automated refactoring capabilities.
Author: Vasiliy Zdanovskiy
Email: vasilyvz@gmail.com
README.md (overview and command→file table), COMMANDS.md (index with links to per-command docs), and one file per command <command_name>.md with: purpose, arguments, return format, examples (correct and incorrect).pip install code-analysis-tool
Dependencies and metadata live in pyproject.toml (distribution name code-analysis). Runtime install:
git clone https://github.com/vasilyvz/code-analysis-tool.git
cd code-analysis-tool
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
# optional — pytest, black, flake8, ruff, mypy:
pip install -e ".[dev]"
Or: pip install -r requirements.txt (editable install from this repo).
code_mapper
This will analyze the current directory and generate reports in the code_analysis folder.
code_mapper --root-dir ./src --output-dir ./reports --max-lines 500 --verbose
--root-dir, -r: Root directory to analyze (default: current directory)--output-dir, -o: Output directory for reports (default: code_analysis)--max-lines, -m: Maximum lines per file (default: 400)--verbose, -v: Enable verbose output--use-sqlite/--no-sqlite: Use SQLite database (default: True)--version: Show version informationSQLite Mode (default):
code_analysis.db: SQLite database with all analysis data
YAML Mode (--no-sqlite):
code_map.yaml: Complete code map with classes, functions, and dependenciescode_issues.yaml: Detailed report of code quality issuesmethod_index.yaml: Index of methods organized by classThe tool detects various code quality issues:
pass statementsNotImplementedError in non-abstract methodsAny type annotationsEach project must have a projectid file in its root directory. The file uses JSON format:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Human readable description of project"
}
Fields:
id (required): UUID4 identifier for the projectdescription (optional): Human-readable descriptionMigration: If you have old format projectid files (plain UUID4 string), use the migration script:
python scripts/migrate_projectid_to_json.py
The system uses unified path normalization across all components:
normalize_file_path(): Main function for normalizing file paths with project information
NormalizedPath with absolute path, project root, project ID, and relative pathfind_project_root_for_path(): Finds project root for a given file path
ProjectInfo with project root, ID, and descriptionMultipleProjectIdError if multiple projectid files found in pathnormalize_path_simple(): Simple path normalization without project information
The ProjectManager class provides centralized project management:
from code_analysis.core.project_manager import ProjectManager
manager = ProjectManager()
# Create a new project
project_info = manager.create_project(
root_path=Path("/path/to/project"),
description="My project",
init_git=True # Optional: initialize git repository
)
# Get project information
info = manager.get_project_info(project_id)
# List all projects
projects = manager.get_project_list()
If you want to refactor by logical blocks (preserving comments, moving imports to the top,
validating via compile()), see docs/CST_TOOLS.md, docs/CST_QUERY.md and MCP commands
cst_apply_buffer / query_cst.
This repository also runs an MCP server (code-analysis-server) via mcp-proxy-adapter.
mcp_MCP-Proxy-2_list_servers(filter_enabled=None)server_id + copy_number, NOT server_key):
mcp_MCP-Proxy-2_call_server(server_id="code-analysis-server", copy_number=1, command="get_database_status", params={"root_dir": "/abs/path"})update_indexes) return a job_id; track via queue_get_job_status / queue_get_job_logs.See docs/MCP_PROXY_USAGE_GUIDE.md for more details.
GET https://<host>:<port>/openapi.json (mTLS)Split a large class into multiple smaller classes while maintaining functionality.
class UserManager:
"""Manages user operations."""
def __init__(self):
self.username = None
self.email = None
self.password = None
self.role = None
self.permissions = []
def authenticate(self, username, password):
"""Authenticate user."""
# ... authentication logic
def authorize(self, action):
"""Check user permissions."""
# ... authorization logic
def send_email(self, subject, body):
"""Send email to user."""
# ... email logic
split_config.json){
"src_class": "UserManager",
"dst_classes": {
"UserAuth": {
"props": ["username", "email", "password"],
"methods": ["authenticate"]
},
"UserPermissions": {
"props": ["role", "permissions"],
"methods": ["authorize"]
},
"UserEmail": {
"props": [],
"methods": ["send_email"]
}
}
}
# Dry run (validate without changes)
code_refactor split-class -f user_manager.py -c split_config.json --dry-run
# Perform split
code_refactor split-class -f user_manager.py -c split_config.json
class UserManager:
"""Manages user operations."""
def __init__(self):
self.userauth = UserAuth()
self.userpermissions = UserPermissions()
self.useremail = UserEmail()
def authenticate(self, username, password):
return self.userauth.authenticate(username, password)
def authorize(self, action):
return self.userpermissions.authorize(action)
def send_email(self, subject, body):
return self.useremail.send_email(subject, body)
class UserAuth:
"""Handles user authentication."""
def __init__(self):
self.username = None
self.email = None
self.password = None
def authenticate(self, username, password):
"""Authenticate user."""
# ... authentication logic
class UserPermissions:
"""Manages user permissions."""
def __init__(self):
self.role = None
self.permissions = []
def authorize(self, action):
"""Check user permissions."""
# ... authorization logic
class UserEmail:
"""Handles user email operations."""
def __init__(self):
pass
def send_email(self, subject, body):
"""Send email to user."""
# ... email logic
.code_mapper_backups/ before changesMerge multiple classes into a single base class. This is the inverse operation of extract-superclass.
class UserAuth:
"""Handles user authentication."""
def __init__(self):
self.username = None
self.password = None
def login(self, username, password):
"""Authenticate user."""
# ... login logic
return True
class UserProfile:
"""Handles user profile operations."""
def __init__(self):
self.email = None
self.name = None
def update_profile(self, email, name):
"""Update user profile."""
# ... profile logic
return True
class UserSettings:
"""Handles user settings."""
def __init__(self):
self.theme = None
self.language = None
def update_settings(self, theme, language):
"""Update user settings."""
# ... settings logic
return True
merge_config.json){
"base_class": "UserService",
"source_classes": ["UserAuth", "UserProfile", "UserSettings"],
"merge_methods": ["login", "update_profile", "update_settings"],
"merge_props": ["username", "password", "email", "name", "theme", "language"]
}
Note: merge_methods and merge_props are optional. If not specified, ALL methods and properties from source classes will be merged.
# Dry run (validate without changes)
code_refactor merge-classes -f user_services.py -c merge_config.json --dry-run
# Perform merge
code_refactor merge-classes -f user_services.py -c merge_config.json
class UserService:
"""Merged class combining functionality from multiple classes."""
def __init__(self):
self.username = None
self.password = None
self.email = None
self.name = None
self.theme = None
self.language = None
def login(self, username, password):
"""Authenticate user."""
# ... login logic
return True
def update_profile(self, email, name):
"""Update user profile."""
# ... profile logic
return True
def update_settings(self, theme, language):
"""Update user settings."""
# ... settings logic
return True
Extract common functionality from multiple classes into a base class.
class Dog:
"""Represents a dog."""
def __init__(self, name):
self.name = name
self.species = "Canis lupus"
self.legs = 4
def make_sound(self):
return "Woof!"
def move(self):
return f"{self.name} is running"
def eat(self, food):
return f"{self.name} is eating {food}"
class Cat:
"""Represents a cat."""
def __init__(self, name):
self.name = name
self.species = "Felis catus"
self.legs = 4
def make_sound(self):
return "Meow!"
def move(self):
return f"{self.name} is walking"
def eat(self, food):
return f"{self.name} is eating {food}"
extract_config.json){
"base_class": "Animal",
"child_classes": ["Dog", "Cat"],
"abstract_methods": ["make_sound"],
"extract_from": {
"Dog": {
"properties": ["name", "species", "legs"],
"methods": ["move", "eat"]
},
"Cat": {
"properties": ["name", "species", "legs"],
"methods": ["move", "eat"]
}
}
}
# Dry run (validate without changes)
code_refactor extract-superclass -f animals.py -c extract_config.json --dry-run
# Perform extraction
code_refactor extract-superclass -f animals.py -c extract_config.json
from abc import ABC, abstractmethod
class Animal(ABC):
"""Base class for extracted functionality."""
def __init__(self):
self.name = None
self.species = None
self.legs = None
def move(self):
return f"{self.name} is moving"
def eat(self, food):
return f"{self.name} is eating {food}"
@abstractmethod
def make_sound(self):
pass
class Dog(Animal):
"""Represents a dog."""
def __init__(self, name):
super().__init__()
self.name = name
self.species = "Canis lupus"
self.legs = 4
def make_sound(self):
return "Woof!"
def move(self):
return f"{self.name} is running"
class Cat(Animal):
"""Represents a cat."""
def __init__(self, name):
super().__init__()
self.name = name
self.species = "Felis catus"
self.legs = 4
def make_sound(self):
return "Meow!"
def move(self):
return f"{self.name} is walking"
{
"base_class": "BaseClassName",
"child_classes": ["ChildClass1", "ChildClass2"],
"abstract_methods": ["method1", "method2"],
"extract_from": {
"ChildClass1": {
"properties": ["prop1", "prop2"],
"methods": ["method1", "method2"]
},
"ChildClass2": {
"properties": ["prop3"],
"methods": ["method3"]
}
}
}
Fields:
base_class: Name of the new base class to createchild_classes: List of existing classes that will inherit from base classabstract_methods: List of method names that will be abstract in base classextract_from: Dictionary mapping child class names to their extracted elements
properties: List of property names to extract to base classmethods: List of method names to extract to base classRequirements:
git clone https://github.com/vasilyvz/code-analysis-tool.git
cd code-analysis-tool
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
Tests that require the server: Some integration tests expect the code-analysis server (and shared database) to be running; otherwise they are skipped (e.g. "Shared database not initialized", "RPC server unavailable"). To run those tests as well, start the server from the project root with the project venv activated:
python -m code_analysis.cli.server_manager_cli --config config.json start
Then run pytest. Use restart instead of start if the server is already running.
black .
flake8 .
ruff check . # configured Ruff scope
mypy .
This project is licensed under the MIT License - see the LICENSE file for details.
merge-classes CLI command for class merging operationscode-analysis to code_mapperDownload counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.179 | 18 Sept 2026 | 30 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 10:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:b5036c1293ea05a55334155be726a450efb4eca3cfccf0b5773e64c8d703ef7f