Skip to content

feat(python): expose language extensions for paths - #17

Closed
DavidBakerEffendi wants to merge 1 commit into
masterfrom
dave/issue-14-extensions-for-paths
Closed

feat(python): expose language extensions for paths#17
DavidBakerEffendi wants to merge 1 commit into
masterfrom
dave/issue-14-extensions-for-paths

Conversation

@DavidBakerEffendi

Copy link
Copy Markdown
Contributor

Description

Adds a workspace-free Python API that expands changed paths to the complete Bifrost source-extension set for their language(s). This lets callers classify a diff before constructing or indexing a scoped session.

Fixes #14

Credit and reference implementation: @sontek, sontek/bifrost#4.

Key Changes

  • Add Language::languages_for_source_extension as the structured classifier for both analyzable and reference-only source extensions.
  • Keep Language::from_extension analyzable-only; .vue and .razor are source files but are not analyzer-entry extensions.
  • Add pure extensions_for_paths to the PyO3 native module, including all extensions for every matching language. A .vue path expands JavaScript and TypeScript together.
  • Wrap the API as bifrost_searchtools.client.extensions_for_paths(paths, library_path=None) and export it, matching tool_descriptors().
  • Add positive, cross-language sibling, and unknown-extension tests.

Adapted from commit 89a3cc41e0 on sontek/bifrost:pr/issue-14-language-extensions. Resolved current-master conflicts around code_query_variant_inventory and corrected reference-only extension classification.

Touch Points

  • crates/bifrost-core/src/analyzer/model.rs
  • src/python_module.rs
  • bifrost_searchtools/client.py
  • bifrost_searchtools/__init__.py

…s_for_paths

Callers building a scoped SearchToolsClient session (sources=[...]) need to know which languages a diff owns so the workspace can be scoped without losing find-usages completeness. Expose the Language source-extension registry as a pure Python function that opens no workspace.

extensions_for_paths resolves each path through Language::languages_for_source_extension, including reference-only siblings such as TS/JS .vue/.svelte and C# .razor/.cshtml. A .vue file expands both JavaScript and TypeScript. Wrap it in bifrost_searchtools.client.extensions_for_paths and export it like tool_descriptors.

This adapts the cherry-pick of sontek/bifrost@89a3cc41e0 to current master: from_extension remains analyzable-only, while the source-extension classifier recognizes reference-only files. Preserve the existing code-query inventory API from master.
@DavidBakerEffendi

Copy link
Copy Markdown
Contributor Author

Retargeted to the private repo: BrokkAi/bifrost-dev#2973. This repo's master is projection-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No lightweight way to get bifrost's own language classification without a workspace

2 participants