codescalpel 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- code_scalpel/README.md +196 -0
- code_scalpel/__init__.py +291 -0
- code_scalpel/agents/README.md +678 -0
- code_scalpel/agents/__init__.py +59 -0
- code_scalpel/agents/base_agent.py +267 -0
- code_scalpel/agents/code_review_agent.py +347 -0
- code_scalpel/agents/documentation_agent.py +213 -0
- code_scalpel/agents/metrics_agent.py +253 -0
- code_scalpel/agents/optimazation_agent.py +515 -0
- code_scalpel/agents/refactoring_agent.py +211 -0
- code_scalpel/agents/security_agent.py +445 -0
- code_scalpel/agents/testing_agent.py +205 -0
- code_scalpel/analysis/__init__.py +69 -0
- code_scalpel/analysis/code_analyzer.py +1641 -0
- code_scalpel/analysis/core.py +107 -0
- code_scalpel/analysis/cross_repo.py +447 -0
- code_scalpel/analysis/custom_metrics.py +574 -0
- code_scalpel/analysis/framework_detector.py +391 -0
- code_scalpel/analysis/generated_code.py +211 -0
- code_scalpel/analysis/gitignore.py +94 -0
- code_scalpel/analysis/incremental_index.py +305 -0
- code_scalpel/analysis/incremental_indexer.py +349 -0
- code_scalpel/analysis/monorepo.py +431 -0
- code_scalpel/analysis/org_index.py +813 -0
- code_scalpel/analysis/parallel_crawler.py +391 -0
- code_scalpel/analysis/project_crawler.py +970 -0
- code_scalpel/analysis/smart_crawl.py +261 -0
- code_scalpel/ast_tools/README.md +758 -0
- code_scalpel/ast_tools/__init__.py +135 -0
- code_scalpel/ast_tools/analyzer.py +286 -0
- code_scalpel/ast_tools/architectural_rules.py +635 -0
- code_scalpel/ast_tools/ast_refactoring.py +178 -0
- code_scalpel/ast_tools/builder.py +154 -0
- code_scalpel/ast_tools/call_graph.py +1366 -0
- code_scalpel/ast_tools/control_flow.py +161 -0
- code_scalpel/ast_tools/cross_file_extractor.py +933 -0
- code_scalpel/ast_tools/data_flow.py +219 -0
- code_scalpel/ast_tools/dependency_parser.py +148 -0
- code_scalpel/ast_tools/import_resolver.py +1409 -0
- code_scalpel/ast_tools/transformer.py +298 -0
- code_scalpel/ast_tools/type_inference.py +121 -0
- code_scalpel/ast_tools/utils.py +208 -0
- code_scalpel/ast_tools/validator.py +277 -0
- code_scalpel/ast_tools/visualizer.py +431 -0
- code_scalpel/autonomy/README.md +672 -0
- code_scalpel/autonomy/__init__.py +126 -0
- code_scalpel/autonomy/audit.py +542 -0
- code_scalpel/autonomy/conftest.py +20 -0
- code_scalpel/autonomy/engine.py +350 -0
- code_scalpel/autonomy/error_to_diff.py +732 -0
- code_scalpel/autonomy/fix_loop.py +354 -0
- code_scalpel/autonomy/integrations/README.md +649 -0
- code_scalpel/autonomy/integrations/__init__.py +16 -0
- code_scalpel/autonomy/integrations/autogen.py +315 -0
- code_scalpel/autonomy/integrations/crewai.py +353 -0
- code_scalpel/autonomy/integrations/langgraph.py +334 -0
- code_scalpel/autonomy/mutation_gate.py +349 -0
- code_scalpel/autonomy/sandbox.py +589 -0
- code_scalpel/autonomy/stubs.py +114 -0
- code_scalpel/cache/README.md +1042 -0
- code_scalpel/cache/__init__.py +28 -0
- code_scalpel/cache/ast_cache.py +419 -0
- code_scalpel/cache/incremental_analyzer.py +46 -0
- code_scalpel/cache/parallel_parser.py +92 -0
- code_scalpel/cache/unified_cache.py +769 -0
- code_scalpel/cli.py +1010 -0
- code_scalpel/code_analyzer.py +48 -0
- code_scalpel/code_parsers/README.md +610 -0
- code_scalpel/code_parsers/__init__.py +84 -0
- code_scalpel/code_parsers/adapters/__init__.py +79 -0
- code_scalpel/code_parsers/adapters/cpp_adapter.py +41 -0
- code_scalpel/code_parsers/adapters/csharp_adapter.py +42 -0
- code_scalpel/code_parsers/adapters/go_adapter.py +42 -0
- code_scalpel/code_parsers/adapters/java_adapter.py +255 -0
- code_scalpel/code_parsers/adapters/javascript_adapter.py +286 -0
- code_scalpel/code_parsers/adapters/kotlin_adapter.py +42 -0
- code_scalpel/code_parsers/adapters/php_adapter.py +42 -0
- code_scalpel/code_parsers/adapters/ruby_adapter.py +42 -0
- code_scalpel/code_parsers/adapters/swift_adapter.py +42 -0
- code_scalpel/code_parsers/base_parser.py +276 -0
- code_scalpel/code_parsers/cpp_parsers/README.md +349 -0
- code_scalpel/code_parsers/cpp_parsers/__init__.py +31 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_Clang-Static-Analyzer.py +131 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_Cppcheck.py +96 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_SonarQube.py +1 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_clang_tidy.py +87 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_coverity.py +92 -0
- code_scalpel/code_parsers/cpp_parsers/cpp_parsers_cpplint.py +76 -0
- code_scalpel/code_parsers/csharp_parsers/README.md +369 -0
- code_scalpel/code_parsers/csharp_parsers/__init__.py +37 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_ReSharper.py +26 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_Roslyn-Analyzers.py +26 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_SecurityCodeScan.py +89 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_SonarQube.py +26 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_StyleCop.py +26 -0
- code_scalpel/code_parsers/csharp_parsers/csharp_parsers_fxcop.py +85 -0
- code_scalpel/code_parsers/extractor.py +529 -0
- code_scalpel/code_parsers/factory.py +155 -0
- code_scalpel/code_parsers/go_parsers/README.md +385 -0
- code_scalpel/code_parsers/go_parsers/__init__.py +40 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_gofmt.py +26 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_golangci_lint.py +92 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_golint.py +26 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_gosec.py +85 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_govet.py +27 -0
- code_scalpel/code_parsers/go_parsers/go_parsers_staticcheck.py +35 -0
- code_scalpel/code_parsers/interface.py +47 -0
- code_scalpel/code_parsers/java_parsers/README.md +910 -0
- code_scalpel/code_parsers/java_parsers/__init__.py +105 -0
- code_scalpel/code_parsers/java_parsers/java_parser_treesitter.py +1066 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Checkstyle.py +143 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_DependencyCheck.py +44 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_ErrorProne.py +151 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_FindSecBugs.py +156 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Gradle.py +41 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Infer.py +170 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_JArchitect.py +169 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_JaCoCo.py +42 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Maven.py +41 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_PMD.py +200 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Pitest.py +41 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_Semgrep.py +42 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_SonarQube.py +243 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_SpotBugs.py +242 -0
- code_scalpel/code_parsers/java_parsers/java_parsers_javalang.py +1602 -0
- code_scalpel/code_parsers/java_parsers/javalang.pyi +167 -0
- code_scalpel/code_parsers/javascript_parsers/README.md +846 -0
- code_scalpel/code_parsers/javascript_parsers/__init__.py +294 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_babel.py +656 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_code_quality.py +977 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_eslint.py +614 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_esprima.py +1298 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_flow.py +672 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_jsdoc.py +40 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_jshint.py +395 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_npm_audit.py +45 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_package_json.py +44 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_prettier.py +485 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_standard.py +347 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_test_detection.py +42 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_treesitter.py +916 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_typescript.py +797 -0
- code_scalpel/code_parsers/javascript_parsers/javascript_parsers_webpack.py +43 -0
- code_scalpel/code_parsers/kotlin_parsers/README.md +892 -0
- code_scalpel/code_parsers/kotlin_parsers/__init__.py +146 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_Detekt.py +265 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_Konsist.py +111 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_compose.py +123 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_diktat.py +125 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_gradle.py +148 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_ktlint.py +326 -0
- code_scalpel/code_parsers/kotlin_parsers/kotlin_parsers_test.py +146 -0
- code_scalpel/code_parsers/language_detection.py +415 -0
- code_scalpel/code_parsers/php_parsers/README.md +632 -0
- code_scalpel/code_parsers/php_parsers/__init__.py +171 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_PHPCS.py +94 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_PHPStan.py +101 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_Psalm.py +97 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_ast.py +104 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_composer.py +98 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_exakat.py +94 -0
- code_scalpel/code_parsers/php_parsers/php_parsers_phpmd.py +114 -0
- code_scalpel/code_parsers/python_parser.py +61 -0
- code_scalpel/code_parsers/python_parsers/README.md +930 -0
- code_scalpel/code_parsers/python_parsers/__init__.py +456 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_ast.py +3871 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_bandit.py +1613 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_code_quality.py +1418 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_flake8.py +1217 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_interrogate.py +429 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_isort.py +270 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_mypy.py +1427 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_prospector.py +1065 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_pycodestyle.py +588 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_pydocstyle.py +1385 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_pylint.py +1650 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_radon.py +442 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_ruff.py +1177 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_safety.py +193 -0
- code_scalpel/code_parsers/python_parsers/python_parsers_vulture.py +155 -0
- code_scalpel/code_parsers/ruby_parsers/README.md +715 -0
- code_scalpel/code_parsers/ruby_parsers/__init__.py +29 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_Reek.py +82 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_RuboCop.py +84 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_ast.py +81 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_brakeman.py +70 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_bundler.py +69 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_fasterer.py +55 -0
- code_scalpel/code_parsers/ruby_parsers/ruby_parsers_simplecov.py +67 -0
- code_scalpel/code_parsers/swift_parsers/README.md +54 -0
- code_scalpel/code_parsers/swift_parsers/__init__.py +27 -0
- code_scalpel/code_parsers/swift_parsers/swift_parsers_SwiftLint.py +80 -0
- code_scalpel/code_parsers/swift_parsers/swift_parsers_Tailor.py +79 -0
- code_scalpel/code_parsers/swift_parsers/swift_parsers_sourcekitten.py +61 -0
- code_scalpel/code_parsers/swift_parsers/swift_parsers_swiftformat.py +44 -0
- code_scalpel/code_parsers/typescript_parsers/__init__.py +110 -0
- code_scalpel/code_parsers/typescript_parsers/alias_resolver.py +335 -0
- code_scalpel/code_parsers/typescript_parsers/analyzer.py +356 -0
- code_scalpel/code_parsers/typescript_parsers/decorator_analyzer.py +295 -0
- code_scalpel/code_parsers/typescript_parsers/parser.py +423 -0
- code_scalpel/code_parsers/typescript_parsers/tsx_analyzer.py +180 -0
- code_scalpel/code_parsers/typescript_parsers/type_narrowing.py +693 -0
- code_scalpel/config/README.md +137 -0
- code_scalpel/config/__init__.py +29 -0
- code_scalpel/config/init_config.py +381 -0
- code_scalpel/config/templates.py +1094 -0
- code_scalpel/core.py +32 -0
- code_scalpel/error_fixer.py +34 -0
- code_scalpel/error_scanner.py +40 -0
- code_scalpel/generators/README.md +169 -0
- code_scalpel/generators/__init__.py +16 -0
- code_scalpel/generators/refactor_simulator.py +1819 -0
- code_scalpel/generators/test_generator.py +1340 -0
- code_scalpel/governance/README.md +761 -0
- code_scalpel/governance/__init__.py +84 -0
- code_scalpel/governance/audit_log.py +10 -0
- code_scalpel/governance/change_budget.py +439 -0
- code_scalpel/governance/compliance_reporter.py +1006 -0
- code_scalpel/governance/governance_config.py +407 -0
- code_scalpel/governance/unified_governance.py +709 -0
- code_scalpel/graph/__init__.py +96 -0
- code_scalpel/graph/graph_query.py +599 -0
- code_scalpel/graph/logical_relationships.py +457 -0
- code_scalpel/graph/path_constraints.py +517 -0
- code_scalpel/graph/semantic_neighbors.py +420 -0
- code_scalpel/graph/traversal_rules.py +571 -0
- code_scalpel/graph_engine/README.md +179 -0
- code_scalpel/graph_engine/__init__.py +57 -0
- code_scalpel/graph_engine/confidence.py +270 -0
- code_scalpel/graph_engine/graph.py +502 -0
- code_scalpel/graph_engine/http_detector.py +362 -0
- code_scalpel/graph_engine/node_id.py +214 -0
- code_scalpel/hooks/__init__.py +85 -0
- code_scalpel/hooks/claude_hooks.py +561 -0
- code_scalpel/hooks/git_hooks.py +496 -0
- code_scalpel/hooks/installer.py +413 -0
- code_scalpel/integrations/README.md +214 -0
- code_scalpel/integrations/__init__.py +80 -0
- code_scalpel/integrations/autogen.py +231 -0
- code_scalpel/integrations/claude.py +1 -0
- code_scalpel/integrations/crewai.py +525 -0
- code_scalpel/integrations/langchain.py +3 -0
- code_scalpel/integrations/protocol_analyzers/__init__.py +55 -0
- code_scalpel/integrations/protocol_analyzers/frontend/__init__.py +30 -0
- code_scalpel/integrations/protocol_analyzers/frontend/input_tracker.py +907 -0
- code_scalpel/integrations/protocol_analyzers/graphql/__init__.py +40 -0
- code_scalpel/integrations/protocol_analyzers/graphql/schema_tracker.py +1229 -0
- code_scalpel/integrations/protocol_analyzers/grpc/__init__.py +28 -0
- code_scalpel/integrations/protocol_analyzers/grpc/contract_analyzer.py +748 -0
- code_scalpel/integrations/protocol_analyzers/kafka/__init__.py +32 -0
- code_scalpel/integrations/protocol_analyzers/kafka/taint_tracker.py +1119 -0
- code_scalpel/integrations/protocol_analyzers/schema/__init__.py +34 -0
- code_scalpel/integrations/protocol_analyzers/schema/drift_detector.py +1015 -0
- code_scalpel/integrations/rest_api_server.py +517 -0
- code_scalpel/ir/README.md +234 -0
- code_scalpel/ir/__init__.py +106 -0
- code_scalpel/ir/nodes.py +710 -0
- code_scalpel/ir/normalizers/README.md +152 -0
- code_scalpel/ir/normalizers/__init__.py +41 -0
- code_scalpel/ir/normalizers/base.py +90 -0
- code_scalpel/ir/normalizers/java_normalizer.py +966 -0
- code_scalpel/ir/normalizers/javascript_normalizer.py +1746 -0
- code_scalpel/ir/normalizers/python_normalizer.py +969 -0
- code_scalpel/ir/normalizers/tree_sitter_visitor.py +412 -0
- code_scalpel/ir/normalizers/typescript_normalizer.py +431 -0
- code_scalpel/ir/operators.py +111 -0
- code_scalpel/ir/semantics.py +684 -0
- code_scalpel/licensing/README.md +1493 -0
- code_scalpel/licensing/__init__.py +185 -0
- code_scalpel/licensing/authorization.py +172 -0
- code_scalpel/licensing/cache.py +548 -0
- code_scalpel/licensing/config_loader.py +466 -0
- code_scalpel/licensing/crl_fetcher.py +177 -0
- code_scalpel/licensing/features.py +1602 -0
- code_scalpel/licensing/jwt_generator.py +349 -0
- code_scalpel/licensing/jwt_validator.py +989 -0
- code_scalpel/licensing/license_manager.py +559 -0
- code_scalpel/licensing/public_key/cs-prod-public-20260101.pem +14 -0
- code_scalpel/licensing/remote_verifier.py +509 -0
- code_scalpel/licensing/runtime_revalidator.py +96 -0
- code_scalpel/licensing/tier_detector.py +475 -0
- code_scalpel/licensing/validator.py +602 -0
- code_scalpel/mcp/README.md +431 -0
- code_scalpel/mcp/REFACTOR_CHECKLIST.md +572 -0
- code_scalpel/mcp/__init__.py +98 -0
- code_scalpel/mcp/archive/server.py.archive +20483 -0
- code_scalpel/mcp/compat.py +179 -0
- code_scalpel/mcp/contract.py +472 -0
- code_scalpel/mcp/governance.py +956 -0
- code_scalpel/mcp/helpers/__init__.py +46 -0
- code_scalpel/mcp/helpers/analyze_helpers.py +1304 -0
- code_scalpel/mcp/helpers/ast_helpers.py +59 -0
- code_scalpel/mcp/helpers/context_helpers.py +2908 -0
- code_scalpel/mcp/helpers/extraction_helpers.py +1956 -0
- code_scalpel/mcp/helpers/graph_helpers.py +2822 -0
- code_scalpel/mcp/helpers/policy_helpers.py +488 -0
- code_scalpel/mcp/helpers/security_helpers.py +3298 -0
- code_scalpel/mcp/helpers/session.py +243 -0
- code_scalpel/mcp/helpers/symbolic_helpers.py +860 -0
- code_scalpel/mcp/logging.py +45 -0
- code_scalpel/mcp/mcp_logging.py +376 -0
- code_scalpel/mcp/models/__init__.py +79 -0
- code_scalpel/mcp/models/core.py +814 -0
- code_scalpel/mcp/models/graph.py +713 -0
- code_scalpel/mcp/models/policy.py +141 -0
- code_scalpel/mcp/models/security.py +246 -0
- code_scalpel/mcp/module_resolver.py +255 -0
- code_scalpel/mcp/path_resolver.py +577 -0
- code_scalpel/mcp/paths.py +65 -0
- code_scalpel/mcp/prompts.py +128 -0
- code_scalpel/mcp/protocol.py +186 -0
- code_scalpel/mcp/resources.py +525 -0
- code_scalpel/mcp/response_config.py +360 -0
- code_scalpel/mcp/server.py +5075 -0
- code_scalpel/mcp/session.py +41 -0
- code_scalpel/mcp/tier.py +8 -0
- code_scalpel/mcp/tools/__init__.py +19 -0
- code_scalpel/mcp/tools/analyze.py +57 -0
- code_scalpel/mcp/tools/context.py +144 -0
- code_scalpel/mcp/tools/extraction.py +211 -0
- code_scalpel/mcp/tools/graph.py +622 -0
- code_scalpel/mcp/tools/policy.py +143 -0
- code_scalpel/mcp/tools/security.py +232 -0
- code_scalpel/mcp/tools/symbolic.py +303 -0
- code_scalpel/parsing/__init__.py +20 -0
- code_scalpel/parsing/unified_parser.py +293 -0
- code_scalpel/pdg_tools/README.md +174 -0
- code_scalpel/pdg_tools/__init__.py +35 -0
- code_scalpel/pdg_tools/analyzer.py +596 -0
- code_scalpel/pdg_tools/builder.py +495 -0
- code_scalpel/pdg_tools/slicer.py +360 -0
- code_scalpel/pdg_tools/transformer.py +605 -0
- code_scalpel/pdg_tools/utils.py +301 -0
- code_scalpel/pdg_tools/visualizer.py +554 -0
- code_scalpel/policy_engine/README.md +1303 -0
- code_scalpel/policy_engine/__init__.py +169 -0
- code_scalpel/policy_engine/audit_log.py +217 -0
- code_scalpel/policy_engine/code_policy_check/__init__.py +53 -0
- code_scalpel/policy_engine/code_policy_check/analyzer.py +1175 -0
- code_scalpel/policy_engine/code_policy_check/models.py +352 -0
- code_scalpel/policy_engine/code_policy_check/patterns.py +660 -0
- code_scalpel/policy_engine/code_policy_check/policy_loader.py +154 -0
- code_scalpel/policy_engine/code_policy_check/templates.py +43 -0
- code_scalpel/policy_engine/crypto_verify.py +572 -0
- code_scalpel/policy_engine/exceptions.py +35 -0
- code_scalpel/policy_engine/models.py +12 -0
- code_scalpel/policy_engine/policy_engine.py +852 -0
- code_scalpel/policy_engine/semantic_analyzer.py +710 -0
- code_scalpel/policy_engine/tamper_resistance.py +367 -0
- code_scalpel/polyglot/README.md +185 -0
- code_scalpel/polyglot/__init__.py +68 -0
- code_scalpel/polyglot/alias_resolver.py +326 -0
- code_scalpel/polyglot/contract_breach_detector.py +318 -0
- code_scalpel/polyglot/extractor.py +529 -0
- code_scalpel/polyglot/tsx_analyzer.py +180 -0
- code_scalpel/polyglot/typescript/README.md +184 -0
- code_scalpel/polyglot/typescript/__init__.py +40 -0
- code_scalpel/polyglot/typescript/analyzer.py +363 -0
- code_scalpel/polyglot/typescript/decorator_analyzer.py +302 -0
- code_scalpel/polyglot/typescript/parser.py +430 -0
- code_scalpel/polyglot/typescript/type_narrowing.py +700 -0
- code_scalpel/project_crawler.py +46 -0
- code_scalpel/py.typed +0 -0
- code_scalpel/quality_assurance/__init__.py +18 -0
- code_scalpel/quality_assurance/error_fixer.py +241 -0
- code_scalpel/quality_assurance/error_scanner.py +937 -0
- code_scalpel/refactor/__init__.py +29 -0
- code_scalpel/refactor/build_verifier.py +331 -0
- code_scalpel/refactor/custom_rules.py +288 -0
- code_scalpel/refactor/regression_predictor.py +260 -0
- code_scalpel/refactor/type_checker.py +284 -0
- code_scalpel/security/README.md +494 -0
- code_scalpel/security/README_DEVELOPER_GUIDE.md +894 -0
- code_scalpel/security/__init__.py +88 -0
- code_scalpel/security/analyzers/__init__.py +64 -0
- code_scalpel/security/analyzers/compliance_mapper.py +285 -0
- code_scalpel/security/analyzers/confidence_scorer.py +202 -0
- code_scalpel/security/analyzers/cross_file_taint.py +1478 -0
- code_scalpel/security/analyzers/custom_rules.py +310 -0
- code_scalpel/security/analyzers/false_positive_analyzer.py +272 -0
- code_scalpel/security/analyzers/policy_engine.py +298 -0
- code_scalpel/security/analyzers/sanitizer_detector.py +253 -0
- code_scalpel/security/analyzers/security_analyzer.py +1069 -0
- code_scalpel/security/analyzers/taint_tracker.py +2353 -0
- code_scalpel/security/analyzers/unified_sink_detector.py +1003 -0
- code_scalpel/security/contract_breach_detector.py +332 -0
- code_scalpel/security/dependencies/__init__.py +91 -0
- code_scalpel/security/dependencies/false_positive_reducer.py +323 -0
- code_scalpel/security/dependencies/license_compliance.py +318 -0
- code_scalpel/security/dependencies/osv_client.py +399 -0
- code_scalpel/security/dependencies/schema_tracker.py +1232 -0
- code_scalpel/security/dependencies/severity_contextualizer.py +319 -0
- code_scalpel/security/dependencies/supply_chain_scorer.py +404 -0
- code_scalpel/security/dependencies/typosquatting_detector.py +335 -0
- code_scalpel/security/dependencies/vulnerability_reachability.py +241 -0
- code_scalpel/security/dependencies/vulnerability_scanner.py +646 -0
- code_scalpel/security/ml/__init__.py +15 -0
- code_scalpel/security/ml/ml_vulnerability_predictor.py +78 -0
- code_scalpel/security/sanitization/__init__.py +16 -0
- code_scalpel/security/sanitization/sanitizer_analyzer.py +102 -0
- code_scalpel/security/secrets/__init__.py +14 -0
- code_scalpel/security/secrets/secret_scanner.py +449 -0
- code_scalpel/security/type_safety/__init__.py +20 -0
- code_scalpel/security/type_safety/type_evaporation_detector.py +677 -0
- code_scalpel/surgery/__init__.py +76 -0
- code_scalpel/surgery/approval_workflow.py +383 -0
- code_scalpel/surgery/audit_trail.py +283 -0
- code_scalpel/surgery/compliance.py +169 -0
- code_scalpel/surgery/multi_repo.py +432 -0
- code_scalpel/surgery/rename_symbol_refactor.py +780 -0
- code_scalpel/surgery/repo_wide.py +364 -0
- code_scalpel/surgery/surgical_extractor.py +3587 -0
- code_scalpel/surgery/surgical_patcher.py +2853 -0
- code_scalpel/surgery/unified_extractor.py +1482 -0
- code_scalpel/surgical_extractor.py +50 -0
- code_scalpel/surgical_patcher.py +48 -0
- code_scalpel/symbolic_execution_tools/README.md +555 -0
- code_scalpel/symbolic_execution_tools/__init__.py +379 -0
- code_scalpel/symbolic_execution_tools/concolic_engine.py +55 -0
- code_scalpel/symbolic_execution_tools/constraint_solver.py +377 -0
- code_scalpel/symbolic_execution_tools/engine.py +543 -0
- code_scalpel/symbolic_execution_tools/ir_interpreter.py +1191 -0
- code_scalpel/symbolic_execution_tools/path_prioritization.py +304 -0
- code_scalpel/symbolic_execution_tools/state_manager.py +373 -0
- code_scalpel/symbolic_execution_tools/symbolic_memory.py +82 -0
- code_scalpel/symbolic_execution_tools/type_inference.py +333 -0
- code_scalpel/tiers/__init__.py +107 -0
- code_scalpel/tiers/decorators.py +185 -0
- code_scalpel/tiers/feature_registry.py +310 -0
- code_scalpel/tiers/tool_registry.py +391 -0
- code_scalpel/unified_extractor.py +52 -0
- code_scalpel/utilities/README.md +143 -0
- code_scalpel/utilities/__init__.py +14 -0
- code_scalpel/utilities/path_resolution.py +190 -0
- code_scalpel/utilities/source_sanitizer.py +44 -0
- codescalpel-1.0.0.dist-info/METADATA +338 -0
- codescalpel-1.0.0.dist-info/RECORD +440 -0
- codescalpel-1.0.0.dist-info/WHEEL +4 -0
- codescalpel-1.0.0.dist-info/entry_points.txt +2 -0
- codescalpel-1.0.0.dist-info/licenses/LICENSE +151 -0
code_scalpel/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Code Scalpel - Source Code
|
|
2
|
+
|
|
3
|
+
**Version:** 3.0.5 "Ninja Consolidation"
|
|
4
|
+
**Release Date:** December 23, 2025
|
|
5
|
+
|
|
6
|
+
<!-- TODO [COMMUNITY]: Maintain documentation alignment with latest release (current)
|
|
7
|
+
TODO [PRO]: Add architecture diagrams for each module
|
|
8
|
+
TODO [ENTERPRISE]: Add automated API documentation generation -->
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
This is the main source directory for Code Scalpel, an MCP server toolkit for AI-driven surgical code analysis and modification.
|
|
13
|
+
|
|
14
|
+
<!-- TODO [COMMUNITY]: Core module status and dependencies (current)
|
|
15
|
+
TODO [PRO]: Performance benchmarks for each module
|
|
16
|
+
TODO [ENTERPRISE]: Distributed deployment topology diagrams -->
|
|
17
|
+
|
|
18
|
+
## Module Organization
|
|
19
|
+
|
|
20
|
+
<!-- TODO [COMMUNITY]: Organization by capability tier (current)
|
|
21
|
+
TODO [PRO]: Cross-module dependency analysis and import tracking
|
|
22
|
+
TODO [ENTERPRISE]: Microservices decomposition for independent deployment -->
|
|
23
|
+
|
|
24
|
+
### Core Analysis
|
|
25
|
+
- **ast_tools/** - AST parsing and analysis
|
|
26
|
+
- **pdg_tools/** - Program Dependence Graph construction and analysis
|
|
27
|
+
- **symbolic_execution_tools/** - Symbolic execution engine and security analysis (500K+ LOC)
|
|
28
|
+
|
|
29
|
+
### Language Support
|
|
30
|
+
- **polyglot/** - Modern multi-language parsing (tree-sitter based)
|
|
31
|
+
- **code_parser/** - Legacy language-specific parsers
|
|
32
|
+
- **ir/** - Unified Intermediate Representation for cross-language analysis
|
|
33
|
+
- **parsers/** - Lightweight parser factory
|
|
34
|
+
|
|
35
|
+
### Security & Governance
|
|
36
|
+
- **security/** - Security analysis tools and vulnerability detection
|
|
37
|
+
- **policy_engine/** - Policy enforcement and semantic analysis
|
|
38
|
+
- **policy/** - Change budget and modification limits
|
|
39
|
+
- **governance/** - Compliance reporting and audit logging
|
|
40
|
+
|
|
41
|
+
### Code Modification
|
|
42
|
+
- **generators/** - Test generation and refactoring simulation
|
|
43
|
+
- **surgical_extractor.py** - Precise code extraction
|
|
44
|
+
- **surgical_patcher.py** - Safe code modification
|
|
45
|
+
- **code_analyzer.py** - Single-file code analysis
|
|
46
|
+
- **project_crawler.py** - Project-wide analysis
|
|
47
|
+
|
|
48
|
+
### Infrastructure
|
|
49
|
+
- **cache/** - Unified caching layer (v3.0.5 consolidation)
|
|
50
|
+
- **utilities/** - Path resolution and shared utilities
|
|
51
|
+
- **config/** - Configuration management
|
|
52
|
+
- **graph_engine/** - Dependency graph construction
|
|
53
|
+
|
|
54
|
+
### Integrations
|
|
55
|
+
- **mcp/** - MCP server with 22 tools
|
|
56
|
+
- **integrations/** - REST API, AutoGen, CrewAI integrations
|
|
57
|
+
- **agents/** - AI agent implementations
|
|
58
|
+
- **autonomy/** - Error-to-diff autonomous fixing engine
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
# Import core functionality
|
|
64
|
+
from code_scalpel import (
|
|
65
|
+
CodeAnalyzer,
|
|
66
|
+
AnalysisResult,
|
|
67
|
+
extract_function,
|
|
68
|
+
update_function_in_file,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Analyze code
|
|
72
|
+
analyzer = CodeAnalyzer()
|
|
73
|
+
result = analyzer.analyze("def foo(): return 1")
|
|
74
|
+
print(result.metrics.num_functions)
|
|
75
|
+
|
|
76
|
+
# Extract function
|
|
77
|
+
from code_scalpel import extract_function
|
|
78
|
+
func_code = extract_function(file_path, "function_name")
|
|
79
|
+
|
|
80
|
+
# Start MCP server
|
|
81
|
+
from code_scalpel import run_server
|
|
82
|
+
run_server(port=8080)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
<!-- TODO [COMMUNITY]: Basic usage examples (current)
|
|
86
|
+
TODO [PRO]: Advanced configuration and profiles
|
|
87
|
+
TODO [ENTERPRISE]: Custom integration patterns and deployment scenarios -->
|
|
88
|
+
|
|
89
|
+
## Module Statistics (v3.0.5)
|
|
90
|
+
|
|
91
|
+
| Module | LOC | Status | Coverage |
|
|
92
|
+
|--------|-----|--------|----------|
|
|
93
|
+
| symbolic_execution_tools | 500K+ | Stable | 95%+ |
|
|
94
|
+
| ir | 180K+ | Stable | 95%+ |
|
|
95
|
+
| code_parser | 150K+ | Legacy | 90%+ |
|
|
96
|
+
| polyglot | 80K+ | Stable | 90%+ |
|
|
97
|
+
| pdg_tools | 120K+ | Stable | 100% |
|
|
98
|
+
| mcp | 4K+ | Stable | 100% |
|
|
99
|
+
| **Total** | **~1.2M LOC** | | **94.86%** |
|
|
100
|
+
|
|
101
|
+
<!-- TODO [COMMUNITY]: Baseline metrics and status tracking (current)
|
|
102
|
+
TODO [PRO]: Performance regression detection across releases
|
|
103
|
+
TODO [ENTERPRISE]: Automated metric collection and trending -->
|
|
104
|
+
|
|
105
|
+
## Key Features (v3.0.5)
|
|
106
|
+
|
|
107
|
+
✅ **Cache Consolidation** - Unified cache implementation (eliminated 277 LOC redundancy)
|
|
108
|
+
✅ **22 MCP Tools** - Full toolkit for AI agents
|
|
109
|
+
✅ **Multi-Language** - Python, Java, JavaScript, TypeScript support
|
|
110
|
+
✅ **Security Analysis** - OWASP Top 10 vulnerability detection
|
|
111
|
+
✅ **Symbolic Execution** - Path exploration with Z3 solver
|
|
112
|
+
✅ **Cross-File Analysis** - Dependency tracking across modules
|
|
113
|
+
✅ **Test Generation** - Automated unit test creation
|
|
114
|
+
✅ **Autonomy Engine** - Error-to-diff automatic fixing
|
|
115
|
+
|
|
116
|
+
## Documentation
|
|
117
|
+
|
|
118
|
+
- **Architecture:** `docs/architecture/`
|
|
119
|
+
- **Guides:** `docs/guides/`
|
|
120
|
+
- **API Reference:** `docs/modules/`
|
|
121
|
+
- **Release Notes:** `docs/release_notes/RELEASE_NOTES_v3.0.5.md`
|
|
122
|
+
- **Organizational Analysis:** `ORGANIZATIONAL_ANALYSIS.md`
|
|
123
|
+
|
|
124
|
+
## Testing
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Run all tests
|
|
128
|
+
pytest tests/
|
|
129
|
+
|
|
130
|
+
# Run specific module tests
|
|
131
|
+
pytest tests/test_cache/
|
|
132
|
+
pytest tests/test_symbolic_execution/
|
|
133
|
+
|
|
134
|
+
# Coverage report
|
|
135
|
+
pytest --cov=src/code_scalpel --cov-report=html
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
<!-- TODO [COMMUNITY]: Standard test execution (current)
|
|
139
|
+
TODO [PRO]: Performance testing and benchmarks
|
|
140
|
+
TODO [ENTERPRISE]: Distributed testing across agents -->
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Install in development mode
|
|
146
|
+
pip install -e .
|
|
147
|
+
|
|
148
|
+
# Format code
|
|
149
|
+
black src/code_scalpel
|
|
150
|
+
ruff check src/code_scalpel --fix
|
|
151
|
+
|
|
152
|
+
# Type checking
|
|
153
|
+
mypy src/code_scalpel
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
<!-- TODO [COMMUNITY]: Standard development workflow (current)
|
|
157
|
+
TODO [PRO]: IDE integration setup and debugging
|
|
158
|
+
TODO [ENTERPRISE]: Custom development environment provisioning -->
|
|
159
|
+
|
|
160
|
+
## Module READMEs
|
|
161
|
+
|
|
162
|
+
Every subdirectory contains a README.md with detailed module documentation:
|
|
163
|
+
- Purpose and overview
|
|
164
|
+
- Key components and APIs
|
|
165
|
+
- Usage examples
|
|
166
|
+
- Integration points
|
|
167
|
+
- Version status
|
|
168
|
+
|
|
169
|
+
<!-- TODO [COMMUNITY]: Documentation completeness checklist (current)
|
|
170
|
+
TODO [PRO]: Auto-generated API docs from docstrings
|
|
171
|
+
TODO [ENTERPRISE]: Multi-language documentation support -->
|
|
172
|
+
|
|
173
|
+
## v3.0.5 Changes
|
|
174
|
+
|
|
175
|
+
**Cache Consolidation:**
|
|
176
|
+
- Merged `cache/analysis_cache.py` + `utilities/cache.py` → `cache/unified_cache.py`
|
|
177
|
+
- Eliminated 277 lines of redundancy
|
|
178
|
+
- Preserved all features from both implementations
|
|
179
|
+
- Backward compatible imports
|
|
180
|
+
|
|
181
|
+
**Documentation:**
|
|
182
|
+
- Fixed MCP tool count (19 → 20)
|
|
183
|
+
- Created READMEs for all 33 directories
|
|
184
|
+
- Archived old cache implementations with explanation
|
|
185
|
+
|
|
186
|
+
<!-- TODO [COMMUNITY]: Release notes and change tracking (current)
|
|
187
|
+
TODO [PRO]: Migration guides and breaking changes documentation
|
|
188
|
+
TODO [ENTERPRISE]: Upgrade automation and compatibility matrices -->
|
|
189
|
+
|
|
190
|
+
## Contact
|
|
191
|
+
|
|
192
|
+
- **Author:** Timmothy Escolopio
|
|
193
|
+
- **Email:** time@3dtechsolutions.us
|
|
194
|
+
- **Organization:** 3D Tech Solutions LLC
|
|
195
|
+
- **License:** MIT
|
|
196
|
+
- **Repository:** [code-scalpel](https://github.com/3D-Tech-Solutions/code-scalpel)
|
code_scalpel/__init__.py
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Code Scalpel - AI Agent toolkit for code analysis using ASTs, PDGs, and Symbolic Execution.
|
|
3
|
+
|
|
4
|
+
Code Scalpel provides precision tools for AI-driven code analysis and transformation,
|
|
5
|
+
enabling AI agents to perform deep analysis and surgical modifications of code.
|
|
6
|
+
|
|
7
|
+
Quick Start:
|
|
8
|
+
>>> from code_scalpel import CodeAnalyzer
|
|
9
|
+
>>> analyzer = CodeAnalyzer()
|
|
10
|
+
>>> result = analyzer.analyze("def hello(): return 42")
|
|
11
|
+
>>> print(result.metrics.num_functions)
|
|
12
|
+
1
|
|
13
|
+
|
|
14
|
+
For MCP server:
|
|
15
|
+
>>> from code_scalpel import run_server
|
|
16
|
+
>>> run_server(port=8080)
|
|
17
|
+
|
|
18
|
+
For AI agent integrations:
|
|
19
|
+
>>> from code_scalpel.integrations import AutogenScalpel, CrewAIScalpel
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
# [20251228_FEATURE] Public sync wrappers for key MCP tools.
|
|
23
|
+
# These are convenience APIs used by tier/tooling validation tests.
|
|
24
|
+
|
|
25
|
+
# [20251225_RELEASE] v3.3.0 - Project Reorganization (Phases 1-4)
|
|
26
|
+
__version__ = "1.0.0"
|
|
27
|
+
__author__ = "Timmothy Escolopio"
|
|
28
|
+
__email__ = "time@3dtechsolutions.us"
|
|
29
|
+
|
|
30
|
+
# [20251228_BUGFIX] Prefer reorganized modules to avoid importing deprecated
|
|
31
|
+
# shims (keeps backward-compatible top-level symbols without warning noise).
|
|
32
|
+
from .analysis.code_analyzer import (
|
|
33
|
+
AnalysisLevel,
|
|
34
|
+
AnalysisMetrics,
|
|
35
|
+
AnalysisResult,
|
|
36
|
+
CodeAnalyzer,
|
|
37
|
+
DeadCodeItem,
|
|
38
|
+
RefactorSuggestion,
|
|
39
|
+
analyze_code,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Project Crawler
|
|
43
|
+
from .analysis.project_crawler import (
|
|
44
|
+
CrawlResult,
|
|
45
|
+
FileAnalysisResult,
|
|
46
|
+
ProjectCrawler,
|
|
47
|
+
crawl_project,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# Core analysis
|
|
51
|
+
# AST tools
|
|
52
|
+
from .ast_tools import (
|
|
53
|
+
ASTAnalyzer,
|
|
54
|
+
ASTBuilder,
|
|
55
|
+
ClassMetrics,
|
|
56
|
+
FunctionMetrics,
|
|
57
|
+
build_ast,
|
|
58
|
+
build_ast_from_file,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Autonomy (Error-to-Diff Engine) - v3.0.0
|
|
62
|
+
# [20251217_FEATURE] v3.0.0 Autonomy - Error-to-Diff Engine
|
|
63
|
+
from .autonomy import ErrorAnalysis, ErrorToDiffEngine, ErrorType, FixHint, ParsedError
|
|
64
|
+
|
|
65
|
+
# REST API Server (legacy) - LAZY IMPORT
|
|
66
|
+
# [20260112_BUGFIX] Flask is optional (code-scalpel[web]). Use lazy imports to avoid
|
|
67
|
+
# crash on bare `pip install code-scalpel`. Users who need REST API should either:
|
|
68
|
+
# 1. Install: pip install code-scalpel[web]
|
|
69
|
+
# 2. Import directly: from code_scalpel.integrations.rest_api_server import run_server
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def __getattr__(name: str):
|
|
73
|
+
"""Lazy loader for optional dependencies (Flask REST API)."""
|
|
74
|
+
if name in ("MCPServerConfig", "create_app", "run_server"):
|
|
75
|
+
try:
|
|
76
|
+
from .integrations import rest_api_server
|
|
77
|
+
|
|
78
|
+
return getattr(rest_api_server, name)
|
|
79
|
+
except ImportError as e:
|
|
80
|
+
raise ImportError("REST API server requires Flask. Install with: pip install code-scalpel[web]") from e
|
|
81
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# PDG tools
|
|
85
|
+
from .pdg_tools import PDGAnalyzer, PDGBuilder, build_pdg # noqa: E402
|
|
86
|
+
|
|
87
|
+
# Surgical Extractor (Token-efficient extraction)
|
|
88
|
+
from .surgery.surgical_extractor import ( # noqa: E402
|
|
89
|
+
ContextualExtraction,
|
|
90
|
+
CrossFileResolution,
|
|
91
|
+
CrossFileSymbol,
|
|
92
|
+
ExtractionResult,
|
|
93
|
+
SurgicalExtractor,
|
|
94
|
+
extract_class,
|
|
95
|
+
extract_function,
|
|
96
|
+
extract_method,
|
|
97
|
+
extract_with_context,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Surgical Patcher (Safe code modification)
|
|
101
|
+
from .surgery.surgical_patcher import ( # noqa: E402
|
|
102
|
+
PatchResult,
|
|
103
|
+
SurgicalPatcher,
|
|
104
|
+
update_class_in_file,
|
|
105
|
+
update_function_in_file,
|
|
106
|
+
update_method_in_file,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Unified Extractor (Multi-language extraction) - v3.1.0
|
|
110
|
+
# [20251221_FEATURE] v3.1.0 - Unified interface for all languages
|
|
111
|
+
from .surgery.unified_extractor import ( # noqa: E402
|
|
112
|
+
Language,
|
|
113
|
+
UnifiedExtractionResult,
|
|
114
|
+
UnifiedExtractor,
|
|
115
|
+
detect_language,
|
|
116
|
+
extract_from_code,
|
|
117
|
+
extract_from_file,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
__all__ = [
|
|
121
|
+
# Version info
|
|
122
|
+
"__version__",
|
|
123
|
+
"__author__",
|
|
124
|
+
"__email__",
|
|
125
|
+
# Core analysis
|
|
126
|
+
"CodeAnalyzer",
|
|
127
|
+
"AnalysisResult",
|
|
128
|
+
"AnalysisLevel",
|
|
129
|
+
"AnalysisMetrics",
|
|
130
|
+
"DeadCodeItem",
|
|
131
|
+
"RefactorSuggestion",
|
|
132
|
+
"analyze_code",
|
|
133
|
+
# AST tools
|
|
134
|
+
"ASTAnalyzer",
|
|
135
|
+
"ASTBuilder",
|
|
136
|
+
"FunctionMetrics",
|
|
137
|
+
"ClassMetrics",
|
|
138
|
+
"build_ast",
|
|
139
|
+
"build_ast_from_file",
|
|
140
|
+
# PDG tools
|
|
141
|
+
"PDGBuilder",
|
|
142
|
+
"PDGAnalyzer",
|
|
143
|
+
"build_pdg",
|
|
144
|
+
# Project Crawler
|
|
145
|
+
"ProjectCrawler",
|
|
146
|
+
"CrawlResult",
|
|
147
|
+
"FileAnalysisResult",
|
|
148
|
+
"crawl_project",
|
|
149
|
+
# Surgical Extractor
|
|
150
|
+
"SurgicalExtractor",
|
|
151
|
+
"ExtractionResult",
|
|
152
|
+
"ContextualExtraction",
|
|
153
|
+
"CrossFileSymbol",
|
|
154
|
+
"CrossFileResolution",
|
|
155
|
+
"extract_function",
|
|
156
|
+
"extract_class",
|
|
157
|
+
"extract_method",
|
|
158
|
+
"extract_with_context",
|
|
159
|
+
# Unified Extractor (v3.1.0)
|
|
160
|
+
"UnifiedExtractor",
|
|
161
|
+
"UnifiedExtractionResult",
|
|
162
|
+
"Language",
|
|
163
|
+
"detect_language",
|
|
164
|
+
"extract_from_file",
|
|
165
|
+
"extract_from_code",
|
|
166
|
+
# Surgical Patcher
|
|
167
|
+
"SurgicalPatcher",
|
|
168
|
+
"PatchResult",
|
|
169
|
+
"update_function_in_file",
|
|
170
|
+
"update_class_in_file",
|
|
171
|
+
"update_method_in_file",
|
|
172
|
+
# Autonomy (v3.0.0)
|
|
173
|
+
"ErrorToDiffEngine",
|
|
174
|
+
"ErrorType",
|
|
175
|
+
"ErrorAnalysis",
|
|
176
|
+
"FixHint",
|
|
177
|
+
"ParsedError",
|
|
178
|
+
# MCP tool convenience wrappers
|
|
179
|
+
"extract_code",
|
|
180
|
+
"security_scan",
|
|
181
|
+
"symbolic_execute",
|
|
182
|
+
"generate_unit_tests",
|
|
183
|
+
"simulate_refactor",
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# [20251228_FEATURE] Provide sync wrappers around async MCP tool functions.
|
|
188
|
+
def _run_mcp_tool_sync(async_fn, /, *args, **kwargs):
|
|
189
|
+
import asyncio
|
|
190
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
191
|
+
|
|
192
|
+
try:
|
|
193
|
+
asyncio.get_running_loop()
|
|
194
|
+
except RuntimeError:
|
|
195
|
+
return asyncio.run(async_fn(*args, **kwargs))
|
|
196
|
+
|
|
197
|
+
# Running inside an event loop (e.g., pytest-asyncio). Run in a separate thread.
|
|
198
|
+
with ThreadPoolExecutor(max_workers=1) as executor:
|
|
199
|
+
future = executor.submit(lambda: asyncio.run(async_fn(*args, **kwargs)))
|
|
200
|
+
return future.result()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def extract_code(
|
|
204
|
+
*,
|
|
205
|
+
target_type: str,
|
|
206
|
+
target_name: str,
|
|
207
|
+
file_path: str | None = None,
|
|
208
|
+
code: str | None = None,
|
|
209
|
+
language: str | None = None,
|
|
210
|
+
include_context: bool = False,
|
|
211
|
+
context_depth: int = 1,
|
|
212
|
+
include_cross_file_deps: bool = False,
|
|
213
|
+
include_token_estimate: bool = True,
|
|
214
|
+
):
|
|
215
|
+
"""[20251228_FEATURE] Sync wrapper for MCP extract_code tool."""
|
|
216
|
+
from code_scalpel.mcp.archive.server import extract_code as _extract_code_async
|
|
217
|
+
|
|
218
|
+
return _run_mcp_tool_sync(
|
|
219
|
+
_extract_code_async,
|
|
220
|
+
target_type=target_type,
|
|
221
|
+
target_name=target_name,
|
|
222
|
+
file_path=file_path,
|
|
223
|
+
code=code,
|
|
224
|
+
language=language,
|
|
225
|
+
include_context=include_context,
|
|
226
|
+
context_depth=context_depth,
|
|
227
|
+
include_cross_file_deps=include_cross_file_deps,
|
|
228
|
+
include_token_estimate=include_token_estimate,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def security_scan(code: str | None = None, file_path: str | None = None):
|
|
233
|
+
"""[20251228_FEATURE] Sync wrapper for MCP security_scan tool."""
|
|
234
|
+
from code_scalpel.mcp.archive.server import security_scan as _security_scan_async
|
|
235
|
+
|
|
236
|
+
return _run_mcp_tool_sync(_security_scan_async, code=code, file_path=file_path)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def symbolic_execute(code: str, max_paths: int | None = None, max_depth: int | None = None):
|
|
240
|
+
"""[20251228_FEATURE] Sync wrapper for MCP symbolic_execute tool."""
|
|
241
|
+
from code_scalpel.mcp.archive.server import (
|
|
242
|
+
symbolic_execute as _symbolic_execute_async,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
# Allow mixed value types for optional numeric parameters
|
|
246
|
+
kwargs: dict[str, str | int] = {"code": code}
|
|
247
|
+
if max_paths is not None:
|
|
248
|
+
kwargs["max_paths"] = max_paths
|
|
249
|
+
if max_depth is not None:
|
|
250
|
+
kwargs["max_depth"] = max_depth
|
|
251
|
+
return _run_mcp_tool_sync(_symbolic_execute_async, **kwargs)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def generate_unit_tests(
|
|
255
|
+
code: str | None = None,
|
|
256
|
+
file_path: str | None = None,
|
|
257
|
+
function_name: str | None = None,
|
|
258
|
+
framework: str = "pytest",
|
|
259
|
+
):
|
|
260
|
+
"""[20251228_FEATURE] Sync wrapper for MCP generate_unit_tests tool."""
|
|
261
|
+
from code_scalpel.mcp.archive.server import (
|
|
262
|
+
generate_unit_tests as _generate_unit_tests_async,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
return _run_mcp_tool_sync(
|
|
266
|
+
_generate_unit_tests_async,
|
|
267
|
+
code=code,
|
|
268
|
+
file_path=file_path,
|
|
269
|
+
function_name=function_name,
|
|
270
|
+
framework=framework,
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def simulate_refactor(
|
|
275
|
+
original_code: str,
|
|
276
|
+
new_code: str | None = None,
|
|
277
|
+
patch: str | None = None,
|
|
278
|
+
strict_mode: bool = False,
|
|
279
|
+
):
|
|
280
|
+
"""[20251228_FEATURE] Sync wrapper for MCP simulate_refactor tool."""
|
|
281
|
+
from code_scalpel.mcp.archive.server import (
|
|
282
|
+
simulate_refactor as _simulate_refactor_async,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
return _run_mcp_tool_sync(
|
|
286
|
+
_simulate_refactor_async,
|
|
287
|
+
original_code=original_code,
|
|
288
|
+
new_code=new_code,
|
|
289
|
+
patch=patch,
|
|
290
|
+
strict_mode=strict_mode,
|
|
291
|
+
)
|