All files / agent/src/utils sdkScanner.ts

85.3% Statements 482/565
74.21% Branches 95/128
100% Functions 28/28
85.3% Lines 482/565

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 5661x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 353x 353x 353x 353x 353x 353x 353x 353x 353x 353x 353x 330x 330x 330x 1x 1x 1x 1x 1x 329x 329x 353x 1x 1x 1x 1x 1x 1x 14x 14x 14x 1x 1x 1x 1x 1x 1x 3x 3x 3x 1x 1x 1x 1x 1x 14x 14x 14x 14x 2x 2x 2x 14x 2x 2x 2x 2x 2x 14x 1x 1x 2x 14x 14x 14x 14x 1x 14x 14x 14x               1x 14x 14x 14x             1x 14x 14x 14x             1x 14x 14x 13x 13x 14x 1x 1x 14x 1x 14x 14x 14x 14x 14x 14x 1x 1x 3x 3x 1x 1x 1x 1x 1x 14x 14x 14x 11x 11x 11x 11x 11x 11x 9x 14x 14x 2x 2x 2x 5x 5x 5x 2x 2x 2x 2x 4x 4x 2x 11x 11x 11x 11x 14x 14x 14x 14x 1x 14x 14x 14x           14x 14x 14x 14x 1x 14x 14x 14x             1x 14x 14x 14x 2x 2x 2x 14x 2x 2x 14x 14x 14x 14x 1x 14x 14x 14x             1x 14x 14x 14x 2x 2x 14x 2x 2x 2x 1x 14x 14x 14x 1x 1x 14x 1x 14x 14x 14x 14x 14x 1x 14x 14x 14x 1x 1x 1x 14x 1x 14x 14x 14x 14x 1x 14x 14x 14x 1x 1x 1x 14x 1x 1x 14x 14x 14x 14x 1x 14x 14x 14x             14x 14x 14x 14x 1x 14x 14x 14x             1x 14x 14x 14x 1x 1x 1x 14x 1x 1x 14x 14x 14x 14x 1x 14x 14x 14x             1x 14x 14x 14x 14x             1x 14x 14x 14x               1x 14x 14x 14x             1x 14x 14x 14x             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 308x 308x 308x 22x 22x 308x     308x 14x 14x 14x 14x 14x 14x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 133x 12x 133x 133x 133x 12x 12x 133x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 1x 7x 7x 7x 2x 2x 1x 1x 2x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 2x 2x 2x 2x 2x 1x 1x 2x     2x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x  
/**
 * SDK & Toolchain Scanner
 *
 * Detects installed SDKs, compilers, and developer toolchains on the host
 * machine.  Results feed into capability tags so the server can match jobs
 * to agents that have the right tools.
 *
 * Design notes:
 *  - Every detection is wrapped in try/catch so a missing tool never crashes
 *    the scanner.
 *  - Commands have a 5-second timeout to avoid blocking on hung processes.
 *  - Works on macOS, Linux, and Windows (adjusts commands per platform).
 *
 * Requirements: MVP.4.1.2 (enhanced)
 */
 
import { execSync } from 'child_process';
import os from 'os';
import { createLogger } from './logger.js';
 
const logger = createLogger('sdkScanner');
 
/** Timeout for each detection command in milliseconds. */
const CMD_TIMEOUT_MS = 5_000;
 
// ---------------------------------------------------------------------------
// Public types
// ---------------------------------------------------------------------------
 
/** Basic information about an installed SDK / tool. */
export interface SDKInfo {
  name: string;
  version: string;
  path?: string;
  metadata?: Record<string, string>;
}
 
/** Aggregated result of scanning all known SDKs on the host. */
export interface SDKScanResult {
  // Development toolchains
  java?: SDKInfo & { javaHome: string };
  kotlin?: SDKInfo;
  gradle?: SDKInfo;
  maven?: SDKInfo;
 
  // Mobile
  xcode?: SDKInfo & { xcodeSelectPath: string; sdks: string[] };
  androidSdk?: SDKInfo & { androidHome: string; apiLevels: number[]; buildToolsVersions: string[] };
  flutter?: SDKInfo & { dartVersion: string };
  cocoapods?: SDKInfo;
 
