alita-sdk 0.3.257__py3-none-any.whl → 0.3.562__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.
- alita_sdk/cli/__init__.py +10 -0
- alita_sdk/cli/__main__.py +17 -0
- alita_sdk/cli/agent/__init__.py +5 -0
- alita_sdk/cli/agent/default.py +258 -0
- alita_sdk/cli/agent_executor.py +155 -0
- alita_sdk/cli/agent_loader.py +215 -0
- alita_sdk/cli/agent_ui.py +228 -0
- alita_sdk/cli/agents.py +3601 -0
- alita_sdk/cli/callbacks.py +647 -0
- alita_sdk/cli/cli.py +168 -0
- alita_sdk/cli/config.py +306 -0
- alita_sdk/cli/context/__init__.py +30 -0
- alita_sdk/cli/context/cleanup.py +198 -0
- alita_sdk/cli/context/manager.py +731 -0
- alita_sdk/cli/context/message.py +285 -0
- alita_sdk/cli/context/strategies.py +289 -0
- alita_sdk/cli/context/token_estimation.py +127 -0
- alita_sdk/cli/formatting.py +182 -0
- alita_sdk/cli/input_handler.py +419 -0
- alita_sdk/cli/inventory.py +1073 -0
- alita_sdk/cli/mcp_loader.py +315 -0
- alita_sdk/cli/toolkit.py +327 -0
- alita_sdk/cli/toolkit_loader.py +85 -0
- alita_sdk/cli/tools/__init__.py +43 -0
- alita_sdk/cli/tools/approval.py +224 -0
- alita_sdk/cli/tools/filesystem.py +1751 -0
- alita_sdk/cli/tools/planning.py +389 -0
- alita_sdk/cli/tools/terminal.py +414 -0
- alita_sdk/community/__init__.py +72 -12
- alita_sdk/community/inventory/__init__.py +236 -0
- alita_sdk/community/inventory/config.py +257 -0
- alita_sdk/community/inventory/enrichment.py +2137 -0
- alita_sdk/community/inventory/extractors.py +1469 -0
- alita_sdk/community/inventory/ingestion.py +3172 -0
- alita_sdk/community/inventory/knowledge_graph.py +1457 -0
- alita_sdk/community/inventory/parsers/__init__.py +218 -0
- alita_sdk/community/inventory/parsers/base.py +295 -0
- alita_sdk/community/inventory/parsers/csharp_parser.py +907 -0
- alita_sdk/community/inventory/parsers/go_parser.py +851 -0
- alita_sdk/community/inventory/parsers/html_parser.py +389 -0
- alita_sdk/community/inventory/parsers/java_parser.py +593 -0
- alita_sdk/community/inventory/parsers/javascript_parser.py +629 -0
- alita_sdk/community/inventory/parsers/kotlin_parser.py +768 -0
- alita_sdk/community/inventory/parsers/markdown_parser.py +362 -0
- alita_sdk/community/inventory/parsers/python_parser.py +604 -0
- alita_sdk/community/inventory/parsers/rust_parser.py +858 -0
- alita_sdk/community/inventory/parsers/swift_parser.py +832 -0
- alita_sdk/community/inventory/parsers/text_parser.py +322 -0
- alita_sdk/community/inventory/parsers/yaml_parser.py +370 -0
- alita_sdk/community/inventory/patterns/__init__.py +61 -0
- alita_sdk/community/inventory/patterns/ast_adapter.py +380 -0
- alita_sdk/community/inventory/patterns/loader.py +348 -0
- alita_sdk/community/inventory/patterns/registry.py +198 -0
- alita_sdk/community/inventory/presets.py +535 -0
- alita_sdk/community/inventory/retrieval.py +1403 -0
- alita_sdk/community/inventory/toolkit.py +173 -0
- alita_sdk/community/inventory/toolkit_utils.py +176 -0
- alita_sdk/community/inventory/visualize.py +1370 -0
- alita_sdk/configurations/__init__.py +11 -0
- alita_sdk/configurations/ado.py +148 -2
- alita_sdk/configurations/azure_search.py +1 -1
- alita_sdk/configurations/bigquery.py +1 -1
- alita_sdk/configurations/bitbucket.py +94 -2
- alita_sdk/configurations/browser.py +18 -0
- alita_sdk/configurations/carrier.py +19 -0
- alita_sdk/configurations/confluence.py +130 -1
- alita_sdk/configurations/delta_lake.py +1 -1
- alita_sdk/configurations/figma.py +76 -5
- alita_sdk/configurations/github.py +65 -1
- alita_sdk/configurations/gitlab.py +81 -0
- alita_sdk/configurations/google_places.py +17 -0
- alita_sdk/configurations/jira.py +103 -0
- alita_sdk/configurations/openapi.py +111 -0
- alita_sdk/configurations/postman.py +1 -1
- alita_sdk/configurations/qtest.py +72 -3
- alita_sdk/configurations/report_portal.py +115 -0
- alita_sdk/configurations/salesforce.py +19 -0
- alita_sdk/configurations/service_now.py +1 -12
- alita_sdk/configurations/sharepoint.py +167 -0
- alita_sdk/configurations/sonar.py +18 -0
- alita_sdk/configurations/sql.py +20 -0
- alita_sdk/configurations/testio.py +101 -0
- alita_sdk/configurations/testrail.py +88 -0
- alita_sdk/configurations/xray.py +94 -1
- alita_sdk/configurations/zephyr_enterprise.py +94 -1
- alita_sdk/configurations/zephyr_essential.py +95 -0
- alita_sdk/runtime/clients/artifact.py +21 -4
- alita_sdk/runtime/clients/client.py +458 -67
- alita_sdk/runtime/clients/mcp_discovery.py +342 -0
- alita_sdk/runtime/clients/mcp_manager.py +262 -0
- alita_sdk/runtime/clients/sandbox_client.py +352 -0
- alita_sdk/runtime/langchain/_constants_bkup.py +1318 -0
- alita_sdk/runtime/langchain/assistant.py +183 -43
- alita_sdk/runtime/langchain/constants.py +647 -1
- alita_sdk/runtime/langchain/document_loaders/AlitaDocxMammothLoader.py +315 -3
- alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py +209 -31
- alita_sdk/runtime/langchain/document_loaders/AlitaImageLoader.py +1 -1
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLinesLoader.py +77 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py +10 -3
- alita_sdk/runtime/langchain/document_loaders/AlitaMarkdownLoader.py +66 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaPDFLoader.py +79 -10
- alita_sdk/runtime/langchain/document_loaders/AlitaPowerPointLoader.py +52 -15
- alita_sdk/runtime/langchain/document_loaders/AlitaPythonLoader.py +9 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaTableLoader.py +1 -4
- alita_sdk/runtime/langchain/document_loaders/AlitaTextLoader.py +15 -2
- alita_sdk/runtime/langchain/document_loaders/ImageParser.py +30 -0
- alita_sdk/runtime/langchain/document_loaders/constants.py +189 -41
- alita_sdk/runtime/langchain/interfaces/llm_processor.py +4 -2
- alita_sdk/runtime/langchain/langraph_agent.py +407 -92
- alita_sdk/runtime/langchain/utils.py +102 -8
- alita_sdk/runtime/llms/preloaded.py +2 -6
- alita_sdk/runtime/models/mcp_models.py +61 -0
- alita_sdk/runtime/skills/__init__.py +91 -0
- alita_sdk/runtime/skills/callbacks.py +498 -0
- alita_sdk/runtime/skills/discovery.py +540 -0
- alita_sdk/runtime/skills/executor.py +610 -0
- alita_sdk/runtime/skills/input_builder.py +371 -0
- alita_sdk/runtime/skills/models.py +330 -0
- alita_sdk/runtime/skills/registry.py +355 -0
- alita_sdk/runtime/skills/skill_runner.py +330 -0
- alita_sdk/runtime/toolkits/__init__.py +28 -0
- alita_sdk/runtime/toolkits/application.py +14 -4
- alita_sdk/runtime/toolkits/artifact.py +24 -9
- alita_sdk/runtime/toolkits/datasource.py +13 -6
- alita_sdk/runtime/toolkits/mcp.py +780 -0
- alita_sdk/runtime/toolkits/planning.py +178 -0
- alita_sdk/runtime/toolkits/skill_router.py +238 -0
- alita_sdk/runtime/toolkits/subgraph.py +11 -6
- alita_sdk/runtime/toolkits/tools.py +314 -70
- alita_sdk/runtime/toolkits/vectorstore.py +11 -5
- alita_sdk/runtime/tools/__init__.py +24 -0
- alita_sdk/runtime/tools/application.py +16 -4
- alita_sdk/runtime/tools/artifact.py +367 -33
- alita_sdk/runtime/tools/data_analysis.py +183 -0
- alita_sdk/runtime/tools/function.py +100 -4
- alita_sdk/runtime/tools/graph.py +81 -0
- alita_sdk/runtime/tools/image_generation.py +218 -0
- alita_sdk/runtime/tools/llm.py +1013 -177
- alita_sdk/runtime/tools/loop.py +3 -1
- alita_sdk/runtime/tools/loop_output.py +3 -1
- alita_sdk/runtime/tools/mcp_inspect_tool.py +284 -0
- alita_sdk/runtime/tools/mcp_remote_tool.py +181 -0
- alita_sdk/runtime/tools/mcp_server_tool.py +3 -1
- alita_sdk/runtime/tools/planning/__init__.py +36 -0
- alita_sdk/runtime/tools/planning/models.py +246 -0
- alita_sdk/runtime/tools/planning/wrapper.py +607 -0
- alita_sdk/runtime/tools/router.py +2 -1
- alita_sdk/runtime/tools/sandbox.py +375 -0
- alita_sdk/runtime/tools/skill_router.py +776 -0
- alita_sdk/runtime/tools/tool.py +3 -1
- alita_sdk/runtime/tools/vectorstore.py +69 -65
- alita_sdk/runtime/tools/vectorstore_base.py +163 -90
- alita_sdk/runtime/utils/AlitaCallback.py +137 -21
- alita_sdk/runtime/utils/mcp_client.py +492 -0
- alita_sdk/runtime/utils/mcp_oauth.py +361 -0
- alita_sdk/runtime/utils/mcp_sse_client.py +434 -0
- alita_sdk/runtime/utils/mcp_tools_discovery.py +124 -0
- alita_sdk/runtime/utils/streamlit.py +41 -14
- alita_sdk/runtime/utils/toolkit_utils.py +28 -9
- alita_sdk/runtime/utils/utils.py +48 -0
- alita_sdk/tools/__init__.py +135 -37
- alita_sdk/tools/ado/__init__.py +2 -2
- alita_sdk/tools/ado/repos/__init__.py +15 -19
- alita_sdk/tools/ado/repos/repos_wrapper.py +12 -20
- alita_sdk/tools/ado/test_plan/__init__.py +26 -8
- alita_sdk/tools/ado/test_plan/test_plan_wrapper.py +56 -28
- alita_sdk/tools/ado/wiki/__init__.py +27 -12
- alita_sdk/tools/ado/wiki/ado_wrapper.py +114 -40
- alita_sdk/tools/ado/work_item/__init__.py +27 -12
- alita_sdk/tools/ado/work_item/ado_wrapper.py +95 -11
- alita_sdk/tools/advanced_jira_mining/__init__.py +12 -8
- alita_sdk/tools/aws/delta_lake/__init__.py +14 -11
- alita_sdk/tools/aws/delta_lake/tool.py +5 -1
- alita_sdk/tools/azure_ai/search/__init__.py +13 -8
- alita_sdk/tools/base/tool.py +5 -1
- alita_sdk/tools/base_indexer_toolkit.py +454 -110
- alita_sdk/tools/bitbucket/__init__.py +27 -19
- alita_sdk/tools/bitbucket/api_wrapper.py +285 -27
- alita_sdk/tools/bitbucket/cloud_api_wrapper.py +5 -5
- alita_sdk/tools/browser/__init__.py +41 -16
- alita_sdk/tools/browser/crawler.py +3 -1
- alita_sdk/tools/browser/utils.py +15 -6
- alita_sdk/tools/carrier/__init__.py +18 -17
- alita_sdk/tools/carrier/backend_reports_tool.py +8 -4
- alita_sdk/tools/carrier/excel_reporter.py +8 -4
- alita_sdk/tools/chunkers/__init__.py +3 -1
- alita_sdk/tools/chunkers/code/codeparser.py +1 -1
- alita_sdk/tools/chunkers/sematic/json_chunker.py +2 -1
- alita_sdk/tools/chunkers/sematic/markdown_chunker.py +97 -6
- alita_sdk/tools/chunkers/sematic/proposal_chunker.py +1 -1
- alita_sdk/tools/chunkers/universal_chunker.py +270 -0
- alita_sdk/tools/cloud/aws/__init__.py +11 -7
- alita_sdk/tools/cloud/azure/__init__.py +11 -7
- alita_sdk/tools/cloud/gcp/__init__.py +11 -7
- alita_sdk/tools/cloud/k8s/__init__.py +11 -7
- alita_sdk/tools/code/linter/__init__.py +9 -8
- alita_sdk/tools/code/loaders/codesearcher.py +3 -2
- alita_sdk/tools/code/sonar/__init__.py +20 -13
- alita_sdk/tools/code_indexer_toolkit.py +199 -0
- alita_sdk/tools/confluence/__init__.py +21 -14
- alita_sdk/tools/confluence/api_wrapper.py +197 -58
- alita_sdk/tools/confluence/loader.py +14 -2
- alita_sdk/tools/custom_open_api/__init__.py +11 -5
- alita_sdk/tools/elastic/__init__.py +10 -8
- alita_sdk/tools/elitea_base.py +546 -64
- alita_sdk/tools/figma/__init__.py +11 -8
- alita_sdk/tools/figma/api_wrapper.py +352 -153
- alita_sdk/tools/github/__init__.py +17 -17
- alita_sdk/tools/github/api_wrapper.py +9 -26
- alita_sdk/tools/github/github_client.py +81 -12
- alita_sdk/tools/github/schemas.py +2 -1
- alita_sdk/tools/github/tool.py +5 -1
- alita_sdk/tools/gitlab/__init__.py +18 -13
- alita_sdk/tools/gitlab/api_wrapper.py +224 -80
- alita_sdk/tools/gitlab_org/__init__.py +13 -10
- alita_sdk/tools/google/bigquery/__init__.py +13 -13
- alita_sdk/tools/google/bigquery/tool.py +5 -1
- alita_sdk/tools/google_places/__init__.py +20 -11
- alita_sdk/tools/jira/__init__.py +21 -11
- alita_sdk/tools/jira/api_wrapper.py +315 -168
- alita_sdk/tools/keycloak/__init__.py +10 -8
- alita_sdk/tools/localgit/__init__.py +8 -3
- alita_sdk/tools/localgit/local_git.py +62 -54
- alita_sdk/tools/localgit/tool.py +5 -1
- alita_sdk/tools/memory/__init__.py +38 -14
- alita_sdk/tools/non_code_indexer_toolkit.py +7 -2
- alita_sdk/tools/ocr/__init__.py +10 -8
- alita_sdk/tools/openapi/__init__.py +281 -108
- alita_sdk/tools/openapi/api_wrapper.py +883 -0
- alita_sdk/tools/openapi/tool.py +20 -0
- alita_sdk/tools/pandas/__init__.py +18 -11
- alita_sdk/tools/pandas/api_wrapper.py +40 -45
- alita_sdk/tools/pandas/dataframe/generator/base.py +3 -1
- alita_sdk/tools/postman/__init__.py +10 -11
- alita_sdk/tools/postman/api_wrapper.py +19 -8
- alita_sdk/tools/postman/postman_analysis.py +8 -1
- alita_sdk/tools/pptx/__init__.py +10 -10
- alita_sdk/tools/qtest/__init__.py +21 -14
- alita_sdk/tools/qtest/api_wrapper.py +1784 -88
- alita_sdk/tools/rally/__init__.py +12 -10
- alita_sdk/tools/report_portal/__init__.py +22 -16
- alita_sdk/tools/salesforce/__init__.py +21 -16
- alita_sdk/tools/servicenow/__init__.py +20 -16
- alita_sdk/tools/servicenow/api_wrapper.py +1 -1
- alita_sdk/tools/sharepoint/__init__.py +16 -14
- alita_sdk/tools/sharepoint/api_wrapper.py +179 -39
- alita_sdk/tools/sharepoint/authorization_helper.py +191 -1
- alita_sdk/tools/sharepoint/utils.py +8 -2
- alita_sdk/tools/slack/__init__.py +11 -7
- alita_sdk/tools/sql/__init__.py +21 -19
- alita_sdk/tools/sql/api_wrapper.py +71 -23
- alita_sdk/tools/testio/__init__.py +20 -13
- alita_sdk/tools/testrail/__init__.py +12 -11
- alita_sdk/tools/testrail/api_wrapper.py +214 -46
- alita_sdk/tools/utils/__init__.py +28 -4
- alita_sdk/tools/utils/content_parser.py +182 -62
- alita_sdk/tools/utils/text_operations.py +254 -0
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +83 -27
- alita_sdk/tools/xray/__init__.py +17 -14
- alita_sdk/tools/xray/api_wrapper.py +58 -113
- alita_sdk/tools/yagmail/__init__.py +8 -3
- alita_sdk/tools/zephyr/__init__.py +11 -7
- alita_sdk/tools/zephyr_enterprise/__init__.py +15 -9
- alita_sdk/tools/zephyr_enterprise/api_wrapper.py +30 -15
- alita_sdk/tools/zephyr_essential/__init__.py +15 -10
- alita_sdk/tools/zephyr_essential/api_wrapper.py +297 -54
- alita_sdk/tools/zephyr_essential/client.py +6 -4
- alita_sdk/tools/zephyr_scale/__init__.py +12 -8
- alita_sdk/tools/zephyr_scale/api_wrapper.py +39 -31
- alita_sdk/tools/zephyr_squad/__init__.py +11 -7
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.562.dist-info}/METADATA +184 -37
- alita_sdk-0.3.562.dist-info/RECORD +450 -0
- alita_sdk-0.3.562.dist-info/entry_points.txt +2 -0
- alita_sdk/tools/bitbucket/tools.py +0 -304
- alita_sdk-0.3.257.dist-info/RECORD +0 -343
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.562.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.562.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.562.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cross-file reference pattern detection module.
|
|
3
|
+
|
|
4
|
+
This module provides extensible pattern matching for detecting cross-file
|
|
5
|
+
relationships in various programming languages and document types.
|
|
6
|
+
|
|
7
|
+
Pattern categories:
|
|
8
|
+
- imports: Code import/include statements
|
|
9
|
+
- links: Documentation links (Markdown, Wiki, HTML)
|
|
10
|
+
- citations: Text references ("see X", "@see X", etc.)
|
|
11
|
+
- mentions: Entity name mentions in content
|
|
12
|
+
|
|
13
|
+
Supported approaches:
|
|
14
|
+
1. Regex patterns - Fast, language-agnostic pattern matching
|
|
15
|
+
2. AST parsing - Accurate code analysis using deepwiki parsers (when available)
|
|
16
|
+
|
|
17
|
+
Each pattern file defines patterns for a specific language or document type.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from .registry import PatternRegistry, Pattern, PatternCategory, RelationType
|
|
21
|
+
from .loader import (
|
|
22
|
+
load_all_patterns,
|
|
23
|
+
get_patterns_for_file,
|
|
24
|
+
get_patterns_for_content_type,
|
|
25
|
+
extract_references_from_content,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# AST adapter - provides integration with deepwiki parsers
|
|
29
|
+
from .ast_adapter import (
|
|
30
|
+
is_ast_available,
|
|
31
|
+
get_supported_ast_languages,
|
|
32
|
+
parse_file_ast,
|
|
33
|
+
parse_files_ast,
|
|
34
|
+
extract_ast_cross_file_relations,
|
|
35
|
+
get_symbols_for_entity_matching,
|
|
36
|
+
ASTSymbol,
|
|
37
|
+
ASTRelation,
|
|
38
|
+
ASTParseResult,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
# Pattern system
|
|
43
|
+
'PatternRegistry',
|
|
44
|
+
'Pattern',
|
|
45
|
+
'PatternCategory',
|
|
46
|
+
'RelationType',
|
|
47
|
+
'load_all_patterns',
|
|
48
|
+
'get_patterns_for_file',
|
|
49
|
+
'get_patterns_for_content_type',
|
|
50
|
+
'extract_references_from_content',
|
|
51
|
+
# AST adapter
|
|
52
|
+
'is_ast_available',
|
|
53
|
+
'get_supported_ast_languages',
|
|
54
|
+
'parse_file_ast',
|
|
55
|
+
'parse_files_ast',
|
|
56
|
+
'extract_ast_cross_file_relations',
|
|
57
|
+
'get_symbols_for_entity_matching',
|
|
58
|
+
'ASTSymbol',
|
|
59
|
+
'ASTRelation',
|
|
60
|
+
'ASTParseResult',
|
|
61
|
+
]
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AST Adapter - Bridge between parsers module and patterns module.
|
|
3
|
+
|
|
4
|
+
This module provides a unified interface for AST-based code analysis,
|
|
5
|
+
integrating with the local parsers module for first-pass extraction.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Dict, List, Any, Optional, Set, Tuple
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
import logging
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
|
|
13
|
+
# Import from local parsers module (self-contained, no external dependencies)
|
|
14
|
+
from ..parsers import (
|
|
15
|
+
parser_registry,
|
|
16
|
+
parse_file,
|
|
17
|
+
parse_files,
|
|
18
|
+
get_parser_for_file,
|
|
19
|
+
ParseResult,
|
|
20
|
+
Symbol,
|
|
21
|
+
Relationship,
|
|
22
|
+
RelationshipType,
|
|
23
|
+
SymbolType,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
# Type aliases for compatibility with patterns module
|
|
29
|
+
ASTSymbol = Symbol
|
|
30
|
+
ASTRelation = Relationship
|
|
31
|
+
ASTParseResult = ParseResult
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def is_ast_available() -> bool:
|
|
35
|
+
"""
|
|
36
|
+
Check if AST parsing is available.
|
|
37
|
+
|
|
38
|
+
Since we use the local parsers module with Python's built-in ast
|
|
39
|
+
and regex patterns, this is always available.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
True - AST parsing is always available
|
|
43
|
+
"""
|
|
44
|
+
return True
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_supported_languages() -> List[str]:
|
|
48
|
+
"""
|
|
49
|
+
Get list of supported programming languages.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
List of language identifiers
|
|
53
|
+
"""
|
|
54
|
+
return parser_registry.get_supported_languages()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def get_supported_ast_languages() -> List[str]:
|
|
58
|
+
"""
|
|
59
|
+
Get list of supported programming languages for AST parsing.
|
|
60
|
+
|
|
61
|
+
Alias for get_supported_languages() for compatibility with patterns module.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
List of language identifiers
|
|
65
|
+
"""
|
|
66
|
+
return get_supported_languages()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_supported_extensions() -> List[str]:
|
|
70
|
+
"""
|
|
71
|
+
Get list of supported file extensions.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
List of file extensions (with dot prefix)
|
|
75
|
+
"""
|
|
76
|
+
return parser_registry.get_supported_extensions()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def parse_file_ast(
|
|
80
|
+
file_path: str,
|
|
81
|
+
content: Optional[str] = None
|
|
82
|
+
) -> Optional[ParseResult]:
|
|
83
|
+
"""
|
|
84
|
+
Parse a single file and extract symbols and relationships.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
file_path: Path to the file to parse
|
|
88
|
+
content: Optional file content (if not provided, will read from disk)
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
ParseResult with symbols and relationships, or None if parsing fails
|
|
92
|
+
"""
|
|
93
|
+
try:
|
|
94
|
+
return parse_file(file_path, content)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
logger.warning(f"Failed to parse {file_path}: {e}")
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def parse_files_ast(
|
|
101
|
+
file_paths: List[str],
|
|
102
|
+
file_contents: Optional[Dict[str, str]] = None,
|
|
103
|
+
resolve_cross_file: bool = True,
|
|
104
|
+
max_workers: int = 4
|
|
105
|
+
) -> Dict[str, ParseResult]:
|
|
106
|
+
"""
|
|
107
|
+
Parse multiple files with optional cross-file resolution.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
file_paths: List of file paths to parse
|
|
111
|
+
file_contents: Optional dict mapping file paths to content
|
|
112
|
+
resolve_cross_file: Whether to resolve cross-file references
|
|
113
|
+
max_workers: Maximum number of parallel workers
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Dict mapping file paths to ParseResult objects
|
|
117
|
+
"""
|
|
118
|
+
results = {}
|
|
119
|
+
|
|
120
|
+
# Group files by language
|
|
121
|
+
files_by_language: Dict[str, List[Tuple[str, Optional[str]]]] = {}
|
|
122
|
+
|
|
123
|
+
for file_path in file_paths:
|
|
124
|
+
parser = get_parser_for_file(file_path)
|
|
125
|
+
if parser:
|
|
126
|
+
lang = parser.language
|
|
127
|
+
if lang not in files_by_language:
|
|
128
|
+
files_by_language[lang] = []
|
|
129
|
+
content = file_contents.get(file_path) if file_contents else None
|
|
130
|
+
files_by_language[lang].append((file_path, content))
|
|
131
|
+
|
|
132
|
+
# Parse each language group
|
|
133
|
+
for lang, files in files_by_language.items():
|
|
134
|
+
parser = parser_registry.get_parser(lang)
|
|
135
|
+
if parser and hasattr(parser, 'parse_multiple_files'):
|
|
136
|
+
try:
|
|
137
|
+
lang_results = parser.parse_multiple_files(
|
|
138
|
+
files,
|
|
139
|
+
resolve_cross_file=resolve_cross_file,
|
|
140
|
+
max_workers=max_workers
|
|
141
|
+
)
|
|
142
|
+
results.update(lang_results)
|
|
143
|
+
except Exception as e:
|
|
144
|
+
logger.warning(f"Failed to parse {lang} files: {e}")
|
|
145
|
+
# Fall back to individual parsing
|
|
146
|
+
for file_path, content in files:
|
|
147
|
+
result = parse_file_ast(file_path, content)
|
|
148
|
+
if result:
|
|
149
|
+
results[file_path] = result
|
|
150
|
+
else:
|
|
151
|
+
# Individual parsing fallback
|
|
152
|
+
for file_path, content in files:
|
|
153
|
+
result = parse_file_ast(file_path, content)
|
|
154
|
+
if result:
|
|
155
|
+
results[file_path] = result
|
|
156
|
+
|
|
157
|
+
return results
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def extract_ast_cross_file_relations(
|
|
161
|
+
parse_results: Dict[str, ParseResult]
|
|
162
|
+
) -> List[Dict[str, Any]]:
|
|
163
|
+
"""
|
|
164
|
+
Extract cross-file relationships from parse results.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
parse_results: Dict mapping file paths to ParseResult objects
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
List of relationship dictionaries with source_file, target_file, etc.
|
|
171
|
+
"""
|
|
172
|
+
cross_file_relations = []
|
|
173
|
+
|
|
174
|
+
# Build symbol index
|
|
175
|
+
symbol_to_file: Dict[str, str] = {}
|
|
176
|
+
for file_path, result in parse_results.items():
|
|
177
|
+
for symbol in result.symbols:
|
|
178
|
+
symbol_to_file[symbol.name] = file_path
|
|
179
|
+
if symbol.qualified_name:
|
|
180
|
+
symbol_to_file[symbol.qualified_name] = file_path
|
|
181
|
+
|
|
182
|
+
# Find cross-file relationships
|
|
183
|
+
for file_path, result in parse_results.items():
|
|
184
|
+
for rel in result.relationships:
|
|
185
|
+
target_file = symbol_to_file.get(rel.target)
|
|
186
|
+
if target_file and target_file != file_path:
|
|
187
|
+
cross_file_relations.append({
|
|
188
|
+
'source_file': file_path,
|
|
189
|
+
'source': rel.source,
|
|
190
|
+
'target_file': target_file,
|
|
191
|
+
'target': rel.target,
|
|
192
|
+
'relationship_type': rel.relationship_type.value,
|
|
193
|
+
'metadata': rel.metadata
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
return cross_file_relations
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def extract_first_pass_entities(
|
|
200
|
+
file_path: str,
|
|
201
|
+
content: str
|
|
202
|
+
) -> List[Dict[str, Any]]:
|
|
203
|
+
"""
|
|
204
|
+
Extract entities (symbols) from a file for first-pass processing.
|
|
205
|
+
|
|
206
|
+
This is a non-LLM based extraction using AST/regex patterns.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
file_path: Path to the file
|
|
210
|
+
content: File content
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
List of entity dictionaries
|
|
214
|
+
"""
|
|
215
|
+
result = parse_file_ast(file_path, content)
|
|
216
|
+
if not result:
|
|
217
|
+
return []
|
|
218
|
+
|
|
219
|
+
entities = []
|
|
220
|
+
for symbol in result.symbols:
|
|
221
|
+
entity = {
|
|
222
|
+
'name': symbol.name,
|
|
223
|
+
'type': symbol.symbol_type.value,
|
|
224
|
+
'file_path': file_path,
|
|
225
|
+
'line_start': symbol.line_start,
|
|
226
|
+
'line_end': symbol.line_end,
|
|
227
|
+
'qualified_name': symbol.qualified_name,
|
|
228
|
+
}
|
|
229
|
+
if symbol.docstring:
|
|
230
|
+
entity['docstring'] = symbol.docstring
|
|
231
|
+
if symbol.metadata:
|
|
232
|
+
entity['metadata'] = symbol.metadata
|
|
233
|
+
entities.append(entity)
|
|
234
|
+
|
|
235
|
+
return entities
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def extract_first_pass_relations(
|
|
239
|
+
file_path: str,
|
|
240
|
+
content: str
|
|
241
|
+
) -> List[Dict[str, Any]]:
|
|
242
|
+
"""
|
|
243
|
+
Extract relationships from a file for first-pass processing.
|
|
244
|
+
|
|
245
|
+
This is a non-LLM based extraction using AST/regex patterns.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
file_path: Path to the file
|
|
249
|
+
content: File content
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
List of relationship dictionaries
|
|
253
|
+
"""
|
|
254
|
+
result = parse_file_ast(file_path, content)
|
|
255
|
+
if not result:
|
|
256
|
+
return []
|
|
257
|
+
|
|
258
|
+
relations = []
|
|
259
|
+
for rel in result.relationships:
|
|
260
|
+
relation = {
|
|
261
|
+
'source': rel.source,
|
|
262
|
+
'target': rel.target,
|
|
263
|
+
'relationship_type': rel.relationship_type.value,
|
|
264
|
+
'file_path': file_path,
|
|
265
|
+
'line': rel.line,
|
|
266
|
+
}
|
|
267
|
+
if rel.metadata:
|
|
268
|
+
relation['metadata'] = rel.metadata
|
|
269
|
+
relations.append(relation)
|
|
270
|
+
|
|
271
|
+
return relations
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def get_file_summary(
|
|
275
|
+
file_path: str,
|
|
276
|
+
content: str
|
|
277
|
+
) -> Dict[str, Any]:
|
|
278
|
+
"""
|
|
279
|
+
Get a summary of a file's structure.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
file_path: Path to the file
|
|
283
|
+
content: File content
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
Summary dictionary with counts and top-level items
|
|
287
|
+
"""
|
|
288
|
+
result = parse_file_ast(file_path, content)
|
|
289
|
+
if not result:
|
|
290
|
+
return {
|
|
291
|
+
'file_path': file_path,
|
|
292
|
+
'language': 'unknown',
|
|
293
|
+
'symbols': [],
|
|
294
|
+
'relationships': [],
|
|
295
|
+
'counts': {}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
# Count by type
|
|
299
|
+
symbol_counts: Dict[str, int] = {}
|
|
300
|
+
for symbol in result.symbols:
|
|
301
|
+
type_name = symbol.symbol_type.value
|
|
302
|
+
symbol_counts[type_name] = symbol_counts.get(type_name, 0) + 1
|
|
303
|
+
|
|
304
|
+
rel_counts: Dict[str, int] = {}
|
|
305
|
+
for rel in result.relationships:
|
|
306
|
+
type_name = rel.relationship_type.value
|
|
307
|
+
rel_counts[type_name] = rel_counts.get(type_name, 0) + 1
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
'file_path': file_path,
|
|
311
|
+
'language': result.language,
|
|
312
|
+
'symbols': [s.name for s in result.symbols],
|
|
313
|
+
'relationships': len(result.relationships),
|
|
314
|
+
'counts': {
|
|
315
|
+
'symbols': symbol_counts,
|
|
316
|
+
'relationships': rel_counts
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def get_symbols_for_entity_matching(
|
|
322
|
+
parse_results: Dict[str, ParseResult]
|
|
323
|
+
) -> Dict[str, List[Dict[str, Any]]]:
|
|
324
|
+
"""
|
|
325
|
+
Get symbols formatted for entity matching.
|
|
326
|
+
|
|
327
|
+
This function extracts symbols from parse results and formats them
|
|
328
|
+
for use in entity matching algorithms.
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
parse_results: Dict mapping file paths to ParseResult objects
|
|
332
|
+
|
|
333
|
+
Returns:
|
|
334
|
+
Dict mapping file paths to lists of symbol dictionaries
|
|
335
|
+
"""
|
|
336
|
+
result = {}
|
|
337
|
+
for file_path, parse_result in parse_results.items():
|
|
338
|
+
symbols = []
|
|
339
|
+
for symbol in parse_result.symbols:
|
|
340
|
+
symbols.append({
|
|
341
|
+
'name': symbol.name,
|
|
342
|
+
'type': symbol.symbol_type.value,
|
|
343
|
+
'full_name': symbol.full_name or symbol.get_qualified_name(),
|
|
344
|
+
'file_path': symbol.file_path,
|
|
345
|
+
'visibility': symbol.visibility,
|
|
346
|
+
'docstring': symbol.docstring,
|
|
347
|
+
'range': {
|
|
348
|
+
'start_line': symbol.range.start.line,
|
|
349
|
+
'end_line': symbol.range.end.line
|
|
350
|
+
} if symbol.range else None,
|
|
351
|
+
'metadata': symbol.metadata
|
|
352
|
+
})
|
|
353
|
+
result[file_path] = symbols
|
|
354
|
+
return result
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
# Export key functions and types
|
|
358
|
+
__all__ = [
|
|
359
|
+
'is_ast_available',
|
|
360
|
+
'get_supported_languages',
|
|
361
|
+
'get_supported_ast_languages',
|
|
362
|
+
'get_supported_extensions',
|
|
363
|
+
'parse_file_ast',
|
|
364
|
+
'parse_files_ast',
|
|
365
|
+
'extract_ast_cross_file_relations',
|
|
366
|
+
'extract_first_pass_entities',
|
|
367
|
+
'extract_first_pass_relations',
|
|
368
|
+
'get_file_summary',
|
|
369
|
+
'get_symbols_for_entity_matching',
|
|
370
|
+
# Type aliases
|
|
371
|
+
'ASTSymbol',
|
|
372
|
+
'ASTRelation',
|
|
373
|
+
'ASTParseResult',
|
|
374
|
+
# Re-export types
|
|
375
|
+
'ParseResult',
|
|
376
|
+
'Symbol',
|
|
377
|
+
'Relationship',
|
|
378
|
+
'RelationshipType',
|
|
379
|
+
'SymbolType',
|
|
380
|
+
]
|