From 812df4e5fe52ac8b09ff4b47dd390b0fbdb6a9e9 Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Thu, 30 Jul 2026 13:03:16 +0200 Subject: [PATCH 1/4] CLI-837 Move remaining commands/_common files, reorganize core/host --- CLAUDE.md | 8 ++++---- build-scripts/build-binary.ts | 2 +- build-scripts/docs/generate-docs.ts | 5 +++-- build-scripts/fetch-signatures.ts | 6 +++--- build-scripts/setup-integration-resources.ts | 4 ++-- src/commands/analyze/analyze-all.ts | 2 +- .../manifest-secrets-guard.ts | 2 +- .../sca-scan-orchestrator.ts | 4 ++-- .../dependency-risk-helpers/sca-urls.ts | 2 +- src/commands/analyze/dependency-risks.ts | 2 +- src/commands/analyze/secrets.ts | 2 +- src/commands/analyze/sqaa-auth.ts | 4 ++-- src/commands/analyze/sqaa-json-report.ts | 2 +- src/commands/analyze/sqaa-run.ts | 2 +- src/commands/analyze/sqaa-types.ts | 2 +- src/commands/analyze/sqaa.ts | 2 +- src/commands/api/api.ts | 2 +- src/commands/auth/login.ts | 4 ++-- src/commands/auth/status.ts | 6 +++--- src/commands/command-tree.ts | 6 +++--- src/commands/context/index.ts | 4 ++-- src/commands/hook/agent-post-tool-use.ts | 2 +- src/commands/hook/codex-post-tool-use.ts | 2 +- .../hook/git-pre-commit-dependency-risks.ts | 2 +- src/commands/hook/git-pre-commit-secrets.ts | 2 +- src/commands/hook/git-pre-commit.ts | 2 +- src/commands/hook/git-pre-push-secrets.ts | 2 +- src/commands/hook/git-pre-push.ts | 2 +- src/commands/hook/hook-dependencies.ts | 4 ++-- src/commands/import/index.ts | 2 +- .../_common/agent-integrate-postlude.ts | 2 +- .../_common/agent-integrate-prelude.ts | 2 +- .../_common/context-augmentation-dependency.ts | 2 +- .../integrate/_common/context-augmentation.ts | 6 +++--- .../features/context-augmentation-feature.ts | 2 +- .../integrate/_common/preflight-summary.ts | 6 +++++- src/commands/integrate/_common/vortex.ts | 2 +- src/commands/integrate/antigravity/index.ts | 4 ++-- src/commands/integrate/claude/index.ts | 4 ++-- src/commands/integrate/codex/index.ts | 4 ++-- src/commands/integrate/copilot/index.ts | 4 ++-- src/commands/integrate/cursor/index.ts | 4 ++-- src/commands/integrate/git/index.ts | 4 ++-- .../git/tools/git-integration-subfeatures.ts | 4 ++-- src/commands/integrate/integrate-bare.ts | 2 +- src/commands/list/issues.ts | 2 +- src/commands/list/projects.ts | 2 +- src/commands/remediate/index.ts | 4 ++-- src/commands/root-help.ts | 6 +----- src/commands/run/mcp.ts | 4 ++-- src/commands/{_common => }/sonar-command.ts | 4 ++-- src/commands/system/reset.ts | 2 +- src/commands/system/status.ts | 18 +++++++++--------- src/commands/update/update-check.ts | 2 +- src/core/{host => auth}/auth-resolver.ts | 2 +- src/{commands/_common => core/auth}/token.ts | 2 +- .../dependencies/sonarsource-binary.ts | 4 ++-- .../framework/features/install-integration.ts | 2 +- src/core/framework/features/types.ts | 2 +- src/core/host/auth-connection-recorder.ts | 2 +- .../host}/context-augmentation-env.ts | 0 .../host/{ => environment}/agent-detector.ts | 0 .../host/{ => environment}/distribution.ts | 0 .../{ => environment}/platform-detector.ts | 2 +- .../host/{ => environment}/tool-detector.ts | 2 +- src/core/host/identity-fetch.ts | 2 +- src/core/host/install/binary.ts | 2 +- src/core/host/install/context-augmentation.ts | 12 ++++++------ src/core/host/install/sca-scanner.ts | 4 ++-- src/core/host/install/secrets.ts | 4 ++-- src/core/host/{ => install}/signatures.ts | 0 src/core/host/mcp/mcp-helper.ts | 4 ++-- src/core/project-info.ts | 4 ++-- src/core/server/discover-project-by-remote.ts | 2 +- .../server}/sca-availability.ts | 2 +- src/core/state/state-manager.ts | 2 +- src/core/state/state.ts | 4 ++-- src/core/telemetry/identity.ts | 2 +- src/core/telemetry/index.ts | 2 +- src/core/telemetry/integrate-telemetry.ts | 2 +- src/core/telemetry/sca-analysis-telemetry.ts | 2 +- src/core/telemetry/sqaa-analysis-telemetry.ts | 2 +- src/core/telemetry/telemetry-events.ts | 4 ++-- .../ui/components}/agent-prompt-hint.ts | 2 +- src/{commands/_common => core/ui}/parsing.ts | 0 src/core/update/notification.ts | 2 +- tests/_common/agent-hint-assertions.ts | 2 +- tests/e2e/context/cag-codex.test.ts | 2 +- tests/e2e/context/cag-copilot.test.ts | 2 +- tests/e2e/context/cag-cursor.test.ts | 2 +- tests/e2e/context/cag-edge-cases.test.ts | 4 ++-- tests/e2e/context/cag-integrate.test.ts | 2 +- tests/e2e/context/cag-offline.test.ts | 4 ++-- tests/e2e/secrets-output-parser.test.ts | 2 +- .../integration/harness/environment-builder.ts | 4 ++-- .../analyze/analyze-dependency-risks.test.ts | 2 +- .../specs/analyze/analyze-secrets.test.ts | 2 +- tests/integration/specs/auth/auth.test.ts | 2 +- .../specs/auth/env-auth-state-sync.test.ts | 2 +- .../hook/hook-agent-prompt-submit.test.ts | 2 +- .../hook/hook-antigravity-pre-tool-use.test.ts | 2 +- .../hook/hook-copilot-pre-tool-use.test.ts | 2 +- .../hook/hook-cursor-prompt-submit.test.ts | 2 +- .../specs/hook/hook-git-pre-commit.test.ts | 2 +- .../specs/hook/hook-git-pre-push.test.ts | 2 +- .../integration/specs/integrate/claude.test.ts | 2 +- .../integrate/context-augmentation.test.ts | 4 ++-- .../specs/update/post-update.test.ts | 2 +- .../unit/commands/analyze/analyze-all.test.ts | 2 +- .../unit/commands/analyze/analyze-sqaa.test.ts | 2 +- .../manifest-secrets-guard.test.ts | 2 +- .../sca-scan-orchestrator.test.ts | 2 +- .../dependency-risk-helpers/sca-urls.test.ts | 2 +- .../analyze/dependency-risks.smoke.test.ts | 2 +- .../unit/commands/analyze/secret-scan.test.ts | 2 +- .../commands/analyze/secrets-install.test.ts | 4 ++-- tests/unit/commands/api/api-command.test.ts | 2 +- tests/unit/commands/auth/auth-helpers.test.ts | 2 +- tests/unit/commands/auth/auth-security.test.ts | 2 +- .../auth/auth-token-interactive.test.ts | 2 +- .../commands/hook/agent-post-tool-use.test.ts | 2 +- .../commands/hook/agent-prompt-submit.test.ts | 2 +- .../commands/hook/claude-pre-tool-use.test.ts | 2 +- .../commands/hook/codex-post-tool-use.test.ts | 2 +- .../commands/hook/cursor-pre-file-read.test.ts | 2 +- .../commands/hook/cursor-pre-tool-use.test.ts | 2 +- .../commands/hook/cursor-prompt-submit.test.ts | 2 +- ...-pre-commit-dependency-risks.mocked.test.ts | 2 +- tests/unit/commands/hook/git.test.ts | 2 +- .../_common/agent-integrate-prelude.test.ts | 2 +- .../_common/preflight-summary.test.ts | 2 +- .../integrate/claude/integrate.test.ts | 4 ++-- .../unit/commands/integrate/claude/mcp.test.ts | 2 +- .../commands/integrate/codex/integrate.test.ts | 4 ++-- .../integrate/copilot/integrate.test.ts | 4 ++-- .../git/git-integration-subfeatures.test.ts | 2 +- tests/unit/commands/list/list.test.ts | 2 +- .../commands/list/projects-command.test.ts | 2 +- tests/unit/commands/run/mcp.test.ts | 4 ++-- .../{_common => }/sonar-command.test.ts | 7 +++---- .../commands/update/update-version.test.ts | 4 ++-- .../auth/auth-resolver.test.ts | 4 ++-- .../core/host/auth-connection-recorder.test.ts | 2 +- .../host}/context-augmentation-env.test.ts | 2 +- .../{ => environment}/agent-detector.test.ts | 2 +- .../{ => environment}/distribution.test.ts | 5 ++++- .../platform-detector.test.ts | 2 +- .../{ => environment}/tool-detector.test.ts | 6 +++--- tests/unit/core/host/install/binary.test.ts | 2 +- tests/unit/core/state/state-manager.test.ts | 2 +- tests/unit/core/telemetry/identity.test.ts | 4 ++-- .../core/telemetry/integrate-telemetry.test.ts | 2 +- .../telemetry/sca-analysis-telemetry.test.ts | 2 +- .../telemetry/sqaa-analysis-telemetry.test.ts | 2 +- .../core/telemetry/telemetry-events.test.ts | 6 +++--- tests/unit/core/telemetry/telemetry.test.ts | 8 ++++---- .../_common => core/ui}/parsing.test.ts | 2 +- .../core/update/telemetry-migration.test.ts | 2 +- 158 files changed, 230 insertions(+), 227 deletions(-) rename src/commands/{_common => }/sonar-command.ts (98%) rename src/core/{host => auth}/auth-resolver.ts (98%) rename src/{commands/_common => core/auth}/token.ts (99%) rename src/{commands/_common => core/host}/context-augmentation-env.ts (100%) rename src/core/host/{ => environment}/agent-detector.ts (100%) rename src/core/host/{ => environment}/distribution.ts (100%) rename src/core/host/{ => environment}/platform-detector.ts (96%) rename src/core/host/{ => environment}/tool-detector.ts (97%) rename src/core/host/{ => install}/signatures.ts (100%) rename src/{commands/_common => core/server}/sca-availability.ts (97%) rename src/{commands/_common => core/ui/components}/agent-prompt-hint.ts (93%) rename src/{commands/_common => core/ui}/parsing.ts (100%) rename tests/unit/commands/{_common => }/sonar-command.test.ts (98%) rename tests/unit/{commands => core}/auth/auth-resolver.test.ts (99%) rename tests/unit/{commands/_common => core/host}/context-augmentation-env.test.ts (98%) rename tests/unit/core/host/{ => environment}/agent-detector.test.ts (99%) rename tests/unit/core/host/{ => environment}/distribution.test.ts (93%) rename tests/unit/core/host/{ => environment}/platform-detector.test.ts (95%) rename tests/unit/core/host/{ => environment}/tool-detector.test.ts (96%) rename tests/unit/{commands/_common => core/ui}/parsing.test.ts (83%) diff --git a/CLAUDE.md b/CLAUDE.md index aae147770..6fd7f5a4b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -37,7 +37,7 @@ bun run test:e2e # end-to-end tests Each command lives in `src/commands/`. The command tree is defined in `src/commands/command-tree.ts` and the entry point is `src/index.ts`. To add a new command: add it to `src/commands/command-tree.ts` and implement the logic in a new folder under `src/commands/`. -Please declare commands using the type defined in `src/commands/_common/sonar-command.ts`. +Please declare commands using the type defined in `src/commands/sonar-command.ts`. By default, new commands should register a `authenticatedAction()`, only technical commands will use `anonymousAction()`. Visible top-level commands use their main `description()` as root help copy. Every visible top-level command should declare `rootHelp({ category })` so the custom root menu can group commands with blank lines between the `core`, `data`, `integrate`, and `cli-management` sections. The order within each group follows the declaration order in `src/commands/command-tree.ts`, so add or move top-level commands in the desired display order there. When a visible top-level command has visible subcommands, the custom root menu derives its label automatically as `name ` unless that command also sets `rootHelp({ expandSubcommands: true })`, in which case the parent command is rendered as just `name` and its visible subcommands are listed individually below it. Add `rootHelp({ label })` only when the default label is not enough. If a command should disappear from help entirely, declare it with Commander `{ hidden: true }` and leave an inline comment when hiding a public compatibility command. The bare `sonar analyze` command accepts `-p, --project ` for the agentic portion of the combined flow. Use it to override auto-detection or to run `sonar analyze` without an installed project integration; `--branch` remains specific to `analyze agentic` / `verify`. SQAA accepts `--depth STANDARD|DEEP`: change-set and multi `--file` default to DEEP; single `--file` defaults to STANDARD unless `--depth DEEP` is set. Per-edit hooks force STANDARD; end-of-turn instructions tell agents to always pass `--depth DEEP` (even for a single file). @@ -92,7 +92,7 @@ Before installing, `sonar integrate claude|copilot|cursor|codex|antigravity` pre After the CAG entitlement check passes, the integrate flow also queries SCA availability via `SonarQubeClient.getScaEnablement(connectionType, orgKey)` (`/sca/feature-enabled` on cloud, `/api/v2/sca/feature-enabled` on SonarQube Server). The resolved boolean is passed to `sonar-context-augmentation tool print-skill` as `--sca-enabled=true|false`, and is persisted on declarative feature attrs together with the recorded `serverUrl`, `orgKey`, and `projectKey` so `sonar context` and post-update can reuse the same connection metadata without re-querying the server. A check failure (network/404) emits a warn line and proceeds with `--sca-enabled=false`. -The CAG installer (`src/core/host/install/context-augmentation.ts`) handles `.tar.gz` archives: download → verify detached `.asc` PGP signature → gunzip + USTAR-extract the inner binary into `~/.sonar/sonarqube-cli/bin/`. Tar reading is in `src/core/io/tar.ts` (no external dep). The pinned CAG version is in `package.json#externalBinaries["sonar-context-augmentation"]` and `src/core/host/signatures.ts`. In the declarative framework, the CAG binary is managed as a shared dependency (`sonar-context-augmentation`), while a single declarative feature owns both the skill file resource and the install-only `tool integrate` operation with the invocation prefix forced to `sonar context`. +The CAG installer (`src/core/host/install/context-augmentation.ts`) handles `.tar.gz` archives: download → verify detached `.asc` PGP signature → gunzip + USTAR-extract the inner binary into `~/.sonar/sonarqube-cli/bin/`. Tar reading is in `src/core/io/tar.ts` (no external dep). The pinned CAG version is in `package.json#externalBinaries["sonar-context-augmentation"]` and `src/core/host/install/signatures.ts`. In the declarative framework, the CAG binary is managed as a shared dependency (`sonar-context-augmentation`), while a single declarative feature owns both the skill file resource and the install-only `tool integrate` operation with the invocation prefix forced to `sonar context`. ### System reset @@ -149,12 +149,12 @@ Error subclasses extend the abstract `CliError` and carry their own `exitCode`, - **Env-var auth records state exactly like `sonar auth login`, minus the keychain write (CLI-866).** `resolveAuth()` (`src/core/host/auth-resolver.ts`) is `resolveFromEnv() ?? resolveFromState()`; whenever the env branch resolves, it calls `recordConnectionFromAuth()` (`src/core/host/auth-connection-recorder.ts`) before returning. That helper is the same state-writing step `sonar auth login` uses: `addOrUpdateConnection()` (server/org/region/tokenName) plus identity enrichment via `resolveTelemetryIdentity()` (`src/core/host/identity-fetch.ts`) — it just never calls `saveToken()`, since env-var auth exists specifically for sandboxed/headless environments (CLI-692) that cannot access the keychain in the first place. It no-ops (no state write, no network call) when the active connection already matches the resolved auth and its identity is already complete (`needsIdentityEnrichment()`), and accepts `force: true` to bypass that check — used by `login.ts` itself, since an explicit `sonar auth login` must always refresh `authenticatedAt`/`tokenName` even when re-authenticating to an already-known connection. `resolveAuth({ silent: true })` suppresses the "partial env vars" warning for callers (telemetry) that must not surface a diagnostic on every command. `src/core/host/sonarcloud-region.ts` holds the pure URL/region helpers (`cloudRegionFromUrl`, `resolveFromEndpoint`, etc., re-exported from `auth-resolver.ts` for compatibility) that both `auth-resolver.ts` and `identity-fetch.ts` need, without creating an import cycle between the two. - All path and URL constants live in `src/core/config-constants.ts` — import from there instead of hardcoding. - Shared Sonar product data lives under `~/.sonar`; CLI-specific data stays under `~/.sonar/sonarqube-cli`, and the stable anonymous telemetry user ID is shared at `~/.sonar/user`. `SONAR_USER_HOME` is only a late-bound override for state persistence and telemetry user-id codepaths; other exported path constants remain fixed after import. -- Caller-agent hints (Cursor, Claude Code, Copilot CLI, Codex, or Antigravity) from the environment: `src/core/host/agent-detector.ts` (`detectCallerAgent`, etc.). +- Caller-agent hints (Cursor, Claude Code, Copilot CLI, Codex, or Antigravity) from the environment: `src/core/host/environment/agent-detector.ts` (`detectCallerAgent`, etc.). - `sonar auth logout` relies on state: if there is no active connection or `isAuthenticated` is false, it only reports that you are already logged out (no keychain changes). - When `sonar auth login` runs the browser-based OAuth flow, the server-generated token name returned in the callback POST body is captured and persisted on the connection as `tokenName` (see `AuthConnection` in `src/core/state/state.ts`). The wire field is `name` (matching `/api/user_tokens/revoke?name=`); we keep it as `tokenName` in-memory to disambiguate from other "name" fields. - On `sonar auth logout`, the CLI best-effort revokes the server-side token via `SonarQubeClient.revokeUserToken(...)` (a one-line wrapper over the generic `postForm(endpoint, params)` helper) before clearing the keychain entry. Failures (network error, non-2xx response) are reported via a warning on stderr; local cleanup still proceeds. When the connection has no `tokenName` (e.g. upgraded from an older CLI version), the CLI emits a manual-revocation hint on stderr instead. - `sonar system status` displays a diagnostic overview: authentication (token verified live via `/api/authentication/validate`, four states: Not Set / Active / Invalid / Set Unverified), installed binaries with update availability, configured integrations with paths, and MCP Server configured/running status. Supports `--json` for machine consumption. Implementation in `src/commands/system/status.ts`. Token verification uses `checkTokenStatus` from `_common/token.ts`; CLI update availability comes from `Distribution/sonarqube-cli/stable.version`, while `sonar update` downloads the platform installer script from the GitHub `user-scripts/` directory when it actually performs the update. MCP config validation is JSON-based for Claude/Copilot (checks `mcpServers.sonarqube` structure) and trusts file existence for Codex TOML configs. -- `sonar self-update` is a deprecated, hidden alias for `sonar update` (only when `CURRENT_DISTRIBUTION.enableSelfUpdate` is true; see `src/core/host/distribution.ts`): calling it prints a deprecation warning pointing to `sonar update`, then runs the same `updateVersion()` logic. Both are registered in `src/commands/command-tree.ts`. +- `sonar self-update` is a deprecated, hidden alias for `sonar update` (only when `CURRENT_DISTRIBUTION.enableSelfUpdate` is true; see `src/core/host/environment/distribution.ts`): calling it prints a deprecation warning pointing to `sonar update`, then runs the same `updateVersion()` logic. Both are registered in `src/commands/command-tree.ts`. ## Tests diff --git a/build-scripts/build-binary.ts b/build-scripts/build-binary.ts index e009d6db3..0e938741e 100644 --- a/build-scripts/build-binary.ts +++ b/build-scripts/build-binary.ts @@ -27,7 +27,7 @@ import { join } from 'node:path'; -import { resolveDistribution } from '@/core/host/distribution.ts'; +import { resolveDistribution } from '@/core/host/environment/distribution.ts'; const PROJECT_ROOT = join(import.meta.dir, '..'); const DEFAULT_OUTFILE = join(PROJECT_ROOT, 'dist', 'sonarqube-cli'); diff --git a/build-scripts/docs/generate-docs.ts b/build-scripts/docs/generate-docs.ts index 3d0108d3e..0ea6d099a 100644 --- a/build-scripts/docs/generate-docs.ts +++ b/build-scripts/docs/generate-docs.ts @@ -30,9 +30,10 @@ import { fileURLToPath } from 'node:url'; import type { Option } from 'commander'; +import { COMMAND_TREE } from '@/commands/command-tree.ts'; +import type { SonarCommand } from '@/commands/sonar-command.ts'; + import { version } from '../../package.json'; -import type { SonarCommand } from '../../src/commands/_common/sonar-command.ts'; -import { COMMAND_TREE } from '../../src/commands/command-tree.ts'; import { EXAMPLES } from './examples'; const __dirname = dirname(fileURLToPath(import.meta.url)); diff --git a/build-scripts/fetch-signatures.ts b/build-scripts/fetch-signatures.ts index 6bea3ee04..b500717f6 100644 --- a/build-scripts/fetch-signatures.ts +++ b/build-scripts/fetch-signatures.ts @@ -21,7 +21,7 @@ /** * Build-time script: download and verify .asc signature files for all * external binaries at the pinned version, then embed them - * into src/core/host/signatures.ts so they compile into the binary. + * into src/core/host/install/signatures.ts so they compile into the binary. * * Run after bumping the version in package.json#externalBinaries: * bun run fetch:signatures @@ -38,7 +38,7 @@ import { readFileSync, writeFileSync } from 'node:fs'; import * as openpgp from 'openpgp'; import { SONARSOURCE_BINARIES_URL } from '@/core/config-constants.ts'; -import { SONARSOURCE_PUBLIC_KEY } from '@/core/host/signatures.ts'; +import { SONARSOURCE_PUBLIC_KEY } from '@/core/host/install/signatures.ts'; interface Platform { os: string; @@ -71,7 +71,7 @@ interface SignatureResult { armoredSignature: string; } -const SIGNATURES_TS_PATH = new URL('../src/core/host/signatures.ts', import.meta.url); +const SIGNATURES_TS_PATH = new URL('../src/core/host/install/signatures.ts', import.meta.url); const PACKAGE_JSON_PATH = new URL('../package.json', import.meta.url); async function fetchSignatures(): Promise { diff --git a/build-scripts/setup-integration-resources.ts b/build-scripts/setup-integration-resources.ts index 3e6e2520d..209b94a57 100644 --- a/build-scripts/setup-integration-resources.ts +++ b/build-scripts/setup-integration-resources.ts @@ -34,11 +34,11 @@ import { existsSync, mkdirSync, statSync } from 'node:fs'; import { chmod } from 'node:fs/promises'; import { join } from 'node:path'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import type { BinarySpec } from '@/core/host/install/binary.ts'; import { SCA_SCANNER_SPEC } from '@/core/host/install/sca-scanner.ts'; import { SECRETS_SPEC } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { buildCagDownloadUrl, buildDownloadUrl, diff --git a/src/commands/analyze/analyze-all.ts b/src/commands/analyze/analyze-all.ts index 2826e9bfe..8debf3050 100644 --- a/src/commands/analyze/analyze-all.ts +++ b/src/commands/analyze/analyze-all.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { resolveSecretsBinaryPath } from '@/core/host/install/secrets.ts'; import { SECRETS_CALLER_COMMANDS } from '@/core/telemetry/secrets-analysis-telemetry.ts'; import { SQAA_ANALYZE_CALLER_COMMAND } from '@/core/telemetry/sqaa-analysis-telemetry.ts'; diff --git a/src/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.ts b/src/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.ts index 2be3a1dc7..0ad23a4a4 100644 --- a/src/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.ts +++ b/src/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.ts @@ -21,8 +21,8 @@ import { tmpdir } from 'node:os'; import { isAbsolute, join } from 'node:path'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { formatSpawnOutput } from '@/core/host/install/install-utils.ts'; import type { ScaScannerInstaller } from '@/core/host/install/sca-scanner.ts'; import type { SecretsInstaller } from '@/core/host/install/secrets.ts'; diff --git a/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts b/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts index 2a3273c5c..e2e44c918 100644 --- a/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts +++ b/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts @@ -21,8 +21,8 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SCA_SCANNER_CACHE_DIR } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { ScaScannerInstaller } from '@/core/host/install/sca-scanner.ts'; import type { SecretsInstaller } from '@/core/host/install/secrets.ts'; import logger, { getLogLevelConfig } from '@/core/observability/logger.ts'; @@ -34,7 +34,7 @@ import { } from '@/core/telemetry/sca-analysis-telemetry.ts'; import { withSpinner } from '@/core/ui'; -import { assertScaAvailable } from '../../_common/sca-availability.ts'; +import { assertScaAvailable } from '../../../core/server/sca-availability.ts'; import { parseAnalysisProperties } from './analysis-properties.ts'; import { preScanManifestsForSecrets } from './manifest-secrets-guard.ts'; import { type AnalyzeProjectResponse, ScaScannerRunner } from './sca-scanner.ts'; diff --git a/src/commands/analyze/dependency-risk-helpers/sca-urls.ts b/src/commands/analyze/dependency-risk-helpers/sca-urls.ts index 7e739b91f..cb5b65ac8 100644 --- a/src/commands/analyze/dependency-risk-helpers/sca-urls.ts +++ b/src/commands/analyze/dependency-risk-helpers/sca-urls.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { type ResolvedAuth, resolveFromEndpoint } from '@/core/auth/auth-resolver.ts'; import { SONARCLOUD_SCA_SCANNER_CDN_URL } from '@/core/config-constants.ts'; -import { type ResolvedAuth, resolveFromEndpoint } from '@/core/host/auth-resolver.ts'; export interface ScaUrls { apiBaseUrl: string; diff --git a/src/commands/analyze/dependency-risks.ts b/src/commands/analyze/dependency-risks.ts index c63664986..febc7105d 100644 --- a/src/commands/analyze/dependency-risks.ts +++ b/src/commands/analyze/dependency-risks.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; -import { type ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { DefaultScaScannerInstaller } from '@/core/host/install/sca-scanner.ts'; import { DefaultSecretsInstaller } from '@/core/host/install/secrets.ts'; import { discoverProject } from '@/core/project-info.ts'; diff --git a/src/commands/analyze/secrets.ts b/src/commands/analyze/secrets.ts index f462fc802..7d7fdca37 100644 --- a/src/commands/analyze/secrets.ts +++ b/src/commands/analyze/secrets.ts @@ -20,8 +20,8 @@ import { randomUUID } from 'node:crypto'; import { existsSync } from 'node:fs'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { buildSubprocessNetworkEnv } from '@/core/host/connectivity/network-config.ts'; import { installSecretsBinary } from '@/core/host/install/secrets.ts'; import logger from '@/core/observability/logger.ts'; diff --git a/src/commands/analyze/sqaa-auth.ts b/src/commands/analyze/sqaa-auth.ts index 0a51bd82d..9d0fdf03a 100644 --- a/src/commands/analyze/sqaa-auth.ts +++ b/src/commands/analyze/sqaa-auth.ts @@ -20,15 +20,15 @@ // Auth and project-key resolution for SQAA commands. -import { printAgentNonInteractiveAlternativeHint } from '@/commands/_common/agent-prompt-hint.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { selectRecordedFeatureForDir } from '@/core/host/recorded-feature-resolver.ts'; import logger from '@/core/observability/logger.ts'; import type { InstalledIntegrationFeature, IntegrationStateAttribute } from '@/core/state/state.ts'; import { loadState } from '@/core/state/state-repository.ts'; import { noteProject } from '@/core/telemetry/project-uuid.ts'; import { blank, confirmPrompt, text, warn } from '@/core/ui'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; import { SQAA_HOOK_FEATURE_ID } from '../integrate/_common/features/sqaa-instructions-feature.ts'; import { isProjectVortexFeature } from '../integrate/_common/vortex.ts'; diff --git a/src/commands/analyze/sqaa-json-report.ts b/src/commands/analyze/sqaa-json-report.ts index b287a0588..7159f0766 100644 --- a/src/commands/analyze/sqaa-json-report.ts +++ b/src/commands/analyze/sqaa-json-report.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { timed } from '@/core/observability/timed.ts'; import type { SqaaAnalysisDepth } from '@/core/server/client.ts'; diff --git a/src/commands/analyze/sqaa-run.ts b/src/commands/analyze/sqaa-run.ts index 409e40164..6c2b247d8 100644 --- a/src/commands/analyze/sqaa-run.ts +++ b/src/commands/analyze/sqaa-run.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { timed } from '@/core/observability/timed.ts'; import type { SqaaAnalysisDepth } from '@/core/server/client.ts'; import { diff --git a/src/commands/analyze/sqaa-types.ts b/src/commands/analyze/sqaa-types.ts index d68670ea2..368a42370 100644 --- a/src/commands/analyze/sqaa-types.ts +++ b/src/commands/analyze/sqaa-types.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { SqaaAnalysisDepth } from '@/core/server/client.ts'; import type { SqaaTelemetryCallerCommand } from '@/core/telemetry/sqaa-analysis-telemetry.ts'; diff --git a/src/commands/analyze/sqaa.ts b/src/commands/analyze/sqaa.ts index 0d627c187..8fd40fe92 100644 --- a/src/commands/analyze/sqaa.ts +++ b/src/commands/analyze/sqaa.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { SqaaAnalysisDepth } from '@/core/server/client.ts'; import { text } from '@/core/ui'; diff --git a/src/commands/api/api.ts b/src/commands/api/api.ts index d9effdcec..4af569cd3 100644 --- a/src/commands/api/api.ts +++ b/src/commands/api/api.ts @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; import { CLOUD_API_DOCS_URL, SERVER_API_DOCS_URL } from '@/core/config-constants.ts'; -import { type ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { GENERIC_HTTP_METHODS, type HttpMethod, diff --git a/src/commands/auth/login.ts b/src/commands/auth/login.ts index 921716bcc..c495a032f 100644 --- a/src/commands/auth/login.ts +++ b/src/commands/auth/login.ts @@ -18,11 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { type BrowserAuthResult, generateTokenViaBrowser } from '@/commands/_common/token.ts'; +import { isSonarQubeCloud } from '@/core/auth/auth-resolver.ts'; +import { type BrowserAuthResult, generateTokenViaBrowser } from '@/core/auth/token.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; import { SONARCLOUD_URL, SONARCLOUD_US_URL } from '@/core/config-constants.ts'; import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; -import { isSonarQubeCloud } from '@/core/host/auth-resolver.ts'; import { deleteStaleTokens, getToken as getKeystoreToken, diff --git a/src/commands/auth/status.ts b/src/commands/auth/status.ts index 0746e4876..29977a0b3 100644 --- a/src/commands/auth/status.ts +++ b/src/commands/auth/status.ts @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { TokenCheckResult } from '@/commands/_common/token.ts'; -import { checkTokenStatus } from '@/commands/_common/token.ts'; +import { ENV_ORG, ENV_SERVER, ENV_TOKEN, resolveFromEnv } from '@/core/auth/auth-resolver.ts'; +import type { TokenCheckResult } from '@/core/auth/token.ts'; +import { checkTokenStatus } from '@/core/auth/token.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import { ENV_ORG, ENV_SERVER, ENV_TOKEN, resolveFromEnv } from '@/core/host/auth-resolver.ts'; import { getToken as getKeystoreToken } from '@/core/host/keychain.ts'; import { loadState } from '@/core/state/state-repository.ts'; import { blank, note, print, withSpinner } from '@/core/ui'; diff --git a/src/commands/command-tree.ts b/src/commands/command-tree.ts index ec0914327..2193e272f 100644 --- a/src/commands/command-tree.ts +++ b/src/commands/command-tree.ts @@ -21,7 +21,7 @@ import { type Command, Help, InvalidArgumentError, Option } from 'commander'; import { CommandFailedError } from '@/core/command-error.ts'; -import { CURRENT_DISTRIBUTION } from '@/core/host/distribution.ts'; +import { CURRENT_DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import { initSentry } from '@/core/observability/sentry.ts'; import { GENERIC_HTTP_METHODS } from '@/core/server/client.ts'; import { MAX_PAGE_SIZE } from '@/core/server/projects.ts'; @@ -39,8 +39,7 @@ import { import { blank, error, warn } from '@/core/ui'; import { version as VERSION } from '../../package.json'; -import { parseInteger } from './_common/parsing.ts'; -import { SonarCommand } from './_common/sonar-command.ts'; +import { parseInteger } from '../core/ui/parsing.ts'; import { analyzeAll, type AnalyzeAllOptions } from './analyze/analyze-all.ts'; import type { Severity } from './analyze/dependency-risk-helpers/sca-scanner.ts'; import { SEVERITIES } from './analyze/dependency-risk-helpers/view-model/build/severity.ts'; @@ -98,6 +97,7 @@ import { listProjects, type ListProjectsOptions } from './list/projects.ts'; import { remediate, type RemediateOptions } from './remediate'; import { getBanner, getCustomRootHelp } from './root-help.ts'; import { runMcp } from './run/mcp.ts'; +import { SonarCommand } from './sonar-command.ts'; import { systemReset, type SystemResetOptions } from './system/reset.ts'; import { systemStatus, type SystemStatusOptions } from './system/status.ts'; import { updateVersion, type UpdateVersionOptions } from './update'; diff --git a/src/commands/context/index.ts b/src/commands/context/index.ts index 67ec57d7d..39f98b39f 100644 --- a/src/commands/context/index.ts +++ b/src/commands/context/index.ts @@ -20,12 +20,12 @@ import { spawn } from 'node:child_process'; -import { buildContextAugmentationEnv } from '@/commands/_common/context-augmentation-env.ts'; import { CONTEXT_AUGMENTATION_FEATURE_ID } from '@/commands/integrate/_common/features/context-augmentation-feature.ts'; import { isProjectVortexFeature } from '@/commands/integrate/_common/vortex.ts'; +import { resolveAuth, type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import { SONAR_CONTEXT_INVOCATION } from '@/core/config-constants.ts'; -import { resolveAuth, type ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import { buildContextAugmentationEnv } from '@/core/host/context-augmentation-env.ts'; import { resolveContextWorkspaceRoot } from '@/core/host/git/worktree.ts'; import { resolveContextAugmentationBinaryPath } from '@/core/host/install/context-augmentation.ts'; import { getToken } from '@/core/host/keychain.ts'; diff --git a/src/commands/hook/agent-post-tool-use.ts b/src/commands/hook/agent-post-tool-use.ts index dfdb1e001..089e95a99 100644 --- a/src/commands/hook/agent-post-tool-use.ts +++ b/src/commands/hook/agent-post-tool-use.ts @@ -23,8 +23,8 @@ import { existsSync, readFileSync } from 'node:fs'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { AGENTIC_PACK_URL } from '@/core/config-constants.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; import { canonicalizePath, toRelativePosixPath } from '@/core/io/fs-utils.ts'; import logger from '@/core/observability/logger.ts'; import { timed } from '@/core/observability/timed.ts'; diff --git a/src/commands/hook/codex-post-tool-use.ts b/src/commands/hook/codex-post-tool-use.ts index c80504f73..62872d0ac 100644 --- a/src/commands/hook/codex-post-tool-use.ts +++ b/src/commands/hook/codex-post-tool-use.ts @@ -22,8 +22,8 @@ import { buildSqaaJsonReport } from '@/commands/analyze/sqaa.ts'; import type { SqaaJsonReport } from '@/commands/analyze/sqaa-display.ts'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { AGENTIC_PACK_URL } from '@/core/config-constants.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; import logger from '@/core/observability/logger.ts'; import { SqaaForbiddenError } from '@/core/server/errors.ts'; import { noteProject } from '@/core/telemetry/project-uuid.ts'; diff --git a/src/commands/hook/git-pre-commit-dependency-risks.ts b/src/commands/hook/git-pre-commit-dependency-risks.ts index 08fec6d44..a20950a8b 100644 --- a/src/commands/hook/git-pre-commit-dependency-risks.ts +++ b/src/commands/hook/git-pre-commit-dependency-risks.ts @@ -24,8 +24,8 @@ // missing, scanner failure), and blocks the commit only when risks matching the // configured filter are found. +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { resolveScaScannerBinaryPath, ScaScannerNoopInstaller, diff --git a/src/commands/hook/git-pre-commit-secrets.ts b/src/commands/hook/git-pre-commit-secrets.ts index 9e4d50772..91a5fa263 100644 --- a/src/commands/hook/git-pre-commit-secrets.ts +++ b/src/commands/hook/git-pre-commit-secrets.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { resolveSecretsBinaryPath } from '@/core/host/install/secrets.ts'; import { SECRETS_CALLER_COMMANDS } from '@/core/telemetry/secrets-analysis-telemetry.ts'; import { print } from '@/core/ui'; diff --git a/src/commands/hook/git-pre-commit.ts b/src/commands/hook/git-pre-commit.ts index 3e0e21451..98ae82093 100644 --- a/src/commands/hook/git-pre-commit.ts +++ b/src/commands/hook/git-pre-commit.ts @@ -22,8 +22,8 @@ // when --dependency-risks is set, runs a dependency-risks scan as a follow-up stage. // Replaces the shell logic that was previously embedded in the git hook script. +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; import { spawnProcess } from '@/core/process/process.ts'; import { noteProject } from '@/core/telemetry/project-uuid.ts'; diff --git a/src/commands/hook/git-pre-push-secrets.ts b/src/commands/hook/git-pre-push-secrets.ts index b139e0113..fbce50d74 100644 --- a/src/commands/hook/git-pre-push-secrets.ts +++ b/src/commands/hook/git-pre-push-secrets.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { resolveSecretsBinaryPath } from '@/core/host/install/secrets.ts'; import { SECRETS_CALLER_COMMANDS } from '@/core/telemetry/secrets-analysis-telemetry.ts'; diff --git a/src/commands/hook/git-pre-push.ts b/src/commands/hook/git-pre-push.ts index 13c2ef211..dbaafa053 100644 --- a/src/commands/hook/git-pre-push.ts +++ b/src/commands/hook/git-pre-push.ts @@ -21,7 +21,7 @@ // git pre-push callback handler — scans files in new commits for secrets. // Replaces the shell logic that was previously embedded in the git hook script. -import { resolveAuth } from '@/core/host/auth-resolver.ts'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { spawnProcess } from '@/core/process/process.ts'; import { runSecretsStage } from './git-pre-push-secrets.ts'; diff --git a/src/commands/hook/hook-dependencies.ts b/src/commands/hook/hook-dependencies.ts index a32d8b02f..d34cc6432 100644 --- a/src/commands/hook/hook-dependencies.ts +++ b/src/commands/hook/hook-dependencies.ts @@ -21,9 +21,9 @@ // Shared guard for hook handlers — resolves auth and binary path, throwing // MissingDependenciesError if either is unavailable so handlers fail loudly. +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { isEnvBasedAuth, resolveAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import { isEnvBasedAuth, resolveAuth } from '@/core/host/auth-resolver.ts'; import { resolveSecretsBinaryPath } from '@/core/host/install/secrets.ts'; import type { SecretsCallerCommand } from '@/core/telemetry/secrets-analysis-telemetry.ts'; import { warn } from '@/core/ui'; diff --git a/src/commands/import/index.ts b/src/commands/import/index.ts index 100192adb..68bcdf8a3 100644 --- a/src/commands/import/index.ts +++ b/src/commands/import/index.ts @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import { runWithConcurrencyLimit } from '@/core/concurrency/concurrency-pool.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { type DopRepository, type ProvisionedProject, diff --git a/src/commands/integrate/_common/agent-integrate-postlude.ts b/src/commands/integrate/_common/agent-integrate-postlude.ts index 44813b06c..3cb7086b1 100644 --- a/src/commands/integrate/_common/agent-integrate-postlude.ts +++ b/src/commands/integrate/_common/agent-integrate-postlude.ts @@ -23,8 +23,8 @@ // agent-specific feature flags, resolve Vortex, assemble the integration // options and recorded attrs, and run the install. +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { installIntegration } from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { supportedIntegrations } from '../index.ts'; import { diff --git a/src/commands/integrate/_common/agent-integrate-prelude.ts b/src/commands/integrate/_common/agent-integrate-prelude.ts index d76a5b955..80f6996a4 100644 --- a/src/commands/integrate/_common/agent-integrate-prelude.ts +++ b/src/commands/integrate/_common/agent-integrate-prelude.ts @@ -22,8 +22,8 @@ import { homedir } from 'node:os'; +import { isSonarQubeCloud, type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; -import { isSonarQubeCloud, type ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { type DiscoveredProject, discoverProject } from '@/core/project-info.ts'; import type { IntegrationScope } from '@/core/state/state.ts'; import { intro, warn, withSpinner } from '@/core/ui'; diff --git a/src/commands/integrate/_common/context-augmentation-dependency.ts b/src/commands/integrate/_common/context-augmentation-dependency.ts index b66dfd2ef..8c6ef6702 100644 --- a/src/commands/integrate/_common/context-augmentation-dependency.ts +++ b/src/commands/integrate/_common/context-augmentation-dependency.ts @@ -33,8 +33,8 @@ import { installContextAugmentationBinary, resolveContextAugmentationBinaryPath, } from '@/core/host/install/context-augmentation.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; import { stopAllContextAugmentationTools } from './context-augmentation.ts'; diff --git a/src/commands/integrate/_common/context-augmentation.ts b/src/commands/integrate/_common/context-augmentation.ts index 987490b51..7600b7967 100644 --- a/src/commands/integrate/_common/context-augmentation.ts +++ b/src/commands/integrate/_common/context-augmentation.ts @@ -20,12 +20,12 @@ import { spawn } from 'node:child_process'; -import { buildContextAugmentationEnv } from '@/commands/_common/context-augmentation-env.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import { SONAR_CONTEXT_INVOCATION } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import { buildContextAugmentationEnv } from '@/core/host/context-augmentation-env.ts'; import { resolveRecordedRepoRoot } from '@/core/host/git/worktree.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import logger from '@/core/observability/logger.ts'; import type { IntegrationStateAttribute } from '@/core/state/state.ts'; import { discreetSuccess, type OutputChannel, print, text, warn, withSpinner } from '@/core/ui'; diff --git a/src/commands/integrate/_common/features/context-augmentation-feature.ts b/src/commands/integrate/_common/features/context-augmentation-feature.ts index fffe1522b..5bf4a11c1 100644 --- a/src/commands/integrate/_common/features/context-augmentation-feature.ts +++ b/src/commands/integrate/_common/features/context-augmentation-feature.ts @@ -22,8 +22,8 @@ import { CommandFailedError } from '@/core/command-error.ts'; import { install, skip } from '@/core/framework/features/selection.ts'; import type { IntegrationContext, SubfeatureDeclaration } from '@/core/framework/features/types.ts'; import { wholeFile } from '@/core/framework/resources'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; import { getOptionalStringAttr } from '../attrs.ts'; import { diff --git a/src/commands/integrate/_common/preflight-summary.ts b/src/commands/integrate/_common/preflight-summary.ts index 65731d02e..8231e381b 100644 --- a/src/commands/integrate/_common/preflight-summary.ts +++ b/src/commands/integrate/_common/preflight-summary.ts @@ -27,7 +27,11 @@ import { SonarQubeClient } from '@/core/server/client.ts'; import type { PhaseItem, StepStatus } from '@/core/ui'; import { info, outro, phase, phaseItem, text } from '@/core/ui'; -import { checkTokenStatus, type TokenCheckResult, type TokenStatus } from '../../_common/token.ts'; +import { + checkTokenStatus, + type TokenCheckResult, + type TokenStatus, +} from '../../../core/auth/token.ts'; export interface AgentPreflightSummaryOptions { serverUrl: string; diff --git a/src/commands/integrate/_common/vortex.ts b/src/commands/integrate/_common/vortex.ts index 49f9a02e2..358eff926 100644 --- a/src/commands/integrate/_common/vortex.ts +++ b/src/commands/integrate/_common/vortex.ts @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { isSonarQubeCloud, type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { VORTEX_PRODUCT_URL } from '@/core/config-constants.ts'; import type { FeatureContainer, SubfeatureDeclaration } from '@/core/framework/features'; import { askUser, skip } from '@/core/framework/features'; -import { isSonarQubeCloud, type ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import type { InstalledIntegrationFeature } from '@/core/state/state.ts'; import { info, warn } from '@/core/ui'; diff --git a/src/commands/integrate/antigravity/index.ts b/src/commands/integrate/antigravity/index.ts index a63f7d1ce..f0163ac23 100644 --- a/src/commands/integrate/antigravity/index.ts +++ b/src/commands/integrate/antigravity/index.ts @@ -18,11 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { installIntegration } from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { IntegrationStateAttribute } from '@/core/state/state.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import { buildRecordedIntegrationAttrs } from '../_common/context-augmentation.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/claude/index.ts b/src/commands/integrate/claude/index.ts index fdc50791a..1bf3a29c0 100644 --- a/src/commands/integrate/claude/index.ts +++ b/src/commands/integrate/claude/index.ts @@ -22,12 +22,12 @@ import { homedir } from 'node:os'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { installIntegration } from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { IntegrationStateAttribute } from '@/core/state/state.ts'; import { removeObsoleteHookArtifacts } from '@/core/update/claude-hooks-migration.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { displayAgentIntegratePrelude, resolveIntegrateInstallTarget, diff --git a/src/commands/integrate/codex/index.ts b/src/commands/integrate/codex/index.ts index cae448ac7..1b9aa2282 100644 --- a/src/commands/integrate/codex/index.ts +++ b/src/commands/integrate/codex/index.ts @@ -20,9 +20,9 @@ // Integrate command — setup SonarQube integration for Codex. -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; import { finalizeAgentInstall } from '../_common/agent-integrate-postlude.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/copilot/index.ts b/src/commands/integrate/copilot/index.ts index ffc6eaa7f..9cd69fb3d 100644 --- a/src/commands/integrate/copilot/index.ts +++ b/src/commands/integrate/copilot/index.ts @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { finalizeAgentInstall } from '../_common/agent-integrate-postlude.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/cursor/index.ts b/src/commands/integrate/cursor/index.ts index 2a9a8f7ec..e3a4a4df5 100644 --- a/src/commands/integrate/cursor/index.ts +++ b/src/commands/integrate/cursor/index.ts @@ -20,10 +20,10 @@ // Integrate command — setup SonarQube integration for Cursor. -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { warn } from '@/core/ui'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { finalizeAgentInstall } from '../_common/agent-integrate-postlude.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/git/index.ts b/src/commands/integrate/git/index.ts index 0f3680a7d..3ff444cf1 100644 --- a/src/commands/integrate/git/index.ts +++ b/src/commands/integrate/git/index.ts @@ -23,10 +23,10 @@ import { existsSync, readFileSync } from 'node:fs'; import { join } from 'node:path'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; import { GLOBAL_HOOKS_DIR } from '@/core/config-constants.ts'; import { installIntegration } from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { findGitRoot } from '@/core/host/git/discover.ts'; import { GitRepo, resolveGitHooksDir } from '@/core/host/git/hooks.ts'; import { normalizePath } from '@/core/io/fs-utils.ts'; @@ -34,7 +34,7 @@ import { discoverProject } from '@/core/project-info.ts'; import { blank, confirmPrompt, info, intro, phase, phaseItem, text, warn } from '@/core/ui'; import { yellow } from '@/core/ui/colors.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { resolveIntegrateScope } from '../_common/integrate-scope.ts'; import { printGitPreflightSummary } from '../_common/preflight-summary.ts'; import { supportedIntegrations } from '../index.ts'; diff --git a/src/commands/integrate/git/tools/git-integration-subfeatures.ts b/src/commands/integrate/git/tools/git-integration-subfeatures.ts index 8a905de83..424371179 100644 --- a/src/commands/integrate/git/tools/git-integration-subfeatures.ts +++ b/src/commands/integrate/git/tools/git-integration-subfeatures.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; import { scaScannerBinaryDependency, @@ -25,10 +26,9 @@ import { } from '@/core/framework/dependencies'; import { askUser, install, skip } from '@/core/framework/features/selection.ts'; import type { FeaturePreview, SubfeatureDeclaration } from '@/core/framework/features/types.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; -import { assertScaAvailable } from '../../../_common/sca-availability.ts'; +import { assertScaAvailable } from '../../../../core/server/sca-availability.ts'; import type { GitHookType, IntegrateGitOptions } from '../options.ts'; export const PRE_COMMIT_DEP_RISKS_SUBFEATURE_ID = 'pre-commit-dependency-risks'; diff --git a/src/commands/integrate/integrate-bare.ts b/src/commands/integrate/integrate-bare.ts index 96fc046b1..1dc9eb306 100644 --- a/src/commands/integrate/integrate-bare.ts +++ b/src/commands/integrate/integrate-bare.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { selectPrompt } from '@/core/ui'; import { assertIntegrateScopeOptions } from './_common/agent-integrate-prelude.ts'; diff --git a/src/commands/list/issues.ts b/src/commands/list/issues.ts index f7bf51917..126225a90 100644 --- a/src/commands/list/issues.ts +++ b/src/commands/list/issues.ts @@ -22,8 +22,8 @@ import { encode as encodeToToon } from '@toon-format/toon'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { IssuesClient } from '@/core/server/issues.ts'; import { MAX_PAGE_SIZE } from '@/core/server/projects.ts'; diff --git a/src/commands/list/projects.ts b/src/commands/list/projects.ts index 34b75eb8d..cd103da8b 100644 --- a/src/commands/list/projects.ts +++ b/src/commands/list/projects.ts @@ -20,8 +20,8 @@ // Issues command - search for SonarQube issues +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { MAX_PAGE_SIZE, ProjectsClient } from '@/core/server/projects.ts'; import { print } from '@/core/ui'; diff --git a/src/commands/remediate/index.ts b/src/commands/remediate/index.ts index a1beb5fc4..e2b57e309 100644 --- a/src/commands/remediate/index.ts +++ b/src/commands/remediate/index.ts @@ -20,13 +20,13 @@ // Remediate command - triggers AI agent remediation for eligible issues +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; import { AGENT_ACTIVITY_PATH, AGENTIC_PACK_URL, AI_REMEDIATION_DOCS_URL, } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import logger from '@/core/observability/logger.ts'; import { discoverProject } from '@/core/project-info.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; @@ -37,7 +37,7 @@ import { noteProject } from '@/core/telemetry/project-uuid.ts'; import { blank, info, multiSelectPrompt, print, success, withSpinner } from '@/core/ui'; import { cyan, dim, red, yellow } from '@/core/ui/colors.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../core/ui/components/agent-prompt-hint.ts'; export interface RemediateOptions { project?: string; diff --git a/src/commands/root-help.ts b/src/commands/root-help.ts index d8b970af0..3b8be743c 100644 --- a/src/commands/root-help.ts +++ b/src/commands/root-help.ts @@ -23,11 +23,7 @@ import type { Help, Option } from 'commander'; import { softBlue, underline } from '@/core/ui/colors.ts'; import { version as VERSION } from '../../package.json'; -import { - COMMAND_CATEGORIES, - type CommandCategory, - type SonarCommand, -} from './_common/sonar-command.ts'; +import { COMMAND_CATEGORIES, type CommandCategory, type SonarCommand } from './sonar-command.ts'; const BANNER_ART = [ ' █▀ █▀█ █▄ █ ▄▀█ █▀█ █▀█ █ █ █▄▄ █▀▀ ▄█▀ █ █', diff --git a/src/commands/run/mcp.ts b/src/commands/run/mcp.ts index d8e2d6ce3..c13537f04 100644 --- a/src/commands/run/mcp.ts +++ b/src/commands/run/mcp.ts @@ -24,16 +24,16 @@ import { spawn } from 'node:child_process'; import { rmSync } from 'node:fs'; import { homedir } from 'node:os'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { getNetworkConfigOrThrow } from '@/core/host/connectivity/network-config.ts'; import type { ResolvedNetworkConfig } from '@/core/host/connectivity/types.ts'; +import { detectContainerRuntime } from '@/core/host/environment/tool-detector.ts'; import { clientCertCachePath, type McpServerContext, resolveMcpContainerCommand, } from '@/core/host/mcp/mcp-helper.ts'; -import { detectContainerRuntime } from '@/core/host/tool-detector.ts'; import { canonicalizePath } from '@/core/io/fs-utils.ts'; import logger from '@/core/observability/logger.ts'; import { discoverProject } from '@/core/project-info.ts'; diff --git a/src/commands/_common/sonar-command.ts b/src/commands/sonar-command.ts similarity index 98% rename from src/commands/_common/sonar-command.ts rename to src/commands/sonar-command.ts index 8c82a0bf8..d481cb897 100644 --- a/src/commands/_common/sonar-command.ts +++ b/src/commands/sonar-command.ts @@ -23,9 +23,9 @@ import type { CommandOptions } from 'commander'; import { Command } from 'commander'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { CliError, CommandFailedError, remediationHintFor } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; import logger from '@/core/observability/logger.ts'; import { blank, error, print } from '@/core/ui'; import type { UpdateNotificationCondition } from '@/core/update/notification.ts'; diff --git a/src/commands/system/reset.ts b/src/commands/system/reset.ts index 4a42d30a2..1b56916dd 100644 --- a/src/commands/system/reset.ts +++ b/src/commands/system/reset.ts @@ -24,7 +24,7 @@ import type { PhaseItem } from '@/core/ui'; import { info, phase, print, success, text, textPrompt, warn } from '@/core/ui'; import { version as VERSION } from '../../../package.json'; -import { printAgentNonInteractiveAlternativeHint } from '../_common/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '../../core/ui/components/agent-prompt-hint.ts'; import { supportedIntegrations } from '../integrate'; import { purgeAuth } from './reset-auth.ts'; import { removeBinaries } from './reset-binaries.ts'; diff --git a/src/commands/system/status.ts b/src/commands/system/status.ts index 88d3f76a4..4b5778d7c 100644 --- a/src/commands/system/status.ts +++ b/src/commands/system/status.ts @@ -24,10 +24,10 @@ import { join } from 'node:path'; import { parse as parseToml } from 'smol-toml'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { CLI_DIR, GLOBAL_HOOKS_DIR, LOG_DIR } from '@/core/config-constants.ts'; import { recordedFeatureResources } from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; import { getNetworkConfig } from '@/core/host/connectivity/network-config.ts'; import type { CaCertConfig, @@ -36,25 +36,25 @@ import type { ProxyGroup, ResolvedNetworkConfig, } from '@/core/host/connectivity/types.ts'; -import { CURRENT_DISTRIBUTION } from '@/core/host/distribution.ts'; +import { CURRENT_DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import { SECRETS_SPEC } from '@/core/host/install/secrets.ts'; +import { + SCA_SCANNER_CLI_VERSION, + SONAR_CONTEXT_AUGMENTATION_VERSION, +} from '@/core/host/install/signatures.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME, SCA_SCANNER_BINARY_NAME, } from '@/core/host/install-types.ts'; import { getMcpConfigFilePath } from '@/core/host/mcp/mcp-helper.ts'; -import { - SCA_SCANNER_CLI_VERSION, - SONAR_CONTEXT_AUGMENTATION_VERSION, -} from '@/core/host/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { loadState } from '@/core/state/state-repository.ts'; import { blank, print, success, text, warn } from '@/core/ui'; import { isNewerVersion, stripBuildNumber } from '@/core/version.ts'; import { version as VERSION } from '../../../package.json'; -import type { TokenCheckResult } from '../_common/token.ts'; -import { checkTokenStatus } from '../_common/token.ts'; +import type { TokenCheckResult } from '../../core/auth/token.ts'; +import { checkTokenStatus } from '../../core/auth/token.ts'; import { supportedIntegrations } from '../integrate'; import { checkAntigravitySecretsHookFile } from '../integrate/antigravity/health.ts'; import { resolveAntigravityHooksJsonPathForScope } from '../integrate/antigravity/hooks.ts'; diff --git a/src/commands/update/update-check.ts b/src/commands/update/update-check.ts index 43cf4382b..c3a771a45 100644 --- a/src/commands/update/update-check.ts +++ b/src/commands/update/update-check.ts @@ -26,7 +26,7 @@ import { join } from 'node:path'; import { CommandFailedError } from '@/core/command-error.ts'; import { UPDATE_SCRIPT_BASE_URL } from '@/core/config-constants.ts'; -import { isWindows } from '@/core/host/platform-detector.ts'; +import { isWindows } from '@/core/host/environment/platform-detector.ts'; import { fetchLatestVersion, fetchText } from '@/core/update/check.ts'; import { Version } from '@/core/version.ts'; diff --git a/src/core/host/auth-resolver.ts b/src/core/auth/auth-resolver.ts similarity index 98% rename from src/core/host/auth-resolver.ts rename to src/core/auth/auth-resolver.ts index 22e9462f9..9d0a8045f 100644 --- a/src/core/host/auth-resolver.ts +++ b/src/core/auth/auth-resolver.ts @@ -20,6 +20,7 @@ // Centralized auth resolver - resolves token + serverUrl from env vars, state, or keychain +import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; import { getToken } from '@/core/host/keychain.ts'; import { warn } from '@/core/ui'; @@ -27,7 +28,6 @@ import { SONARCLOUD_URL } from '../config-constants.ts'; import logger from '../observability/logger.ts'; import { getActiveConnection } from '../state/state-manager.ts'; import { loadState } from '../state/state-repository.ts'; -import { recordConnectionFromAuth } from './auth-connection-recorder.ts'; // Re-exported for backward compatibility (lives in server/sonarcloud-region.ts to avoid an import cycle). export { diff --git a/src/commands/_common/token.ts b/src/core/auth/token.ts similarity index 99% rename from src/commands/_common/token.ts rename to src/core/auth/token.ts index 49a83575b..68f92e309 100644 --- a/src/commands/_common/token.ts +++ b/src/core/auth/token.ts @@ -23,7 +23,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http'; import * as readline from 'node:readline'; -import { isSonarQubeCloud } from '@/core/host/auth-resolver.ts'; +import { isSonarQubeCloud } from '@/core/auth/auth-resolver.ts'; import { openBrowser } from '@/core/host/browser.ts'; import { startLoopbackServer } from '@/core/host/loopback-server.ts'; import logger from '@/core/observability/logger.ts'; diff --git a/src/core/framework/dependencies/sonarsource-binary.ts b/src/core/framework/dependencies/sonarsource-binary.ts index 176c8e1bc..6cb219cce 100644 --- a/src/core/framework/dependencies/sonarsource-binary.ts +++ b/src/core/framework/dependencies/sonarsource-binary.ts @@ -25,14 +25,14 @@ import { removeBinary, resolveBinaryPath, } from '@/core/host/install/binary.ts'; -import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import { SCA_SCANNER_CLI_SIGNATURES, SCA_SCANNER_CLI_VERSION, SONAR_SECRETS_SIGNATURES, SONAR_SECRETS_VERSION, SONARSOURCE_PUBLIC_KEY, -} from '@/core/host/signatures.ts'; +} from '@/core/host/install/signatures.ts'; +import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import type { DependencyInstallContext, diff --git a/src/core/framework/features/install-integration.ts b/src/core/framework/features/install-integration.ts index d1798b2c9..0698f71ce 100644 --- a/src/core/framework/features/install-integration.ts +++ b/src/core/framework/features/install-integration.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { findGitRoot } from '@/core/host/git/discover.ts'; import logger from '@/core/observability/logger.ts'; import type { diff --git a/src/core/framework/features/types.ts b/src/core/framework/features/types.ts index ced31c260..8fbfaf1cf 100644 --- a/src/core/framework/features/types.ts +++ b/src/core/framework/features/types.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { CliState, IntegrationScope, IntegrationStateAttribute } from '@/core/state/state.ts'; import type { DependencyDeclaration } from '../dependencies'; diff --git a/src/core/host/auth-connection-recorder.ts b/src/core/host/auth-connection-recorder.ts index 57cc77cff..2b5036f13 100644 --- a/src/core/host/auth-connection-recorder.ts +++ b/src/core/host/auth-connection-recorder.ts @@ -20,6 +20,7 @@ // Records a resolved auth into state.auth.connections like `sonar auth login` does, minus saveToken(). +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { cloudRegionFromUrl } from '@/core/server/sonarcloud-region.ts'; import type { AuthConnection } from '../state/state.ts'; @@ -29,7 +30,6 @@ import { getActiveConnection, } from '../state/state-manager.ts'; import { loadState, saveState } from '../state/state-repository.ts'; -import type { ResolvedAuth } from './auth-resolver.ts'; import { identityFromConnection, needsIdentityEnrichment, diff --git a/src/commands/_common/context-augmentation-env.ts b/src/core/host/context-augmentation-env.ts similarity index 100% rename from src/commands/_common/context-augmentation-env.ts rename to src/core/host/context-augmentation-env.ts diff --git a/src/core/host/agent-detector.ts b/src/core/host/environment/agent-detector.ts similarity index 100% rename from src/core/host/agent-detector.ts rename to src/core/host/environment/agent-detector.ts diff --git a/src/core/host/distribution.ts b/src/core/host/environment/distribution.ts similarity index 100% rename from src/core/host/distribution.ts rename to src/core/host/environment/distribution.ts diff --git a/src/core/host/platform-detector.ts b/src/core/host/environment/platform-detector.ts similarity index 96% rename from src/core/host/platform-detector.ts rename to src/core/host/environment/platform-detector.ts index 26ad2892c..27056d38c 100644 --- a/src/core/host/platform-detector.ts +++ b/src/core/host/environment/platform-detector.ts @@ -22,7 +22,7 @@ import { arch, platform } from 'node:os'; -import type { PlatformInfo } from './install-types.ts'; +import type { PlatformInfo } from '../install-types.ts'; const OS_MAP: Record = { darwin: 'macos', diff --git a/src/core/host/tool-detector.ts b/src/core/host/environment/tool-detector.ts similarity index 97% rename from src/core/host/tool-detector.ts rename to src/core/host/environment/tool-detector.ts index e3e5ab94e..a4ac5b0cb 100644 --- a/src/core/host/tool-detector.ts +++ b/src/core/host/environment/tool-detector.ts @@ -20,7 +20,7 @@ // Tool detector - checks presence and availability of system tools -import { spawnProcess } from '../process/process.ts'; +import { spawnProcess } from '../../process/process.ts'; import { isWindows } from './platform-detector.ts'; const CONTAINER_RUNTIMES = ['docker', 'podman', 'nerdctl'] as const; diff --git a/src/core/host/identity-fetch.ts b/src/core/host/identity-fetch.ts index 7a3031a7d..7ef186b7d 100644 --- a/src/core/host/identity-fetch.ts +++ b/src/core/host/identity-fetch.ts @@ -24,12 +24,12 @@ import { createHash } from 'node:crypto'; import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { resolveFromEndpoint } from '@/core/server/sonarcloud-region.ts'; import { getTelemetryDir } from '../config-constants.ts'; import type { AuthConnection, ServerType } from '../state/state.ts'; -import type { ResolvedAuth } from './auth-resolver.ts'; export interface TelemetryIdentity { user_uuid: string | null; diff --git a/src/core/host/install/binary.ts b/src/core/host/install/binary.ts index 5e0935fb0..fea4bc538 100644 --- a/src/core/host/install/binary.ts +++ b/src/core/host/install/binary.ts @@ -25,8 +25,8 @@ import { existsSync, rmSync } from 'node:fs'; import { join } from 'node:path'; import { BIN_DIR } from '@/core/config-constants.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildPlatformSuffix, type PlatformInfo } from '@/core/host/install-types.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { buildDownloadUrl, downloadBinary, diff --git a/src/core/host/install/context-augmentation.ts b/src/core/host/install/context-augmentation.ts index cf0fa3dc2..81b331cb5 100644 --- a/src/core/host/install/context-augmentation.ts +++ b/src/core/host/install/context-augmentation.ts @@ -23,17 +23,17 @@ import { join } from 'node:path'; import { CommandFailedError } from '@/core/command-error.ts'; import { BIN_DIR } from '@/core/config-constants.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; +import { + SONAR_CONTEXT_AUGMENTATION_SIGNATURES, + SONAR_CONTEXT_AUGMENTATION_VERSION, + SONARSOURCE_PUBLIC_KEY, +} from '@/core/host/install/signatures.ts'; import { buildCagPlatformSuffix, CONTEXT_AUGMENTATION_BINARY_NAME, type PlatformInfo, } from '@/core/host/install-types.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { - SONAR_CONTEXT_AUGMENTATION_SIGNATURES, - SONAR_CONTEXT_AUGMENTATION_VERSION, - SONARSOURCE_PUBLIC_KEY, -} from '@/core/host/signatures.ts'; import { buildCagDownloadUrl, downloadBinary, diff --git a/src/core/host/install/sca-scanner.ts b/src/core/host/install/sca-scanner.ts index 18724591c..8e06cc62c 100644 --- a/src/core/host/install/sca-scanner.ts +++ b/src/core/host/install/sca-scanner.ts @@ -21,12 +21,12 @@ // sca-scanner-cli install: thin wrapper over the generic binary install pipeline. import { SCA_SCANNER_CLI_DIST_PREFIX } from '@/core/config-constants.ts'; -import { type PlatformInfo, SCA_SCANNER_BINARY_NAME } from '@/core/host/install-types.ts'; import { SCA_SCANNER_CLI_SIGNATURES, SCA_SCANNER_CLI_VERSION, SONARSOURCE_PUBLIC_KEY, -} from '@/core/host/signatures.ts'; +} from '@/core/host/install/signatures.ts'; +import { type PlatformInfo, SCA_SCANNER_BINARY_NAME } from '@/core/host/install-types.ts'; import { discreetSuccess } from '@/core/ui'; import { diff --git a/src/core/host/install/secrets.ts b/src/core/host/install/secrets.ts index 6c663dadf..a1979343b 100644 --- a/src/core/host/install/secrets.ts +++ b/src/core/host/install/secrets.ts @@ -21,12 +21,12 @@ // sonar-secrets install: thin wrapper over the generic binary install pipeline. import { SONAR_SECRETS_DIST_PREFIX } from '@/core/config-constants.ts'; -import { type PlatformInfo, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import { SONAR_SECRETS_SIGNATURES, SONAR_SECRETS_VERSION, SONARSOURCE_PUBLIC_KEY, -} from '@/core/host/signatures.ts'; +} from '@/core/host/install/signatures.ts'; +import { type PlatformInfo, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import { discreetSuccess, type OutputChannel } from '@/core/ui'; import { diff --git a/src/core/host/signatures.ts b/src/core/host/install/signatures.ts similarity index 100% rename from src/core/host/signatures.ts rename to src/core/host/install/signatures.ts diff --git a/src/core/host/mcp/mcp-helper.ts b/src/core/host/mcp/mcp-helper.ts index 698d45d7e..a394b3286 100644 --- a/src/core/host/mcp/mcp-helper.ts +++ b/src/core/host/mcp/mcp-helper.ts @@ -24,7 +24,7 @@ import { readFile, writeFile } from 'node:fs/promises'; import { homedir } from 'node:os'; import { dirname, join } from 'node:path'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { getNetworkConfig } from '@/core/host/connectivity/network-config.ts'; import type { ClientCertConfig, @@ -39,8 +39,8 @@ import { SONARQUBE_MCP_DOCKER_IMAGE_NAME, } from '../../config-constants.ts'; import { normalizePath } from '../../io/fs-utils.ts'; +import type { ContainerRuntime, ContainerRuntimeDetection } from '../environment/tool-detector.ts'; import type { RedactedUrl } from '../redacted-url.ts'; -import type { ContainerRuntime, ContainerRuntimeDetection } from '../tool-detector.ts'; export interface McpServerConfig { command: string; diff --git a/src/core/project-info.ts b/src/core/project-info.ts index f8b969b8e..d39120cb1 100644 --- a/src/core/project-info.ts +++ b/src/core/project-info.ts @@ -23,8 +23,8 @@ import { existsSync } from 'node:fs'; import { basename, join } from 'node:path'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import { resolveAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { resolveAuth } from '@/core/auth/auth-resolver.ts'; import { findGitRoot, getGitRemote } from '@/core/host/git/discover.ts'; import { discoverProjectKeyByGitRemote, diff --git a/src/core/server/discover-project-by-remote.ts b/src/core/server/discover-project-by-remote.ts index c5960358f..453ea382e 100644 --- a/src/core/server/discover-project-by-remote.ts +++ b/src/core/server/discover-project-by-remote.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import type { ResolvedAuth } from '../host/auth-resolver.ts'; +import type { ResolvedAuth } from '../auth/auth-resolver.ts'; import logger from '../observability/logger.ts'; import { SonarQubeClient } from './client.ts'; diff --git a/src/commands/_common/sca-availability.ts b/src/core/server/sca-availability.ts similarity index 97% rename from src/commands/_common/sca-availability.ts rename to src/core/server/sca-availability.ts index 8d6aa939e..875e88b33 100644 --- a/src/commands/_common/sca-availability.ts +++ b/src/core/server/sca-availability.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { SonarQubeClient } from '@/core/server/client.ts'; import { fetchServerVersion, isAtLeast } from '@/core/server/server-info.ts'; diff --git a/src/core/state/state-manager.ts b/src/core/state/state-manager.ts index 79603ae3b..c97ff073d 100644 --- a/src/core/state/state-manager.ts +++ b/src/core/state/state-manager.ts @@ -25,7 +25,7 @@ import crypto from 'node:crypto'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import logger from '@/core/observability/logger.ts'; import { warn } from '@/core/ui'; diff --git a/src/core/state/state.ts b/src/core/state/state.ts index 4a8823300..1a53913f6 100644 --- a/src/core/state/state.ts +++ b/src/core/state/state.ts @@ -25,8 +25,8 @@ import { randomUUID } from 'node:crypto'; -import type { CallerAgent } from '@/core/host/agent-detector.ts'; -import type { Distribution } from '@/core/host/distribution.ts'; +import type { CallerAgent } from '@/core/host/environment/agent-detector.ts'; +import type { Distribution } from '@/core/host/environment/distribution.ts'; /** * Region for SonarCloud instances diff --git a/src/core/telemetry/identity.ts b/src/core/telemetry/identity.ts index 4b3b55d58..92e615f8c 100644 --- a/src/core/telemetry/identity.ts +++ b/src/core/telemetry/identity.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { resolveAuth, type ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import { resolveAuth, type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { identityFromConnection, needsIdentityEnrichment, diff --git a/src/core/telemetry/index.ts b/src/core/telemetry/index.ts index 92e802ec3..0b09cc71c 100644 --- a/src/core/telemetry/index.ts +++ b/src/core/telemetry/index.ts @@ -20,7 +20,7 @@ import { type Command } from 'commander'; -import { DISTRIBUTION } from '../host/distribution.ts'; +import { DISTRIBUTION } from '../host/environment/distribution.ts'; import { tryLoadState } from '../state/state-manager.ts'; import { isTelemetryEnabled } from './enabled.ts'; import { currentProjectUuid } from './project-uuid.ts'; diff --git a/src/core/telemetry/integrate-telemetry.ts b/src/core/telemetry/integrate-telemetry.ts index f166c123e..fcb7e7609 100644 --- a/src/core/telemetry/integrate-telemetry.ts +++ b/src/core/telemetry/integrate-telemetry.ts @@ -20,7 +20,7 @@ import { createHash } from 'node:crypto'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { canonicalizePath } from '../io/fs-utils.ts'; import logger from '../observability/logger.ts'; diff --git a/src/core/telemetry/sca-analysis-telemetry.ts b/src/core/telemetry/sca-analysis-telemetry.ts index 9ec29f355..dd09b0ab8 100644 --- a/src/core/telemetry/sca-analysis-telemetry.ts +++ b/src/core/telemetry/sca-analysis-telemetry.ts @@ -20,7 +20,7 @@ import { randomUUID } from 'node:crypto'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { AnalyzeProjectResponse } from '../../commands/analyze/dependency-risk-helpers/sca-scanner.ts'; import { emitAnalysisCompleted } from './telemetry-events.ts'; diff --git a/src/core/telemetry/sqaa-analysis-telemetry.ts b/src/core/telemetry/sqaa-analysis-telemetry.ts index 190698f62..3f52901bc 100644 --- a/src/core/telemetry/sqaa-analysis-telemetry.ts +++ b/src/core/telemetry/sqaa-analysis-telemetry.ts @@ -20,7 +20,7 @@ import { randomUUID } from 'node:crypto'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { SqaaIssue } from '@/core/server/client.ts'; import type { FileResult, RunTally } from '../../commands/analyze/sqaa-analysis.ts'; diff --git a/src/core/telemetry/telemetry-events.ts b/src/core/telemetry/telemetry-events.ts index 7f0d6bdd1..ddcbc2662 100644 --- a/src/core/telemetry/telemetry-events.ts +++ b/src/core/telemetry/telemetry-events.ts @@ -22,10 +22,10 @@ import { randomUUID } from 'node:crypto'; import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs'; import { join } from 'node:path'; -import { detectCallerAgent } from '@/core/host/agent-detector.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { buildFetchNetworkOptions } from '@/core/host/connectivity/network-config.ts'; import type { FetchNetworkOptions } from '@/core/host/connectivity/types.ts'; +import { detectCallerAgent } from '@/core/host/environment/agent-detector.ts'; import { buildFetchInit, fetchGuarded } from '@/core/server/fetch-guarded.ts'; import { INVOCATION_ID } from '@/core/telemetry/invocation-id.ts'; diff --git a/src/commands/_common/agent-prompt-hint.ts b/src/core/ui/components/agent-prompt-hint.ts similarity index 93% rename from src/commands/_common/agent-prompt-hint.ts rename to src/core/ui/components/agent-prompt-hint.ts index e0574a994..e09035707 100644 --- a/src/commands/_common/agent-prompt-hint.ts +++ b/src/core/ui/components/agent-prompt-hint.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { detectCallerAgent } from '@/core/host/agent-detector.ts'; +import { detectCallerAgent } from '@/core/host/environment/agent-detector.ts'; import { info, print } from '@/core/ui'; export function printAgentNonInteractiveAlternativeHint(...nonInteractiveExamples: string[]): void { diff --git a/src/commands/_common/parsing.ts b/src/core/ui/parsing.ts similarity index 100% rename from src/commands/_common/parsing.ts rename to src/core/ui/parsing.ts diff --git a/src/core/update/notification.ts b/src/core/update/notification.ts index 09acfd582..4ce5bb2b2 100644 --- a/src/core/update/notification.ts +++ b/src/core/update/notification.ts @@ -39,7 +39,7 @@ export type UpdateNotificationCondition = (opts: Record) => boo * Owns the per-command opt-in registry for the post-command "new version * available" stderr notice, plus the eligibility/suppression checks and the * actual throttled version check. There is no shared singleton here: the root - * `SonarCommand` (commands/_common/sonar-command.ts) owns one instance and + * `SonarCommand` (commands/sonar-command.ts) owns one instance and * propagates it to every subcommand, so `showUpdateNotification()` can call * `register()` on it without this module depending on that class. */ diff --git a/tests/_common/agent-hint-assertions.ts b/tests/_common/agent-hint-assertions.ts index 0b576410f..43746fe62 100644 --- a/tests/_common/agent-hint-assertions.ts +++ b/tests/_common/agent-hint-assertions.ts @@ -19,7 +19,7 @@ */ // Shared assertions for `printAgentNonInteractiveAlternativeHint` output -// (src/commands/_common/agent-prompt-hint.ts). Callers only supply the +// (src/core/ui/components/agent-prompt-hint.ts). Callers only supply the // non-interactive example(s), mirroring the real function's own signature. import { expect } from 'bun:test'; diff --git a/tests/e2e/context/cag-codex.test.ts b/tests/e2e/context/cag-codex.test.ts index 675f937ac..4006c475f 100644 --- a/tests/e2e/context/cag-codex.test.ts +++ b/tests/e2e/context/cag-codex.test.ts @@ -29,7 +29,7 @@ import { dirname, join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it, setDefaultTimeout } from 'bun:test'; import { CODEX_INTEGRATION_ID } from '@/commands/integrate/codex/declaration.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { TestHarness } from '../../integration/harness'; diff --git a/tests/e2e/context/cag-copilot.test.ts b/tests/e2e/context/cag-copilot.test.ts index dae8d3db9..f8dd1dfdf 100644 --- a/tests/e2e/context/cag-copilot.test.ts +++ b/tests/e2e/context/cag-copilot.test.ts @@ -29,7 +29,7 @@ import { dirname, join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it, setDefaultTimeout } from 'bun:test'; import { COPILOT_INTEGRATION_ID } from '@/commands/integrate/copilot/declaration.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { TestHarness } from '../../integration/harness'; diff --git a/tests/e2e/context/cag-cursor.test.ts b/tests/e2e/context/cag-cursor.test.ts index ae14c640b..74d0cb259 100644 --- a/tests/e2e/context/cag-cursor.test.ts +++ b/tests/e2e/context/cag-cursor.test.ts @@ -31,7 +31,7 @@ import { dirname, join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it, setDefaultTimeout } from 'bun:test'; import { CURSOR_INTEGRATION_ID } from '@/commands/integrate/cursor/declaration.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { TestHarness } from '../../integration/harness'; diff --git a/tests/e2e/context/cag-edge-cases.test.ts b/tests/e2e/context/cag-edge-cases.test.ts index e83e72a1f..4932f9dce 100644 --- a/tests/e2e/context/cag-edge-cases.test.ts +++ b/tests/e2e/context/cag-edge-cases.test.ts @@ -30,10 +30,10 @@ import { dirname, join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, setDefaultTimeout } from 'bun:test'; import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { version as CURRENT_CLI_VERSION } from '../../../package.json'; diff --git a/tests/e2e/context/cag-integrate.test.ts b/tests/e2e/context/cag-integrate.test.ts index 85c14e28d..10b9f9502 100644 --- a/tests/e2e/context/cag-integrate.test.ts +++ b/tests/e2e/context/cag-integrate.test.ts @@ -47,8 +47,8 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, setDefaultTimeout } from 'bun:test'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import type { CliState } from '@/core/state/state.ts'; import { TestHarness } from '../../integration/harness'; diff --git a/tests/e2e/context/cag-offline.test.ts b/tests/e2e/context/cag-offline.test.ts index c86d38991..6d15e8f85 100644 --- a/tests/e2e/context/cag-offline.test.ts +++ b/tests/e2e/context/cag-offline.test.ts @@ -39,9 +39,9 @@ import { dirname, join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it, setDefaultTimeout } from 'bun:test'; import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import type { CliState } from '@/core/state/state.ts'; import { TestHarness } from '../../integration/harness'; diff --git a/tests/e2e/secrets-output-parser.test.ts b/tests/e2e/secrets-output-parser.test.ts index 1f43888e4..59f127413 100644 --- a/tests/e2e/secrets-output-parser.test.ts +++ b/tests/e2e/secrets-output-parser.test.ts @@ -33,7 +33,7 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, setDefaultTimeout } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { resolveSecretsBinaryPath } from '@/core/host/install/secrets.ts'; import { diff --git a/tests/integration/harness/environment-builder.ts b/tests/integration/harness/environment-builder.ts index 6092ce3a1..2d4feac7e 100644 --- a/tests/integration/harness/environment-builder.ts +++ b/tests/integration/harness/environment-builder.ts @@ -29,14 +29,14 @@ import { SQAA_HOOK_FEATURE_ID } from '@/commands/integrate/_common/features/sqaa import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.ts'; import type { IntegrationDeclaration } from '@/core/framework/features'; import { recordInstalledFeature } from '@/core/framework/features/installation-recorder.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { type BinarySpec, buildLocalBinaryName } from '@/core/host/install/binary.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; import { SCA_SCANNER_SPEC } from '@/core/host/install/sca-scanner.ts'; import { SECRETS_SPEC } from '@/core/host/install/secrets.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; import { generateKeychainAccount } from '@/core/host/keychain.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; import { buildDownloadUrl } from '@/core/host/sonarsource-releases.ts'; import { canonicalizePath } from '@/core/io/fs-utils.ts'; import type { diff --git a/tests/integration/specs/analyze/analyze-dependency-risks.test.ts b/tests/integration/specs/analyze/analyze-dependency-risks.test.ts index f06c23980..20ac71495 100644 --- a/tests/integration/specs/analyze/analyze-dependency-risks.test.ts +++ b/tests/integration/specs/analyze/analyze-dependency-risks.test.ts @@ -26,8 +26,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/sca-scanner.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { readCommandEvents } from '../../../_common/telemetry-helpers'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/analyze/analyze-secrets.test.ts b/tests/integration/specs/analyze/analyze-secrets.test.ts index 1d671b0b9..f4734d257 100644 --- a/tests/integration/specs/analyze/analyze-secrets.test.ts +++ b/tests/integration/specs/analyze/analyze-secrets.test.ts @@ -25,8 +25,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { readAnalysisEvents } from '../../../_common/telemetry-helpers'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/auth/auth.test.ts b/tests/integration/specs/auth/auth.test.ts index 6115da586..5e05f921b 100644 --- a/tests/integration/specs/auth/auth.test.ts +++ b/tests/integration/specs/auth/auth.test.ts @@ -24,8 +24,8 @@ import { readFileSync } from 'node:fs'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/auth/auth-resolver.ts'; import { SONARCLOUD_URL, SONARCLOUD_US_URL } from '@/core/config-constants.ts'; -import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/host/auth-resolver.ts'; import { generateKeychainAccount } from '@/core/host/keychain.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/auth/env-auth-state-sync.test.ts b/tests/integration/specs/auth/env-auth-state-sync.test.ts index 649ce1e32..c05d793c9 100644 --- a/tests/integration/specs/auth/env-auth-state-sync.test.ts +++ b/tests/integration/specs/auth/env-auth-state-sync.test.ts @@ -24,7 +24,7 @@ import { readFileSync } from 'node:fs'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; -import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/host/auth-resolver.ts'; +import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/auth/auth-resolver.ts'; import { generateKeychainAccount } from '@/core/host/keychain.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-agent-prompt-submit.test.ts b/tests/integration/specs/hook/hook-agent-prompt-submit.test.ts index b336402e9..e077da5bd 100644 --- a/tests/integration/specs/hook/hook-agent-prompt-submit.test.ts +++ b/tests/integration/specs/hook/hook-agent-prompt-submit.test.ts @@ -32,8 +32,8 @@ import { SECRETS_INACTIVE_BINARY_MISSING, SECRETS_INACTIVE_UNAUTHENTICATED, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-antigravity-pre-tool-use.test.ts b/tests/integration/specs/hook/hook-antigravity-pre-tool-use.test.ts index b57cb7731..cc57e5a72 100644 --- a/tests/integration/specs/hook/hook-antigravity-pre-tool-use.test.ts +++ b/tests/integration/specs/hook/hook-antigravity-pre-tool-use.test.ts @@ -37,8 +37,8 @@ import { SECRETS_INACTIVE_BINARY_MISSING, SECRETS_INACTIVE_UNAUTHENTICATED, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-copilot-pre-tool-use.test.ts b/tests/integration/specs/hook/hook-copilot-pre-tool-use.test.ts index 091558582..933694b51 100644 --- a/tests/integration/specs/hook/hook-copilot-pre-tool-use.test.ts +++ b/tests/integration/specs/hook/hook-copilot-pre-tool-use.test.ts @@ -39,8 +39,8 @@ import { SECRETS_INACTIVE_BINARY_MISSING, SECRETS_INACTIVE_UNAUTHENTICATED, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-cursor-prompt-submit.test.ts b/tests/integration/specs/hook/hook-cursor-prompt-submit.test.ts index 9f403028b..6b8e8e07a 100644 --- a/tests/integration/specs/hook/hook-cursor-prompt-submit.test.ts +++ b/tests/integration/specs/hook/hook-cursor-prompt-submit.test.ts @@ -33,8 +33,8 @@ import { SECRETS_INACTIVE_BINARY_MISSING, SECRETS_INACTIVE_UNAUTHENTICATED, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-git-pre-commit.test.ts b/tests/integration/specs/hook/hook-git-pre-commit.test.ts index 70181d440..ca6113582 100644 --- a/tests/integration/specs/hook/hook-git-pre-commit.test.ts +++ b/tests/integration/specs/hook/hook-git-pre-commit.test.ts @@ -29,8 +29,8 @@ import { HOOK_INACTIVE_UNAUTHENTICATED, SECRETS_INACTIVE_BINARY_MISSING, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { readCommandEvents } from '../../../_common/telemetry-helpers.ts'; import { TestHarness } from '../../harness'; diff --git a/tests/integration/specs/hook/hook-git-pre-push.test.ts b/tests/integration/specs/hook/hook-git-pre-push.test.ts index 91fe14b36..2b5ae2ade 100644 --- a/tests/integration/specs/hook/hook-git-pre-push.test.ts +++ b/tests/integration/specs/hook/hook-git-pre-push.test.ts @@ -29,8 +29,8 @@ import { SECRETS_INACTIVE_BINARY_MISSING, SECRETS_INACTIVE_UNAUTHENTICATED, } from '@/commands/hook/hook-dependencies.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { TestHarness } from '../../harness'; import { commitFile, initGitRepo } from './git-test-helpers'; diff --git a/tests/integration/specs/integrate/claude.test.ts b/tests/integration/specs/integrate/claude.test.ts index d104af811..41387348d 100644 --- a/tests/integration/specs/integrate/claude.test.ts +++ b/tests/integration/specs/integrate/claude.test.ts @@ -28,8 +28,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; import { SQAA_INSTRUCTIONS_SUBFEATURE_ID } from '@/commands/integrate/_common/features/sqaa-instructions-feature.ts'; import { VORTEX_FEATURE_ID } from '@/commands/integrate/_common/vortex.ts'; import { claudeIntegration } from '@/commands/integrate/claude/declaration.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import { expectAgentPromptHint, diff --git a/tests/integration/specs/integrate/context-augmentation.test.ts b/tests/integration/specs/integrate/context-augmentation.test.ts index b5b31c521..b1e4cc599 100644 --- a/tests/integration/specs/integrate/context-augmentation.test.ts +++ b/tests/integration/specs/integrate/context-augmentation.test.ts @@ -31,9 +31,9 @@ import { VORTEX_FEATURE_ID } from '@/commands/integrate/_common/vortex.js'; import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.js'; import { CODEX_INTEGRATION_ID } from '@/commands/integrate/codex/declaration.js'; import { COPILOT_INTEGRATION_ID } from '@/commands/integrate/copilot/declaration.js'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.js'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; import { pathComparisonKey } from '@/core/io/fs-utils.ts'; import type { CliState, InstalledIntegrationFeature } from '@/core/state/state.ts'; diff --git a/tests/integration/specs/update/post-update.test.ts b/tests/integration/specs/update/post-update.test.ts index 23a8fe4e6..ebecd7e23 100644 --- a/tests/integration/specs/update/post-update.test.ts +++ b/tests/integration/specs/update/post-update.test.ts @@ -30,9 +30,9 @@ import { SQAA_INSTRUCTIONS_SUBFEATURE_ID, } from '@/commands/integrate/_common/features/sqaa-instructions-feature.ts'; import { VORTEX_FEATURE_ID } from '@/commands/integrate/_common/vortex.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; import type { CliState, InstalledIntegrationFeature } from '@/core/state/state.ts'; import { version as CURRENT_VERSION } from '../../../../package.json'; diff --git a/tests/unit/commands/analyze/analyze-all.test.ts b/tests/unit/commands/analyze/analyze-all.test.ts index e5012f920..f9c21fc6c 100644 --- a/tests/unit/commands/analyze/analyze-all.test.ts +++ b/tests/unit/commands/analyze/analyze-all.test.ts @@ -24,7 +24,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as processLib from '@/core/process/process.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/commands/analyze/analyze-sqaa.test.ts b/tests/unit/commands/analyze/analyze-sqaa.test.ts index 949e0d544..cf124748b 100644 --- a/tests/unit/commands/analyze/analyze-sqaa.test.ts +++ b/tests/unit/commands/analyze/analyze-sqaa.test.ts @@ -45,7 +45,7 @@ const TEST_TOKEN = 'squ_test_token'; const FILE_CONTENT = 'const x = 1;\n'; /** Fake auth for a cloud connection */ -const FAKE_AUTH: import('@/core/host/auth-resolver.ts').ResolvedAuth = { +const FAKE_AUTH: import('@/core/auth/auth-resolver.ts').ResolvedAuth = { token: TEST_TOKEN, serverUrl: SONARCLOUD_URL, orgKey: TEST_ORG, diff --git a/tests/unit/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.test.ts b/tests/unit/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.test.ts index e9736c6d4..1cac0866d 100644 --- a/tests/unit/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.test.ts +++ b/tests/unit/commands/analyze/dependency-risk-helpers/manifest-secrets-guard.test.ts @@ -23,8 +23,8 @@ import { join } from 'node:path'; import { beforeEach, describe, expect, it, mock } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { SecretsInstaller } from '@/core/host/install/secrets.ts'; import type { SpawnResult } from '@/core/process/process.ts'; diff --git a/tests/unit/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.test.ts b/tests/unit/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.test.ts index ae5ed8bee..76ee565a3 100644 --- a/tests/unit/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.test.ts +++ b/tests/unit/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.test.ts @@ -20,8 +20,8 @@ import { describe, expect, it, mock, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { SecretsInstaller } from '@/core/host/install/secrets.ts'; import type { SonarQubeClient } from '@/core/server/client.ts'; import type { SettingsValue } from '@/core/server/settings-value.ts'; diff --git a/tests/unit/commands/analyze/dependency-risk-helpers/sca-urls.test.ts b/tests/unit/commands/analyze/dependency-risk-helpers/sca-urls.test.ts index cbe9ad97b..316b6468d 100644 --- a/tests/unit/commands/analyze/dependency-risk-helpers/sca-urls.test.ts +++ b/tests/unit/commands/analyze/dependency-risk-helpers/sca-urls.test.ts @@ -20,7 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { buildScaUrls } from '../../../../../src/commands/analyze/dependency-risk-helpers/sca-urls.ts'; diff --git a/tests/unit/commands/analyze/dependency-risks.smoke.test.ts b/tests/unit/commands/analyze/dependency-risks.smoke.test.ts index b55302245..8de6159ab 100644 --- a/tests/unit/commands/analyze/dependency-risks.smoke.test.ts +++ b/tests/unit/commands/analyze/dependency-risks.smoke.test.ts @@ -20,7 +20,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { clearMockUiCalls, getMockUiCalls, setMockTty, setMockUi } from '@/core/ui'; import { ScaScanOrchestrator } from '../../../../src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts'; diff --git a/tests/unit/commands/analyze/secret-scan.test.ts b/tests/unit/commands/analyze/secret-scan.test.ts index e385d7ab6..010da7202 100644 --- a/tests/unit/commands/analyze/secret-scan.test.ts +++ b/tests/unit/commands/analyze/secret-scan.test.ts @@ -27,8 +27,8 @@ import * as fs from 'node:fs'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as processLib from '@/core/process/process.ts'; import { getDefaultState } from '@/core/state/state.ts'; diff --git a/tests/unit/commands/analyze/secrets-install.test.ts b/tests/unit/commands/analyze/secrets-install.test.ts index 749278001..666a56127 100644 --- a/tests/unit/commands/analyze/secrets-install.test.ts +++ b/tests/unit/commands/analyze/secrets-install.test.ts @@ -26,9 +26,9 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalBinaryName } from '@/core/host/install/secrets.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; -import { SONAR_SECRETS_VERSION } from '@/core/host/signatures.ts'; +import { SONAR_SECRETS_VERSION } from '@/core/host/install/signatures.ts'; import * as processLib from '@/core/process/process.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; diff --git a/tests/unit/commands/api/api-command.test.ts b/tests/unit/commands/api/api-command.test.ts index 9292198bf..527d583b6 100644 --- a/tests/unit/commands/api/api-command.test.ts +++ b/tests/unit/commands/api/api-command.test.ts @@ -20,7 +20,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/commands/auth/auth-helpers.test.ts b/tests/unit/commands/auth/auth-helpers.test.ts index 46e0deb40..fb828e54f 100644 --- a/tests/unit/commands/auth/auth-helpers.test.ts +++ b/tests/unit/commands/auth/auth-helpers.test.ts @@ -20,7 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import { buildAuthURL, parseBrowserAuthCallback } from '../../../../src/commands/_common/token.ts'; +import { buildAuthURL, parseBrowserAuthCallback } from '@/core/auth/token.ts'; const SONARCLOUD_SERVER = 'https://sonarcloud.io'; const SONARQUBE_CLOUD_US_SERVER = 'https://sonarqube.us'; diff --git a/tests/unit/commands/auth/auth-security.test.ts b/tests/unit/commands/auth/auth-security.test.ts index 4e0f95e21..98eb904b5 100644 --- a/tests/unit/commands/auth/auth-security.test.ts +++ b/tests/unit/commands/auth/auth-security.test.ts @@ -23,7 +23,7 @@ import { afterEach, describe, expect, it } from 'bun:test'; -import { createRequestHandler } from '@/commands/_common/token.ts'; +import { createRequestHandler } from '@/core/auth/token.ts'; import { type LoopbackServerResult, startLoopbackServer } from '@/core/host/loopback-server.ts'; const LOOPBACK_HOST = '127.0.0.1'; diff --git a/tests/unit/commands/auth/auth-token-interactive.test.ts b/tests/unit/commands/auth/auth-token-interactive.test.ts index 565035654..98f3376d1 100644 --- a/tests/unit/commands/auth/auth-token-interactive.test.ts +++ b/tests/unit/commands/auth/auth-token-interactive.test.ts @@ -61,7 +61,7 @@ import { type BrowserAuthResult, openBrowserWithFallback, waitForTokenInteractive, -} from '@/commands/_common/token.ts'; +} from '@/core/auth/token.ts'; // ─── Shared setup ───────────────────────────────────────────────────────────── diff --git a/tests/unit/commands/hook/agent-post-tool-use.test.ts b/tests/unit/commands/hook/agent-post-tool-use.test.ts index b02f80b1e..cb7d2716c 100644 --- a/tests/unit/commands/hook/agent-post-tool-use.test.ts +++ b/tests/unit/commands/hook/agent-post-tool-use.test.ts @@ -23,7 +23,7 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authResolver from '@/core/host/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import * as processLib from '@/core/process/process.ts'; import * as clientModule from '@/core/server/client.ts'; import * as sqaaTelemetry from '@/core/telemetry/sqaa-analysis-telemetry.ts'; diff --git a/tests/unit/commands/hook/agent-prompt-submit.test.ts b/tests/unit/commands/hook/agent-prompt-submit.test.ts index 9412e0f9b..36b6cff2f 100644 --- a/tests/unit/commands/hook/agent-prompt-submit.test.ts +++ b/tests/unit/commands/hook/agent-prompt-submit.test.ts @@ -24,7 +24,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authResolver from '@/core/host/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as analyzeSecrets from '../../../../src/commands/analyze/secrets.ts'; diff --git a/tests/unit/commands/hook/claude-pre-tool-use.test.ts b/tests/unit/commands/hook/claude-pre-tool-use.test.ts index 15762295e..ae3ad9218 100644 --- a/tests/unit/commands/hook/claude-pre-tool-use.test.ts +++ b/tests/unit/commands/hook/claude-pre-tool-use.test.ts @@ -22,7 +22,7 @@ import * as fs from 'node:fs'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authResolver from '@/core/host/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as analyzeSecrets from '../../../../src/commands/analyze/secrets.ts'; diff --git a/tests/unit/commands/hook/codex-post-tool-use.test.ts b/tests/unit/commands/hook/codex-post-tool-use.test.ts index 337f99a9e..dcb1dc087 100644 --- a/tests/unit/commands/hook/codex-post-tool-use.test.ts +++ b/tests/unit/commands/hook/codex-post-tool-use.test.ts @@ -20,7 +20,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authResolver from '@/core/host/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import * as sqaaTelemetry from '@/core/telemetry/sqaa-analysis-telemetry.ts'; import { SQAA_CODEX_POST_TOOL_USE_CALLER_COMMAND, diff --git a/tests/unit/commands/hook/cursor-pre-file-read.test.ts b/tests/unit/commands/hook/cursor-pre-file-read.test.ts index d1e7c4377..9706efd03 100644 --- a/tests/unit/commands/hook/cursor-pre-file-read.test.ts +++ b/tests/unit/commands/hook/cursor-pre-file-read.test.ts @@ -26,8 +26,8 @@ import { dirname, join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import { CURSOR_IGNORE_FILE } from '@/core/config-constants.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as analyzeSecrets from '../../../../src/commands/analyze/secrets.ts'; diff --git a/tests/unit/commands/hook/cursor-pre-tool-use.test.ts b/tests/unit/commands/hook/cursor-pre-tool-use.test.ts index 4b8b516b3..f2403d1b3 100644 --- a/tests/unit/commands/hook/cursor-pre-tool-use.test.ts +++ b/tests/unit/commands/hook/cursor-pre-tool-use.test.ts @@ -26,8 +26,8 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import { CURSOR_IGNORE_FILE } from '@/core/config-constants.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as analyzeSecrets from '../../../../src/commands/analyze/secrets.ts'; diff --git a/tests/unit/commands/hook/cursor-prompt-submit.test.ts b/tests/unit/commands/hook/cursor-prompt-submit.test.ts index 1506e4e45..292dd1259 100644 --- a/tests/unit/commands/hook/cursor-prompt-submit.test.ts +++ b/tests/unit/commands/hook/cursor-prompt-submit.test.ts @@ -24,7 +24,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authResolver from '@/core/host/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as analyzeSecrets from '../../../../src/commands/analyze/secrets.ts'; diff --git a/tests/unit/commands/hook/git-pre-commit-dependency-risks.mocked.test.ts b/tests/unit/commands/hook/git-pre-commit-dependency-risks.mocked.test.ts index af5b78b71..45723540a 100644 --- a/tests/unit/commands/hook/git-pre-commit-dependency-risks.mocked.test.ts +++ b/tests/unit/commands/hook/git-pre-commit-dependency-risks.mocked.test.ts @@ -20,8 +20,8 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import * as scaInstall from '@/core/host/install/sca-scanner.ts'; import { clearMockUiCalls, findMockUiCall, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/commands/hook/git.test.ts b/tests/unit/commands/hook/git.test.ts index e7a388699..c963d7448 100644 --- a/tests/unit/commands/hook/git.test.ts +++ b/tests/unit/commands/hook/git.test.ts @@ -20,8 +20,8 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; import * as installSecrets from '@/core/host/install/secrets.ts'; import * as processLib from '@/core/process/process.ts'; diff --git a/tests/unit/commands/integrate/_common/agent-integrate-prelude.test.ts b/tests/unit/commands/integrate/_common/agent-integrate-prelude.test.ts index 6ce7ef19f..460b24fc2 100644 --- a/tests/unit/commands/integrate/_common/agent-integrate-prelude.test.ts +++ b/tests/unit/commands/integrate/_common/agent-integrate-prelude.test.ts @@ -20,7 +20,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/commands/integrate/_common/preflight-summary.test.ts b/tests/unit/commands/integrate/_common/preflight-summary.test.ts index 17f9e0a85..058f9d873 100644 --- a/tests/unit/commands/integrate/_common/preflight-summary.test.ts +++ b/tests/unit/commands/integrate/_common/preflight-summary.test.ts @@ -20,11 +20,11 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as token from '@/commands/_common/token.ts'; import { printAgentPreflightSummary, printGitPreflightSummary, } from '@/commands/integrate/_common/preflight-summary.ts'; +import * as token from '@/core/auth/token.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import * as processLib from '@/core/process/process.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; diff --git a/tests/unit/commands/integrate/claude/integrate.test.ts b/tests/unit/commands/integrate/claude/integrate.test.ts index 8a3a9ef78..4c8030303 100644 --- a/tests/unit/commands/integrate/claude/integrate.test.ts +++ b/tests/unit/commands/integrate/claude/integrate.test.ts @@ -22,12 +22,12 @@ import { homedir } from 'node:os'; import { afterEach, beforeEach, describe, expect, it, Mock, spyOn } from 'bun:test'; -import * as token from '@/commands/_common/token.ts'; import { integrateClaude } from '@/commands/integrate/claude'; import * as hooks from '@/commands/integrate/claude/hooks.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import * as token from '@/core/auth/token.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import * as registry from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import * as gitWorktree from '@/core/host/git/worktree.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; import * as discovery from '@/core/project-info.ts'; diff --git a/tests/unit/commands/integrate/claude/mcp.test.ts b/tests/unit/commands/integrate/claude/mcp.test.ts index c9637a3ab..e1083151e 100644 --- a/tests/unit/commands/integrate/claude/mcp.test.ts +++ b/tests/unit/commands/integrate/claude/mcp.test.ts @@ -26,8 +26,8 @@ import { dirname, join } from 'node:path'; import { afterEach, describe, expect, it, spyOn } from 'bun:test'; import { setupMcpServer } from '@/commands/integrate/claude/mcp.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CLI_TMP_DIR, SONARQUBE_MCP_DOCKER_IMAGE_NAME } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { ClientCertConfig, ResolvedNetworkConfig } from '@/core/host/connectivity/types.ts'; import * as pkcs12Module from '@/core/host/crypto/pkcs12.ts'; import { diff --git a/tests/unit/commands/integrate/codex/integrate.test.ts b/tests/unit/commands/integrate/codex/integrate.test.ts index 652efd292..0e678b76b 100644 --- a/tests/unit/commands/integrate/codex/integrate.test.ts +++ b/tests/unit/commands/integrate/codex/integrate.test.ts @@ -20,11 +20,11 @@ import { afterEach, beforeEach, describe, expect, it, type Mock, spyOn } from 'bun:test'; -import * as token from '@/commands/_common/token.ts'; import * as vortex from '@/commands/integrate/_common/vortex.ts'; import { integrateCodex } from '@/commands/integrate/codex'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import * as token from '@/core/auth/token.ts'; import * as registry from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; import * as discovery from '@/core/project-info.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; diff --git a/tests/unit/commands/integrate/copilot/integrate.test.ts b/tests/unit/commands/integrate/copilot/integrate.test.ts index f5b8594d0..76fc97485 100644 --- a/tests/unit/commands/integrate/copilot/integrate.test.ts +++ b/tests/unit/commands/integrate/copilot/integrate.test.ts @@ -20,12 +20,12 @@ import { afterEach, beforeEach, describe, expect, it, type Mock, spyOn } from 'bun:test'; -import * as token from '@/commands/_common/token.ts'; import * as vortex from '@/commands/integrate/_common/vortex.ts'; import { integrateCopilot } from '@/commands/integrate/copilot'; import * as hooks from '@/commands/integrate/copilot/hooks.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import * as token from '@/core/auth/token.ts'; import * as registry from '@/core/framework/features'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; import * as discovery from '@/core/project-info.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; diff --git a/tests/unit/commands/integrate/git/git-integration-subfeatures.test.ts b/tests/unit/commands/integrate/git/git-integration-subfeatures.test.ts index 8f69c72bd..76d8b9390 100644 --- a/tests/unit/commands/integrate/git/git-integration-subfeatures.test.ts +++ b/tests/unit/commands/integrate/git/git-integration-subfeatures.test.ts @@ -20,8 +20,8 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import type { IntegrateGitOptions } from '../../../../../src/commands/integrate/git/options.ts'; diff --git a/tests/unit/commands/list/list.test.ts b/tests/unit/commands/list/list.test.ts index eb147a7e9..53aa7af5a 100644 --- a/tests/unit/commands/list/list.test.ts +++ b/tests/unit/commands/list/list.test.ts @@ -24,7 +24,7 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { IssuesClient } from '@/core/server/issues.ts'; import { MAX_PAGE_SIZE, ProjectsClient } from '@/core/server/projects.ts'; diff --git a/tests/unit/commands/list/projects-command.test.ts b/tests/unit/commands/list/projects-command.test.ts index fb9036bf4..c6342f0de 100644 --- a/tests/unit/commands/list/projects-command.test.ts +++ b/tests/unit/commands/list/projects-command.test.ts @@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { MAX_PAGE_SIZE } from '@/core/server/projects.ts'; import type { ProjectsSearchResponse } from '@/core/server/types.ts'; diff --git a/tests/unit/commands/run/mcp.test.ts b/tests/unit/commands/run/mcp.test.ts index 71323c765..81bd7a050 100644 --- a/tests/unit/commands/run/mcp.test.ts +++ b/tests/unit/commands/run/mcp.test.ts @@ -29,12 +29,13 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; import { runMcp } from '@/commands/run/mcp.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import { SONARQUBE_MCP_DOCKER_IMAGE_NAME } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { ProxyGroup, ResolvedNetworkConfig } from '@/core/host/connectivity/types.ts'; import type { ClientCertConfig } from '@/core/host/connectivity/types.ts'; import * as pkcs12Module from '@/core/host/crypto/pkcs12.ts'; +import * as toolDetector from '@/core/host/environment/tool-detector.ts'; import { clientCertCachePath, getMcpContainerCommand, @@ -43,7 +44,6 @@ import { resolveMcpContainerCommand, } from '@/core/host/mcp/mcp-helper.ts'; import { createRedactedUrl } from '@/core/host/redacted-url.ts'; -import * as toolDetector from '@/core/host/tool-detector.ts'; import { normalizePath } from '@/core/io/fs-utils.ts'; import * as projectInfo from '@/core/project-info.ts'; diff --git a/tests/unit/commands/_common/sonar-command.test.ts b/tests/unit/commands/sonar-command.test.ts similarity index 98% rename from tests/unit/commands/_common/sonar-command.test.ts rename to tests/unit/commands/sonar-command.test.ts index 6c5af4d2d..7a414e227 100644 --- a/tests/unit/commands/_common/sonar-command.test.ts +++ b/tests/unit/commands/sonar-command.test.ts @@ -22,14 +22,13 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test'; +import { SonarCommand } from '@/commands/sonar-command.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; import { RateLimitError, ServiceUnavailableError } from '@/core/server/errors.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; -import { SonarCommand } from '../../../../src/commands/_common/sonar-command.ts'; - const FAKE_AUTH: ResolvedAuth = { token: 'fake-token', serverUrl: 'https://sonar.example.com', diff --git a/tests/unit/commands/update/update-version.test.ts b/tests/unit/commands/update/update-version.test.ts index 56d3bbfbb..f4bcb8629 100644 --- a/tests/unit/commands/update/update-version.test.ts +++ b/tests/unit/commands/update/update-version.test.ts @@ -56,9 +56,9 @@ void mock.module('node:child_process', () => ({ })); // Mock platform-detector so both Unix and Windows branches are reachable on any OS. -const platformDetector = await import('@/core/host/platform-detector.ts'); +const platformDetector = await import('@/core/host/environment/platform-detector.ts'); const isWindowsMock = mock(() => false); -void mock.module('@/core/host/platform-detector.js', () => ({ +void mock.module('@/core/host/environment/platform-detector.ts', () => ({ ...platformDetector, isWindows: isWindowsMock, })); diff --git a/tests/unit/commands/auth/auth-resolver.test.ts b/tests/unit/core/auth/auth-resolver.test.ts similarity index 99% rename from tests/unit/commands/auth/auth-resolver.test.ts rename to tests/unit/core/auth/auth-resolver.test.ts index 1432e47f9..17bf8f788 100644 --- a/tests/unit/commands/auth/auth-resolver.test.ts +++ b/tests/unit/core/auth/auth-resolver.test.ts @@ -22,7 +22,6 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import * as authConnectionRecorder from '@/core/host/auth-connection-recorder.ts'; import { cloudRegionFromUrl, ENV_SERVER, @@ -31,7 +30,8 @@ import { resetEnvAuthRecordGuard, resolveAuth, resolveFromEndpoint, -} from '@/core/host/auth-resolver.ts'; +} from '@/core/auth/auth-resolver.ts'; +import * as authConnectionRecorder from '@/core/host/auth-connection-recorder.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/core/host/auth-connection-recorder.test.ts b/tests/unit/core/host/auth-connection-recorder.test.ts index 9d5f144c2..d8780d1c7 100644 --- a/tests/unit/core/host/auth-connection-recorder.test.ts +++ b/tests/unit/core/host/auth-connection-recorder.test.ts @@ -30,9 +30,9 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { addOrUpdateConnection, getActiveConnection } from '@/core/state/state-manager.ts'; import { loadState, saveState } from '@/core/state/state-repository.ts'; diff --git a/tests/unit/commands/_common/context-augmentation-env.test.ts b/tests/unit/core/host/context-augmentation-env.test.ts similarity index 98% rename from tests/unit/commands/_common/context-augmentation-env.test.ts rename to tests/unit/core/host/context-augmentation-env.test.ts index 5493b1709..5ad435ebc 100644 --- a/tests/unit/commands/_common/context-augmentation-env.test.ts +++ b/tests/unit/core/host/context-augmentation-env.test.ts @@ -20,8 +20,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; -import { buildContextAugmentationEnv } from '@/commands/_common/context-augmentation-env.ts'; import { clearNetworkConfigCache } from '@/core/host/connectivity/network-config.ts'; +import { buildContextAugmentationEnv } from '@/core/host/context-augmentation-env.ts'; import { INVOCATION_ID } from '@/core/telemetry/invocation-id.ts'; const KEYS = [ diff --git a/tests/unit/core/host/agent-detector.test.ts b/tests/unit/core/host/environment/agent-detector.test.ts similarity index 99% rename from tests/unit/core/host/agent-detector.test.ts rename to tests/unit/core/host/environment/agent-detector.test.ts index 8e2c84860..27f053cdc 100644 --- a/tests/unit/core/host/agent-detector.test.ts +++ b/tests/unit/core/host/environment/agent-detector.test.ts @@ -27,7 +27,7 @@ import { isCodexAgentEnv, isCopilotCliAgentEnv, isCursorAgentEnv, -} from '@/core/host/agent-detector.ts'; +} from '@/core/host/environment/agent-detector.ts'; function env(overrides: Record): NodeJS.ProcessEnv { return overrides; diff --git a/tests/unit/core/host/distribution.test.ts b/tests/unit/core/host/environment/distribution.test.ts similarity index 93% rename from tests/unit/core/host/distribution.test.ts rename to tests/unit/core/host/environment/distribution.test.ts index 878454b3b..4634e1879 100644 --- a/tests/unit/core/host/distribution.test.ts +++ b/tests/unit/core/host/environment/distribution.test.ts @@ -20,7 +20,10 @@ import { describe, expect, it } from 'bun:test'; -import { resolveDistribution, resolveDistributionConfig } from '@/core/host/distribution.ts'; +import { + resolveDistribution, + resolveDistributionConfig, +} from '@/core/host/environment/distribution.ts'; describe('distribution', () => { it('defaults to standalone when no distribution is provided', () => { diff --git a/tests/unit/core/host/platform-detector.test.ts b/tests/unit/core/host/environment/platform-detector.test.ts similarity index 95% rename from tests/unit/core/host/platform-detector.test.ts rename to tests/unit/core/host/environment/platform-detector.test.ts index 4cb64b50e..c62f95b0e 100644 --- a/tests/unit/core/host/platform-detector.test.ts +++ b/tests/unit/core/host/environment/platform-detector.test.ts @@ -20,7 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; describe('platform-detector', () => { describe('detectPlatform', () => { diff --git a/tests/unit/core/host/tool-detector.test.ts b/tests/unit/core/host/environment/tool-detector.test.ts similarity index 96% rename from tests/unit/core/host/tool-detector.test.ts rename to tests/unit/core/host/environment/tool-detector.test.ts index 4087175e1..e9f0e8e68 100644 --- a/tests/unit/core/host/tool-detector.test.ts +++ b/tests/unit/core/host/environment/tool-detector.test.ts @@ -23,14 +23,14 @@ import { afterEach, describe, expect, it, mock, spyOn } from 'bun:test'; import * as process from '@/core/process/process.ts'; // Mock platform-detector so both Windows and non-Windows branches are reachable on any OS. -const platformDetector = await import('@/core/host/platform-detector.ts'); +const platformDetector = await import('@/core/host/environment/platform-detector.ts'); const isWindowsMock = mock(() => false); -void mock.module('@/core/host/platform-detector.ts', () => ({ +void mock.module('@/core/host/environment/platform-detector.ts', () => ({ ...platformDetector, isWindows: isWindowsMock, })); -const { detectContainerRuntime } = await import('@/core/host/tool-detector.ts'); +const { detectContainerRuntime } = await import('@/core/host/environment/tool-detector.ts'); describe('detectContainerRuntime', () => { let spawnSpy: ReturnType; diff --git a/tests/unit/core/host/install/binary.test.ts b/tests/unit/core/host/install/binary.test.ts index 10ba06565..ac3a91409 100644 --- a/tests/unit/core/host/install/binary.test.ts +++ b/tests/unit/core/host/install/binary.test.ts @@ -24,8 +24,8 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { type BinarySpec, buildLocalBinaryName, removeBinary } from '@/core/host/install/binary.ts'; -import { detectPlatform } from '@/core/host/platform-detector.ts'; const baseSpec: Omit = { distPrefix: 'CommercialDistribution/whatever', diff --git a/tests/unit/core/state/state-manager.test.ts b/tests/unit/core/state/state-manager.test.ts index f0e4f9056..621fd2300 100644 --- a/tests/unit/core/state/state-manager.test.ts +++ b/tests/unit/core/state/state-manager.test.ts @@ -30,7 +30,7 @@ import { join } from 'node:path'; import { afterAll, afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import type { AuthConnection } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; import { diff --git a/tests/unit/core/telemetry/identity.test.ts b/tests/unit/core/telemetry/identity.test.ts index 9f51dd4f6..3326d0094 100644 --- a/tests/unit/core/telemetry/identity.test.ts +++ b/tests/unit/core/telemetry/identity.test.ts @@ -32,9 +32,9 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME, getTelemetryDir } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; import { resolveTelemetryIdentity } from '@/core/host/identity-fetch.ts'; import type { AuthConnection } from '@/core/state/state.ts'; import { diff --git a/tests/unit/core/telemetry/integrate-telemetry.test.ts b/tests/unit/core/telemetry/integrate-telemetry.test.ts index 319c45a9f..00f7f246c 100644 --- a/tests/unit/core/telemetry/integrate-telemetry.test.ts +++ b/tests/unit/core/telemetry/integrate-telemetry.test.ts @@ -22,7 +22,7 @@ import { createHash } from 'node:crypto'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { canonicalizePath } from '@/core/io/fs-utils.ts'; import type { InstalledIntegrationFeature } from '@/core/state/state.ts'; import { emitIntegrationConfiguredTelemetry } from '@/core/telemetry/integrate-telemetry.ts'; diff --git a/tests/unit/core/telemetry/sca-analysis-telemetry.test.ts b/tests/unit/core/telemetry/sca-analysis-telemetry.test.ts index e9f05d2da..7ccaec8aa 100644 --- a/tests/unit/core/telemetry/sca-analysis-telemetry.test.ts +++ b/tests/unit/core/telemetry/sca-analysis-telemetry.test.ts @@ -32,8 +32,8 @@ import type { ScaIssueType, Severity, } from '@/commands/analyze/dependency-risk-helpers/sca-scanner.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import * as stateManager from '@/core/state/state-manager.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; import { diff --git a/tests/unit/core/telemetry/sqaa-analysis-telemetry.test.ts b/tests/unit/core/telemetry/sqaa-analysis-telemetry.test.ts index fd90f8f0e..5d43037d6 100644 --- a/tests/unit/core/telemetry/sqaa-analysis-telemetry.test.ts +++ b/tests/unit/core/telemetry/sqaa-analysis-telemetry.test.ts @@ -26,8 +26,8 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; import type { RunTally } from '@/commands/analyze/sqaa-analysis.ts'; import type { SqaaJsonReport } from '@/commands/analyze/sqaa-display-json.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import type { SqaaIssue } from '@/core/server/client.ts'; import * as stateManager from '@/core/state/state-manager.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; diff --git a/tests/unit/core/telemetry/telemetry-events.test.ts b/tests/unit/core/telemetry/telemetry-events.test.ts index 1b2ca67a2..48085a5b1 100644 --- a/tests/unit/core/telemetry/telemetry-events.test.ts +++ b/tests/unit/core/telemetry/telemetry-events.test.ts @@ -32,11 +32,11 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; import { scanAndEmitSecrets } from '@/commands/analyze/secrets.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME, TELEMETRY_ENDPOINT } from '@/core/config-constants.ts'; -import * as agentDetector from '@/core/host/agent-detector.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import * as networkConfig from '@/core/host/connectivity/network-config.ts'; -import { DISTRIBUTION } from '@/core/host/distribution.ts'; +import * as agentDetector from '@/core/host/environment/agent-detector.ts'; +import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import type { SpawnResult } from '@/core/process/process.ts'; import * as fetchGuardedModule from '@/core/server/fetch-guarded.ts'; import type { diff --git a/tests/unit/core/telemetry/telemetry.test.ts b/tests/unit/core/telemetry/telemetry.test.ts index b492d019b..bb7cebad5 100644 --- a/tests/unit/core/telemetry/telemetry.test.ts +++ b/tests/unit/core/telemetry/telemetry.test.ts @@ -31,11 +31,11 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; import type { Command } from 'commander'; +import * as authResolver from '@/core/auth/auth-resolver.ts'; +import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/auth/auth-resolver.ts'; import { ENV_DO_NOT_TRACK, ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; -import * as agentDetector from '@/core/host/agent-detector.ts'; -import * as authResolver from '@/core/host/auth-resolver.ts'; -import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/host/auth-resolver.ts'; -import { DISTRIBUTION } from '@/core/host/distribution.ts'; +import * as agentDetector from '@/core/host/environment/agent-detector.ts'; +import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import { resolveTelemetryIdentity } from '@/core/host/identity-fetch.ts'; import type { StoredAnalysisCompletedEvent } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; diff --git a/tests/unit/commands/_common/parsing.test.ts b/tests/unit/core/ui/parsing.test.ts similarity index 83% rename from tests/unit/commands/_common/parsing.test.ts rename to tests/unit/core/ui/parsing.test.ts index cbdeb452c..971068e8e 100644 --- a/tests/unit/commands/_common/parsing.test.ts +++ b/tests/unit/core/ui/parsing.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'bun:test'; import { InvalidArgumentError } from 'commander'; -import { parseInteger } from '../../../../src/commands/_common/parsing.ts'; +import { parseInteger } from '@/core/ui/parsing.ts'; describe('CLI option parsing', () => { it('should throw if not a valid number', () => { diff --git a/tests/unit/core/update/telemetry-migration.test.ts b/tests/unit/core/update/telemetry-migration.test.ts index e9f07f250..1a738bf1e 100644 --- a/tests/unit/core/update/telemetry-migration.test.ts +++ b/tests/unit/core/update/telemetry-migration.test.ts @@ -26,7 +26,7 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, Mock, spyOn } from 'bun:test'; import * as configConstants from '@/core/config-constants.ts'; -import { DISTRIBUTION } from '@/core/host/distribution.ts'; +import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import type { CliState, StoredCommandExecutedEvent } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; From 15d63e67011ef2c83ca2e3ef58d6d0027812874e Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Thu, 30 Jul 2026 15:31:36 +0200 Subject: [PATCH 2/4] Update imports --- .../dependency-risk-helpers/sca-scan-orchestrator.ts | 2 +- src/commands/command-tree.ts | 2 +- src/commands/integrate/_common/preflight-summary.ts | 7 +------ src/commands/integrate/antigravity/index.ts | 2 +- src/commands/integrate/claude/index.ts | 2 +- src/commands/integrate/copilot/index.ts | 2 +- src/commands/integrate/cursor/index.ts | 2 +- src/commands/integrate/git/index.ts | 2 +- .../integrate/git/tools/git-integration-subfeatures.ts | 2 +- src/commands/remediate/index.ts | 3 +-- src/commands/system/reset.ts | 2 +- src/commands/system/status.ts | 4 ++-- tests/unit/core/auth/auth-resolver.test.ts | 2 +- 13 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts b/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts index e2e44c918..a3d731398 100644 --- a/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts +++ b/src/commands/analyze/dependency-risk-helpers/sca-scan-orchestrator.ts @@ -27,6 +27,7 @@ import type { ScaScannerInstaller } from '@/core/host/install/sca-scanner.ts'; import type { SecretsInstaller } from '@/core/host/install/secrets.ts'; import logger, { getLogLevelConfig } from '@/core/observability/logger.ts'; import { type SonarQubeClient } from '@/core/server/client.ts'; +import { assertScaAvailable } from '@/core/server/sca-availability.ts'; import type { SettingsValue } from '@/core/server/settings-value.ts'; import { emitScaAnalysisTelemetry, @@ -34,7 +35,6 @@ import { } from '@/core/telemetry/sca-analysis-telemetry.ts'; import { withSpinner } from '@/core/ui'; -import { assertScaAvailable } from '../../../core/server/sca-availability.ts'; import { parseAnalysisProperties } from './analysis-properties.ts'; import { preScanManifestsForSecrets } from './manifest-secrets-guard.ts'; import { type AnalyzeProjectResponse, ScaScannerRunner } from './sca-scanner.ts'; diff --git a/src/commands/command-tree.ts b/src/commands/command-tree.ts index 2193e272f..63631051b 100644 --- a/src/commands/command-tree.ts +++ b/src/commands/command-tree.ts @@ -37,9 +37,9 @@ import { SQAA_VERIFY_CALLER_COMMAND, } from '@/core/telemetry/sqaa-analysis-telemetry.ts'; import { blank, error, warn } from '@/core/ui'; +import { parseInteger } from '@/core/ui/parsing.ts'; import { version as VERSION } from '../../package.json'; -import { parseInteger } from '../core/ui/parsing.ts'; import { analyzeAll, type AnalyzeAllOptions } from './analyze/analyze-all.ts'; import type { Severity } from './analyze/dependency-risk-helpers/sca-scanner.ts'; import { SEVERITIES } from './analyze/dependency-risk-helpers/view-model/build/severity.ts'; diff --git a/src/commands/integrate/_common/preflight-summary.ts b/src/commands/integrate/_common/preflight-summary.ts index 8231e381b..e2729bd48 100644 --- a/src/commands/integrate/_common/preflight-summary.ts +++ b/src/commands/integrate/_common/preflight-summary.ts @@ -20,6 +20,7 @@ // Preflight summaries shown at the start of integrate commands, before install. +import { checkTokenStatus, type TokenCheckResult, type TokenStatus } from '@/core/auth/token.ts'; import { CommandFailedError } from '@/core/command-error.ts'; import { GitRepo } from '@/core/host/git/hooks.ts'; import type { DiscoveredProject } from '@/core/project-info.ts'; @@ -27,12 +28,6 @@ import { SonarQubeClient } from '@/core/server/client.ts'; import type { PhaseItem, StepStatus } from '@/core/ui'; import { info, outro, phase, phaseItem, text } from '@/core/ui'; -import { - checkTokenStatus, - type TokenCheckResult, - type TokenStatus, -} from '../../../core/auth/token.ts'; - export interface AgentPreflightSummaryOptions { serverUrl: string; organization?: string; diff --git a/src/commands/integrate/antigravity/index.ts b/src/commands/integrate/antigravity/index.ts index f0163ac23..22ca3e96c 100644 --- a/src/commands/integrate/antigravity/index.ts +++ b/src/commands/integrate/antigravity/index.ts @@ -21,8 +21,8 @@ import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { installIntegration } from '@/core/framework/features'; import type { IntegrationStateAttribute } from '@/core/state/state.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import { buildRecordedIntegrationAttrs } from '../_common/context-augmentation.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/claude/index.ts b/src/commands/integrate/claude/index.ts index 1bf3a29c0..2cadb3f11 100644 --- a/src/commands/integrate/claude/index.ts +++ b/src/commands/integrate/claude/index.ts @@ -25,9 +25,9 @@ import { homedir } from 'node:os'; import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { installIntegration } from '@/core/framework/features'; import type { IntegrationStateAttribute } from '@/core/state/state.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; import { removeObsoleteHookArtifacts } from '@/core/update/claude-hooks-migration.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { displayAgentIntegratePrelude, resolveIntegrateInstallTarget, diff --git a/src/commands/integrate/copilot/index.ts b/src/commands/integrate/copilot/index.ts index 9cd69fb3d..c1323e125 100644 --- a/src/commands/integrate/copilot/index.ts +++ b/src/commands/integrate/copilot/index.ts @@ -19,8 +19,8 @@ */ import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { finalizeAgentInstall } from '../_common/agent-integrate-postlude.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/cursor/index.ts b/src/commands/integrate/cursor/index.ts index e3a4a4df5..653001563 100644 --- a/src/commands/integrate/cursor/index.ts +++ b/src/commands/integrate/cursor/index.ts @@ -22,8 +22,8 @@ import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { warn } from '@/core/ui'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { finalizeAgentInstall } from '../_common/agent-integrate-postlude.ts'; import { displayAgentIntegratePrelude } from '../_common/agent-integrate-prelude.ts'; import type { IntegrateAgentOptions } from '../_common/types.ts'; diff --git a/src/commands/integrate/git/index.ts b/src/commands/integrate/git/index.ts index 3ff444cf1..b0958af5c 100644 --- a/src/commands/integrate/git/index.ts +++ b/src/commands/integrate/git/index.ts @@ -33,8 +33,8 @@ import { normalizePath } from '@/core/io/fs-utils.ts'; import { discoverProject } from '@/core/project-info.ts'; import { blank, confirmPrompt, info, intro, phase, phaseItem, text, warn } from '@/core/ui'; import { yellow } from '@/core/ui/colors.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; -import { printAgentNonInteractiveAlternativeHint } from '../../../core/ui/components/agent-prompt-hint.ts'; import { resolveIntegrateScope } from '../_common/integrate-scope.ts'; import { printGitPreflightSummary } from '../_common/preflight-summary.ts'; import { supportedIntegrations } from '../index.ts'; diff --git a/src/commands/integrate/git/tools/git-integration-subfeatures.ts b/src/commands/integrate/git/tools/git-integration-subfeatures.ts index 424371179..bdc281c05 100644 --- a/src/commands/integrate/git/tools/git-integration-subfeatures.ts +++ b/src/commands/integrate/git/tools/git-integration-subfeatures.ts @@ -27,8 +27,8 @@ import { import { askUser, install, skip } from '@/core/framework/features/selection.ts'; import type { FeaturePreview, SubfeatureDeclaration } from '@/core/framework/features/types.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; +import { assertScaAvailable } from '@/core/server/sca-availability.ts'; -import { assertScaAvailable } from '../../../../core/server/sca-availability.ts'; import type { GitHookType, IntegrateGitOptions } from '../options.ts'; export const PRE_COMMIT_DEP_RISKS_SUBFEATURE_ID = 'pre-commit-dependency-risks'; diff --git a/src/commands/remediate/index.ts b/src/commands/remediate/index.ts index e2b57e309..2475f37d7 100644 --- a/src/commands/remediate/index.ts +++ b/src/commands/remediate/index.ts @@ -36,8 +36,7 @@ import type { SonarQubeIssue } from '@/core/server/types.ts'; import { noteProject } from '@/core/telemetry/project-uuid.ts'; import { blank, info, multiSelectPrompt, print, success, withSpinner } from '@/core/ui'; import { cyan, dim, red, yellow } from '@/core/ui/colors.ts'; - -import { printAgentNonInteractiveAlternativeHint } from '../../core/ui/components/agent-prompt-hint.ts'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; export interface RemediateOptions { project?: string; diff --git a/src/commands/system/reset.ts b/src/commands/system/reset.ts index 1b56916dd..4d7870e0d 100644 --- a/src/commands/system/reset.ts +++ b/src/commands/system/reset.ts @@ -22,9 +22,9 @@ import { type CliState, getDefaultState, type InstalledIntegration } from '@/cor import { loadState, saveState } from '@/core/state/state-repository.ts'; import type { PhaseItem } from '@/core/ui'; import { info, phase, print, success, text, textPrompt, warn } from '@/core/ui'; +import { printAgentNonInteractiveAlternativeHint } from '@/core/ui/components/agent-prompt-hint.ts'; import { version as VERSION } from '../../../package.json'; -import { printAgentNonInteractiveAlternativeHint } from '../../core/ui/components/agent-prompt-hint.ts'; import { supportedIntegrations } from '../integrate'; import { purgeAuth } from './reset-auth.ts'; import { removeBinaries } from './reset-binaries.ts'; diff --git a/src/commands/system/status.ts b/src/commands/system/status.ts index 4b5778d7c..2bb3f670b 100644 --- a/src/commands/system/status.ts +++ b/src/commands/system/status.ts @@ -26,6 +26,8 @@ import { parse as parseToml } from 'smol-toml'; import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { resolveAuth } from '@/core/auth/auth-resolver.ts'; +import type { TokenCheckResult } from '@/core/auth/token.ts'; +import { checkTokenStatus } from '@/core/auth/token.ts'; import { CLI_DIR, GLOBAL_HOOKS_DIR, LOG_DIR } from '@/core/config-constants.ts'; import { recordedFeatureResources } from '@/core/framework/features'; import { getNetworkConfig } from '@/core/host/connectivity/network-config.ts'; @@ -53,8 +55,6 @@ import { blank, print, success, text, warn } from '@/core/ui'; import { isNewerVersion, stripBuildNumber } from '@/core/version.ts'; import { version as VERSION } from '../../../package.json'; -import type { TokenCheckResult } from '../../core/auth/token.ts'; -import { checkTokenStatus } from '../../core/auth/token.ts'; import { supportedIntegrations } from '../integrate'; import { checkAntigravitySecretsHookFile } from '../integrate/antigravity/health.ts'; import { resolveAntigravityHooksJsonPathForScope } from '../integrate/antigravity/hooks.ts'; diff --git a/tests/unit/core/auth/auth-resolver.test.ts b/tests/unit/core/auth/auth-resolver.test.ts index 17bf8f788..b0157caf3 100644 --- a/tests/unit/core/auth/auth-resolver.test.ts +++ b/tests/unit/core/auth/auth-resolver.test.ts @@ -36,7 +36,7 @@ import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; -import { createKeychainTestHandle } from '../../core/host/keychain-test-handle.ts'; +import { createKeychainTestHandle } from '../host/keychain-test-handle.ts'; const SONARCLOUD_URL = 'https://sonarcloud.io'; const FAKE_TOKEN = 'squ_test_token_abc123'; From cda8755d6e803faa68f35716db307b4ed9f7024a Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Thu, 30 Jul 2026 16:27:57 +0200 Subject: [PATCH 3/4] fix issues, move some files --- CLAUDE.md | 12 ++++++------ build-scripts/build-binary.ts | 2 +- build-scripts/setup-integration-resources.ts | 2 +- src/commands/auth/login.ts | 2 +- src/commands/command-tree.ts | 2 +- .../_common/context-augmentation-dependency.ts | 2 +- .../_common/features/context-augmentation-feature.ts | 2 +- src/commands/system/reset-binaries.ts | 2 +- src/commands/system/status.ts | 10 +++++----- src/core/{host => auth}/auth-connection-recorder.ts | 2 +- src/core/auth/auth-resolver.ts | 2 +- .../framework/dependencies/sonarsource-binary.ts | 2 +- src/core/host/{environment => }/distribution.ts | 0 src/core/host/environment/platform-detector.ts | 2 +- src/core/host/install/binary.ts | 4 ++-- src/core/host/install/context-augmentation.ts | 12 ++++++------ src/core/host/{ => install}/install-types.ts | 0 src/core/host/install/sca-scanner.ts | 2 +- src/core/host/install/secrets.ts | 2 +- src/core/host/{ => install}/sonarsource-releases.ts | 6 +++--- src/core/state/state.ts | 2 +- src/core/{host => telemetry}/identity-fetch.ts | 0 src/core/telemetry/identity.ts | 8 ++++---- src/core/telemetry/index.ts | 2 +- src/core/update/binary-refresh.ts | 2 +- tests/e2e/context/_helpers.ts | 2 +- tests/e2e/context/cag-edge-cases.test.ts | 2 +- tests/integration/harness/environment-builder.ts | 4 ++-- tests/integration/harness/fake-binaries-server.ts | 2 +- tests/integration/specs/update/post-update.test.ts | 2 +- tests/unit/commands/analyze/secrets-install.test.ts | 2 +- tests/unit/commands/update/pgp-verification.test.ts | 7 +++++-- .../commands/update/sonarsource-releases.test.ts | 2 +- .../{host => auth}/auth-connection-recorder.test.ts | 2 +- tests/unit/core/auth/auth-resolver.test.ts | 2 +- .../core/host/{environment => }/distribution.test.ts | 5 +---- .../core/host/{ => install}/install-types.test.ts | 2 +- .../host/{ => install}/sonarsource-releases.test.ts | 2 +- tests/unit/core/telemetry/identity.test.ts | 2 +- tests/unit/core/telemetry/telemetry-events.test.ts | 2 +- tests/unit/core/telemetry/telemetry.test.ts | 4 ++-- tests/unit/core/update/binary-refresh.test.ts | 2 +- tests/unit/core/update/telemetry-migration.test.ts | 2 +- 43 files changed, 66 insertions(+), 66 deletions(-) rename src/core/{host => auth}/auth-connection-recorder.ts (98%) rename src/core/host/{environment => }/distribution.ts (100%) rename src/core/host/{ => install}/install-types.ts (100%) rename src/core/host/{ => install}/sonarsource-releases.ts (97%) rename src/core/{host => telemetry}/identity-fetch.ts (100%) rename tests/unit/core/{host => auth}/auth-connection-recorder.test.ts (99%) rename tests/unit/core/host/{environment => }/distribution.test.ts (93%) rename tests/unit/core/host/{ => install}/install-types.test.ts (98%) rename tests/unit/core/host/{ => install}/sonarsource-releases.test.ts (98%) diff --git a/CLAUDE.md b/CLAUDE.md index 6fd7f5a4b..0e759ed09 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -100,17 +100,17 @@ The CAG installer (`src/core/host/install/context-augmentation.ts`) handles `.ta ### Telemetry -All telemetry events (`CliCommandExecuted` from `storeEvent`, `CliAnalysisCompleted`, `CliIntegrationConfigured`) are appended to `telemetry-events.ndjson` in `src/core/telemetry/telemetry-events.ts` and drained by `flushTelemetryEvents`, sharing the identity resolver in `src/core/telemetry/identity.ts` (which delegates raw fetching/caching to `src/core/host/identity-fetch.ts` — see CLI-866 below). Each analyzer run (sonar-secrets, SQAA, SCA) emits exactly one `CliAnalysisCompleted` event; its required `details` field carries a JSON-encoded, analyzer-specific per-rule blob when `findings_count > 0` and is `""` (empty string, never `null`, so `flushTelemetryEvents`'s null-stripping replacer keeps the column) otherwise. Each analyzer helper builds its own `details`; the shared emitter stays analyzer-agnostic. It fills `connection_type`, `user_uuid`, `organization_uuid_v4`, and `sqs_installation_id` on every event, for both keychain- and env-var-based auth alike. +All telemetry events (`CliCommandExecuted` from `storeEvent`, `CliAnalysisCompleted`, `CliIntegrationConfigured`) are appended to `telemetry-events.ndjson` in `src/core/telemetry/telemetry-events.ts` and drained by `flushTelemetryEvents`, sharing the identity resolver in `src/core/telemetry/identity.ts` (which delegates raw fetching/caching to `src/core/telemetry/identity-fetch.ts` — see CLI-866 below). Each analyzer run (sonar-secrets, SQAA, SCA) emits exactly one `CliAnalysisCompleted` event; its required `details` field carries a JSON-encoded, analyzer-specific per-rule blob when `findings_count > 0` and is `""` (empty string, never `null`, so `flushTelemetryEvents`'s null-stripping replacer keeps the column) otherwise. Each analyzer helper builds its own `details`; the shared emitter stays analyzer-agnostic. It fills `connection_type`, `user_uuid`, `organization_uuid_v4`, and `sqs_installation_id` on every event, for both keychain- and env-var-based auth alike. **Resolution order** (per auth token, keyed by connection type + server URL + org key + token fingerprint): 1. **Connection seed** — `identityFromConnection()` maps `AuthConnection.userUuid`, `organizationUuidV4`, and `sqsInstallationId` — kept in sync for both keychain and env-var auth by `recordConnectionFromAuth()` (see CLI-866 below), not just at `sonar auth login`. -2. **Disk cache** — `{SONAR_USER_HOME}/sonarqube-cli/telemetry/identity-cache.json`, one entry per auth fingerprint (`src/core/host/identity-fetch.ts`). Avoids repeat API calls across CLI invocations, independently of the connection seed. +2. **Disk cache** — `{SONAR_USER_HOME}/sonarqube-cli/telemetry/identity-cache.json`, one entry per auth fingerprint (`src/core/telemetry/identity-fetch.ts`). Avoids repeat API calls across CLI invocations, independently of the connection seed. 3. **API enrichment** — `SonarQubeClient.getSafe()` fetches only missing fields: `/api/users/current` (cloud and server), `/organizations/organizations` (cloud only, when `orgKey` is set), `/api/system/status` (server only). **Fast path** (skip resolving auth entirely, in `resolveStoreEventTelemetryIdentity`): when `conn` (the currently active `AuthConnection`, read fresh from state) already satisfies `needsIdentityEnrichment() === false`. This check is source-agnostic — it is not gated on `isEnvBasedAuth()` — because `resolveAuth()`'s env branch keeps `state.auth.connections` synced before this ever runs (see CLI-866 below), so a fully-populated `conn` is trustworthy regardless of which auth source produced it. When the fast path doesn't apply, telemetry calls `resolveAuth({ silent: true })` — `silent` suppresses the "partial env vars" warning so this best-effort, source-agnostic shadow resolution never prints a diagnostic the command's own `resolveAuth()` call would already have shown (or wouldn't have shown at all, for a non-authenticated command). -**Field completeness** (`isIdentityCompleteForConnection`, in `src/core/host/identity-fetch.ts`): +**Field completeness** (`isIdentityCompleteForConnection`, in `src/core/telemetry/identity-fetch.ts`): - **Cloud** — requires `user_uuid` and `organization_uuid_v4`. - **Server** — requires `sqs_installation_id` only; `user_uuid` is optional on older SonarQube Server versions that do not return it (see `TelemetryEventPayload`). @@ -146,15 +146,15 @@ Error subclasses extend the abstract `CliError` and carry their own `exitCode`, - `loadState()` returns defaults only when `state.json` is absent; if an existing file fails to read/parse it retries then throws (so `saveState()` can't wipe a corrupt file — CLI-834). Best-effort callers (Sentry init, `storeEvent`/`flushTelemetry`, `runPostUpdateActions`) use `tryLoadState()`, which returns `null` on failure. - Declarative integration installs are tracked as integration entries in the top-level `integrations.installed` state registry, with installed feature targets nested under each integration. Shared declarative dependencies (for example SonarSource binaries required by multiple features) are recorded separately in `dependencies.installed` and referenced from features by id. This is the generic state surface for Git, Claude, Codex, Copilot, Antigravity, and future integrations; legacy `agents` and `agentExtensions` remain for compatibility. - Tokens are stored in the system keychain via `src/core/host/keychain.ts` — never store tokens in plain files. -- **Env-var auth records state exactly like `sonar auth login`, minus the keychain write (CLI-866).** `resolveAuth()` (`src/core/host/auth-resolver.ts`) is `resolveFromEnv() ?? resolveFromState()`; whenever the env branch resolves, it calls `recordConnectionFromAuth()` (`src/core/host/auth-connection-recorder.ts`) before returning. That helper is the same state-writing step `sonar auth login` uses: `addOrUpdateConnection()` (server/org/region/tokenName) plus identity enrichment via `resolveTelemetryIdentity()` (`src/core/host/identity-fetch.ts`) — it just never calls `saveToken()`, since env-var auth exists specifically for sandboxed/headless environments (CLI-692) that cannot access the keychain in the first place. It no-ops (no state write, no network call) when the active connection already matches the resolved auth and its identity is already complete (`needsIdentityEnrichment()`), and accepts `force: true` to bypass that check — used by `login.ts` itself, since an explicit `sonar auth login` must always refresh `authenticatedAt`/`tokenName` even when re-authenticating to an already-known connection. `resolveAuth({ silent: true })` suppresses the "partial env vars" warning for callers (telemetry) that must not surface a diagnostic on every command. `src/core/host/sonarcloud-region.ts` holds the pure URL/region helpers (`cloudRegionFromUrl`, `resolveFromEndpoint`, etc., re-exported from `auth-resolver.ts` for compatibility) that both `auth-resolver.ts` and `identity-fetch.ts` need, without creating an import cycle between the two. +- **Env-var auth records state exactly like `sonar auth login`, minus the keychain write (CLI-866).** `resolveAuth()` (`src/core/auth/auth-resolver.ts`) is `resolveFromEnv() ?? resolveFromState()`; whenever the env branch resolves, it calls `recordConnectionFromAuth()` (`src/core/auth/auth-connection-recorder.ts`) before returning. That helper is the same state-writing step `sonar auth login` uses: `addOrUpdateConnection()` (server/org/region/tokenName) plus identity enrichment via `resolveTelemetryIdentity()` (`src/core/telemetry/identity-fetch.ts`) — it just never calls `saveToken()`, since env-var auth exists specifically for sandboxed/headless environments (CLI-692) that cannot access the keychain in the first place. It no-ops (no state write, no network call) when the active connection already matches the resolved auth and its identity is already complete (`needsIdentityEnrichment()`), and accepts `force: true` to bypass that check — used by `login.ts` itself, since an explicit `sonar auth login` must always refresh `authenticatedAt`/`tokenName` even when re-authenticating to an already-known connection. `resolveAuth({ silent: true })` suppresses the "partial env vars" warning for callers (telemetry) that must not surface a diagnostic on every command. `src/core/server/sonarcloud-region.ts` holds the pure URL/region helpers (`cloudRegionFromUrl`, `resolveFromEndpoint`, etc., re-exported from `auth-resolver.ts` for compatibility) that both `auth-resolver.ts` and `identity-fetch.ts` need, without creating an import cycle between the two. - All path and URL constants live in `src/core/config-constants.ts` — import from there instead of hardcoding. - Shared Sonar product data lives under `~/.sonar`; CLI-specific data stays under `~/.sonar/sonarqube-cli`, and the stable anonymous telemetry user ID is shared at `~/.sonar/user`. `SONAR_USER_HOME` is only a late-bound override for state persistence and telemetry user-id codepaths; other exported path constants remain fixed after import. - Caller-agent hints (Cursor, Claude Code, Copilot CLI, Codex, or Antigravity) from the environment: `src/core/host/environment/agent-detector.ts` (`detectCallerAgent`, etc.). - `sonar auth logout` relies on state: if there is no active connection or `isAuthenticated` is false, it only reports that you are already logged out (no keychain changes). - When `sonar auth login` runs the browser-based OAuth flow, the server-generated token name returned in the callback POST body is captured and persisted on the connection as `tokenName` (see `AuthConnection` in `src/core/state/state.ts`). The wire field is `name` (matching `/api/user_tokens/revoke?name=`); we keep it as `tokenName` in-memory to disambiguate from other "name" fields. - On `sonar auth logout`, the CLI best-effort revokes the server-side token via `SonarQubeClient.revokeUserToken(...)` (a one-line wrapper over the generic `postForm(endpoint, params)` helper) before clearing the keychain entry. Failures (network error, non-2xx response) are reported via a warning on stderr; local cleanup still proceeds. When the connection has no `tokenName` (e.g. upgraded from an older CLI version), the CLI emits a manual-revocation hint on stderr instead. -- `sonar system status` displays a diagnostic overview: authentication (token verified live via `/api/authentication/validate`, four states: Not Set / Active / Invalid / Set Unverified), installed binaries with update availability, configured integrations with paths, and MCP Server configured/running status. Supports `--json` for machine consumption. Implementation in `src/commands/system/status.ts`. Token verification uses `checkTokenStatus` from `_common/token.ts`; CLI update availability comes from `Distribution/sonarqube-cli/stable.version`, while `sonar update` downloads the platform installer script from the GitHub `user-scripts/` directory when it actually performs the update. MCP config validation is JSON-based for Claude/Copilot (checks `mcpServers.sonarqube` structure) and trusts file existence for Codex TOML configs. -- `sonar self-update` is a deprecated, hidden alias for `sonar update` (only when `CURRENT_DISTRIBUTION.enableSelfUpdate` is true; see `src/core/host/environment/distribution.ts`): calling it prints a deprecation warning pointing to `sonar update`, then runs the same `updateVersion()` logic. Both are registered in `src/commands/command-tree.ts`. +- `sonar system status` displays a diagnostic overview: authentication (token verified live via `/api/authentication/validate`, four states: Not Set / Active / Invalid / Set Unverified), installed binaries with update availability, configured integrations with paths, and MCP Server configured/running status. Supports `--json` for machine consumption. Implementation in `src/commands/system/status.ts`. Token verification uses `checkTokenStatus` from `src/core/auth/token.ts`; CLI update availability comes from `Distribution/sonarqube-cli/stable.version`, while `sonar update` downloads the platform installer script from the GitHub `user-scripts/` directory when it actually performs the update. MCP config validation is JSON-based for Claude/Copilot (checks `mcpServers.sonarqube` structure) and trusts file existence for Codex TOML configs. +- `sonar self-update` is a deprecated, hidden alias for `sonar update` (only when `CURRENT_DISTRIBUTION.enableSelfUpdate` is true; see `src/core/host/distribution.ts`): calling it prints a deprecation warning pointing to `sonar update`, then runs the same `updateVersion()` logic. Both are registered in `src/commands/command-tree.ts`. ## Tests diff --git a/build-scripts/build-binary.ts b/build-scripts/build-binary.ts index 0e938741e..e009d6db3 100644 --- a/build-scripts/build-binary.ts +++ b/build-scripts/build-binary.ts @@ -27,7 +27,7 @@ import { join } from 'node:path'; -import { resolveDistribution } from '@/core/host/environment/distribution.ts'; +import { resolveDistribution } from '@/core/host/distribution.ts'; const PROJECT_ROOT = join(import.meta.dir, '..'); const DEFAULT_OUTFILE = join(PROJECT_ROOT, 'dist', 'sonarqube-cli'); diff --git a/build-scripts/setup-integration-resources.ts b/build-scripts/setup-integration-resources.ts index 209b94a57..4de3e1172 100644 --- a/build-scripts/setup-integration-resources.ts +++ b/build-scripts/setup-integration-resources.ts @@ -44,7 +44,7 @@ import { buildDownloadUrl, downloadBinary, verifyBinarySignature, -} from '@/core/host/sonarsource-releases.ts'; +} from '@/core/host/install/sonarsource-releases.ts'; import { DEPENDENCY_ARTIFACTS_DIR } from './dependency-artifacts-path.js'; diff --git a/src/commands/auth/login.ts b/src/commands/auth/login.ts index c495a032f..555dfcc2a 100644 --- a/src/commands/auth/login.ts +++ b/src/commands/auth/login.ts @@ -18,11 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { recordConnectionFromAuth } from '@/core/auth/auth-connection-recorder.ts'; import { isSonarQubeCloud } from '@/core/auth/auth-resolver.ts'; import { type BrowserAuthResult, generateTokenViaBrowser } from '@/core/auth/token.ts'; import { CommandFailedError, InvalidOptionError } from '@/core/command-error.ts'; import { SONARCLOUD_URL, SONARCLOUD_US_URL } from '@/core/config-constants.ts'; -import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; import { deleteStaleTokens, getToken as getKeystoreToken, diff --git a/src/commands/command-tree.ts b/src/commands/command-tree.ts index 63631051b..f671bfa88 100644 --- a/src/commands/command-tree.ts +++ b/src/commands/command-tree.ts @@ -21,7 +21,7 @@ import { type Command, Help, InvalidArgumentError, Option } from 'commander'; import { CommandFailedError } from '@/core/command-error.ts'; -import { CURRENT_DISTRIBUTION } from '@/core/host/environment/distribution.ts'; +import { CURRENT_DISTRIBUTION } from '@/core/host/distribution.ts'; import { initSentry } from '@/core/observability/sentry.ts'; import { GENERIC_HTTP_METHODS } from '@/core/server/client.ts'; import { MAX_PAGE_SIZE } from '@/core/server/projects.ts'; diff --git a/src/commands/integrate/_common/context-augmentation-dependency.ts b/src/commands/integrate/_common/context-augmentation-dependency.ts index 8c6ef6702..ca5dee163 100644 --- a/src/commands/integrate/_common/context-augmentation-dependency.ts +++ b/src/commands/integrate/_common/context-augmentation-dependency.ts @@ -33,8 +33,8 @@ import { installContextAugmentationBinary, resolveContextAugmentationBinaryPath, } from '@/core/host/install/context-augmentation.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; import { stopAllContextAugmentationTools } from './context-augmentation.ts'; diff --git a/src/commands/integrate/_common/features/context-augmentation-feature.ts b/src/commands/integrate/_common/features/context-augmentation-feature.ts index 5bf4a11c1..126cc8862 100644 --- a/src/commands/integrate/_common/features/context-augmentation-feature.ts +++ b/src/commands/integrate/_common/features/context-augmentation-feature.ts @@ -22,8 +22,8 @@ import { CommandFailedError } from '@/core/command-error.ts'; import { install, skip } from '@/core/framework/features/selection.ts'; import type { IntegrationContext, SubfeatureDeclaration } from '@/core/framework/features/types.ts'; import { wholeFile } from '@/core/framework/resources'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; import { getOptionalStringAttr } from '../attrs.ts'; import { diff --git a/src/commands/system/reset-binaries.ts b/src/commands/system/reset-binaries.ts index b828fe49f..e3676374e 100644 --- a/src/commands/system/reset-binaries.ts +++ b/src/commands/system/reset-binaries.ts @@ -21,7 +21,7 @@ import { existsSync, rmSync } from 'node:fs'; import { BIN_DIR } from '@/core/config-constants.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import type { CliState } from '@/core/state/state.ts'; import type { PhaseItem } from '@/core/ui'; import { phaseItem } from '@/core/ui'; diff --git a/src/commands/system/status.ts b/src/commands/system/status.ts index 2bb3f670b..def3cced7 100644 --- a/src/commands/system/status.ts +++ b/src/commands/system/status.ts @@ -38,16 +38,16 @@ import type { ProxyGroup, ResolvedNetworkConfig, } from '@/core/host/connectivity/types.ts'; -import { CURRENT_DISTRIBUTION } from '@/core/host/environment/distribution.ts'; +import { CURRENT_DISTRIBUTION } from '@/core/host/distribution.ts'; +import { + CONTEXT_AUGMENTATION_BINARY_NAME, + SCA_SCANNER_BINARY_NAME, +} from '@/core/host/install/install-types.ts'; import { SECRETS_SPEC } from '@/core/host/install/secrets.ts'; import { SCA_SCANNER_CLI_VERSION, SONAR_CONTEXT_AUGMENTATION_VERSION, } from '@/core/host/install/signatures.ts'; -import { - CONTEXT_AUGMENTATION_BINARY_NAME, - SCA_SCANNER_BINARY_NAME, -} from '@/core/host/install-types.ts'; import { getMcpConfigFilePath } from '@/core/host/mcp/mcp-helper.ts'; import type { CliState } from '@/core/state/state.ts'; import { loadState } from '@/core/state/state-repository.ts'; diff --git a/src/core/host/auth-connection-recorder.ts b/src/core/auth/auth-connection-recorder.ts similarity index 98% rename from src/core/host/auth-connection-recorder.ts rename to src/core/auth/auth-connection-recorder.ts index 2b5036f13..a3b881712 100644 --- a/src/core/host/auth-connection-recorder.ts +++ b/src/core/auth/auth-connection-recorder.ts @@ -35,7 +35,7 @@ import { needsIdentityEnrichment, resolveTelemetryIdentity, type TelemetryIdentity, -} from './identity-fetch.ts'; +} from '../telemetry/identity-fetch.ts'; export interface RecordConnectionOptions { /** Only browser-OAuth logins carry a token name — env-var auth never does. */ diff --git a/src/core/auth/auth-resolver.ts b/src/core/auth/auth-resolver.ts index 9d0a8045f..9875808d7 100644 --- a/src/core/auth/auth-resolver.ts +++ b/src/core/auth/auth-resolver.ts @@ -20,7 +20,7 @@ // Centralized auth resolver - resolves token + serverUrl from env vars, state, or keychain -import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; +import { recordConnectionFromAuth } from '@/core/auth/auth-connection-recorder.ts'; import { getToken } from '@/core/host/keychain.ts'; import { warn } from '@/core/ui'; diff --git a/src/core/framework/dependencies/sonarsource-binary.ts b/src/core/framework/dependencies/sonarsource-binary.ts index 6cb219cce..11c5aee43 100644 --- a/src/core/framework/dependencies/sonarsource-binary.ts +++ b/src/core/framework/dependencies/sonarsource-binary.ts @@ -25,6 +25,7 @@ import { removeBinary, resolveBinaryPath, } from '@/core/host/install/binary.ts'; +import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SCA_SCANNER_CLI_SIGNATURES, SCA_SCANNER_CLI_VERSION, @@ -32,7 +33,6 @@ import { SONAR_SECRETS_VERSION, SONARSOURCE_PUBLIC_KEY, } from '@/core/host/install/signatures.ts'; -import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import type { DependencyInstallContext, diff --git a/src/core/host/environment/distribution.ts b/src/core/host/distribution.ts similarity index 100% rename from src/core/host/environment/distribution.ts rename to src/core/host/distribution.ts diff --git a/src/core/host/environment/platform-detector.ts b/src/core/host/environment/platform-detector.ts index 27056d38c..9d3153af8 100644 --- a/src/core/host/environment/platform-detector.ts +++ b/src/core/host/environment/platform-detector.ts @@ -22,7 +22,7 @@ import { arch, platform } from 'node:os'; -import type { PlatformInfo } from '../install-types.ts'; +import type { PlatformInfo } from '../install/install-types.ts'; const OS_MAP: Record = { darwin: 'macos', diff --git a/src/core/host/install/binary.ts b/src/core/host/install/binary.ts index fea4bc538..639068037 100644 --- a/src/core/host/install/binary.ts +++ b/src/core/host/install/binary.ts @@ -26,12 +26,12 @@ import { join } from 'node:path'; import { BIN_DIR } from '@/core/config-constants.ts'; import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; -import { buildPlatformSuffix, type PlatformInfo } from '@/core/host/install-types.ts'; +import { buildPlatformSuffix, type PlatformInfo } from '@/core/host/install/install-types.ts'; import { buildDownloadUrl, downloadBinary, verifyBinarySignature, -} from '@/core/host/sonarsource-releases.ts'; +} from '@/core/host/install/sonarsource-releases.ts'; import { recordInstallationInState } from '@/core/state/state-manager.ts'; import { type OutputChannel, print, text, withSpinner } from '@/core/ui'; diff --git a/src/core/host/install/context-augmentation.ts b/src/core/host/install/context-augmentation.ts index 81b331cb5..008b84d37 100644 --- a/src/core/host/install/context-augmentation.ts +++ b/src/core/host/install/context-augmentation.ts @@ -24,21 +24,21 @@ import { join } from 'node:path'; import { CommandFailedError } from '@/core/command-error.ts'; import { BIN_DIR } from '@/core/config-constants.ts'; import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; +import { + buildCagPlatformSuffix, + CONTEXT_AUGMENTATION_BINARY_NAME, + type PlatformInfo, +} from '@/core/host/install/install-types.ts'; import { SONAR_CONTEXT_AUGMENTATION_SIGNATURES, SONAR_CONTEXT_AUGMENTATION_VERSION, SONARSOURCE_PUBLIC_KEY, } from '@/core/host/install/signatures.ts'; -import { - buildCagPlatformSuffix, - CONTEXT_AUGMENTATION_BINARY_NAME, - type PlatformInfo, -} from '@/core/host/install-types.ts'; import { buildCagDownloadUrl, downloadBinary, verifyPgpSignature, -} from '@/core/host/sonarsource-releases.ts'; +} from '@/core/host/install/sonarsource-releases.ts'; import { extractFileFromTarGz } from '@/core/io/tar.ts'; import { recordInstallationInState } from '@/core/state/state-manager.ts'; import { text, withSpinner } from '@/core/ui'; diff --git a/src/core/host/install-types.ts b/src/core/host/install/install-types.ts similarity index 100% rename from src/core/host/install-types.ts rename to src/core/host/install/install-types.ts diff --git a/src/core/host/install/sca-scanner.ts b/src/core/host/install/sca-scanner.ts index 8e06cc62c..c188d7b8d 100644 --- a/src/core/host/install/sca-scanner.ts +++ b/src/core/host/install/sca-scanner.ts @@ -21,12 +21,12 @@ // sca-scanner-cli install: thin wrapper over the generic binary install pipeline. import { SCA_SCANNER_CLI_DIST_PREFIX } from '@/core/config-constants.ts'; +import { type PlatformInfo, SCA_SCANNER_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SCA_SCANNER_CLI_SIGNATURES, SCA_SCANNER_CLI_VERSION, SONARSOURCE_PUBLIC_KEY, } from '@/core/host/install/signatures.ts'; -import { type PlatformInfo, SCA_SCANNER_BINARY_NAME } from '@/core/host/install-types.ts'; import { discreetSuccess } from '@/core/ui'; import { diff --git a/src/core/host/install/secrets.ts b/src/core/host/install/secrets.ts index a1979343b..a01e64c91 100644 --- a/src/core/host/install/secrets.ts +++ b/src/core/host/install/secrets.ts @@ -21,12 +21,12 @@ // sonar-secrets install: thin wrapper over the generic binary install pipeline. import { SONAR_SECRETS_DIST_PREFIX } from '@/core/config-constants.ts'; +import { type PlatformInfo, SECRETS_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SONAR_SECRETS_SIGNATURES, SONAR_SECRETS_VERSION, SONARSOURCE_PUBLIC_KEY, } from '@/core/host/install/signatures.ts'; -import { type PlatformInfo, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import { discreetSuccess, type OutputChannel } from '@/core/ui'; import { diff --git a/src/core/host/sonarsource-releases.ts b/src/core/host/install/sonarsource-releases.ts similarity index 97% rename from src/core/host/sonarsource-releases.ts rename to src/core/host/install/sonarsource-releases.ts index 52f31ecfa..67a65005f 100644 --- a/src/core/host/sonarsource-releases.ts +++ b/src/core/host/install/sonarsource-releases.ts @@ -24,12 +24,12 @@ import { readFileSync } from 'node:fs'; import { buildFetchNetworkOptions } from '@/core/host/connectivity/network-config.ts'; -import { version as VERSION } from '../../../package.json'; +import { version as VERSION } from '../../../../package.json'; import { SONAR_CONTEXT_AUGMENTATION_DIST_PREFIX, SONARSOURCE_BINARIES_URL, -} from '../config-constants.ts'; -import logger from '../observability/logger.ts'; +} from '../../config-constants.ts'; +import logger from '../../observability/logger.ts'; import { buildCagPlatformSuffix, type PlatformInfo } from './install-types.ts'; const DOWNLOAD_TIMEOUT_MS = 60000; diff --git a/src/core/state/state.ts b/src/core/state/state.ts index 1a53913f6..a0cdfa17e 100644 --- a/src/core/state/state.ts +++ b/src/core/state/state.ts @@ -25,8 +25,8 @@ import { randomUUID } from 'node:crypto'; +import type { Distribution } from '@/core/host/distribution.ts'; import type { CallerAgent } from '@/core/host/environment/agent-detector.ts'; -import type { Distribution } from '@/core/host/environment/distribution.ts'; /** * Region for SonarCloud instances diff --git a/src/core/host/identity-fetch.ts b/src/core/telemetry/identity-fetch.ts similarity index 100% rename from src/core/host/identity-fetch.ts rename to src/core/telemetry/identity-fetch.ts diff --git a/src/core/telemetry/identity.ts b/src/core/telemetry/identity.ts index 92e615f8c..acd0f6522 100644 --- a/src/core/telemetry/identity.ts +++ b/src/core/telemetry/identity.ts @@ -19,21 +19,21 @@ */ import { resolveAuth, type ResolvedAuth } from '@/core/auth/auth-resolver.ts'; +import { authMatchesConnection } from '@/core/state/state-manager.ts'; import { identityFromConnection, needsIdentityEnrichment, resolveTelemetryIdentity, type TelemetryIdentity, -} from '@/core/host/identity-fetch.ts'; -import { authMatchesConnection } from '@/core/state/state-manager.ts'; +} from '@/core/telemetry/identity-fetch.ts'; import type { AuthConnection, ServerType, TelemetryConnectionType } from '../state/state.ts'; -export type { TelemetryIdentity } from '@/core/host/identity-fetch.ts'; +export type { TelemetryIdentity } from '@/core/telemetry/identity-fetch.ts'; export { identityFromConnection, isIdentityCompleteForConnection, -} from '@/core/host/identity-fetch.ts'; +} from '@/core/telemetry/identity-fetch.ts'; function toTelemetryConnectionType(type: ServerType): Exclude { return type === 'cloud' ? 'sqc' : 'sqs'; diff --git a/src/core/telemetry/index.ts b/src/core/telemetry/index.ts index 0b09cc71c..92e802ec3 100644 --- a/src/core/telemetry/index.ts +++ b/src/core/telemetry/index.ts @@ -20,7 +20,7 @@ import { type Command } from 'commander'; -import { DISTRIBUTION } from '../host/environment/distribution.ts'; +import { DISTRIBUTION } from '../host/distribution.ts'; import { tryLoadState } from '../state/state-manager.ts'; import { isTelemetryEnabled } from './enabled.ts'; import { currentProjectUuid } from './project-uuid.ts'; diff --git a/src/core/update/binary-refresh.ts b/src/core/update/binary-refresh.ts index ec36845cf..df3512de8 100644 --- a/src/core/update/binary-refresh.ts +++ b/src/core/update/binary-refresh.ts @@ -21,9 +21,9 @@ // Binary version refresh for already-installed SonarSource tools, consumed by // the post-update mechanism that runs automatically after CLI upgrades. +import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { installScaScannerBinary } from '@/core/host/install/sca-scanner.ts'; import { installSecretsBinary } from '@/core/host/install/secrets.ts'; -import { SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME } from '@/core/host/install-types.ts'; import logger from '../observability/logger.ts'; import type { CliState } from '../state/state.ts'; diff --git a/tests/e2e/context/_helpers.ts b/tests/e2e/context/_helpers.ts index bad73d5ab..6bd67722a 100644 --- a/tests/e2e/context/_helpers.ts +++ b/tests/e2e/context/_helpers.ts @@ -37,7 +37,7 @@ import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.t import { CODEX_INTEGRATION_ID } from '@/commands/integrate/codex/declaration.ts'; import { COPILOT_INTEGRATION_ID } from '@/commands/integrate/copilot/declaration.ts'; import { CURSOR_INTEGRATION_ID } from '@/commands/integrate/cursor/declaration.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import type { CliState, InstalledIntegrationDependency, diff --git a/tests/e2e/context/cag-edge-cases.test.ts b/tests/e2e/context/cag-edge-cases.test.ts index 4932f9dce..62a50caa4 100644 --- a/tests/e2e/context/cag-edge-cases.test.ts +++ b/tests/e2e/context/cag-edge-cases.test.ts @@ -32,8 +32,8 @@ import { afterEach, beforeEach, describe, expect, it, setDefaultTimeout } from ' import { CLAUDE_INTEGRATION_ID } from '@/commands/integrate/claude/declaration.ts'; import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; import type { CliState } from '@/core/state/state.ts'; import { version as CURRENT_CLI_VERSION } from '../../../package.json'; diff --git a/tests/integration/harness/environment-builder.ts b/tests/integration/harness/environment-builder.ts index 2d4feac7e..10e930dfe 100644 --- a/tests/integration/harness/environment-builder.ts +++ b/tests/integration/harness/environment-builder.ts @@ -32,12 +32,12 @@ import { recordInstalledFeature } from '@/core/framework/features/installation-r import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { type BinarySpec, buildLocalBinaryName } from '@/core/host/install/binary.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import { SCA_SCANNER_SPEC } from '@/core/host/install/sca-scanner.ts'; import { SECRETS_SPEC } from '@/core/host/install/secrets.ts'; import { SONAR_CONTEXT_AUGMENTATION_VERSION } from '@/core/host/install/signatures.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; +import { buildDownloadUrl } from '@/core/host/install/sonarsource-releases.ts'; import { generateKeychainAccount } from '@/core/host/keychain.ts'; -import { buildDownloadUrl } from '@/core/host/sonarsource-releases.ts'; import { canonicalizePath } from '@/core/io/fs-utils.ts'; import type { CliState, diff --git a/tests/integration/harness/fake-binaries-server.ts b/tests/integration/harness/fake-binaries-server.ts index 081a72715..b6b519b50 100644 --- a/tests/integration/harness/fake-binaries-server.ts +++ b/tests/integration/harness/fake-binaries-server.ts @@ -31,7 +31,7 @@ import { CONTEXT_AUGMENTATION_BINARY_NAME, SCA_SCANNER_BINARY_NAME, SECRETS_BINARY_NAME, -} from '@/core/host/install-types.ts'; +} from '@/core/host/install/install-types.ts'; import { DEPENDENCY_ARTIFACTS_DIR } from '../../../build-scripts/dependency-artifacts-path.js'; import type { RecordedRequest } from './types.js'; diff --git a/tests/integration/specs/update/post-update.test.ts b/tests/integration/specs/update/post-update.test.ts index ebecd7e23..e54d5bf2c 100644 --- a/tests/integration/specs/update/post-update.test.ts +++ b/tests/integration/specs/update/post-update.test.ts @@ -32,7 +32,7 @@ import { import { VORTEX_FEATURE_ID } from '@/commands/integrate/_common/vortex.ts'; import { detectPlatform } from '@/core/host/environment/platform-detector.ts'; import { buildLocalCagBinaryName } from '@/core/host/install/context-augmentation.ts'; -import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install-types.ts'; +import { CONTEXT_AUGMENTATION_BINARY_NAME } from '@/core/host/install/install-types.ts'; import type { CliState, InstalledIntegrationFeature } from '@/core/state/state.ts'; import { version as CURRENT_VERSION } from '../../../../package.json'; diff --git a/tests/unit/commands/analyze/secrets-install.test.ts b/tests/unit/commands/analyze/secrets-install.test.ts index 666a56127..94b883cff 100644 --- a/tests/unit/commands/analyze/secrets-install.test.ts +++ b/tests/unit/commands/analyze/secrets-install.test.ts @@ -38,7 +38,7 @@ import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; // Because mock.module returns a plain mutable object (not a frozen ES namespace), // spyOn can patch individual exports per-test and restore them in afterEach — // without permanently replacing any function for other test files in this process. -const releases = await import('@/core/host/sonarsource-releases.ts'); +const releases = await import('@/core/host/install/sonarsource-releases.ts'); void mock.module('@/core/host/sonarsource-releases.ts', () => ({ ...releases, })); diff --git a/tests/unit/commands/update/pgp-verification.test.ts b/tests/unit/commands/update/pgp-verification.test.ts index a1954a74a..b5c9bdc3e 100644 --- a/tests/unit/commands/update/pgp-verification.test.ts +++ b/tests/unit/commands/update/pgp-verification.test.ts @@ -29,8 +29,11 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; import * as openpgp from 'openpgp'; -import type { PlatformInfo } from '@/core/host/install-types.ts'; -import { verifyBinarySignature, verifyPgpSignature } from '@/core/host/sonarsource-releases.ts'; +import type { PlatformInfo } from '@/core/host/install/install-types.ts'; +import { + verifyBinarySignature, + verifyPgpSignature, +} from '@/core/host/install/sonarsource-releases.ts'; const PLATFORM: PlatformInfo = { os: 'linux', arch: 'x86-64', extension: '' }; diff --git a/tests/unit/commands/update/sonarsource-releases.test.ts b/tests/unit/commands/update/sonarsource-releases.test.ts index e2abcf9b7..8f5ab3886 100644 --- a/tests/unit/commands/update/sonarsource-releases.test.ts +++ b/tests/unit/commands/update/sonarsource-releases.test.ts @@ -21,7 +21,7 @@ import { describe, expect, it } from 'bun:test'; import { SONAR_SECRETS_DIST_PREFIX, SONARSOURCE_BINARIES_URL } from '@/core/config-constants.ts'; -import { buildDownloadUrl } from '@/core/host/sonarsource-releases.ts'; +import { buildDownloadUrl } from '@/core/host/install/sonarsource-releases.ts'; const SECRETS = 'sonar-secrets'; diff --git a/tests/unit/core/host/auth-connection-recorder.test.ts b/tests/unit/core/auth/auth-connection-recorder.test.ts similarity index 99% rename from tests/unit/core/host/auth-connection-recorder.test.ts rename to tests/unit/core/auth/auth-connection-recorder.test.ts index d8780d1c7..ad9756102 100644 --- a/tests/unit/core/host/auth-connection-recorder.test.ts +++ b/tests/unit/core/auth/auth-connection-recorder.test.ts @@ -30,9 +30,9 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it } from 'bun:test'; +import { recordConnectionFromAuth } from '@/core/auth/auth-connection-recorder.ts'; import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; -import { recordConnectionFromAuth } from '@/core/host/auth-connection-recorder.ts'; import { addOrUpdateConnection, getActiveConnection } from '@/core/state/state-manager.ts'; import { loadState, saveState } from '@/core/state/state-repository.ts'; diff --git a/tests/unit/core/auth/auth-resolver.test.ts b/tests/unit/core/auth/auth-resolver.test.ts index b0157caf3..6b5ea3188 100644 --- a/tests/unit/core/auth/auth-resolver.test.ts +++ b/tests/unit/core/auth/auth-resolver.test.ts @@ -22,6 +22,7 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import * as authConnectionRecorder from '@/core/auth/auth-connection-recorder.ts'; import { cloudRegionFromUrl, ENV_SERVER, @@ -31,7 +32,6 @@ import { resolveAuth, resolveFromEndpoint, } from '@/core/auth/auth-resolver.ts'; -import * as authConnectionRecorder from '@/core/host/auth-connection-recorder.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; diff --git a/tests/unit/core/host/environment/distribution.test.ts b/tests/unit/core/host/distribution.test.ts similarity index 93% rename from tests/unit/core/host/environment/distribution.test.ts rename to tests/unit/core/host/distribution.test.ts index 4634e1879..878454b3b 100644 --- a/tests/unit/core/host/environment/distribution.test.ts +++ b/tests/unit/core/host/distribution.test.ts @@ -20,10 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import { - resolveDistribution, - resolveDistributionConfig, -} from '@/core/host/environment/distribution.ts'; +import { resolveDistribution, resolveDistributionConfig } from '@/core/host/distribution.ts'; describe('distribution', () => { it('defaults to standalone when no distribution is provided', () => { diff --git a/tests/unit/core/host/install-types.test.ts b/tests/unit/core/host/install/install-types.test.ts similarity index 98% rename from tests/unit/core/host/install-types.test.ts rename to tests/unit/core/host/install/install-types.test.ts index 340da86a5..a4e55216f 100644 --- a/tests/unit/core/host/install-types.test.ts +++ b/tests/unit/core/host/install/install-types.test.ts @@ -20,7 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import { buildCagPlatformSuffix, buildPlatformSuffix } from '@/core/host/install-types.ts'; +import { buildCagPlatformSuffix, buildPlatformSuffix } from '@/core/host/install/install-types.ts'; describe('install-types', () => { describe('buildPlatformSuffix (sonar-secrets convention)', () => { diff --git a/tests/unit/core/host/sonarsource-releases.test.ts b/tests/unit/core/host/install/sonarsource-releases.test.ts similarity index 98% rename from tests/unit/core/host/sonarsource-releases.test.ts rename to tests/unit/core/host/install/sonarsource-releases.test.ts index a78f4d63e..3c774ff70 100644 --- a/tests/unit/core/host/sonarsource-releases.test.ts +++ b/tests/unit/core/host/install/sonarsource-releases.test.ts @@ -20,7 +20,7 @@ import { describe, expect, it } from 'bun:test'; -import { buildCagDownloadUrl, buildDownloadUrl } from '@/core/host/sonarsource-releases.ts'; +import { buildCagDownloadUrl, buildDownloadUrl } from '@/core/host/install/sonarsource-releases.ts'; describe('sonarsource-releases', () => { describe('buildDownloadUrl (sonar-secrets convention)', () => { diff --git a/tests/unit/core/telemetry/identity.test.ts b/tests/unit/core/telemetry/identity.test.ts index 3326d0094..90799e0b6 100644 --- a/tests/unit/core/telemetry/identity.test.ts +++ b/tests/unit/core/telemetry/identity.test.ts @@ -35,7 +35,6 @@ import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import * as authResolver from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME, getTelemetryDir } from '@/core/config-constants.ts'; -import { resolveTelemetryIdentity } from '@/core/host/identity-fetch.ts'; import type { AuthConnection } from '@/core/state/state.ts'; import { identityFromConnection, @@ -43,6 +42,7 @@ import { resolveCommandTelemetryIdentity, resolveStoreEventTelemetryIdentitySafely, } from '@/core/telemetry/identity.ts'; +import { resolveTelemetryIdentity } from '@/core/telemetry/identity-fetch.ts'; import { mockIdentityGetSafe } from './identity-api-mock.ts'; diff --git a/tests/unit/core/telemetry/telemetry-events.test.ts b/tests/unit/core/telemetry/telemetry-events.test.ts index 48085a5b1..dbfc22b62 100644 --- a/tests/unit/core/telemetry/telemetry-events.test.ts +++ b/tests/unit/core/telemetry/telemetry-events.test.ts @@ -35,8 +35,8 @@ import { scanAndEmitSecrets } from '@/commands/analyze/secrets.ts'; import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME, TELEMETRY_ENDPOINT } from '@/core/config-constants.ts'; import * as networkConfig from '@/core/host/connectivity/network-config.ts'; +import { DISTRIBUTION } from '@/core/host/distribution.ts'; import * as agentDetector from '@/core/host/environment/agent-detector.ts'; -import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; import type { SpawnResult } from '@/core/process/process.ts'; import * as fetchGuardedModule from '@/core/server/fetch-guarded.ts'; import type { diff --git a/tests/unit/core/telemetry/telemetry.test.ts b/tests/unit/core/telemetry/telemetry.test.ts index bb7cebad5..d6320c293 100644 --- a/tests/unit/core/telemetry/telemetry.test.ts +++ b/tests/unit/core/telemetry/telemetry.test.ts @@ -34,9 +34,8 @@ import type { Command } from 'commander'; import * as authResolver from '@/core/auth/auth-resolver.ts'; import { ENV_ORG, ENV_SERVER, ENV_TOKEN } from '@/core/auth/auth-resolver.ts'; import { ENV_DO_NOT_TRACK, ENV_SONAR_USER_HOME } from '@/core/config-constants.ts'; +import { DISTRIBUTION } from '@/core/host/distribution.ts'; import * as agentDetector from '@/core/host/environment/agent-detector.ts'; -import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; -import { resolveTelemetryIdentity } from '@/core/host/identity-fetch.ts'; import type { StoredAnalysisCompletedEvent } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateManager from '@/core/state/state-manager.ts'; @@ -47,6 +46,7 @@ import { storeEvent, TELEMETRY_FLUSH_MODE_ENV, } from '@/core/telemetry'; +import { resolveTelemetryIdentity } from '@/core/telemetry/identity-fetch.ts'; import * as userModule from '@/core/telemetry/user.ts'; import * as ui from '@/core/ui'; diff --git a/tests/unit/core/update/binary-refresh.test.ts b/tests/unit/core/update/binary-refresh.test.ts index 196d05b08..890494b93 100644 --- a/tests/unit/core/update/binary-refresh.test.ts +++ b/tests/unit/core/update/binary-refresh.test.ts @@ -20,9 +20,9 @@ import { afterEach, beforeEach, describe, expect, it, Mock, spyOn } from 'bun:test'; +import { SCA_SCANNER_BINARY_NAME } from '@/core/host/install/install-types.ts'; import * as scaScannerInstall from '@/core/host/install/sca-scanner.ts'; import * as secretsInstall from '@/core/host/install/secrets.ts'; -import { SCA_SCANNER_BINARY_NAME } from '@/core/host/install-types.ts'; import type { CliState } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; diff --git a/tests/unit/core/update/telemetry-migration.test.ts b/tests/unit/core/update/telemetry-migration.test.ts index 1a738bf1e..e9f07f250 100644 --- a/tests/unit/core/update/telemetry-migration.test.ts +++ b/tests/unit/core/update/telemetry-migration.test.ts @@ -26,7 +26,7 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, Mock, spyOn } from 'bun:test'; import * as configConstants from '@/core/config-constants.ts'; -import { DISTRIBUTION } from '@/core/host/environment/distribution.ts'; +import { DISTRIBUTION } from '@/core/host/distribution.ts'; import type { CliState, StoredCommandExecutedEvent } from '@/core/state/state.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; From 8abbdfb03e78f64760cee029497f6bf67a94ca9f Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Thu, 30 Jul 2026 16:32:43 +0200 Subject: [PATCH 4/4] fix --- src/core/telemetry/project-uuid.ts | 2 +- tests/unit/commands/analyze/secrets-install.test.ts | 2 +- tests/unit/core/telemetry/project-uuid.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/telemetry/project-uuid.ts b/src/core/telemetry/project-uuid.ts index 9e352a537..2bb9e2d13 100644 --- a/src/core/telemetry/project-uuid.ts +++ b/src/core/telemetry/project-uuid.ts @@ -26,7 +26,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { SonarQubeClient } from '@/core/server/client.ts'; import { getTelemetryDir } from '../config-constants.ts'; diff --git a/tests/unit/commands/analyze/secrets-install.test.ts b/tests/unit/commands/analyze/secrets-install.test.ts index 94b883cff..55cfb2ae9 100644 --- a/tests/unit/commands/analyze/secrets-install.test.ts +++ b/tests/unit/commands/analyze/secrets-install.test.ts @@ -39,7 +39,7 @@ import { clearMockUiCalls, getMockUiCalls, setMockUi } from '@/core/ui'; // spyOn can patch individual exports per-test and restore them in afterEach — // without permanently replacing any function for other test files in this process. const releases = await import('@/core/host/install/sonarsource-releases.ts'); -void mock.module('@/core/host/sonarsource-releases.ts', () => ({ +void mock.module('@/core/host/install/sonarsource-releases.ts', () => ({ ...releases, })); diff --git a/tests/unit/core/telemetry/project-uuid.test.ts b/tests/unit/core/telemetry/project-uuid.test.ts index 2561f6052..3037bb096 100644 --- a/tests/unit/core/telemetry/project-uuid.test.ts +++ b/tests/unit/core/telemetry/project-uuid.test.ts @@ -30,8 +30,8 @@ import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test'; +import type { ResolvedAuth } from '@/core/auth/auth-resolver.ts'; import { ENV_SONAR_USER_HOME, getTelemetryDir } from '@/core/config-constants.ts'; -import type { ResolvedAuth } from '@/core/host/auth-resolver.ts'; import { getDefaultState } from '@/core/state/state.ts'; import * as stateRepository from '@/core/state/state-repository.ts'; import {