  // Web / Backend
  node?: SDKInfo & { npmVersion?: string };
  yarn?: SDKInfo;
  pnpm?: SDKInfo;
  python?: SDKInfo & { pipVersion?: string };
  go?: SDKInfo & { gopath?: string };
  rust?: SDKInfo & { cargoVersion?: string };
  ruby?: SDKInfo & { bundlerVersion?: string };
  dotnet?: SDKInfo;
 
  // DevOps
  docker?: SDKInfo & { composeVersion?: string };
  terraform?: SDKInfo;
  kubectl?: SDKInfo;
 
  // General
  git?: SDKInfo;
  cmake?: SDKInfo;
  make?: SDKInfo;
}
 
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
 
/**
 * Run a shell command synchronously, returning trimmed stdout or `null` on
 * failure.  Stderr is included in the output because some tools (notably
 * `java -version`) print to stderr.
 */
export function runCmd(cmd: string, timeoutMs: number = CMD_TIMEOUT_MS): string | null {
  try {
    const isWindows = os.platform() === 'win32';
    const result = execSync(cmd, {
      timeout: timeoutMs,
      stdio: ['pipe', 'pipe', 'pipe'],
      encoding: 'utf-8',
      shell: isWindows ? 'cmd.exe' : '/bin/sh',
      env: { ...process.env },
    });
    return result?.trim() ?? null;
  } catch (err: unknown) {
    // Some commands write version info to stderr.  If the process exited
    // with code 0 but threw because of the stderr capture, try stderr.
    if (err && typeof err === 'object' && 'stderr' in err) {
      const stderr = (err as { stderr?: string }).stderr;
      if (stderr && typeof stderr === 'string' && stderr.trim().length > 0) {
        return stderr.trim();
      }
    }
    return null;
  }
}
 
/**
 * Extract major version number from a semver-ish string.
 * e.g. "17.0.9" -> 17, "1.8.0_392" -> 8 (Java-specific handled externally).
 */
export function majorVersion(version: string): number {
  const match = version.match(/^(\d+)/);
  return match ? parseInt(match[1], 10) : 0;
}
 
/**
 * Extract major.minor from a version string.
 * e.g. "15.4.1" -> "15.4"
 */
export function majorMinor(version: string): string {
  const match = version.match(/^(\d+\.\d+)/);
  return match ? match[1] : version;
}
 
// ---------------------------------------------------------------------------
// Individual SDK detectors
// ---------------------------------------------------------------------------
 
function detectJava(): SDKScanResult['java'] {
  // `java -version` prints to stderr
  const raw = runCmd('java -version 2>&1');
  if (!raw) return undefined;
 
  // Matches: openjdk version "17.0.9"  or  java version "1.8.0_392"
  const versionMatch = raw.match(/(?:openjdk|java) version "([^"]+)"/i);
  if (!versionMatch) return undefined;
 
  let version = versionMatch[1];
 
  // Normalise legacy Java 1.x naming: "1.8.0_392" -> "8.0.392"
  const legacyMatch = version.match(/^1\.(\d+)\.0(?:_(\d+))?/);
  if (legacyMatch) {
    version = legacyMatch[2] ? `${legacyMatch[1]}.0.${legacyMatch[2]}` : `${legacyMatch[1]}.0`;
  }
 
  const javaHome = process.env.JAVA_HOME ?? runCmd('echo $JAVA_HOME') ?? '';
 
  return { name: 'java', version, javaHome };
}
 
function detectKotlin(): SDKScanResult['kotlin'] {
  const raw = runCmd('kotlin -version 2>&1');
  if (!raw) return undefined;

  // "Kotlin version 2.0.0-release-341 (JRE ...)"  or  "Kotlin version 1.9.22 ..."
  const match = raw.match(/Kotlin version ([\d.]+)/i);
  if (!match) return undefined;

  return { name: 'kotlin', version: match[1] };
}
 
