/** * Tool Detection Strategy Pattern * * Provides ecosystem-specific logic for detecting tool availability, * generating install instructions, and determining how to run tools. * * Each ecosystem (Node, Python, Go, Rust) has different conventions for: * - Where dev tools are declared (package.json vs pyproject.toml vs go.mod vs Cargo.toml) * - How tools are installed (npm vs pip vs go install vs cargo/rustup) * - Where scripts/commands are defined (npm scripts vs Makefile vs cargo aliases) */ import type { ConfigFile, PackageCommand } from '../types/layer-types'; /** * Supported package ecosystems */ export type Ecosystem = 'node' | 'python' | 'go' | 'rust'; /** * How a tool is made available in the ecosystem */ export type ToolSource = 'dependency' | 'toolchain' | 'binary' | 'dev-group' | 'unknown'; /** * Result of checking if a tool is available */ export interface ToolAvailability { /** Whether the tool package/binary is available */ installed: boolean; /** Whether configuration exists for this tool */ configured: boolean; /** Whether there's a command/script to run this tool */ hasRunCommand: boolean; /** How the tool was detected */ source: ToolSource; /** Version if known */ version?: string; /** Additional details about detection */ details?: string; } /** * Unified package data passed to detection strategies */ export interface PackageData { /** Package name */ name: string; /** Package ecosystem */ ecosystem: Ecosystem; /** Path to the package root */ path: string; /** Production dependencies */ dependencies: Record; /** Development dependencies */ devDependencies: Record; /** All dependency groups (Python optional-dependencies, etc.) */ dependencyGroups?: Record>; /** Available commands/scripts */ commands: PackageCommand[]; /** Detected package manager */ packageManager: string; /** Raw manifest content for ecosystem-specific parsing */ manifestContent?: unknown; /** Path to tools.go file (Go only) */ toolsGoPath?: string; /** Content of tools.go if it exists (Go only) */ toolsGoContent?: string; } /** * Install instruction with ecosystem-appropriate commands */ export interface InstallInstruction { /** Primary install command */ command: string; /** Alternative commands for different package managers */ alternatives?: Record; /** Additional setup steps if needed */ additionalSteps?: string[]; /** Notes about the installation */ notes?: string; } /** * Strategy interface for ecosystem-specific tool detection */ export interface ToolDetectionStrategy { /** Which ecosystem this strategy handles */ ecosystem: Ecosystem; /** Human-readable name for this ecosystem */ displayName: string; /** * Check if a tool is available for use in this package */ detectToolAvailability(toolId: string, packageData: PackageData, configFiles: Record): ToolAvailability; /** * Generate ecosystem-appropriate install instructions */ getInstallInstructions(toolId: string, packageManager?: string): InstallInstruction; /** * Get the default command to run this tool * Used when no explicit script is defined */ getDefaultCommand(toolId: string): string; /** * Check if this tool is part of the language toolchain * (e.g., gofmt for Go, rustfmt for Rust) */ isToolchainTool(toolId: string): boolean; /** * Get the canonical tool ID for a given package name * Handles aliases (e.g., 'ruff' package provides 'ruff' and 'ruff-format') */ getToolIdFromPackage(packageName: string): string[]; } /** * Metadata for a tool within an ecosystem */ export interface ToolMetadata { /** Tool identifier */ toolId: string; /** Human-readable name */ displayName: string; /** Package name to install (may differ from toolId) */ packageName: string; /** For Go: full module path */ goModule?: string; /** For Rust: whether it's a rustup component */ isRustupComponent?: boolean; /** Config file patterns to look for */ configPatterns: string[]; /** Alternative config locations (e.g., pyproject.toml section) */ configAlternatives?: string[]; /** Default command to run the tool */ defaultCommand: string; /** Minimum recommended version */ minVersion?: string; } /** * Registry mapping tool IDs to their metadata per ecosystem */ export type ToolRegistry = Record>; //# sourceMappingURL=tool-detection.d.ts.map