[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "tree-sitter-analyzer"
version = "1.9.17"
description = "AI-era enterprise-grade code analysis tool with comprehensive HTML/CSS support, dynamic plugin architecture, and MCP integration"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "MIT"}
authors = [
    { name = "aisheng.yu", email = "aimasteracc@gmail.com" },
]
maintainers = [
    { name = "aisheng.yu", email = "aimasteracc@gmail.com" },
]
keywords = [
    "tree-sitter",
    "code-analysis",
    "ast",
    "parsing",
    "static-analysis",
    "multi-language",
    "html",
    "css",
    "web-development",
    "mcp",
    "mcp-server",
    "model-context-protocol",
    "ai-tools"
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Topic :: Software Development :: Code Generators",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Topic :: Software Development :: Quality Assurance",
    "Topic :: Text Processing :: Linguistic",
    "Topic :: Scientific/Engineering :: Artificial Intelligence",
    "Topic :: Communications",
    "Framework :: AsyncIO",
    "Operating System :: OS Independent",
    "Typing :: Typed",
]

# Core dependencies (minimal set for basic functionality)
# Includes HTML/CSS support for comprehensive web technology analysis
dependencies = [
    "tree-sitter>=0.25.0",
    "chardet>=5.0.0",
    "cachetools>=5.0.0",
    "tree-sitter-java>=0.23.5,<0.25.0",
    "tree-sitter-cpp>=0.23.4,<0.25.0",
    "tree-sitter-python>=0.23.6,<0.25.0",
    "mcp>=1.12.3",
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-markdown>=0.3.1",
    "tree-sitter-html>=0.23.0,<0.25.0", # HTML language support with MarkupElement data model
    "tree-sitter-css>=0.23.0,<0.25.0", # CSS language support with StyleElement data model
    "psutil>=5.9.8",
    "tree-sitter-typescript>=0.23.2",
    "deepdiff>=6.7.1",
    "tree-sitter-c-sharp>=0.23.1",
    "tree-sitter-sql>=0.3.11",
    "tree-sitter-php>=0.24.1",
    "tree-sitter-ruby>=0.23.1",
    "tree-sitter-yaml>=0.7.0",  # YAML language support with YAMLElement data model
]

# Add C# to optional dependencies
[project.optional-dependencies]
# Core language support - install specific languages as needed
java = ["tree-sitter-java>=0.23.5,<0.25.0"]
javascript = [
    "tree-sitter-javascript>=0.23.1,<0.25.0",
]
typescript = [
    "tree-sitter-typescript>=0.20.0,<0.25.0",
]
python = [
    "tree-sitter-python>=0.23.0,<0.25.0",
]
c = ["tree-sitter-c>=0.20.0,<0.25.0"]
cpp = ["tree-sitter-cpp>=0.23.4,<0.25.0"]
rust = ["tree-sitter-rust>=0.20.0,<0.25.0"]
go = ["tree-sitter-go>=0.20.0,<0.25.0"]
markdown = ["tree-sitter-markdown>=0.3.1"]
html = ["tree-sitter-html>=0.23.0,<0.25.0"]  # HTML DOM analysis with element classification
css = ["tree-sitter-css>=0.23.0,<0.25.0"]   # CSS selector and property analysis with specificity calculation
sql = ["tree-sitter-sql>=0.3.11,<0.4.0"]   # SQL language support for database schema analysis
csharp = ["tree-sitter-c-sharp>=0.23.1"]  # C# language support for .NET applications
php = ["tree-sitter-php>=0.23.0,<0.25.0"]  # PHP language support for web applications
ruby = ["tree-sitter-ruby>=0.23.0,<0.25.0"]  # Ruby language support for Rails and scripting
yaml = ["tree-sitter-yaml>=0.7.0"]  # YAML language support for configuration files
kotlin = [
    "tree-sitter-kotlin>=0.3.0",
]  # Kotlin language support for Android and JVM applications

