attocode-code-intel 0.1.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.
- attocode_code_intel-0.1.0.dist-info/METADATA +221 -0
- attocode_code_intel-0.1.0.dist-info/RECORD +345 -0
- attocode_code_intel-0.1.0.dist-info/WHEEL +4 -0
- attocode_code_intel-0.1.0.dist-info/entry_points.txt +2 -0
- attocode_code_intel-0.1.0.dist-info/licenses/LICENSE +21 -0
- attocode_intel/GUIDELINES.md +432 -0
- attocode_intel/__init__.py +52 -0
- attocode_intel/_internal/__init__.py +1 -0
- attocode_intel/_internal/errors/__init__.py +126 -0
- attocode_intel/_internal/integrations/__init__.py +1 -0
- attocode_intel/_internal/integrations/context/__init__.py +1 -0
- attocode_intel/_internal/integrations/context/architecture_drift.py +354 -0
- attocode_intel/_internal/integrations/context/ast_chunker.py +202 -0
- attocode_intel/_internal/integrations/context/ast_service.py +1483 -0
- attocode_intel/_internal/integrations/context/blob_oid.py +423 -0
- attocode_intel/_internal/integrations/context/cache_manifest.py +221 -0
- attocode_intel/_internal/integrations/context/cas.py +466 -0
- attocode_intel/_internal/integrations/context/code_analyzer.py +528 -0
- attocode_intel/_internal/integrations/context/codebase_ast.py +1461 -0
- attocode_intel/_internal/integrations/context/codebase_context.py +1736 -0
- attocode_intel/_internal/integrations/context/cross_mode.py +263 -0
- attocode_intel/_internal/integrations/context/cross_references.py +616 -0
- attocode_intel/_internal/integrations/context/embedding_rotation.py +597 -0
- attocode_intel/_internal/integrations/context/embeddings.py +282 -0
- attocode_intel/_internal/integrations/context/frecency.py +427 -0
- attocode_intel/_internal/integrations/context/fuzzy.py +320 -0
- attocode_intel/_internal/integrations/context/hierarchical_explorer.py +331 -0
- attocode_intel/_internal/integrations/context/hydration.py +90 -0
- attocode_intel/_internal/integrations/context/index_repair.py +87 -0
- attocode_intel/_internal/integrations/context/index_store.py +586 -0
- attocode_intel/_internal/integrations/context/memory_store.py +602 -0
- attocode_intel/_internal/integrations/context/module_resolution.py +52 -0
- attocode_intel/_internal/integrations/context/query_constraints.py +361 -0
- attocode_intel/_internal/integrations/context/query_history.py +417 -0
- attocode_intel/_internal/integrations/context/reranker.py +351 -0
- attocode_intel/_internal/integrations/context/semantic_search.py +2931 -0
- attocode_intel/_internal/integrations/context/syntax_evidence.py +94 -0
- attocode_intel/_internal/integrations/context/systemone_ranker.py +245 -0
- attocode_intel/_internal/integrations/context/temporal_coupling.py +411 -0
- attocode_intel/_internal/integrations/context/trigram_index.py +820 -0
- attocode_intel/_internal/integrations/context/trigram_regex.py +171 -0
- attocode_intel/_internal/integrations/context/ts_parser.py +2199 -0
- attocode_intel/_internal/integrations/context/vector_store.py +795 -0
- attocode_intel/_internal/integrations/feature_flags/__init__.py +357 -0
- attocode_intel/_internal/integrations/lsp/__init__.py +1 -0
- attocode_intel/_internal/integrations/lsp/client.py +1140 -0
- attocode_intel/_internal/integrations/mcp/__init__.py +1 -0
- attocode_intel/_internal/integrations/mcp/client.py +253 -0
- attocode_intel/_internal/integrations/security/__init__.py +1 -0
- attocode_intel/_internal/integrations/security/custom_rules.py +176 -0
- attocode_intel/_internal/integrations/security/dataflow.py +522 -0
- attocode_intel/_internal/integrations/security/dependency_audit.py +303 -0
- attocode_intel/_internal/integrations/security/matcher.py +44 -0
- attocode_intel/_internal/integrations/security/patterns.py +724 -0
- attocode_intel/_internal/integrations/security/scanner.py +351 -0
- attocode_intel/_internal/integrations/utilities/__init__.py +1 -0
- attocode_intel/_internal/integrations/utilities/ignore.py +64 -0
- attocode_intel/_internal/integrations/utilities/token_estimate.py +51 -0
- attocode_intel/_internal/tricks/__init__.py +1 -0
- attocode_intel/_internal/tricks/recursive_context.py +357 -0
- attocode_intel/_internal/types/__init__.py +1 -0
- attocode_intel/_internal/types/events.py +289 -0
- attocode_intel/_internal/types/severity.py +15 -0
- attocode_intel/_shared.py +341 -0
- attocode_intel/analysis_coverage.py +56 -0
- attocode_intel/api/__init__.py +1 -0
- attocode_intel/api/access.py +32 -0
- attocode_intel/api/app.py +247 -0
- attocode_intel/api/auth/__init__.py +128 -0
- attocode_intel/api/auth/api_keys.py +61 -0
- attocode_intel/api/auth/context.py +34 -0
- attocode_intel/api/auth/jwt.py +66 -0
- attocode_intel/api/auth/oauth.py +146 -0
- attocode_intel/api/auth/passwords.py +15 -0
- attocode_intel/api/deps.py +351 -0
- attocode_intel/api/knowledge_bridge.py +13 -0
- attocode_intel/api/mcp_transport.py +51 -0
- attocode_intel/api/middleware.py +411 -0
- attocode_intel/api/models.py +698 -0
- attocode_intel/api/providers/__init__.py +1 -0
- attocode_intel/api/providers/db_provider.py +1106 -0
- attocode_intel/api/providers/local_provider.py +476 -0
- attocode_intel/api/providers/remote_provider.py +740 -0
- attocode_intel/api/repository_source.py +21 -0
- attocode_intel/api/routes/__init__.py +1 -0
- attocode_intel/api/routes/_pin_helper.py +158 -0
- attocode_intel/api/routes/activity.py +148 -0
- attocode_intel/api/routes/adr.py +102 -0
- attocode_intel/api/routes/analysis.py +515 -0
- attocode_intel/api/routes/api_keys.py +170 -0
- attocode_intel/api/routes/auth.py +428 -0
- attocode_intel/api/routes/branches.py +262 -0
- attocode_intel/api/routes/cross_repo_search.py +198 -0
- attocode_intel/api/routes/embeddings.py +386 -0
- attocode_intel/api/routes/files.py +132 -0
- attocode_intel/api/routes/files_v2.py +388 -0
- attocode_intel/api/routes/gc.py +322 -0
- attocode_intel/api/routes/git_v2.py +433 -0
- attocode_intel/api/routes/graph.py +174 -0
- attocode_intel/api/routes/graph_viz.py +160 -0
- attocode_intel/api/routes/health.py +62 -0
- attocode_intel/api/routes/history.py +175 -0
- attocode_intel/api/routes/jobs.py +84 -0
- attocode_intel/api/routes/learning.py +205 -0
- attocode_intel/api/routes/lsp.py +272 -0
- attocode_intel/api/routes/notify.py +623 -0
- attocode_intel/api/routes/operations.py +27 -0
- attocode_intel/api/routes/orgs.py +924 -0
- attocode_intel/api/routes/preferences.py +100 -0
- attocode_intel/api/routes/presence.py +42 -0
- attocode_intel/api/routes/projects.py +116 -0
- attocode_intel/api/routes/repos.py +47 -0
- attocode_intel/api/routes/search.py +180 -0
- attocode_intel/api/routes/snapshots.py +614 -0
- attocode_intel/api/routes/webhooks.py +313 -0
- attocode_intel/api/routes/websocket.py +116 -0
- attocode_intel/api/static/graph.html +239 -0
- attocode_intel/api/utils.py +96 -0
- attocode_intel/artifacts/__init__.py +45 -0
- attocode_intel/artifacts/hashing.py +230 -0
- attocode_intel/artifacts/provenance.py +190 -0
- attocode_intel/artifacts/retrieval_pin.py +159 -0
- attocode_intel/audit.py +59 -0
- attocode_intel/bug_finder.py +206 -0
- attocode_intel/bundle.py +80 -0
- attocode_intel/catalog.py +242 -0
- attocode_intel/change_review.py +75 -0
- attocode_intel/cli.py +3062 -0
- attocode_intel/community.py +63 -0
- attocode_intel/confidence/__init__.py +144 -0
- attocode_intel/confidence/jev.py +234 -0
- attocode_intel/confidence/llm.py +330 -0
- attocode_intel/confidence/redact.py +44 -0
- attocode_intel/confidence/settings.py +74 -0
- attocode_intel/config.py +256 -0
- attocode_intel/crypto.py +31 -0
- attocode_intel/db/__init__.py +7 -0
- attocode_intel/db/base.py +33 -0
- attocode_intel/db/engine.py +61 -0
- attocode_intel/db/models.py +529 -0
- attocode_intel/entrypoint.py +185 -0
- attocode_intel/focused_evidence.py +130 -0
- attocode_intel/freshness.py +154 -0
- attocode_intel/gateway.py +734 -0
- attocode_intel/git/__init__.py +7 -0
- attocode_intel/git/credentials.py +75 -0
- attocode_intel/git/manager.py +493 -0
- attocode_intel/git/models.py +96 -0
- attocode_intel/git/storage.py +98 -0
- attocode_intel/graph_query_parser.py +761 -0
- attocode_intel/helpers.py +712 -0
- attocode_intel/indexing/__init__.py +29 -0
- attocode_intel/indexing/debouncer.py +136 -0
- attocode_intel/indexing/delta_indexer.py +151 -0
- attocode_intel/indexing/full_indexer.py +323 -0
- attocode_intel/indexing/incremental.py +240 -0
- attocode_intel/indexing/parser.py +403 -0
- attocode_intel/indexing/summarizer.py +264 -0
- attocode_intel/installer.py +1896 -0
- attocode_intel/knowledge.py +269 -0
- attocode_intel/local_knowledge.py +77 -0
- attocode_intel/migrations/alembic.ini +36 -0
- attocode_intel/migrations/env.py +71 -0
- attocode_intel/migrations/script.py.mako +27 -0
- attocode_intel/migrations/versions/001_initial_schema.py +219 -0
- attocode_intel/migrations/versions/002_branch_version_and_embeddings.py +61 -0
- attocode_intel/migrations/versions/003_embedding_uniqueness_and_cascade.py +51 -0
- attocode_intel/migrations/versions/004_audit_events.py +38 -0
- attocode_intel/migrations/versions/005_user_preferences.py +30 -0
- attocode_intel/migrations/versions/006_google_oauth.py +27 -0
- attocode_intel/migrations/versions/007_pgvector_embeddings.py +28 -0
- attocode_intel/migrations/versions/008_symbol_references.py +37 -0
- attocode_intel/migrations/versions/009_webhook_secret_encryption.py +25 -0
- attocode_intel/migrations/versions/010_add_commits_table.py +40 -0
- attocode_intel/migrations/versions/011_commit_changed_files.py +25 -0
- attocode_intel/migrations/versions/012_branch_merged_at.py +25 -0
- attocode_intel/migrations/versions/013_revoked_tokens.py +32 -0
- attocode_intel/migrations/versions/014_blame_hunks.py +40 -0
- attocode_intel/migrations/versions/015_commit_file_stats.py +40 -0
- attocode_intel/migrations/versions/016_embedding_provenance_columns.py +179 -0
- attocode_intel/migrations/versions/017_provenance_table.py +102 -0
- attocode_intel/migrations/versions/018_repo_snapshots.py +178 -0
- attocode_intel/migrations/versions/019_symref_caller.py +42 -0
- attocode_intel/migrations/versions/020_shared_knowledge.py +29 -0
- attocode_intel/onboarding.py +258 -0
- attocode_intel/output.py +178 -0
- attocode_intel/precision.py +133 -0
- attocode_intel/presence.py +160 -0
- attocode_intel/probe.py +110 -0
- attocode_intel/project_dir.py +97 -0
- attocode_intel/pubsub.py +113 -0
- attocode_intel/query_ranking.py +242 -0
- attocode_intel/readiness.py +972 -0
- attocode_intel/redis.py +51 -0
- attocode_intel/reference_pages.py +60 -0
- attocode_intel/remote.py +131 -0
- attocode_intel/repo_ranker.py +246 -0
- attocode_intel/request_context.py +82 -0
- attocode_intel/rules/__init__.py +28 -0
- attocode_intel/rules/ci.py +320 -0
- attocode_intel/rules/combinators.py +293 -0
- attocode_intel/rules/enricher.py +127 -0
- attocode_intel/rules/evolution.py +452 -0
- attocode_intel/rules/executor.py +531 -0
- attocode_intel/rules/filters/__init__.py +5 -0
- attocode_intel/rules/filters/pipeline.py +151 -0
- attocode_intel/rules/formatter.py +198 -0
- attocode_intel/rules/hygiene.py +242 -0
- attocode_intel/rules/importers/__init__.py +1 -0
- attocode_intel/rules/importers/semgrep.py +382 -0
- attocode_intel/rules/loader.py +292 -0
- attocode_intel/rules/marketplace.py +375 -0
- attocode_intel/rules/metavar.py +181 -0
- attocode_intel/rules/model.py +317 -0
- attocode_intel/rules/packs/__init__.py +1 -0
- attocode_intel/rules/packs/community/_license_templates/Apache-2.0.txt +176 -0
- attocode_intel/rules/packs/community/_license_templates/MIT.txt +21 -0
- attocode_intel/rules/packs/community/bandit-python/LICENSE +176 -0
- attocode_intel/rules/packs/community/bandit-python/NOTICE +13 -0
- attocode_intel/rules/packs/community/bandit-python/PORTING.md +23 -0
- attocode_intel/rules/packs/community/bandit-python/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B105-hardcoded-password.yaml +23 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B303-weak-md5.yaml +21 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B304-weak-des.yaml +20 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B307-use-of-eval.yaml +22 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B324-weak-sha1.yaml +21 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B501-no-cert-validation.yaml +23 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B602-shell-true.yaml +22 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B608-sqli.yaml +22 -0
- attocode_intel/rules/packs/community/eslint-typescript/LICENSE +21 -0
- attocode_intel/rules/packs/community/eslint-typescript/NOTICE +13 -0
- attocode_intel/rules/packs/community/eslint-typescript/PORTING.md +23 -0
- attocode_intel/rules/packs/community/eslint-typescript/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/eqeqeq.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-eval.yaml +22 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-implied-eval.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-new-func.yaml +21 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-throw-literal.yaml +19 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-var.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-with.yaml +18 -0
- attocode_intel/rules/packs/community/gosec-go/LICENSE +176 -0
- attocode_intel/rules/packs/community/gosec-go/NOTICE +13 -0
- attocode_intel/rules/packs/community/gosec-go/PORTING.md +23 -0
- attocode_intel/rules/packs/community/gosec-go/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G101-hardcoded-credentials.yaml +22 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G102-bind-all-interfaces.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G103-unsafe-block.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G201-sql-format.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G304-file-inclusion.yaml +23 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G401-weak-cipher.yaml +20 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G402-tls-min-version.yaml +20 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G501-md5-import.yaml +21 -0
- attocode_intel/rules/packs/examples/cpp/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/cpp/rules/security.yaml +90 -0
- attocode_intel/rules/packs/examples/cpp/rules/structural.yaml +42 -0
- attocode_intel/rules/packs/examples/csharp/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/csharp/rules/security.yaml +69 -0
- attocode_intel/rules/packs/examples/csharp/rules/structural.yaml +42 -0
- attocode_intel/rules/packs/examples/go/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/go/rules/performance.yaml +136 -0
- attocode_intel/rules/packs/examples/go/rules/security.yaml +48 -0
- attocode_intel/rules/packs/examples/go/rules/structural.yaml +58 -0
- attocode_intel/rules/packs/examples/go/taint/sanitizers.yaml +24 -0
- attocode_intel/rules/packs/examples/go/taint/sinks.yaml +51 -0
- attocode_intel/rules/packs/examples/go/taint/sources.yaml +26 -0
- attocode_intel/rules/packs/examples/java/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/java/rules/correctness.yaml +55 -0
- attocode_intel/rules/packs/examples/java/rules/structural.yaml +48 -0
- attocode_intel/rules/packs/examples/java/taint/sinks.yaml +37 -0
- attocode_intel/rules/packs/examples/java/taint/sources.yaml +21 -0
- attocode_intel/rules/packs/examples/kotlin/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/kotlin/rules/correctness.yaml +50 -0
- attocode_intel/rules/packs/examples/kotlin/rules/structural.yaml +38 -0
- attocode_intel/rules/packs/examples/php/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/php/rules/security.yaml +66 -0
- attocode_intel/rules/packs/examples/php/rules/structural.yaml +41 -0
- attocode_intel/rules/packs/examples/python/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/python/rules/performance.yaml +90 -0
- attocode_intel/rules/packs/examples/python/rules/structural.yaml +55 -0
- attocode_intel/rules/packs/examples/ruby/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/ruby/rules/security.yaml +73 -0
- attocode_intel/rules/packs/examples/ruby/rules/structural.yaml +41 -0
- attocode_intel/rules/packs/examples/rust/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/rust/rules/correctness.yaml +51 -0
- attocode_intel/rules/packs/examples/rust/rules/structural.yaml +49 -0
- attocode_intel/rules/packs/examples/typescript/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/typescript/rules/performance.yaml +70 -0
- attocode_intel/rules/packs/examples/typescript/rules/structural.yaml +48 -0
- attocode_intel/rules/packs/pack_loader.py +244 -0
- attocode_intel/rules/plugins/__init__.py +1 -0
- attocode_intel/rules/plugins/plugin_loader.py +132 -0
- attocode_intel/rules/profiling.py +332 -0
- attocode_intel/rules/registry.py +213 -0
- attocode_intel/rules/sarif.py +187 -0
- attocode_intel/rules/synthesis.py +420 -0
- attocode_intel/rules/testing.py +326 -0
- attocode_intel/server.py +734 -0
- attocode_intel/service.py +3416 -0
- attocode_intel/sharing.py +57 -0
- attocode_intel/storage/__init__.py +6 -0
- attocode_intel/storage/branch_overlay.py +352 -0
- attocode_intel/storage/content_store.py +220 -0
- attocode_intel/storage/dependency_store.py +143 -0
- attocode_intel/storage/diff_engine.py +187 -0
- attocode_intel/storage/embedding_store.py +594 -0
- attocode_intel/storage/provenance_store.py +137 -0
- attocode_intel/storage/security_scanner_db.py +164 -0
- attocode_intel/storage/symbol_store.py +160 -0
- attocode_intel/structural_evidence.py +144 -0
- attocode_intel/symbol_inspection.py +141 -0
- attocode_intel/symbol_links.py +167 -0
- attocode_intel/telemetry.py +42 -0
- attocode_intel/test_ranking.py +73 -0
- attocode_intel/testing/__init__.py +43 -0
- attocode_intel/testing/fixtures.py +122 -0
- attocode_intel/testing/helpers.py +75 -0
- attocode_intel/testing/mocks.py +99 -0
- attocode_intel/tools/__init__.py +2 -0
- attocode_intel/tools/adr_tools.py +628 -0
- attocode_intel/tools/analysis_tools.py +382 -0
- attocode_intel/tools/composite_tools.py +695 -0
- attocode_intel/tools/cross_mode_tools.py +173 -0
- attocode_intel/tools/dead_code_tools.py +582 -0
- attocode_intel/tools/distill_tools.py +353 -0
- attocode_intel/tools/frecency_tools.py +220 -0
- attocode_intel/tools/fuzzy_tools.py +255 -0
- attocode_intel/tools/history_tools.py +486 -0
- attocode_intel/tools/learning_tools.py +222 -0
- attocode_intel/tools/lsp_tools.py +218 -0
- attocode_intel/tools/maintenance_tools.py +1662 -0
- attocode_intel/tools/navigation_tools.py +220 -0
- attocode_intel/tools/overlay_tools.py +540 -0
- attocode_intel/tools/pin_store.py +432 -0
- attocode_intel/tools/pin_tools.py +266 -0
- attocode_intel/tools/query_constraints_tools.py +262 -0
- attocode_intel/tools/query_history_tools.py +158 -0
- attocode_intel/tools/readiness_tools.py +44 -0
- attocode_intel/tools/rule_tools.py +992 -0
- attocode_intel/tools/search_tools.py +770 -0
- attocode_intel/tools/snapshot_tools.py +624 -0
- attocode_intel/workers/__init__.py +1 -0
- attocode_intel/workers/job_utils.py +111 -0
- attocode_intel/workers/jobs.py +573 -0
- attocode_intel/workers/run.py +30 -0
- attocode_intel/workers/settings.py +61 -0
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
"""Remote-mode providers — proxy MCP and HTTP calls through the HTTP API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RemoteClient:
|
|
12
|
+
"""HTTP client for the remote code-intel API."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, server: str, token: str, repo_id: str) -> None:
|
|
15
|
+
import httpx
|
|
16
|
+
self._server = server.rstrip("/")
|
|
17
|
+
self._repo_id = repo_id
|
|
18
|
+
self._client = httpx.AsyncClient(
|
|
19
|
+
base_url=self._server,
|
|
20
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
21
|
+
timeout=30,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
async def get(self, path: str, **kwargs) -> dict:
|
|
25
|
+
resp = await self._client.get(path, **kwargs)
|
|
26
|
+
resp.raise_for_status()
|
|
27
|
+
return resp.json()
|
|
28
|
+
|
|
29
|
+
async def post(self, path: str, **kwargs) -> dict:
|
|
30
|
+
resp = await self._client.post(path, **kwargs)
|
|
31
|
+
resp.raise_for_status()
|
|
32
|
+
return resp.json()
|
|
33
|
+
|
|
34
|
+
async def close(self) -> None:
|
|
35
|
+
await self._client.aclose()
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def repo_id(self) -> str:
|
|
39
|
+
return self._repo_id
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RemoteTextService:
|
|
43
|
+
"""Sync/async text-oriented proxy used by MCP remote mode."""
|
|
44
|
+
|
|
45
|
+
__slots__ = ("_server", "_repo_id", "_headers", "_client")
|
|
46
|
+
|
|
47
|
+
def __init__(self, server: str, token: str, repo_id: str) -> None:
|
|
48
|
+
import httpx
|
|
49
|
+
|
|
50
|
+
self._server = server.rstrip("/")
|
|
51
|
+
self._repo_id = repo_id
|
|
52
|
+
self._headers = {"Authorization": f"Bearer {token}"}
|
|
53
|
+
self._client = httpx.Client(
|
|
54
|
+
base_url=self._server,
|
|
55
|
+
headers=self._headers,
|
|
56
|
+
timeout=30,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def close(self) -> None:
|
|
60
|
+
self._client.close()
|
|
61
|
+
|
|
62
|
+
def ping(self, timeout: float = 2.0) -> bool:
|
|
63
|
+
"""Best-effort reachability probe (does NOT validate the token).
|
|
64
|
+
|
|
65
|
+
Returns True when the server answers with a status < 500, False on
|
|
66
|
+
connection/timeout errors or a 5xx. Token expiry is checked separately
|
|
67
|
+
(before this is called) since ``/health`` is typically unauthenticated.
|
|
68
|
+
"""
|
|
69
|
+
try:
|
|
70
|
+
resp = self._client.get("/health", timeout=timeout)
|
|
71
|
+
return resp.status_code < 500
|
|
72
|
+
except Exception:
|
|
73
|
+
return False
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def _unwrap_text(payload: dict[str, Any]) -> str:
|
|
77
|
+
if "result" in payload and isinstance(payload["result"], str):
|
|
78
|
+
return payload["result"]
|
|
79
|
+
return str(payload)
|
|
80
|
+
|
|
81
|
+
def _get_json(self, path: str, *, params: Any = None) -> dict[str, Any]:
|
|
82
|
+
resp = self._client.get(path, params=params)
|
|
83
|
+
resp.raise_for_status()
|
|
84
|
+
return resp.json()
|
|
85
|
+
|
|
86
|
+
def _post_json(self, path: str, *, json: Any = None, params: Any = None) -> dict[str, Any]:
|
|
87
|
+
resp = self._client.post(path, json=json, params=params)
|
|
88
|
+
resp.raise_for_status()
|
|
89
|
+
return resp.json()
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def project_dir(self) -> str:
|
|
93
|
+
return f"remote:{self._server}#{self._repo_id}"
|
|
94
|
+
|
|
95
|
+
def repo_map(self, *, include_symbols: bool = True, max_tokens: int = 6000) -> str:
|
|
96
|
+
payload = self._get_json(
|
|
97
|
+
f"/api/v1/projects/{self._repo_id}/map",
|
|
98
|
+
params={"include_symbols": include_symbols, "max_tokens": max_tokens},
|
|
99
|
+
)
|
|
100
|
+
return self._unwrap_text(payload)
|
|
101
|
+
|
|
102
|
+
def project_summary(self, max_tokens: int = 4000) -> str:
|
|
103
|
+
payload = self._get_json(
|
|
104
|
+
f"/api/v1/projects/{self._repo_id}/summary",
|
|
105
|
+
params={"max_tokens": max_tokens},
|
|
106
|
+
)
|
|
107
|
+
return self._unwrap_text(payload)
|
|
108
|
+
|
|
109
|
+
def bootstrap(self, task_hint: str = "", max_tokens: int = 8000, indexing_depth: str = "auto") -> str:
|
|
110
|
+
payload = self._post_json(
|
|
111
|
+
f"/api/v1/projects/{self._repo_id}/bootstrap",
|
|
112
|
+
json={
|
|
113
|
+
"task_hint": task_hint,
|
|
114
|
+
"max_tokens": max_tokens,
|
|
115
|
+
"indexing_depth": indexing_depth,
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
return self._unwrap_text(payload)
|
|
119
|
+
|
|
120
|
+
def symbols(self, path: str) -> str:
|
|
121
|
+
payload = self._get_json(
|
|
122
|
+
f"/api/v1/projects/{self._repo_id}/symbols",
|
|
123
|
+
params={"path": path},
|
|
124
|
+
)
|
|
125
|
+
return self._unwrap_text(payload)
|
|
126
|
+
|
|
127
|
+
def search_symbols(self, name: str, limit: int = 30, kind: str = "") -> str:
|
|
128
|
+
payload = self._get_json(
|
|
129
|
+
f"/api/v1/projects/{self._repo_id}/search-symbols",
|
|
130
|
+
params={"name": name, "limit": limit, "kind": kind},
|
|
131
|
+
)
|
|
132
|
+
return self._unwrap_text(payload)
|
|
133
|
+
|
|
134
|
+
def dependencies(self, path: str) -> str:
|
|
135
|
+
payload = self._get_json(
|
|
136
|
+
f"/api/v1/projects/{self._repo_id}/dependencies",
|
|
137
|
+
params={"path": path},
|
|
138
|
+
)
|
|
139
|
+
return self._unwrap_text(payload)
|
|
140
|
+
|
|
141
|
+
def impact_analysis(self, changed_files: list[str]) -> str:
|
|
142
|
+
params = [("files", item) for item in changed_files]
|
|
143
|
+
payload = self._get_json(f"/api/v1/projects/{self._repo_id}/impact", params=params)
|
|
144
|
+
return self._unwrap_text(payload)
|
|
145
|
+
|
|
146
|
+
def cross_references(self, symbol_name: str) -> str:
|
|
147
|
+
payload = self._get_json(
|
|
148
|
+
f"/api/v1/projects/{self._repo_id}/cross-refs",
|
|
149
|
+
params={"symbol": symbol_name},
|
|
150
|
+
)
|
|
151
|
+
return self._unwrap_text(payload)
|
|
152
|
+
|
|
153
|
+
def file_analysis(self, path: str) -> str:
|
|
154
|
+
payload = self._get_json(
|
|
155
|
+
f"/api/v1/projects/{self._repo_id}/file-analysis",
|
|
156
|
+
params={"path": path},
|
|
157
|
+
)
|
|
158
|
+
return self._unwrap_text(payload)
|
|
159
|
+
|
|
160
|
+
def dependency_graph(self, start_file: str, depth: int = 2) -> str:
|
|
161
|
+
payload = self._post_json(
|
|
162
|
+
f"/api/v1/projects/{self._repo_id}/dependency-graph",
|
|
163
|
+
json={"start_file": start_file, "depth": depth},
|
|
164
|
+
)
|
|
165
|
+
return self._unwrap_text(payload)
|
|
166
|
+
|
|
167
|
+
def hotspots(self, top_n: int = 15) -> str:
|
|
168
|
+
payload = self._get_json(
|
|
169
|
+
f"/api/v1/projects/{self._repo_id}/hotspots",
|
|
170
|
+
params={"top_n": top_n},
|
|
171
|
+
)
|
|
172
|
+
return self._unwrap_text(payload)
|
|
173
|
+
|
|
174
|
+
def repo_map_ranked(
|
|
175
|
+
self,
|
|
176
|
+
*,
|
|
177
|
+
task_context: str = "",
|
|
178
|
+
token_budget: int = 1024,
|
|
179
|
+
exclude_tests: bool = True,
|
|
180
|
+
) -> str:
|
|
181
|
+
payload = self._post_json(
|
|
182
|
+
f"/api/v1/projects/{self._repo_id}/repo-map-ranked",
|
|
183
|
+
json={
|
|
184
|
+
"task_context": task_context,
|
|
185
|
+
"token_budget": token_budget,
|
|
186
|
+
"exclude_tests": exclude_tests,
|
|
187
|
+
},
|
|
188
|
+
)
|
|
189
|
+
return self._unwrap_text(payload)
|
|
190
|
+
|
|
191
|
+
def conventions(self, sample_size: int = 50, path: str = "") -> str:
|
|
192
|
+
payload = self._get_json(
|
|
193
|
+
f"/api/v1/projects/{self._repo_id}/conventions",
|
|
194
|
+
params={"sample_size": sample_size, "path": path},
|
|
195
|
+
)
|
|
196
|
+
return self._unwrap_text(payload)
|
|
197
|
+
|
|
198
|
+
def graph_query(self, *, file: str, edge_type: str = "IMPORTS", direction: str = "outbound", depth: int = 2) -> str:
|
|
199
|
+
payload = self._post_json(
|
|
200
|
+
f"/api/v1/projects/{self._repo_id}/graph/query",
|
|
201
|
+
json={
|
|
202
|
+
"file": file,
|
|
203
|
+
"edge_type": edge_type,
|
|
204
|
+
"direction": direction,
|
|
205
|
+
"depth": depth,
|
|
206
|
+
},
|
|
207
|
+
)
|
|
208
|
+
return self._unwrap_text(payload)
|
|
209
|
+
|
|
210
|
+
def graph_dsl(self, query: str) -> str:
|
|
211
|
+
payload = self._post_json(
|
|
212
|
+
f"/api/v1/projects/{self._repo_id}/graph/dsl",
|
|
213
|
+
json={"query": query},
|
|
214
|
+
)
|
|
215
|
+
return self._unwrap_text(payload)
|
|
216
|
+
|
|
217
|
+
def find_related(self, file: str, top_k: int = 10) -> str:
|
|
218
|
+
payload = self._post_json(
|
|
219
|
+
f"/api/v1/projects/{self._repo_id}/graph/related",
|
|
220
|
+
json={"file": file, "top_k": top_k},
|
|
221
|
+
)
|
|
222
|
+
return self._unwrap_text(payload)
|
|
223
|
+
|
|
224
|
+
def community_detection(self, min_community_size: int = 3, max_communities: int = 20) -> str:
|
|
225
|
+
payload = self._get_json(
|
|
226
|
+
f"/api/v1/projects/{self._repo_id}/graph/communities",
|
|
227
|
+
params={
|
|
228
|
+
"min_community_size": min_community_size,
|
|
229
|
+
"max_communities": max_communities,
|
|
230
|
+
},
|
|
231
|
+
)
|
|
232
|
+
return self._unwrap_text(payload)
|
|
233
|
+
|
|
234
|
+
def relevant_context(
|
|
235
|
+
self,
|
|
236
|
+
*,
|
|
237
|
+
files: list[str],
|
|
238
|
+
depth: int = 1,
|
|
239
|
+
max_tokens: int = 4000,
|
|
240
|
+
include_symbols: bool = True,
|
|
241
|
+
) -> str:
|
|
242
|
+
payload = self._post_json(
|
|
243
|
+
f"/api/v1/projects/{self._repo_id}/graph/context",
|
|
244
|
+
json={
|
|
245
|
+
"files": files,
|
|
246
|
+
"depth": depth,
|
|
247
|
+
"max_tokens": max_tokens,
|
|
248
|
+
"include_symbols": include_symbols,
|
|
249
|
+
},
|
|
250
|
+
)
|
|
251
|
+
return self._unwrap_text(payload)
|
|
252
|
+
|
|
253
|
+
def explore_codebase(
|
|
254
|
+
self,
|
|
255
|
+
*,
|
|
256
|
+
path: str = "",
|
|
257
|
+
max_items: int = 30,
|
|
258
|
+
importance_threshold: float = 0.3,
|
|
259
|
+
) -> str:
|
|
260
|
+
payload = self._post_json(
|
|
261
|
+
f"/api/v1/projects/{self._repo_id}/explore",
|
|
262
|
+
json={
|
|
263
|
+
"path": path,
|
|
264
|
+
"max_items": max_items,
|
|
265
|
+
"importance_threshold": importance_threshold,
|
|
266
|
+
},
|
|
267
|
+
)
|
|
268
|
+
return self._unwrap_text(payload)
|
|
269
|
+
|
|
270
|
+
def semantic_search(
|
|
271
|
+
self,
|
|
272
|
+
query: str,
|
|
273
|
+
top_k: int = 10,
|
|
274
|
+
file_filter: str = "",
|
|
275
|
+
branch: str = "",
|
|
276
|
+
mode: str = "auto",
|
|
277
|
+
) -> str:
|
|
278
|
+
payload = self._post_json(
|
|
279
|
+
f"/api/v1/projects/{self._repo_id}/search",
|
|
280
|
+
json={
|
|
281
|
+
"query": query,
|
|
282
|
+
"top_k": top_k,
|
|
283
|
+
"file_filter": file_filter,
|
|
284
|
+
"mode": mode,
|
|
285
|
+
},
|
|
286
|
+
params={"branch": branch},
|
|
287
|
+
)
|
|
288
|
+
return self._unwrap_text(payload)
|
|
289
|
+
|
|
290
|
+
def security_scan(self, mode: str = "full", path: str = "") -> str:
|
|
291
|
+
payload = self._post_json(
|
|
292
|
+
f"/api/v1/projects/{self._repo_id}/security-scan",
|
|
293
|
+
json={"mode": mode, "path": path},
|
|
294
|
+
)
|
|
295
|
+
return self._unwrap_text(payload)
|
|
296
|
+
|
|
297
|
+
def start_indexing(self) -> dict[str, Any]:
|
|
298
|
+
return self._post_json(f"/api/v1/projects/{self._repo_id}/index")
|
|
299
|
+
|
|
300
|
+
def indexing_status(self) -> dict[str, Any]:
|
|
301
|
+
return self._get_json(f"/api/v1/projects/{self._repo_id}/index/status")
|
|
302
|
+
|
|
303
|
+
def hydration_status(self) -> dict[str, Any]:
|
|
304
|
+
"""Mirror :meth:`CodeIntelService.hydration_status` for MCP remote mode."""
|
|
305
|
+
return self._get_json(f"/api/v1/projects/{self._repo_id}/hydration")
|
|
306
|
+
|
|
307
|
+
def semantic_search_status(self) -> str:
|
|
308
|
+
payload = self.indexing_status()
|
|
309
|
+
lines = [
|
|
310
|
+
"Semantic search status:",
|
|
311
|
+
f" Provider: {payload.get('provider', '')}",
|
|
312
|
+
f" Available: {payload.get('available', False)}",
|
|
313
|
+
f" Status: {payload.get('status', 'idle')}",
|
|
314
|
+
(
|
|
315
|
+
" Coverage: "
|
|
316
|
+
f"{float(payload.get('coverage', 0.0)):.0%} "
|
|
317
|
+
f"({payload.get('indexed_files', 0)}/{payload.get('total_files', 0)} files)"
|
|
318
|
+
),
|
|
319
|
+
f" Failed: {payload.get('failed_files', 0)}",
|
|
320
|
+
f" Vector search active: {payload.get('vector_search_active', False)}",
|
|
321
|
+
f" Health: {payload.get('health_status', 'unknown')}",
|
|
322
|
+
]
|
|
323
|
+
if payload.get("degraded_reason"):
|
|
324
|
+
lines.append(f" Degradation reason: {payload['degraded_reason']}")
|
|
325
|
+
if payload.get("last_error"):
|
|
326
|
+
lines.append(f" Last error: {payload['last_error']}")
|
|
327
|
+
if payload.get("elapsed_seconds", 0):
|
|
328
|
+
lines.append(f" Elapsed: {float(payload['elapsed_seconds']):.1f}s")
|
|
329
|
+
return "\n".join(lines)
|
|
330
|
+
|
|
331
|
+
def dead_code(
|
|
332
|
+
self,
|
|
333
|
+
*,
|
|
334
|
+
scope: str = "",
|
|
335
|
+
entry_points: list[str] | None = None,
|
|
336
|
+
level: str = "symbol",
|
|
337
|
+
min_confidence: float = 0.5,
|
|
338
|
+
top_n: int = 30,
|
|
339
|
+
) -> str:
|
|
340
|
+
payload = self._post_json(
|
|
341
|
+
f"/api/v1/projects/{self._repo_id}/dead-code",
|
|
342
|
+
json={
|
|
343
|
+
"scope": scope,
|
|
344
|
+
"entry_points": entry_points,
|
|
345
|
+
"level": level,
|
|
346
|
+
"min_confidence": min_confidence,
|
|
347
|
+
"top_n": top_n,
|
|
348
|
+
},
|
|
349
|
+
)
|
|
350
|
+
return self._unwrap_text(payload)
|
|
351
|
+
|
|
352
|
+
def distill(
|
|
353
|
+
self,
|
|
354
|
+
*,
|
|
355
|
+
files: list[str] | None = None,
|
|
356
|
+
depth: int = 1,
|
|
357
|
+
level: str = "signatures",
|
|
358
|
+
max_tokens: int = 4000,
|
|
359
|
+
) -> str:
|
|
360
|
+
payload = self._post_json(
|
|
361
|
+
f"/api/v1/projects/{self._repo_id}/distill",
|
|
362
|
+
json={
|
|
363
|
+
"files": files,
|
|
364
|
+
"depth": depth,
|
|
365
|
+
"level": level,
|
|
366
|
+
"max_tokens": max_tokens,
|
|
367
|
+
},
|
|
368
|
+
)
|
|
369
|
+
return self._unwrap_text(payload)
|
|
370
|
+
|
|
371
|
+
def readiness_report(
|
|
372
|
+
self,
|
|
373
|
+
*,
|
|
374
|
+
phases: list[int] | None = None,
|
|
375
|
+
scope: str = "",
|
|
376
|
+
tracer_bullets: bool = True,
|
|
377
|
+
min_severity: str = "info",
|
|
378
|
+
) -> str:
|
|
379
|
+
payload = self._post_json(
|
|
380
|
+
f"/api/v1/projects/{self._repo_id}/readiness-report",
|
|
381
|
+
json={
|
|
382
|
+
"phases": phases,
|
|
383
|
+
"scope": scope,
|
|
384
|
+
"tracer_bullets": tracer_bullets,
|
|
385
|
+
"min_severity": min_severity,
|
|
386
|
+
},
|
|
387
|
+
)
|
|
388
|
+
return self._unwrap_text(payload)
|
|
389
|
+
|
|
390
|
+
def bug_scan(self, *, base_branch: str = "main", min_confidence: float = 0.5) -> str:
|
|
391
|
+
payload = self._post_json(
|
|
392
|
+
f"/api/v1/projects/{self._repo_id}/bug-scan",
|
|
393
|
+
json={"base_branch": base_branch, "min_confidence": min_confidence},
|
|
394
|
+
)
|
|
395
|
+
return self._unwrap_text(payload)
|
|
396
|
+
|
|
397
|
+
def fast_search(
|
|
398
|
+
self,
|
|
399
|
+
*,
|
|
400
|
+
pattern: str,
|
|
401
|
+
path: str = "",
|
|
402
|
+
max_results: int = 50,
|
|
403
|
+
case_insensitive: bool = False,
|
|
404
|
+
selectivity_threshold: float = 0.10,
|
|
405
|
+
explain: bool = False,
|
|
406
|
+
) -> str:
|
|
407
|
+
payload = self._post_json(
|
|
408
|
+
f"/api/v1/projects/{self._repo_id}/fast-search",
|
|
409
|
+
json={
|
|
410
|
+
"pattern": pattern,
|
|
411
|
+
"path": path,
|
|
412
|
+
"max_results": max_results,
|
|
413
|
+
"case_insensitive": case_insensitive,
|
|
414
|
+
"selectivity_threshold": selectivity_threshold,
|
|
415
|
+
"explain": explain,
|
|
416
|
+
},
|
|
417
|
+
)
|
|
418
|
+
return self._unwrap_text(payload)
|
|
419
|
+
|
|
420
|
+
async def lsp_definition(self, file: str, line: int, col: int = 0) -> str:
|
|
421
|
+
import httpx
|
|
422
|
+
|
|
423
|
+
async with httpx.AsyncClient(base_url=self._server, headers=self._headers, timeout=30) as client:
|
|
424
|
+
resp = await client.post(
|
|
425
|
+
f"/api/v1/projects/{self._repo_id}/lsp/definition",
|
|
426
|
+
json={"file": file, "line": line, "col": col},
|
|
427
|
+
)
|
|
428
|
+
resp.raise_for_status()
|
|
429
|
+
return self._unwrap_text(resp.json())
|
|
430
|
+
|
|
431
|
+
async def lsp_references(
|
|
432
|
+
self, file: str, line: int, col: int = 0, include_declaration: bool = True,
|
|
433
|
+
) -> str:
|
|
434
|
+
import httpx
|
|
435
|
+
|
|
436
|
+
async with httpx.AsyncClient(base_url=self._server, headers=self._headers, timeout=30) as client:
|
|
437
|
+
resp = await client.post(
|
|
438
|
+
f"/api/v1/projects/{self._repo_id}/lsp/references",
|
|
439
|
+
json={
|
|
440
|
+
"file": file,
|
|
441
|
+
"line": line,
|
|
442
|
+
"col": col,
|
|
443
|
+
"include_declaration": include_declaration,
|
|
444
|
+
},
|
|
445
|
+
)
|
|
446
|
+
resp.raise_for_status()
|
|
447
|
+
return self._unwrap_text(resp.json())
|
|
448
|
+
|
|
449
|
+
async def lsp_hover(self, file: str, line: int, col: int = 0) -> str:
|
|
450
|
+
import httpx
|
|
451
|
+
|
|
452
|
+
async with httpx.AsyncClient(base_url=self._server, headers=self._headers, timeout=30) as client:
|
|
453
|
+
resp = await client.post(
|
|
454
|
+
f"/api/v1/projects/{self._repo_id}/lsp/hover",
|
|
455
|
+
json={"file": file, "line": line, "col": col},
|
|
456
|
+
)
|
|
457
|
+
resp.raise_for_status()
|
|
458
|
+
return self._unwrap_text(resp.json())
|
|
459
|
+
|
|
460
|
+
async def lsp_enrich(self, files: list[str]) -> str:
|
|
461
|
+
import httpx
|
|
462
|
+
|
|
463
|
+
async with httpx.AsyncClient(base_url=self._server, headers=self._headers, timeout=30) as client:
|
|
464
|
+
resp = await client.post(
|
|
465
|
+
f"/api/v1/projects/{self._repo_id}/lsp/enrich",
|
|
466
|
+
json={"files": files},
|
|
467
|
+
)
|
|
468
|
+
resp.raise_for_status()
|
|
469
|
+
return self._unwrap_text(resp.json())
|
|
470
|
+
|
|
471
|
+
def lsp_diagnostics(self, file: str) -> str:
|
|
472
|
+
payload = self._get_json(
|
|
473
|
+
f"/api/v1/projects/{self._repo_id}/lsp/diagnostics",
|
|
474
|
+
params={"file": file},
|
|
475
|
+
)
|
|
476
|
+
return self._unwrap_text(payload)
|
|
477
|
+
|
|
478
|
+
def code_evolution(
|
|
479
|
+
self, path: str, symbol: str = "", since: str = "", max_results: int = 20,
|
|
480
|
+
) -> str:
|
|
481
|
+
payload = self._get_json(
|
|
482
|
+
f"/api/v1/projects/{self._repo_id}/history/evolution",
|
|
483
|
+
params={"path": path, "symbol": symbol, "since": since, "max_results": max_results},
|
|
484
|
+
)
|
|
485
|
+
return self._unwrap_text(payload)
|
|
486
|
+
|
|
487
|
+
def recent_changes(self, days: int = 7, path: str = "", top_n: int = 20) -> str:
|
|
488
|
+
payload = self._get_json(
|
|
489
|
+
f"/api/v1/projects/{self._repo_id}/history/recent-changes",
|
|
490
|
+
params={"days": days, "path": path, "top_n": top_n},
|
|
491
|
+
)
|
|
492
|
+
return self._unwrap_text(payload)
|
|
493
|
+
|
|
494
|
+
def change_coupling(
|
|
495
|
+
self,
|
|
496
|
+
*,
|
|
497
|
+
file: str,
|
|
498
|
+
days: int = 90,
|
|
499
|
+
min_coupling: float = 0.3,
|
|
500
|
+
top_k: int = 20,
|
|
501
|
+
) -> str:
|
|
502
|
+
payload = self._post_json(
|
|
503
|
+
f"/api/v1/projects/{self._repo_id}/history/change-coupling",
|
|
504
|
+
json={
|
|
505
|
+
"file": file,
|
|
506
|
+
"days": days,
|
|
507
|
+
"min_coupling": min_coupling,
|
|
508
|
+
"top_k": top_k,
|
|
509
|
+
},
|
|
510
|
+
)
|
|
511
|
+
return self._unwrap_text(payload)
|
|
512
|
+
|
|
513
|
+
def churn_hotspots(self, *, days: int = 90, top_n: int = 20) -> str:
|
|
514
|
+
payload = self._get_json(
|
|
515
|
+
f"/api/v1/projects/{self._repo_id}/history/churn-hotspots",
|
|
516
|
+
params={"days": days, "top_n": top_n},
|
|
517
|
+
)
|
|
518
|
+
return self._unwrap_text(payload)
|
|
519
|
+
|
|
520
|
+
def merge_risk(self, *, files: list[str], days: int = 90) -> str:
|
|
521
|
+
payload = self._post_json(
|
|
522
|
+
f"/api/v1/projects/{self._repo_id}/history/merge-risk",
|
|
523
|
+
json={"files": files, "days": days},
|
|
524
|
+
)
|
|
525
|
+
return self._unwrap_text(payload)
|
|
526
|
+
|
|
527
|
+
def recall(self, query: str, scope: str = "", max_results: int = 10) -> str:
|
|
528
|
+
payload = self._get_json(
|
|
529
|
+
f"/api/v1/projects/{self._repo_id}/learnings/recall",
|
|
530
|
+
params={"query": query, "scope": scope, "max_results": max_results},
|
|
531
|
+
)
|
|
532
|
+
return self._unwrap_text(payload)
|
|
533
|
+
|
|
534
|
+
def record_learning(
|
|
535
|
+
self,
|
|
536
|
+
*,
|
|
537
|
+
type: str, # noqa: A002
|
|
538
|
+
description: str,
|
|
539
|
+
details: str = "",
|
|
540
|
+
scope: str = "",
|
|
541
|
+
confidence: float = 0.7,
|
|
542
|
+
) -> str:
|
|
543
|
+
payload = self._post_json(
|
|
544
|
+
f"/api/v1/projects/{self._repo_id}/learnings",
|
|
545
|
+
json={
|
|
546
|
+
"type": type,
|
|
547
|
+
"description": description,
|
|
548
|
+
"details": details,
|
|
549
|
+
"scope": scope,
|
|
550
|
+
"confidence": confidence,
|
|
551
|
+
},
|
|
552
|
+
)
|
|
553
|
+
return self._unwrap_text(payload)
|
|
554
|
+
|
|
555
|
+
def learning_feedback(self, learning_id: int, helpful: bool) -> str:
|
|
556
|
+
payload = self._post_json(
|
|
557
|
+
f"/api/v1/projects/{self._repo_id}/learnings/{learning_id}/feedback",
|
|
558
|
+
json={"helpful": helpful},
|
|
559
|
+
)
|
|
560
|
+
return self._unwrap_text(payload)
|
|
561
|
+
|
|
562
|
+
def list_learnings(self, status: str = "active", type: str = "", scope: str = "") -> str: # noqa: A002
|
|
563
|
+
payload = self._get_json(
|
|
564
|
+
f"/api/v1/projects/{self._repo_id}/learnings",
|
|
565
|
+
params={"status": status, "type": type, "scope": scope},
|
|
566
|
+
)
|
|
567
|
+
return self._unwrap_text(payload)
|
|
568
|
+
|
|
569
|
+
def record_adr(
|
|
570
|
+
self,
|
|
571
|
+
*,
|
|
572
|
+
title: str,
|
|
573
|
+
context: str,
|
|
574
|
+
decision: str,
|
|
575
|
+
consequences: str = "",
|
|
576
|
+
related_files: list[str] | None = None,
|
|
577
|
+
tags: list[str] | None = None,
|
|
578
|
+
) -> str:
|
|
579
|
+
payload = self._post_json(
|
|
580
|
+
f"/api/v1/projects/{self._repo_id}/adrs",
|
|
581
|
+
json={
|
|
582
|
+
"title": title,
|
|
583
|
+
"context": context,
|
|
584
|
+
"decision": decision,
|
|
585
|
+
"consequences": consequences,
|
|
586
|
+
"related_files": related_files,
|
|
587
|
+
"tags": tags,
|
|
588
|
+
},
|
|
589
|
+
)
|
|
590
|
+
return self._unwrap_text(payload)
|
|
591
|
+
|
|
592
|
+
def list_adrs(self, status: str = "", tag: str = "", search: str = "") -> str:
|
|
593
|
+
payload = self._get_json(
|
|
594
|
+
f"/api/v1/projects/{self._repo_id}/adrs",
|
|
595
|
+
params={"status": status, "tag": tag, "search": search},
|
|
596
|
+
)
|
|
597
|
+
return self._unwrap_text(payload)
|
|
598
|
+
|
|
599
|
+
def get_adr(self, number: int) -> str:
|
|
600
|
+
payload = self._get_json(f"/api/v1/projects/{self._repo_id}/adrs/{number}")
|
|
601
|
+
return self._unwrap_text(payload)
|
|
602
|
+
|
|
603
|
+
def update_adr_status(self, *, number: int, status: str, superseded_by: int | None = None) -> str:
|
|
604
|
+
payload = self._post_json(
|
|
605
|
+
f"/api/v1/projects/{self._repo_id}/adrs/{number}/status",
|
|
606
|
+
json={"status": status, "superseded_by": superseded_by},
|
|
607
|
+
)
|
|
608
|
+
return self._unwrap_text(payload)
|
|
609
|
+
|
|
610
|
+
def notify_file_changed(self, files: list[str]) -> str:
|
|
611
|
+
payload = self._post_json(
|
|
612
|
+
f"/api/v1/projects/{self._repo_id}/notify",
|
|
613
|
+
json={"files": files},
|
|
614
|
+
)
|
|
615
|
+
return self._unwrap_text(payload)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
class RemoteAnalysisProvider:
|
|
619
|
+
"""Proxy analysis requests through the remote HTTP API."""
|
|
620
|
+
|
|
621
|
+
__slots__ = ("_client",)
|
|
622
|
+
|
|
623
|
+
def __init__(self, client: RemoteClient) -> None:
|
|
624
|
+
self._client = client
|
|
625
|
+
|
|
626
|
+
async def symbols(self, path: str, branch: str) -> dict:
|
|
627
|
+
return await self._client.get(
|
|
628
|
+
f"/api/v2/projects/{self._client.repo_id}/symbols",
|
|
629
|
+
params={"path": path, "branch": branch},
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
async def search_symbols(self, name: str, branch: str, directory: str = "") -> dict:
|
|
633
|
+
params: dict[str, str] = {"name": name, "branch": branch}
|
|
634
|
+
if directory:
|
|
635
|
+
params["dir"] = directory
|
|
636
|
+
return await self._client.get(
|
|
637
|
+
f"/api/v2/projects/{self._client.repo_id}/search-symbols",
|
|
638
|
+
params=params,
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
async def cross_references(self, symbol: str, branch: str) -> dict:
|
|
642
|
+
return await self._client.get(
|
|
643
|
+
f"/api/v2/projects/{self._client.repo_id}/cross-refs",
|
|
644
|
+
params={"symbol": symbol, "branch": branch},
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
async def impact_analysis(self, files: list[str], branch: str) -> dict:
|
|
648
|
+
params: list[tuple[str, str]] = [("branch", branch)] if branch else []
|
|
649
|
+
params.extend(("files", item) for item in files)
|
|
650
|
+
return await self._client.get(
|
|
651
|
+
f"/api/v2/projects/{self._client.repo_id}/impact",
|
|
652
|
+
params=params,
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
async def dependency_graph(self, start_file: str, depth: int, branch: str, directory: str = "") -> dict:
|
|
656
|
+
payload: dict[str, Any] = {"start_file": start_file, "depth": depth}
|
|
657
|
+
if directory:
|
|
658
|
+
payload["directory"] = directory
|
|
659
|
+
return await self._client.post(
|
|
660
|
+
f"/api/v2/projects/{self._client.repo_id}/dependency-graph",
|
|
661
|
+
json=payload,
|
|
662
|
+
params={"branch": branch},
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
async def dependencies(self, path: str, branch: str) -> dict:
|
|
666
|
+
return await self._client.get(
|
|
667
|
+
f"/api/v2/projects/{self._client.repo_id}/dependencies",
|
|
668
|
+
params={"path": path, "branch": branch},
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
async def file_analysis(self, path: str, branch: str) -> dict:
|
|
672
|
+
return await self._client.get(
|
|
673
|
+
f"/api/v2/projects/{self._client.repo_id}/file-analysis",
|
|
674
|
+
params={"path": path, "branch": branch},
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
async def hotspots(self, branch: str, top_n: int) -> dict:
|
|
678
|
+
return await self._client.get(
|
|
679
|
+
f"/api/v2/projects/{self._client.repo_id}/hotspots",
|
|
680
|
+
params={"branch": branch, "top_n": top_n},
|
|
681
|
+
)
|
|
682
|
+
|
|
683
|
+
async def conventions(self, branch: str, sample_size: int, path: str) -> dict:
|
|
684
|
+
return await self._client.get(
|
|
685
|
+
f"/api/v2/projects/{self._client.repo_id}/conventions",
|
|
686
|
+
params={"branch": branch, "sample_size": sample_size, "path": path},
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
class RemoteSearchProvider:
|
|
691
|
+
"""Proxy search requests through the remote HTTP API."""
|
|
692
|
+
|
|
693
|
+
__slots__ = ("_client",)
|
|
694
|
+
|
|
695
|
+
def __init__(self, client: RemoteClient) -> None:
|
|
696
|
+
self._client = client
|
|
697
|
+
|
|
698
|
+
async def semantic_search(self, query: str, top_k: int, file_filter: str, branch: str) -> dict:
|
|
699
|
+
payload: dict[str, Any] = {"query": query, "top_k": top_k, "file_filter": file_filter}
|
|
700
|
+
return await self._client.post(
|
|
701
|
+
f"/api/v2/projects/{self._client.repo_id}/search",
|
|
702
|
+
json=payload,
|
|
703
|
+
params={"branch": branch},
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
async def security_scan(self, mode: str, path: str, branch: str) -> dict:
|
|
707
|
+
return await self._client.post(
|
|
708
|
+
f"/api/v2/projects/{self._client.repo_id}/security-scan",
|
|
709
|
+
json={"mode": mode, "path": path},
|
|
710
|
+
params={"branch": branch},
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
class RemoteGraphProvider:
|
|
715
|
+
"""Proxy graph requests through the remote HTTP API."""
|
|
716
|
+
|
|
717
|
+
__slots__ = ("_client",)
|
|
718
|
+
|
|
719
|
+
def __init__(self, client: RemoteClient) -> None:
|
|
720
|
+
self._client = client
|
|
721
|
+
|
|
722
|
+
async def graph_query(self, file: str, edge_type: str, direction: str, depth: int, branch: str) -> dict:
|
|
723
|
+
return await self._client.post(
|
|
724
|
+
f"/api/v2/projects/{self._client.repo_id}/graph/query",
|
|
725
|
+
json={"file": file, "edge_type": edge_type, "direction": direction, "depth": depth},
|
|
726
|
+
params={"branch": branch},
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
async def find_related(self, file: str, top_k: int, branch: str) -> dict:
|
|
730
|
+
return await self._client.post(
|
|
731
|
+
f"/api/v2/projects/{self._client.repo_id}/graph/related",
|
|
732
|
+
json={"file": file, "top_k": top_k},
|
|
733
|
+
params={"branch": branch},
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
async def community_detection(self, branch: str, min_community_size: int, max_communities: int) -> dict:
|
|
737
|
+
return await self._client.get(
|
|
738
|
+
f"/api/v2/projects/{self._client.repo_id}/graph/communities",
|
|
739
|
+
params={"branch": branch, "min_community_size": min_community_size, "max_communities": max_communities},
|
|
740
|
+
)
|