Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ichim-david/8f0b269868eed8aa04c12b8945ca79d3 to your computer and use it in GitHub Desktop.
Save ichim-david/8f0b269868eed8aa04c12b8945ca79d3 to your computer and use it in GitHub Desktop.
Cursor extension to watch for trigger word in chat/composer/edit - and reply with something.

Auto-Continue Extension for VS Code & Cursor

Quick Install Instructions for Auto-Continue Extension

  1. Download the files from the gist (extension.ts, package.json, and README.md)

  2. Create a new VS Code extension project:

    npm init vscode-extension
    # Choose TypeScript when prompted
  3. Replace the files:

    • Replace the generated extension.ts with the one from the gist
    • Replace the generated package.json with the one from the gist
    • (Keep the README.md for reference)
  4. Install dependencies and build:

    npm install
    npm run compile
  5. Test in development mode:

    • Press F5 in VS Code to launch a new window with the extension
    • The extension will automatically detect AI pause messages and insert "continue"
  6. To install permanently:

    npm install -g vsce
    vsce package
    code --install-extension text-trigger-0.0.1.vsix

That's it! Now the extension will automatically help you continue AI conversations when they hit limitations.

A lightweight VS Code/Cursor extension that automatically helps you continue AI conversations when they hit limitations or pause.

Problem Statement

When working with AI coding assistants like Cursor, you may encounter common limitations:

  • Tool Call Limits: Messages like "I've reached my tool call limit of 25" or "I need to pause execution"
  • Token Limitations: When the AI needs to break up responses due to length constraints
  • Generation Pauses: When the AI stops mid-generation and needs a prompt to continue

These interruptions disrupt your workflow, requiring manual intervention to type "continue" or similar phrases.

Solution

This simple extension watches your editor content for specific trigger phrases (like error messages about tool call limits) and automatically inserts the text "continue" into your chat window, allowing the AI to resume operation without manual intervention.

Installation

  1. Clone this repository or create the files from scratch:

    git clone https://github.com/yourusername/cursor-continue-extension.git
    cd cursor-continue-extension
  2. Install dependencies:

    npm install
  3. Build the extension:

    npm run compile
  4. To test in development mode:

    • Press F5 in VS Code with this project open
    • This launches a new Extension Development Host window with the extension loaded
  5. To install for regular use:

    • Package the extension: vsce package
    • Install the generated .vsix file: code --install-extension text-trigger-0.0.1.vsix

Usage

Once installed, the extension automatically watches your editor content for trigger phrases.

Default Triggers

Trigger Text Response
"I've reached my tool call limit of 25" "continue"
"I need to pause execution" "continue"
"To proceed with the remaining" "continue"
"Would you like me to continue" "Yes, please continue"

How It Works

The extension:

  1. Polls the active editor content every 500ms
  2. Checks for any of the trigger phrases
  3. When detected, automatically replaces the trigger with the corresponding response
  4. The AI detects this as user input and continues its operation

Example Scenarios

Cursor Tool Call Limits

When Cursor outputs:

I've reached my tool call limit of 25. Would you like me to continue?

The extension will automatically replace this with:

continue

Allowing Cursor to immediately resume execution.

Long Generation Splits

When the AI says:

This is a complex task. To proceed with the remaining steps, please let me know.

The extension will automatically insert "continue", prompting the AI to continue with the next part of the response.

Customization

You can easily add your own triggers by modifying the triggerResponses object in extension.ts:

const triggerResponses: { [key: string]: string } = {
    "I've reached my tool call limit of 25": "continue",
    "I need to pause execution": "continue",
    "To proceed with the remaining": "continue",
    "Would you like me to continue": "Yes, please continue",
    // Add your custom triggers here
    "Your custom trigger phrase": "Your custom response"
};

Configuration

This extension is intentionally minimal with no external configuration. Customize by directly editing the source code.

Limitations

  • The polling approach (checking every 500ms) is simple but may miss very fast interactions
  • Only works in the active editor window
  • May not work with all AI interfaces depending on how they handle text input

License

MIT

Contributing

Pull requests welcome! This is an intentionally minimal tool that solves a specific pain point.


Note: This extension is not officially affiliated with Cursor, Anthropic, or any other AI assistant provider.

// This is a minimal VS Code extension that watches for trigger text and inserts predefined text
// File: extension.ts
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
console.log('Text Trigger extension is now active');
// Store the last known text to detect changes
let lastText = '';
// Define your trigger text and response
const triggerResponses: { [key: string]: string } = {
'!hello': 'Hello there! How can I help you today?',
'!template': '```typescript\nfunction example() {\n console.log("This is a template");\n}\n```',
'!date': new Date().toLocaleDateString()
};
// Create a function that checks the editor content
function checkForTriggers() {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
const document = editor.document;
const text = document.getText();
// Only process if text has changed
if (text === lastText) return;
lastText = text;
// Check for each trigger
for (const trigger in triggerResponses) {
if (text.includes(trigger)) {
// Get cursor position
const position = editor.selection.active;
// Replace the trigger with the response
editor.edit(editBuilder => {
// Find the trigger position
const triggerPos = text.lastIndexOf(trigger);
const startPos = document.positionAt(triggerPos);
const endPos = document.positionAt(triggerPos + trigger.length);
// Replace the trigger with the response
editBuilder.replace(new vscode.Range(startPos, endPos), triggerResponses[trigger]);
});
// Only handle one trigger at a time
break;
}
}
}
// Set up a timer to check for triggers periodically
const interval = setInterval(checkForTriggers, 500);
// Clean up when the extension is deactivated
context.subscriptions.push({
dispose: () => clearInterval(interval)
});
}
export function deactivate() {
console.log('Text Trigger extension is now deactivated');
}
{
"name": "text-trigger",
"displayName": "Text Trigger",
"description": "Watches for trigger text and replaces it with predefined content",
"version": "0.0.1",
"engines": {
"vscode": "^1.60.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onStartupFinished"
],
"main": "./out/extension.js",
"contributes": {
"commands": []
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/vscode": "^1.60.0",
"@types/node": "^16.11.7",
"typescript": "^4.5.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment