package cc.unitmesh.agent.runconfig import kotlinx.serialization.Serializable /** * RunConfig - Project run configuration discovered by analyzing the codebase. * * Similar to IDE run configurations (IntelliJ, VS Code), this represents * executable commands like: * - `npm start` / `npm run dev` * - `./gradlew run` / `./gradlew bootRun` * - `python main.py` * - `cargo run` * - `go run main.go` */ @Serializable data class RunConfig( /** Unique identifier */ val id: String, /** Display name shown in the menu */ val name: String, /** Type of run configuration */ val type: RunConfigType, /** The command to execute */ val command: String, /** Working directory (relative to project root) */ val workingDir: String = ".", /** Environment variables */ val env: Map = emptyMap(), /** Description of what this config does */ val description: String = "", /** Icon identifier for UI */ val icon: String? = null, /** Whether this is the default/primary run config */ val isDefault: Boolean = false, /** Whether this config is enabled */ val enabled: Boolean = true, /** Source of this config (auto-detected, user-defined, etc.) */ val source: RunConfigSource = RunConfigSource.AUTO_DETECTED ) /** * Type of run configuration */ @Serializable enum class RunConfigType { /** Start the application */ RUN, /** Run in development/watch mode */ DEV, /** Run tests */ TEST, /** Build the project */ BUILD, /** Lint/format code */ LINT, /** Deploy the project */ DEPLOY, /** Clean build artifacts */ CLEAN, /** Install dependencies */ INSTALL, /** Custom command */ CUSTOM } /** * Source of the run configuration */ @Serializable enum class RunConfigSource { /** Auto-detected from project files */ AUTO_DETECTED, /** Defined by user */ USER_DEFINED, /** Loaded from project config file */ PROJECT_CONFIG, /** Generated by AI analysis */ AI_GENERATED } /** * State of run config discovery/analysis */ @Serializable enum class RunConfigState { /** Not analyzed yet */ NOT_CONFIGURED, /** Currently analyzing project */ ANALYZING, /** Analysis complete, configs available */ CONFIGURED, /** Analysis failed */ ERROR } /** * Result of executing a run config */ @Serializable data class RunConfigResult( /** Whether execution started successfully */ val success: Boolean, /** Process ID if running in background */ val pid: Int? = null, /** Output message */ val message: String = "", /** Error message if failed */ val error: String? = null, /** Exit code if completed */ val exitCode: Int? = null ) /** * Storage format for persisting run configs in .xiuper/run-configs.json */ @Serializable data class RunConfigStorage( /** Version for format compatibility */ val version: Int = 1, /** Project path this config belongs to */ val projectPath: String, /** Detected project type */ val projectType: String? = null, /** List of run configurations */ val configs: List = emptyList(), /** ID of the default run config */ val defaultConfigId: String? = null, /** Last analysis timestamp */ val lastAnalyzedAt: Long? = null )