# Language bundles for convenience
web = [
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-typescript>=0.20.0,<0.25.0",
    "tree-sitter-html>=0.23.0,<0.25.0",      # Complete HTML5 support with semantic analysis
    "tree-sitter-css>=0.23.0,<0.25.0",       # Complete CSS3 support with advanced property categorization
    "tree-sitter-php>=0.23.0,<0.25.0",       # PHP for WordPress, Laravel, Symfony
    "tree-sitter-ruby>=0.23.0,<0.25.0"       # Ruby for Rails applications
]
systems = [
    "tree-sitter-c>=0.20.0,<0.25.0",
    "tree-sitter-cpp>=0.23.4,<0.25.0",
    "tree-sitter-rust>=0.20.0,<0.25.0",
    "tree-sitter-go>=0.20.0,<0.25.0"
]
popular = [
    "tree-sitter-java>=0.23.5,<0.25.0",
    "tree-sitter-python>=0.23.0,<0.25.0",
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-typescript>=0.20.0,<0.25.0"
]
all-languages = [
    "tree-sitter-java>=0.23.5,<0.25.0",
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-typescript>=0.20.0,<0.25.0",
    "tree-sitter-python>=0.23.0,<0.25.0",
    "tree-sitter-c>=0.20.0,<0.25.0",
    "tree-sitter-cpp>=0.23.4,<0.25.0",
    "tree-sitter-rust>=0.20.0,<0.25.0",
    "tree-sitter-go>=0.20.0,<0.25.0",
    "tree-sitter-kotlin>=0.3.0",  # Kotlin language support for Android and JVM applications
    "tree-sitter-markdown>=0.3.1",
    "tree-sitter-html>=0.23.0,<0.25.0",
    "tree-sitter-css>=0.23.0,<0.25.0",
    "tree-sitter-sql>=0.3.11,<0.4.0",  # SQL language support for database schema analysis
    "tree-sitter-c-sharp>=0.23.1",  # C# language support for .NET applications
    "tree-sitter-php>=0.23.0,<0.25.0",  # PHP language support for web applications
    "tree-sitter-ruby>=0.23.0,<0.25.0",  # Ruby language support for Rails and scripting
    "tree-sitter-yaml>=0.7.0",  # YAML language support for configuration files
]

# MCP server support
mcp = [
    "mcp>=1.12.2",
    "anyio>=4.0.0",
    "httpx>=0.27.0,<1.0.0",
    "pydantic>=2.5.0",
    "pydantic-settings>=2.2.1",
]

# Development dependencies
dev = [
    "pytest>=8.4.1",
    "pytest-cov>=4.0.0",
    "pytest-asyncio>=1.1.0",
    "pytest-mock>=3.14.1",
    "hypothesis>=6.0.0",
    "black>=24.0.0",
    "ruff>=0.5.0",
    "mypy>=1.17.0",
    "isort>=5.13.0",
    "types-psutil>=5.9.0",
    "memory-profiler>=0.61.0",
    "psutil>=5.9.6,<6",
    "pre-commit>=3.0.0",
]

# Testing with comprehensive language support
test = [
    "pytest>=8.4.1",
    "pytest-cov>=4.0.0",
    "pytest-asyncio>=1.1.0",
    "pytest-mock>=3.14.1",
    "tree-sitter-java>=0.23.5",
    "tree-sitter-python>=0.23.0",
    "tree-sitter-javascript>=0.23.1",
    "tree-sitter-cpp>=0.23.4",
    "tree-sitter-sql>=0.3.11,<0.4.0",
    "tree-sitter-php>=0.23.0,<0.25.0",
    "tree-sitter-ruby>=0.23.0,<0.25.0",
    "tree-sitter-c-sharp>=0.23.1",
]

# Integration testing dependencies (Phase 7)
integration = [
    "pytest>=8.4.1",
    "pytest-cov>=4.0.0",
    "pytest-asyncio>=0.21.0",
    "pytest-mock>=3.14.1",
    "pytest-benchmark>=4.0.0",
    "psutil>=5.9.8",
    "memory-profiler>=0.61.0",
    "tree-sitter-java>=0.23.5",
    "tree-sitter-python>=0.23.0",
    "tree-sitter-javascript>=0.23.1",
    "tree-sitter-typescript>=0.20.0",
    "tree-sitter-markdown>=0.3.1",
    "mcp>=1.12.2",
    "anyio>=4.0.0",
]

# Complete development environment
full = [
    "tree-sitter-java>=0.23.5,<0.25.0",
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-typescript>=0.20.0,<0.25.0",
    "tree-sitter-python>=0.23.0,<0.25.0",
    "tree-sitter-c>=0.20.0,<0.25.0",
    "tree-sitter-cpp>=0.23.4,<0.25.0",
    "tree-sitter-rust>=0.20.0,<0.25.0",
    "tree-sitter-go>=0.20.0,<0.25.0",
    "tree-sitter-markdown>=0.3.1",
    "mcp>=1.12.2",
    "anyio>=4.0.0",
    "httpx>=0.27.0,<1.0.0",
    "pydantic>=2.5.0",
    "pydantic-settings>=2.2.1",
    "pytest>=8.4.1",
    "pytest-cov>=4.0.0",
    "pytest-asyncio>=1.1.0",
    "pytest-mock>=3.14.1",
    "black>=24.0.0",
    "ruff>=0.5.0",
    "mypy>=1.17.0",
    "isort>=5.13.0",
    "types-psutil>=5.9.0",
    "memory-profiler>=0.61.0",
    "psutil>=5.9.6,<6",
    "pre-commit>=3.0.0",
]

