Implement multi-root CodeQL query resolution with workspace support#308
Open
data-douser wants to merge 6 commits into
Open
Implement multi-root CodeQL query resolution with workspace support#308data-douser wants to merge 6 commits into
data-douser wants to merge 6 commits into
Conversation
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Make the VS Code extension select CodeQL query/pack resolution roots from workspace folders that contain a top-level codeql-workspace.yml, and give the MCP server's completion providers an independent per-root scan budget so non-first folders are never starved. Extension: - Add codeql-mcp.requireCodeqlWorkspace (default true); only folders with a top-level codeql-workspace.yml become resolution roots. - queryPackIncludeDirs remains the explicit opt-in; fall back to all folders with a warning when none qualify and no include dirs are set. - Export computeResolutionRoots/hasTopLevelCodeqlWorkspaceFile. Server: - Give each workspace root (and base dir) its own completion scan budget so a populous first root no longer hides later roots. Tests/docs: - Add codeql-workspace-resolution and multi-root completion integration suites, unit tests, and codeql-workspace.yml fixtures. - Update README and CHANGELOG.
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
64 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR (#308) fixes multi-root workspace resolution for CodeQL MCP prompt-driven workflows by making both the VS Code extension and the MCP server’s prompt completion providers “multi-root aware”, with explicit include/exclude controls and a default CodeQL-workspace-based root selection model.
Changes:
- Extend server-side prompt completions to scan all workspace roots (
CODEQL_MCP_WORKSPACE_FOLDERS) with a per-root scan budget to avoid “first root starvation”. - Add VS Code extension settings (
queryPackIncludeDirs,queryPackExcludeDirs,requireCodeqlWorkspace) and implement CodeQL-workspace-aware root selection in the environment builder. - Add/expand unit + integration tests, update extension README, and add changelog entries.
Show a summary per file
| File | Description |
|---|---|
| server/test/src/prompts/prompt-completions.test.ts | Adds server-side unit tests asserting completions span multiple workspace roots and that later roots aren’t starved. |
| server/src/utils/package-paths.ts | Clarifies multi-root workspace dir resolution documentation (uses CODEQL_MCP_WORKSPACE_FOLDERS). |
| server/src/prompts/workflow-prompts.ts | Minor doc/comment updates related to multi-root path resolution. |
| server/src/prompts/prompt-completions.ts | Implements multi-root scanning and per-root budgets for query/sarif/db/pack completions. |
| server/dist/codeql-development-mcp-server.js | Updates the bundled server build output to reflect TypeScript changes. |
| extensions/vscode/src/bridge/environment-builder.ts | Computes effective resolution roots using new settings + codeql-workspace.yml detection and exports them via env vars. |
| extensions/vscode/package.json | Adds settings definitions/descriptions for include/exclude and CodeQL workspace requirement. |
| extensions/vscode/README.md | Documents multi-root behavior, new settings, and recommended codeql-workspace.yml usage. |
| extensions/vscode/test/bridge/environment-builder.test.ts | Adds unit tests for root computation logic, include/exclude behavior, and fallback warning. |
| extensions/vscode/test/suite/workspace-scenario.integration.test.ts | Adds integration coverage for CODEQL_MCP_WORKSPACE_FOLDERS and include/exclude effects. |
| extensions/vscode/test/suite/workspace-folder-change.integration.test.ts | Adjusts workspace-folder change tests to align with the default CodeQL-workspace requirement. |
| extensions/vscode/test/suite/mcp-completion-multiroot.integration.test.ts | New end-to-end test spawning the server with synthetic multi-root env to validate completions + prompt resolution. |
| extensions/vscode/test/suite/codeql-workspace-resolution.integration.test.ts | New integration tests for default CodeQL-workspace-aware root selection and opt-in/out settings. |
| extensions/vscode/test/fixtures/single-folder-workspace/codeql-workspace.yml | Adds fixture CodeQL workspace marker file. |
| extensions/vscode/test/fixtures/multi-root-workspace/folder-a/codeql-workspace.yml | Adds fixture CodeQL workspace marker file. |
| extensions/vscode/test/fixtures/multi-root-workspace/folder-b/codeql-workspace.yml | Adds fixture CodeQL workspace marker file. |
| extensions/vscode/test/fixtures/multi-root-workspace/folder-c/codeql-workspace.yml | Adds fixture CodeQL workspace marker file. |
| extensions/vscode/test/fixtures/multi-root-workspace/folder-d/codeql-workspace.yml | Adds fixture CodeQL workspace marker file. |
| extensions/vscode/esbuild.config.js | Registers new extension integration test entrypoints in the test bundle config. |
| CHANGELOG.md | Adds Unreleased entries describing the new settings, default behavior changes, and the multi-root prompt fix. |
Copilot's findings
- Files reviewed: 19/21 changed files
- Comments generated: 8
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Comment on lines
+389
to
394
| } | ||
| aggregated.push(...perRoot); | ||
| } | ||
|
|
||
| allResults = results; | ||
| allResults = [...new Set(aggregated)]; | ||
| setCachedResults(cacheKey, allResults); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request:
Summary of Changes
This pull request introduces significant improvements to how the VS Code extension for CodeQL MCP resolves query and pack paths, especially in multi-root workspaces. It adds new settings to give users explicit control over which directories are scanned, makes the extension aware of CodeQL workspaces by default, and ensures that queries in any workspace folder can be found and used regardless of folder order. It also improves test isolation and updates documentation to reflect these changes.
Multi-root workspace and resolution improvements:
package.jsonand documented them inREADME.md:codeql-mcp.queryPackIncludeDirs(explicitly include directories for query/pack resolution),codeql-mcp.queryPackExcludeDirs(exclude certain directories from resolution), andcodeql-mcp.requireCodeqlWorkspace(use only folders with a top-levelcodeql-workspace.ymlby default). These settings are folded into the environment variables passed to the MCP server. [1] [2]codeql-workspace.ymlas CodeQL query/pack resolution roots, matching the CodeQL CLI's workspace model. The previous behavior (using every open folder) is still available via settings or fallback. [1] [2]environment-builder.tswith helper functions for workspace file detection, path resolution, and exclusion, making the codebase more robust and testable. [1] [2]Testing and infrastructure:
These changes provide more predictable, user-configurable, and CodeQL-native behavior for resolving queries and packs in complex workspace setups.