A command for passing a prompt to the chat

Feature request for product/service

Chat

Describe the request

I’m developing an extension (React Compiler Marker ✨ - Visual Studio Marketplace) and I would like to send text to the chat. For VSCode I do:

vscode.commands.executeCommand('workbench.action.chat.open', prompt);

This command is not supported in Cursor and there are no alternatives, could you add support for it? Or at least allow cursor.startComposerPrompt command to take a prompt argument.

Anyone from the Cursor team can look into it?

Yeah this would be great. Basically the “Add to chat” command but with the option to pass a custom prompt/wrapper.

1 Like

Btw - I found a workaround by opening the chat using composer.newAgentChat and using clipboard manipulation to paste the text

Example:

import * as vscode from "vscode";
import { PROMPT_TEMPLATE } from "./prompt-template";

async function sendTextToChat(prompt: string): Promise<void> {
  // write prompt to clipboard
  await vscode.env.clipboard.writeText(prompt);

  // open cursor chat
  await vscode.commands.executeCommand("composer.newAgentChat");

  // timeout to wait for UI
  await new Promise((resolve) => setTimeout(resolve, 100));]

  // paste clipboard to chat
  await vscode.commands.executeCommand("editor.action.clipboardPasteAction");
}

// Usage example:
export function activate(context: vscode.ExtensionContext) {
  const cmd = vscode.commands.registerCommand(
    "your-extension.sendToChat",
    async () => {
      const editor = vscode.window.activeTextEditor;
      const selectedText = editor.document.getText(editor.selection);
      const prompt = PROMPT_TEMPLATE.replace("{{INPUT_TEXT}}", text);
      await sendTextToChat(prompt);
    }
  );
  context.subscriptions.push(cmd);
}

this is just a workaround - a native command that accepts a prompt argument would be cleaner imo. I built a Cursor Rule Extension yesterday that uses this implementation and it seems to be working so far.

here is the code if you wanna see more details