function detectGradle(): SDKScanResult['gradle'] {
  const raw = runCmd('gradle --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/Gradle ([\d.]+)/);
  if (!match) return undefined;

  return { name: 'gradle', version: match[1] };
}
 
function detectMaven(): SDKScanResult['maven'] {
  const raw = runCmd('mvn --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/Apache Maven ([\d.]+)/);
  if (!match) return undefined;

  return { name: 'maven', version: match[1] };
}
 
function detectXcode(): SDKScanResult['xcode'] {
  if (os.platform() !== 'darwin') return undefined;
 
  const raw = runCmd('xcodebuild -version 2>&1');
  if (!raw) return undefined;
 
  const versionMatch = raw.match(/Xcode ([\d.]+)/);
  if (!versionMatch) return undefined;
 
  const xcodeSelectPath = runCmd('xcode-select -p 2>&1') ?? '';
 
  // Gather available SDKs
  const sdksRaw = runCmd('xcodebuild -showsdks 2>&1');
  const sdks: string[] = [];
  if (sdksRaw) {
    const sdkMatches = sdksRaw.matchAll(/-sdk\s+(\S+)/g);
    for (const m of sdkMatches) {
      sdks.push(m[1]);
    }
  }
 
  return { name: 'xcode', version: versionMatch[1], xcodeSelectPath, sdks };
}
 
function detectAndroidSdk(): SDKScanResult['androidSdk'] {
  const androidHome = process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? '';
  if (!androidHome) return undefined;
 
  // Try to get installed API levels and build-tools versions
  const apiLevels: number[] = [];
  const buildToolsVersions: string[] = [];
 
  const listRaw = runCmd(`"${androidHome}/cmdline-tools/latest/bin/sdkmanager" --list 2>&1`)
    ?? runCmd(`"${androidHome}/tools/bin/sdkmanager" --list 2>&1`);
 
  if (listRaw) {
    // Match "platforms;android-34"
    const platformMatches = listRaw.matchAll(/platforms;android-(\d+)/g);
    for (const m of platformMatches) {
      const level = parseInt(m[1], 10);
      if (!apiLevels.includes(level)) apiLevels.push(level);
    }
 
    // Match "build-tools;34.0.0"
    const btMatches = listRaw.matchAll(/build-tools;([\d.]+)/g);
    for (const m of btMatches) {
      if (!buildToolsVersions.includes(m[1])) buildToolsVersions.push(m[1]);
    }
  }
 
  apiLevels.sort((a, b) => b - a);
  buildToolsVersions.sort().reverse();
 
  const version = apiLevels.length > 0 ? String(apiLevels[0]) : 'unknown';
 
  return { name: 'android-sdk', version, androidHome, apiLevels, buildToolsVersions };
}
 
function detectFlutter(): SDKScanResult['flutter'] {
  const raw = runCmd('flutter --version 2>&1');
  if (!raw) return undefined;

  const versionMatch = raw.match(/Flutter ([\d.]+)/);
  if (!versionMatch) return undefined;

  const dartMatch = raw.match(/Dart ([\d.]+)/);
  const dartVersion = dartMatch ? dartMatch[1] : 'unknown';
 
  return { name: 'flutter', version: versionMatch[1], dartVersion };
}
 
function detectCocoapods(): SDKScanResult['cocoapods'] {
  const raw = runCmd('pod --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/([\d.]+)/);
  if (!match) return undefined;

  return { name: 'cocoapods', version: match[1] };
}
 
function detectNode(): SDKScanResult['node'] {
  const raw = runCmd('node --version 2>&1');
  if (!raw) return undefined;
 
  // "v20.11.0" -> "20.11.0"
  const match = raw.match(/v?([\d.]+)/);
  if (!match) return undefined;
 
  const npmRaw = runCmd('npm --version 2>&1');
  const npmMatch = npmRaw?.match(/([\d.]+)/);
 
  return { name: 'node', version: match[1], npmVersion: npmMatch?.[1] };
}
 
function detectYarn(): SDKScanResult['yarn'] {
  const raw = runCmd('yarn --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/([\d.]+)/);
  if (!match) return undefined;

  return { name: 'yarn', version: match[1] };
}
 
function detectPnpm(): SDKScanResult['pnpm'] {
  const raw = runCmd('pnpm --version 2>&1');
  if (!raw) return undefined;
 
  const match = raw.match(/([\d.]+)/);
  if (!match) return undefined;
 
  return { name: 'pnpm', version: match[1] };
}
 
function detectPython(): SDKScanResult['python'] {
  const raw = runCmd('python3 --version 2>&1') ?? runCmd('python --version 2>&1');
  if (!raw) return undefined;
 
  const match = raw.match(/Python ([\d.]+)/i);
  if (!match) return undefined;
 
  const pipRaw = runCmd('pip3 --version 2>&1') ?? runCmd('pip --version 2>&1');
  const pipMatch = pipRaw?.match(/pip ([\d.]+)/);
 
  return { name: 'python', version: match[1], pipVersion: pipMatch?.[1] };
}
 
function detectGo(): SDKScanResult['go'] {
  const raw = runCmd('go version 2>&1');
  if (!raw) return undefined;
 
  // "go version go1.22.0 darwin/arm64"
  const match = raw.match(/go([\d.]+)/);
  if (!match) return undefined;
 
  const gopath = process.env.GOPATH ?? runCmd('go env GOPATH 2>&1') ?? undefined;
 
  return { name: 'go', version: match[1], gopath };
}
 
function detectRust(): SDKScanResult['rust'] {
  const raw = runCmd('rustc --version 2>&1');
  if (!raw) return undefined;
 
  // "rustc 1.75.0 (82e1608df 2023-12-21)"
  const match = raw.match(/rustc ([\d.]+)/);
  if (!match) return undefined;
 
  const cargoRaw = runCmd('cargo --version 2>&1');
  const cargoMatch = cargoRaw?.match(/cargo ([\d.]+)/);
 
  return { name: 'rust', version: match[1], cargoVersion: cargoMatch?.[1] };
}
 
function detectRuby(): SDKScanResult['ruby'] {
  const raw = runCmd('ruby --version 2>&1');
  if (!raw) return undefined;

  // "ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]"
  const match = raw.match(/ruby ([\d.]+)/);
  if (!match) return undefined;

  const bundlerRaw = runCmd('bundler --version 2>&1');
  const bundlerMatch = bundlerRaw?.match(/Bundler version ([\d.]+)/);
 
  return { name: 'ruby', version: match[1], bundlerVersion: bundlerMatch?.[1] };
}
 
function detectDotnet(): SDKScanResult['dotnet'] {
  const raw = runCmd('dotnet --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/([\d.]+)/);
  if (!match) return undefined;

  return { name: 'dotnet', version: match[1] };
}
 
function detectDocker(): SDKScanResult['docker'] {
  const raw = runCmd('docker --version 2>&1');
  if (!raw) return undefined;
 
  // "Docker version 24.0.7, build afdd53b"
  const match = raw.match(/Docker version ([\d.]+)/i);
  if (!match) return undefined;
 
  const composeRaw = runCmd('docker compose version 2>&1');
  const composeMatch = composeRaw?.match(/v?([\d.]+)/);
 
  return { name: 'docker', version: match[1], composeVersion: composeMatch?.[1] };
}
 
function detectTerraform(): SDKScanResult['terraform'] {
  const raw = runCmd('terraform --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/Terraform v?([\d.]+)/i);
  if (!match) return undefined;

  return { name: 'terraform', version: match[1] };
}
 
function detectKubectl(): SDKScanResult['kubectl'] {
  const raw = runCmd('kubectl version --client --short 2>&1')
    ?? runCmd('kubectl version --client 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/v?([\d.]+)/);
  if (!match) return undefined;

  return { name: 'kubectl', version: match[1] };
}
 
function detectGit(): SDKScanResult['git'] {
  const raw = runCmd('git --version 2>&1');
  if (!raw) return undefined;

  // "git version 2.43.0"
  const match = raw.match(/git version ([\d.]+)/);
  if (!match) return undefined;

  return { name: 'git', version: match[1] };
}
 
function detectCmake(): SDKScanResult['cmake'] {
  const raw = runCmd('cmake --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/cmake version ([\d.]+)/i);
  if (!match) return undefined;

  return { name: 'cmake', version: match[1] };
}
 
function detectMake(): SDKScanResult['make'] {
  const raw = runCmd('make --version 2>&1');
  if (!raw) return undefined;

  const match = raw.match(/(?:GNU Make|Make) ([\d.]+)/i);
  if (!match) return undefined;

  return { name: 'make', version: match[1] };
}
 
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
 
/**
 * Scan the host for all known SDKs and toolchains.
 *
 * Each detector is independent and wrapped in try/catch so a failure in one
 * tool never blocks detection of the others.
 */
export async function scanInstalledSDKs(): Promise<SDKScanResult> {
  logger.info('Scanning installed SDKs and toolchains...');
 
  const result: SDKScanResult = {};
 
  // Run detectors sequentially to avoid spawning too many child processes at
  // once on resource-constrained machines. Each has its own timeout guard.
  const detectors: Array<[keyof SDKScanResult, () => SDKScanResult[keyof SDKScanResult]]> = [
    ['java', detectJava],
    ['kotlin', detectKotlin],
    ['gradle', detectGradle],
    ['maven', detectMaven],
    ['xcode', detectXcode],
    ['androidSdk', detectAndroidSdk],
    ['flutter', detectFlutter],
    ['cocoapods', detectCocoapods],
    ['node', detectNode],
    ['yarn', detectYarn],
    ['pnpm', detectPnpm],
    ['python', detectPython],
    ['go', detectGo],
    ['rust', detectRust],
    ['ruby', detectRuby],
    ['dotnet', detectDotnet],
    ['docker', detectDocker],
    ['terraform', detectTerraform],
    ['kubectl', detectKubectl],
    ['git', detectGit],
    ['cmake', detectCmake],
    ['make', detectMake],
  ];
 
  for (const [key, detector] of detectors) {
    try {
      const info = detector();
      if (info) {
        (result as Record<string, unknown>)[key] = info;
      }
    } catch (err) {
      logger.warn(`SDK detector for '${key}' threw unexpectedly:`, err);
    }
  }
 
  const detected = Object.keys(result);
  logger.info(`Detected ${detected.length} SDK(s): ${detected.join(', ')}`);
 
  return result;
}
 
/**
 * Generate capability tags from an SDK scan result.
 *
 * Tag conventions:
 *  - Generic tag without version: `java`, `docker`, `xcode`
 *  - Major-version tag: `java-17`, `node-20`, `go-1`
 *  - For Xcode, major.minor: `xcode-15.4`
 *  - For Android SDK, highest API level: `android-sdk-34`
 *  - Special: `docker` (Docker available), `dind` (Docker-in-Docker capable)
 */
export function generateTagsFromSDKs(sdks: SDKScanResult): string[] {
  const tags: string[] = [];
 
  const addVersionedTag = (info: SDKInfo | undefined, tagName?: string): void => {
    if (!info) return;
    const name = tagName ?? info.name;
    tags.push(name);
    const major = majorVersion(info.version);
    if (major > 0) {
      tags.push(`${name}-${major}`);
    }
  };
 
  // Development toolchains
  addVersionedTag(sdks.java);
  addVersionedTag(sdks.kotlin);
  addVersionedTag(sdks.gradle);
  addVersionedTag(sdks.maven);
 
  // Mobile - Xcode uses major.minor
  if (sdks.xcode) {
    tags.push('xcode');
    tags.push(`xcode-${majorMinor(sdks.xcode.version)}`);
  }
 
  // Android SDK - tag with highest API level
  if (sdks.androidSdk) {
    tags.push('android-sdk');
    if (sdks.androidSdk.apiLevels.length > 0) {
      tags.push(`android-sdk-${sdks.androidSdk.apiLevels[0]}`);
    }
  }
 
  addVersionedTag(sdks.flutter);
  addVersionedTag(sdks.cocoapods);
 
  // Web / Backend
  addVersionedTag(sdks.node);
  addVersionedTag(sdks.yarn);
  addVersionedTag(sdks.pnpm);
  addVersionedTag(sdks.python);
  addVersionedTag(sdks.go);
  addVersionedTag(sdks.rust);
  addVersionedTag(sdks.ruby);
  addVersionedTag(sdks.dotnet);
 
  // DevOps
  if (sdks.docker) {
    tags.push('docker');
    // Check if Docker-in-Docker is plausible (Docker socket exists)
    try {
      const socketCheck = runCmd('ls /var/run/docker.sock 2>&1');
      if (socketCheck && !socketCheck.includes('No such file')) {
        tags.push('dind');
      }
    } catch {
      // ignore
    }
  }
 
  addVersionedTag(sdks.terraform);
  addVersionedTag(sdks.kubectl);
 
  // General
  addVersionedTag(sdks.git);
  addVersionedTag(sdks.cmake);
  addVersionedTag(sdks.make);
 
  // De-duplicate (preserving order)
  return [...new Set(tags)];
}