# All dependencies (alias for full)
all = [
    "tree-sitter-java>=0.23.5,<0.25.0",
    "tree-sitter-javascript>=0.23.1,<0.25.0",
    "tree-sitter-typescript>=0.20.0,<0.25.0",
    "tree-sitter-python>=0.23.0,<0.25.0",
    "tree-sitter-c>=0.20.0,<0.25.0",
    "tree-sitter-cpp>=0.23.4,<0.25.0",
    "tree-sitter-rust>=0.20.0,<0.25.0",
    "tree-sitter-go>=0.20.0,<0.25.0",
    "tree-sitter-markdown>=0.3.1",
    "tree-sitter-html>=0.23.0,<0.25.0",
    "tree-sitter-css>=0.23.0,<0.25.0",
    "tree-sitter-sql>=0.3.11,<0.4.0",  # SQL language support for database schema analysis
    "mcp>=1.12.2",
    "anyio>=4.0.0",
    "httpx>=0.27.0,<1.0.0",
    "pydantic>=2.5.0",
    "pydantic-settings>=2.2.1",
    "pytest>=8.4.1",
    "pytest-cov>=4.0.0",
    "pytest-asyncio>=1.1.0",
    "pytest-mock>=3.14.1",
    "black>=24.0.0",
    "ruff>=0.5.0",
    "mypy>=1.17.0",
    "isort>=5.13.0",
    "types-psutil>=5.9.0",
    "memory-profiler>=0.61.0",
    "psutil>=5.9.6,<6",
    "pre-commit>=3.0.0",
]

[project.scripts]
# Main CLI entry point
tree-sitter-analyzer = "tree_sitter_analyzer.cli_main:main"
# MCP server entry point
tree-sitter-analyzer-mcp = "tree_sitter_analyzer.mcp.server:main_sync"
# Legacy aliases for backward compatibility
code-analyzer = "tree_sitter_analyzer.cli_main:main"
java-analyzer = "tree_sitter_analyzer.cli_main:main"
list-files = "tree_sitter_analyzer.cli.commands.list_files_cli:main"
search-content = "tree_sitter_analyzer.cli.commands.search_content_cli:main"
find-and-grep = "tree_sitter_analyzer.cli.commands.find_and_grep_cli:main"

[project.entry-points."tree_sitter_analyzer.plugins"]
# Core language plugins (automatically discovered)
java = "tree_sitter_analyzer.languages.java_plugin:JavaPlugin"
python = "tree_sitter_analyzer.languages.python_plugin:PythonPlugin"
javascript = "tree_sitter_analyzer.languages.javascript_plugin:JavaScriptPlugin"
typescript = "tree_sitter_analyzer.languages.typescript_plugin:TypeScriptPlugin"
markdown = "tree_sitter_analyzer.languages.markdown_plugin:MarkdownPlugin"
html = "tree_sitter_analyzer.languages.html_plugin:HtmlPlugin"
css = "tree_sitter_analyzer.languages.css_plugin:CssPlugin"
csharp = "tree_sitter_analyzer.languages.csharp_plugin:CSharpPlugin"
sql = "tree_sitter_analyzer.languages.sql_plugin:SQLPlugin"
php = "tree_sitter_analyzer.languages.php_plugin:PHPPlugin"
ruby = "tree_sitter_analyzer.languages.ruby_plugin:RubyPlugin"
yaml = "tree_sitter_analyzer.languages.yaml_plugin:YAMLPlugin"
go = "tree_sitter_analyzer.languages.go_plugin:GoPlugin"
rust = "tree_sitter_analyzer.languages.rust_plugin:RustPlugin"
kotlin = "tree_sitter_analyzer.languages.kotlin_plugin:KotlinPlugin"

[project.urls]
Homepage = "https://github.com/aimasteracc/tree-sitter-analyzer"
Documentation = "https://github.com/aimasteracc/tree-sitter-analyzer#readme"
Repository = "https://github.com/aimasteracc/tree-sitter-analyzer.git"
Issues = "https://github.com/aimasteracc/tree-sitter-analyzer/issues"
Changelog = "https://github.com/aimasteracc/tree-sitter-analyzer/blob/main/CHANGELOG.md"
"Bug Reports" = "https://github.com/aimasteracc/tree-sitter-analyzer/issues"
"Source Code" = "https://github.com/aimasteracc/tree-sitter-analyzer"

