Skip to content

CLI-366 SQAA workaround for copilot integration#257

Open
tomshafir-sonarsource wants to merge 6 commits into
masterfrom
task/ts/CLI-366-sqaa-workaround-for-copilot-integration
Open

CLI-366 SQAA workaround for copilot integration#257
tomshafir-sonarsource wants to merge 6 commits into
masterfrom
task/ts/CLI-366-sqaa-workaround-for-copilot-integration

Conversation

@tomshafir-sonarsource
Copy link
Copy Markdown
Contributor

@tomshafir-sonarsource tomshafir-sonarsource commented May 8, 2026

Screenshot 2026-05-12 at 14 57 00 Screenshot 2026-05-12 at 15 20 19

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 8, 2026

CLI-366

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from 74b3137 to 9dbfd30 Compare May 11, 2026 09:17
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from 6e82038 to e4ddbf5 Compare May 12, 2026 07:41
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource marked this pull request as ready for review May 12, 2026 08:36
@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha Bot commented May 12, 2026

Summary

This PR adds SonarQube Agentic Analysis (SQAA) support to Copilot integration. It extends the CLI's custom instructions to include directives that trigger sonar analyze agentic at end-of-turn for modified files, alongside the existing prompt-secrets warnings.

Key changes:

  • Instructions now contain two sections: prompt-secrets (existing) and SQAA (new, conditional)
  • Instructions file is now CLI-owned and rewritten on every run (no skip-on-existing-global logic)
  • SQAA installs only when org is entitled, project key is available, and auth is cloud
  • State tracking split: instructionsInstalledpromptSecretsInstructionsInstalled + sqaaInstructionsInstalled (with cloud metadata)
  • Global installs can have prompt-secrets globally and SQAA project-scoped when a project key is discoverable
  • Added MCP server configuration file (.mcp.json)

What reviewers should know

Where to start:

  • Read src/cli/commands/integrate/copilot/instructions.ts first to understand the two instruction sections and how they're composed
  • Then index.ts to see the entitlement check (resolveSqaaProjectKey) and orchestration
  • Finally state.ts to understand the new schema for tracking both sections separately

Non-obvious decisions:

  1. CLI-owned file: The instructions file is no longer skipped when a global version exists — both global and project files can coexist with different content. This is intentional; the file is "CLI-owned" and rewritten fresh each run.
  2. SQAA is always project-scoped: Even integrate copilot -g can write SQAA to a project file (under .github/instructions/) when a project key is discovered from sonar-project.properties. The prompt-secrets section goes global, SQAA goes project.
  3. Idempotency: Running the command twice produces no duplicate sections (file is fully rewritten, not appended to). Tests verify this.
  4. Scope mismatch tolerance: An orphan warning surfaces if a global instructions file exists when installing project-level (the global file is left untouched).

Things to watch:

  • Entitlement check (resolveSqaaProjectKey): Runs a real API call; failures are logged as warnings and SQAA is skipped gracefully
  • Auth requirement: SQAA requires cloud auth with organization; on-premise deployments silently skip it
  • Test coverage: Extensive SQAA-specific tests cover entitled/not-entitled orgs, global/project scope interactions, and project key discovery paths
  • MCP registration: .mcp.json is new; it registers the SonarQube MCP server for Copilot to use (implementation in mcp.ts)

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

sonar-review-alpha[bot]

This comment was marked as resolved.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from e4ddbf5 to 1add9b3 Compare May 12, 2026 10:53
sonar-review-alpha[bot]

This comment was marked as outdated.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from 1add9b3 to 7534a82 Compare May 12, 2026 11:51
sonar-review-alpha[bot]

This comment was marked as outdated.

sonar-review-alpha[bot]

This comment was marked as outdated.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from 7534a82 to 6bec1ac Compare May 12, 2026 12:28
sonar-review-alpha[bot]

This comment was marked as resolved.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from 6bec1ac to b2183dd Compare May 12, 2026 12:47
sonar-review-alpha[bot]

This comment was marked as outdated.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the task/ts/CLI-366-sqaa-workaround-for-copilot-integration branch from b2183dd to ae6b48c Compare May 12, 2026 13:06
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

The previously flagged bug around uncaught errors in resolveSqaaProjectKey has been fixed — the function now wraps the API call in a try/catch and emits a warning on failure. The two acknowledged design decisions (global install writing SQAA-only to the project file, and the untested formatInstructionsLines "not installed" branch) remain as-is per prior agreement.

The rest of the PR is clean: the SQAA section logic, state tracking split, orphan-file warning, and the comprehensive new integration tests all look correct and follow the codebase's conventions.

🗣️ Give feedback

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.

2 participants