Files
cline-multi-mirror/src/core/controller/commands/explainWithCline.ts
T
Sarah Fortuneandellipsis-dev[bot] b44d3c8793 Add fix, explain, and improve commands to the ProtoBus (#5574)
* Add fix, explain, and improve commands to Cline

- Rename AddToClineRequest to CommandContext for reusability
- Implement fixWithCline, explainWithCline, and improveWithCline commands
- Extract common command utilities to commandUtils.ts
- Move file mention logic to mentions module
- Update command registration and handlers in extension.ts

* Update src/core/controller/commands/addToCline.ts

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

* Update src/extension.ts

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

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-08-15 02:21:40 +01:00

24 lines
999 B
TypeScript

import { Controller } from "../index"
import { CommandContext, Empty } from "@/shared/proto/index.cline"
import { telemetryService } from "@/services/posthog/PostHogClientProvider"
import { HostProvider } from "@/hosts/host-provider"
import { ShowMessageType } from "@/shared/proto/index.host"
import { getFileMentionFromPath } from "@/core/mentions"
export async function explainWithCline(controller: Controller, request: CommandContext): Promise<Empty> {
if (!request.selectedText || !request.selectedText.trim()) {
HostProvider.window.showMessage({
type: ShowMessageType.INFORMATION,
message: "Please select some code to explain.",
})
return {}
}
const fileMention = await getFileMentionFromPath(request.filePath || "")
const prompt = `Explain the following code from ${fileMention}:
\`\`\`${request.language}\n${request.selectedText}\n\`\`\``
await controller.initTask(prompt)
telemetryService.captureButtonClick("codeAction_explainCode", controller.task?.ulid)
return {}
}