Files
cline-multi-mirror/src/utils/cli-detector.ts
T
b351a8b92b feat: add banner to install Cline for CLI and experimental subagents feature (#6782)
* feat: add banner to install Cline for CLI and experimental subagents feature

* Update snapshots

* Fix copy

* Style fixes

* A few small changes to cli detection, prompting, cleanup

* Prompting tweaks and npm command update

* Prompting, bug fix

* Prompt changes around command syntax

* Command parsing and flag substitution for easier subagent invocation

* Added terminal output slider setting for subagents

* Improved CLI subagent settings injection

* Added max_consecutive_mistakes setting and cli flag

* Terminal line limit added to enchanced terminal, prompting and settings tweaks

* feat: Add OpenTelemetry settings schema and state infrastructure (1/5) (#6826)

* feat: Add OpenTelemetry settings schema and state infrastructure (1/5)

- Add 16 OpenTelemetry configuration fields to Settings interface
- Add 17 OpenTelemetry fields to RemoteConfig schema
- Add state persistence helpers for OpenTelemetry settings
- Foundation for dynamic OpenTelemetry configuration

Part 1 of 5 in the telemetry settings refactor series.

* chore: add changeset for OpenTelemetry schema

* fix: Address PR review feedback for OpenTelemetry settings

- Remove | undefined from 8 OpenTelemetry fields with default values
- Add default values in state-helpers.ts for all non-optional fields
- Add OpenTelemetry field mappings to remote-config/utils.ts
- Add comprehensive test coverage for OpenTelemetry fields in schema.test.ts
- Update changeset terminology from 'Otel' to 'OpenTelemetry'

Addresses feedback from:
- sjf: Remote config transformation and test coverage
- celestial-vault: Type cleanup and default values
- Copilot: Terminology improvement

* Prompting changes

* Fixed system prompt empty sections issue, fixed rebase mistake

* Added telemetry for CLI subagent use in IDEs

* Platform aware banner, fixed settings layout issues

* Post rebase fixes & changes to accomodate new terminal UI

* Cline Icon SVG in ChatRow - WIP

* Fixed outputLine limit issue

* Fixed rebase merge conflict remnant

* Rebase fix

* Cleanup and changes to instructions for new CLI users

* Added CLI documentation link

* Small prompt adjustments

* One more bullet point

* Updated remaining npm install command

* Updated subagent command format for CLI release spec

* Added check to prevent subagents from getting  subagent prompt

* Added subagent slash command

* Apply suggestion from @ellipsis-dev[bot]

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Remove workdir

* Update src/core/prompts/system-prompt/variants/xs/overrides.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* removed logging

* Updated expected version output

* Removed checkCliInstallation check in getStateToPostToWebview

* removed more logging

* fix: force subagents to use terminal stuff

---------

Co-authored-by: Kevin Bond <kevin@cline.bot>
Co-authored-by: Daniel Steigman <35793213+NightTrek@users.noreply.github.com>
Co-authored-by: Andrei Eternal <206184+Garoth@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: canvrno <46584286+canvrno@users.noreply.github.com>
Co-authored-by: Arafatkatze <arafat.da.khan@gmail.com>
2025-10-15 22:10:08 -07:00

52 lines
1.7 KiB
TypeScript

import { exec } from "child_process"
import { promisify } from "util"
const execAsync = promisify(exec)
/**
* Parameters used to detect CLI subagent context
*/
interface CliSubagentDetectionParams {
yoloModeToggled: boolean
maxConsecutiveMistakes: number
isOneshot?: boolean
outputFormat?: string
}
/**
* Check if the Cline CLI tool is installed on the system
* @returns true if CLI is installed, false otherwise
*/
export async function isClineCliInstalled(): Promise<boolean> {
try {
// Try to get the version of the cline CLI tool
// This will fail if the tool is not installed
const { stdout } = await execAsync("cline version", {
timeout: 5000, // 5 second timeout
})
// If we get here, the CLI is installed
// We could also validate the version if needed
return stdout.includes("Cline CLI Version") || stdout.includes("Cline Core Version")
} catch (error) {
// Command failed, which likely means CLI is not installed
// or not in PATH
return false
}
}
/**
* Detect if the current Cline instance is running as a CLI subagent.
* CLI subagents are identified by specific parameter patterns set by the transformClineCommand function.
* TODO - For now we are relying on the maxConsecutiveMistakes value, which will only ever be "3"
* unless users pass in "-s max_consecutive_mistakes=6" via Cline CLI. Would like better detection.
* @param params The current task parameters to analyze
* @returns true if this appears to be a CLI subagent context
*/
export function isCliSubagentContext(params: CliSubagentDetectionParams): boolean {
const hasYoloMode = params.yoloModeToggled === true
const hasHighMistakeLimit = params.maxConsecutiveMistakes === 6
return hasYoloMode && hasHighMistakeLimit
}