[tool.hatch.build.targets.wheel]
packages = ["tree_sitter_analyzer"]

[tool.hatch.build.targets.sdist]
exclude = [
    "/.github",
    "/tests",
    "/archived_files",
    "/.pytest_cache",
    "/.mypy_cache",
    "/.coverage",
    "/htmlcov",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.black]
line-length = 88
target-version = ['py310', 'py311', 'py312', 'py313']
include = '\.pyi?$'
extend-exclude = '''
/(
  # directories
  \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | _build
  | buck-out
  | build
  | dist
  | archived_files
)/
'''

[tool.isort]
profile = "black"
line_length = 88
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
known_first_party = ["tree_sitter_analyzer"]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]

[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
show_error_codes = true
show_column_numbers = true
pretty = true

# Exclude archived files and test files from strict checking
[[tool.mypy.overrides]]
module = [
    "tests.*",
    "archived_files.*",
]
ignore_errors = true

# Handle missing stubs for tree-sitter packages
[[tool.mypy.overrides]]
module = [
    "tree_sitter.*",
    "tree_sitter_java.*",
    "tree_sitter_python.*",
    "tree_sitter_javascript.*",
    "tree_sitter_cpp.*",
    "tree_sitter_markdown.*",
]
ignore_missing_imports = true

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "test_*.py"
python_classes = "Test*"
python_functions = "test_*"
asyncio_mode = "strict"
addopts = [
    "--strict-markers",
    "--strict-config",
    "--verbose",
    "--tb=short",
    "--durations=10",
]
markers = [
    "slow: marks tests as slow (deselect with '-m \"not slow\"')",
    "integration: marks tests as integration tests",
    "unit: marks tests as unit tests",
    "mcp: marks tests as MCP-related tests",
    "requires_python: marks tests that require tree-sitter-python",
    "requires_java: marks tests that require tree-sitter-java",
]
filterwarnings = [
    "ignore::DeprecationWarning",
    "ignore::PendingDeprecationWarning",
]

[tool.coverage.run]
source = ["tree_sitter_analyzer"]
omit = [
    "*/tests/*",
    "*/archived_files/*",
    "*/__pycache__/*",
    "*/.*",
]
branch = true

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "def __repr__",
    "if self.debug:",
    "if settings.DEBUG",
    "raise AssertionError",
    "raise NotImplementedError",
    "if 0:",
    "if __name__ == .__main__.:",
    "class .*\\bProtocol\\):",
    "@(abc\\.)?abstractmethod",
    "TYPE_CHECKING",
]
show_missing = true
skip_covered = false
precision = 2

[tool.coverage.html]
directory = "htmlcov"

# MCP server configuration
[tool.mcp]
server_name = "tree-sitter-analyzer"
server_version = "1.9.17"
description = "AI-era enterprise-grade code analysis MCP server with comprehensive HTML/CSS support and multi-language capabilities"
capabilities = [
    "check_code_scale",
    "analyze_code_structure",
    "extract_code_section",
]

[tool.ruff]
line-length = 88
target-version = "py310"

[tool.ruff.lint]
select = [
    "E",  # pycodestyle errors
    "W",  # pycodestyle warnings
    "F",  # pyflakes
    "I",  # isort
    "B",  # flake8-bugbear
    "C4", # flake8-comprehensions
    "UP", # pyupgrade
]
ignore = [
    "E501",  # line too long, handled by black
    "B008",  # do not perform function calls in argument defaults
    "C901",  # too complex
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["B011"]

[tool.ruff.lint.isort]
known-first-party = ["tree_sitter_analyzer"]

[tool.bandit]
exclude_dirs = ["tests", "archived_files"]
skips = ["B101", "B601"]

[dependency-groups]
dev = [
    "build>=1.2.2.post1",
    "pre-commit>=4.2.0",
    "pytest>=8.4.1",
    "pytest-asyncio>=1.1.0",
    "pytest-mock>=3.14.1",
    "pytest-cov>=4.0.0",
    "ruff>=0.5.0",
    "twine>=4.0.2",
    "black>=24.0.0",
    "isort>=5.13.0",
    "bandit>=1.7.0",
    "safety>=3.0.0",
    "psutil>=5.9.8",
    "types-toml>=0.10.8.20240310",
    "types-requests>=2.32.4.20250913",
    "mypy==1.18.2",
    "hypothesis>=6.0.0",
]
