// universal-developer-vscode/src/extension.ts import * as vscode from 'vscode'; /** * Symbolic command definition */ interface SymbolicCommand { name: string; description: string; parameters?: { name: string; description: string; required?: boolean; default?: any; }[]; examples: string[]; provider?: { claude?: boolean; openai?: boolean; qwen?: boolean; gemini?: boolean; ollama?: boolean; }; } /** * Universal developer extension activation function */ export function activate(context: vscode.ExtensionContext) { console.log('Universal Developer extension is now active'); // Register command palette commands const insertSymbolicCommand = vscode.commands.registerCommand( 'universal-developer.insertSymbolicCommand', async () => { const commandName = await showSymbolicCommandQuickPick(); if (!commandName) return; const command = SYMBOLIC_COMMANDS.find(cmd => cmd.name === commandName); if (!command) return; // Check if command has parameters let commandString = `/${command.name}`; if (command.parameters && command.parameters.length > 0) { const parameters = await collectCommandParameters(command); if (parameters) { Object.entries(parameters).forEach(([key, value]) => { if (value !== undefined && value !== null && value !== '') { commandString += ` --${key}=${value}`; } }); } } // Insert command at cursor position const editor = vscode.window.activeTextEditor; if (editor) { editor.edit(editBuilder => { editBuilder.insert(editor.selection.active, commandString + ' '); }); } } ); // Register the symbolic command chain builder const buildSymbolicChain = vscode.commands.registerCommand( 'universal-developer.buildSymbolicChain', async () => { await showCommandChainBuilder(); } ); // Register symbolic command hover provider const hoverProvider = vscode.languages.registerHoverProvider( ['javascript', 'typescript', 'python', 'markdown', 'plaintext'], { provideHover(document, position, token) { const range = document.getWordRangeAtPosition(position, /\/[a-zA-Z0-9_]+/); if (!range) return; const commandText = document.getText(range); const commandName = commandText.substring(1); // Remove the leading / const command = SYMBOLIC_COMMANDS.find(cmd => cmd.name === commandName); if (!command) return; // Create hover markdown const hoverContent = new vscode.MarkdownString(); hoverContent.appendMarkdown(`**/${command.name}**\n\n`); hoverContent.appendMarkdown(`${command.description}\n\n`); if (command.parameters && command.parameters.length > 0) { hoverContent.appendMarkdown('**Parameters:**\n\n'); command.parameters.forEach(param => { const required = param.required ? ' (required)' : ''; const defaultValue = param.default !== undefined ? ` (default: ${param.default})` : ''; hoverContent.appendMarkdown(`- \`--${param.name}\`${required}${defaultValue}: ${param.description}\n`); }); hoverContent.appendMarkdown('\n'); } if (command.examples && command.examples.length > 0) { hoverContent.appendMarkdown('**Examples:**\n\n'); command.examples.forEach(example => { hoverContent.appendCodeBlock(example, 'markdown'); }); } // Show provider compatibility if (command.provider) { hoverContent.appendMarkdown('\n**Compatible with:**\n\n'); const supported = Object.entries(command.provider) .filter(([_, isSupported]) => isSupported) .map(([provider]) => provider); hoverContent.appendMarkdown(supported.join(', ')); } return new vscode.Hover(hoverContent, range); } } ); // Register completion provider for symbolic commands const completionProvider = vscode.languages.registerCompletionItemProvider( ['javascript', 'typescript', 'python', 'markdown', 'plaintext'], { provideCompletionItems(document, position) { const linePrefix = document.lineAt(position).text.substring(0, position.character); // Check if we're at the start of a potential symbolic command if (!linePrefix.endsWith('/')) { return undefined; } const completionItems = SYMBOLIC_COMMANDS.map(command => { const item = new vscode.CompletionItem( command.name, vscode.CompletionItemKind.Keyword ); item.insertText = command.name; item.detail = command.description; item.documentation = new vscode.MarkdownString(command.description); return item; }); return completionItems; } }, '/' // Only trigger after the / character ); // Register parameter completion provider const parameterCompletionProvider = vscode.languages.registerCompletionItemProvider( ['javascript', 'typescript', 'python', 'markdown', 'plaintext'], { provideCompletionItems(document, position) { const linePrefix = document.lineAt(position).text.substring(0, position.character); // Match a symbolic command with a potential parameter start const commandMatch = linePrefix.match(/\/([a-zA-Z0-9_]+)(?:\s+(?:[^\s]+\s+)*)?--$/); if (!commandMatch) { return undefined; } const commandName = commandMatch[1]; const command = SYMBOLIC_COMMANDS.find(cmd => cmd.name === commandName); if (!command || !command.parameters || command.parameters.length === 0) { return undefined; } // Offer parameter completions const completionItems = command.parameters.map(param => { const item = new vscode.CompletionItem( param.name, vscode.CompletionItemKind.Property ); item.insertText = `${param.name}=`; item.detail = param.description; if (param.default !== undefined) { item.documentation = new vscode.MarkdownString( `${param.description}\n\nDefault: \`${param.default}\`` ); } else { item.documentation = new vscode.MarkdownString(param.description); } return item; }); return completionItems; } }, '-' // Trigger after - (the second dash in --) ); // Register code actions provider for symbolic command suggestions const codeActionsProvider = vscode.languages.registerCodeActionsProvider( ['javascript', 'typescript', 'python'], { provideCodeActions(document, range, context, token) { // Check if there's any LLM API call in the current line const line = document.lineAt(range.start.line).text; const llmApiPatterns = [ /\.generate\(\s*{/, // UniversalLLM.generate() /\.createCompletion\(/, // OpenAI /\.createChatCompletion\(/, // OpenAI /\.chat\.completions\.create\(/, // OpenAI v2 /\.messages\.create\(/, // Anthropic/Claude /\.generateContent\(/ // Google Gemini ]; if (!llmApiPatterns.some(pattern => pattern.test(line))) { return; } // Create code actions for adding symbolic commands const actions: vscode.CodeAction[] = []; // Find the prompt parameter const promptMatch = line.match(/(prompt|messages|content)\s*:/); if (!promptMatch) return; // Add actions for common symbolic commands ['think', 'fast', 'reflect', 'loop'].forEach(commandName => { const command = SYMBOLIC_COMMANDS.find(cmd => cmd.name === commandName); if (!command) return; const action = new vscode.CodeAction( `Add /${commandName} command`, vscode.CodeActionKind.RefactorRewrite ); action.command = { title: `Insert /${commandName}`, command: 'universal-developer.insertSymbolicCommandAtPrompt', arguments: [range.start.line, command] }; actions.push(action); }); return actions; } } ); // Register command to insert symbolic command at prompt const insertSymbolicCommandAtPrompt = vscode.commands.registerCommand( 'universal-developer.insertSymbolicCommandAtPrompt', async (line: number, command: SymbolicCommand) => { const editor = vscode.window.activeTextEditor; if (!editor) return; const document = editor.document; const lineText = document.lineAt(line).text; // Find where the prompt string starts const promptMatch = lineText.match(/(prompt|messages|content)\s*:\s*['"]/); if (!promptMatch) return; const promptStartIdx = promptMatch.index! + promptMatch[0].length; const position = new vscode.Position(line, promptStartIdx); editor.edit(editBuilder => { editBuilder.insert(position, `/${command.name} `); }); } ); // Register status bar item for active symbolic context const statusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, 100 ); statusBarItem.text = "$(symbol-keyword) Symbolic"; statusBarItem.tooltip = "Universal Developer: Click to insert symbolic command"; statusBarItem.command = 'universal-developer.insertSymbolicCommand'; statusBarItem.show(); // Register documentation webview const showDocumentation = vscode.commands.registerCommand( 'universal-developer.showDocumentation', () => { const panel = vscode.window.createWebviewPanel( 'universalDeveloperDocs', 'Universal Developer Documentation', vscode.ViewColumn.One, { enableScripts: true } ); panel.webview.html = getDocumentationHtml(); } ); // Register commands for the extension context.subscriptions.push( insertSymbolicCommand, buildSymbolicChain, hoverProvider, completionProvider, parameterCompletionProvider, codeActionsProvider, insertSymbolicCommandAtPrompt, statusBarItem, showDocumentation ); // Telemetry for command usage (anonymized) context.subscriptions.push( vscode.commands.registerCommand( 'universal-developer.trackCommandUsage', (commandName: string) => { // Only track if user has opted in to telemetry const config = vscode.workspace.getConfiguration('universal-developer'); if (config.get('enableTelemetry', true)) { sendAnonymizedTelemetry('command_used', { command: commandName }); } } ) ); } // Helper function to show a quick pick for symbolic commands async function showSymbolicCommandQuickPick(): Promise { const items = SYMBOLIC_COMMANDS.map(command => ({ label: `/${command.name}`, description: command.description, detail: command.parameters && command.parameters.length > 0 ? `Parameters: ${command.parameters.map(p => p.name).join(', ')}` : undefined })); const selected = await vscode // universal-developer-vscode/src/extension.ts (continued) // Helper function to show a quick pick for symbolic commands async function showSymbolicCommandQuickPick(): Promise { const items = SYMBOLIC_COMMANDS.map(command => ({ label: `/${command.name}`, description: command.description, detail: command.parameters && command.parameters.length > 0 ? `Parameters: ${command.parameters.map(p => p.name).join(', ')}` : undefined })); const selected = await vscode.window.showQuickPick(items, { placeHolder: 'Select a symbolic runtime command', }); return selected ? selected.label.substring(1) : undefined; // Remove the leading / } // Helper function to collect parameters for a command async function collectCommandParameters(command: SymbolicCommand): Promise | undefined> { if (!command.parameters || command.parameters.length === 0) { return {}; } const parameters: Record = {}; // Set default values command.parameters.forEach(param => { if (param.default !== undefined) { parameters[param.name] = param.default; } }); // Ask for each parameter for (const param of command.parameters) { const value = await vscode.window.showInputBox({ prompt: param.description, placeHolder: param.default !== undefined ? `Default: ${param.default}` : undefined, ignoreFocusOut: true, validateInput: text => { if (param.required && !text) { return `${param.name} is required`; } return null; } }); // User canceled if (value === undefined) { return undefined; } // Only set if value is provided if (value !== '') { parameters[param.name] = value; } } return parameters; } // Command Chain Builder Interface async function showCommandChainBuilder() { // Create webview panel for the command chain builder const panel = vscode.window.createWebviewPanel( 'universalDeveloperChainBuilder', 'Symbolic Command Chain Builder', vscode.ViewColumn.Two, { enableScripts: true, retainContextWhenHidden: true } ); // Load chain builder HTML panel.webview.html = getCommandChainBuilderHtml(); // Handle messages from webview panel.webview.onDidReceiveMessage( message => { switch (message.command) { case 'insertCommandChain': const editor = vscode.window.activeTextEditor; if (editor) { editor.edit(editBuilder => { editBuilder.insert(editor.selection.active, message.commandChain); }); } break; case 'getCommandInfo': panel.webview.postMessage({ command: 'commandInfo', commands: SYMBOLIC_COMMANDS }); break; } }, undefined, [] ); } // Get HTML for the command chain builder webview function getCommandChainBuilderHtml() { return ` Symbolic Command Chain Builder

Symbolic Command Chain Builder

Preview:
`; } // Get HTML for the documentation webview function getDocumentationHtml() { return ` Universal Developer Documentation

Universal Developer Documentation

The Universal Developer extension enables you to control large language model behavior through intuitive symbolic commands. These commands provide a standardized interface for controlling model reasoning depth, response format, and other behaviors across all major LLM platforms.

Core Symbolic Commands

/think All Providers

Activates extended reasoning pathways, encouraging the model to approach the problem with deeper analysis and step-by-step reasoning.

Example:
/think What are the economic implications of increasing minimum wage?

When to use: Complex questions, strategic planning, multi-factor analysis, ethical dilemmas.

/fast All Providers

Optimizes for low-latency, concise responses. Prioritizes brevity and directness over comprehensiveness.

Example:
/fast What's the capital of France?

When to use: Simple fact queries, quick summaries, situations where speed is prioritized over depth.

/loop All Providers

Enables iterative refinement cycles, where the model improves its response through multiple revisions.

Example:
/loop --iterations=3 Improve this paragraph: Climate change is a big problem that affects many people and animals.

Parameters:

  • iterations: Number of refinement iterations (default: 3)

When to use: Content refinement, code improvement, iterative problem-solving.

/reflect All Providers

Triggers meta-analysis of outputs, causing the model to critically examine its own response for biases, limitations, and improvements.

Example:
/reflect How might AI impact the future of work?

When to use: Critical analysis, identifying biases, ensuring balanced perspectives, philosophical inquiries.

/fork All Providers

Generates multiple alternative responses representing different approaches or perspectives.

Example:
/fork --count=3 What are some approaches to reducing carbon emissions?

Parameters:

  • count: Number of alternatives to generate (default: 2)

When to use: Exploring multiple options, creative brainstorming, presenting diverse perspectives.

/collapse All Providers

Returns to default behavior, disabling any special processing modes.

Example:
/collapse What time is it?

When to use: Basic queries, resetting to default behavior, standard responses.

Command Chaining

Commands can be chained together to create complex behaviors. The order of commands matters:

Example:
/think /loop --iterations=2 What strategy should a startup use to enter a competitive market?

This will engage deep thinking mode and then apply two refinement iterations to the output.

Example:
/reflect /fork --count=2 What are the ethical implications of AI in healthcare?

This will generate two alternative responses, each with critical reflection on limitations and biases.

Provider Compatibility

The Universal Developer extension adapts these symbolic commands to work across different LLM providers, ensuring consistent behavior regardless of the underlying model API.

Provider Supported Models Implementation Notes
Anthropic Claude 3 Opus, Sonnet, Haiku Native thinking mode support via enable_thinking parameter
OpenAI GPT-4, GPT-3.5 System prompt engineering for command emulation
Qwen Qwen 3 models Native thinking mode support via /think and /no_think markers
Gemini Gemini Pro, Ultra System prompt engineering with temperature adjustments
Local Models Ollama, LMStudio Limited support via prompt engineering

Code Integration

JavaScript/TypeScript:
import { UniversalLLM } from 'universal-developer';

const llm = new UniversalLLM({
  provider: 'anthropic',
  apiKey: process.env.ANTHROPIC_API_KEY
});

async function analyze() {
  const response = await llm.generate({
    prompt: "/think What are the implications of quantum computing for cybersecurity?"
  });
  console.log(response);
}
Python:
from universal_developer import UniversalLLM

llm = UniversalLLM(
    provider="openai",
    api_key=os.environ["OPENAI_API_KEY"]
)

def improve_code():
    code = "def factorial(n):\\n  result = 0\\n  for i in range(1, n+1):\\n    result *= i\\n  return result"
    response = llm.generate(
        prompt=f"/loop --iterations=2 Improve this code:\\n```python\\n{code}\\n```"
    )
    print(response)

Custom Commands

You can register custom symbolic commands to extend functionality:

llm.registerCommand("debate", {
  description: "Generate a balanced debate with arguments for both sides",
  parameters: [
    {
      name: "format",
      description: "Format for the debate output",
      required: false,
      default: "point-counterpoint"
    }
  ],
  transform: async (prompt, options) => {
    // Custom implementation
  }
});

Extension Settings

The Universal Developer extension includes the following settings:

  • universal-developer.enableTelemetry: Enable anonymous usage data collection (default: true)
  • universal-developer.defaultProvider: Default provider for command examples
  • universal-developer.showStatusBar: Show status bar item (default: true)

/reflect This interface creates a new layer of intentionality between developer and model—enabling deeper connection through structured symbolic prompting.

`; } // Telemetry function - only collects anonymous usage data if enabled async function sendAnonymizedTelemetry(event: string, data: Record = {}) { try { const config = vscode.workspace.getConfiguration('universal-developer'); const telemetryEndpoint = config.get('telemetryEndpoint', 'https://telemetry.universal-developer.org/v1/events'); // Generate anonymous ID if not already cached const extensionContext = await getContext(); let anonymousId = extensionContext.globalState.get('anonymousId'); if (!anonymousId) { anonymousId = generateAnonymousId(); extensionContext.globalState.update('anonymousId', anonymousId); } // Add metadata to telemetry payload const payload = { event, properties: { ...data, timestamp: new Date().toISOString(), extension_version: vscode.extensions.getExtension('universal-developer.vscode')?.packageJSON.version, vscode_version: vscode.version }, anonymousId }; // Send data in non-blocking way fetch(telemetryEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }).catch(() => { // Silently fail on telemetry errors }); } catch (error) { // Never let telemetry errors impact extension functionality } } // Helper function to get extension context async function getContext(): Promise { return new Promise((resolve) => { vscode.commands.executeCommand('universal-developer.getContext') .then((context: vscode.ExtensionContext) => resolve(context)); }); } // Generate anonymous ID for telemetry function generateAnonymousId(): string { return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); } // Symbolic commands data const SYMBOLIC_COMMANDS: SymbolicCommand[] = [ { name: 'think', description: 'Activate extended reasoning pathways', examples: [ '/think What are the implications of quantum computing for cybersecurity?', '/think Analyze the economic impact of increasing minimum wage.' ], provider: { claude: true, openai: true, qwen: true, gemini: true, ollama: true } }, { name: 'fast', description: 'Optimize for low-latency responses', examples: [ '/fast What\'s the capital of France?', '/fast Summarize the key points of this article.' ], provider: { claude: true, openai: true, qwen: true, gemini: true, ollama: true } }, { name: 'loop', description: 'Enable iterative refinement cycles', parameters: [ { name: 'iterations', description: 'Number of refinement iterations', required: false, default: 3 } ], examples: [ '/loop Improve this code snippet: function add(a, b) { return a + b }', '/loop --iterations=5 Refine this paragraph until it\'s clear and concise.' ], provider: { claude: true, openai: true, qwen: true, gemini: true, ollama: true } }, { name: 'reflect', description: 'Trigger meta-analysis of outputs', examples: [ '/reflect How might AI impact the future of work?', '/reflect What are the ethical implications of genetic engineering?' ], provider: { claude: true, openai: true, qwen: true, gemini: true, ollama: true } }, { name: 'collapse', description: 'Return to default behavior', examples: [ '/collapse What time is it?', '/collapse Tell me about the history of Rome.' ], provider: { claude: true, openai: true, qwen: true, gemini: true, ollama: true } }, { name: 'fork', description: 'Generate multiple alternative responses', parameters: [ { name: 'count', description: 'Number of alternatives to generate', required: false, default: 2 } ], examples: [ '/fork --count=3 What are some approaches to reducing carbon emissions?', '/fork Generate two different marketing slogans { "name": "universal-developer", "displayName": "Universal Developer - Symbolic Runtime Controls", "description": "Control LLM behavior through symbolic runtime commands across all major AI platforms", "version": "0.1.0", "engines": { "vscode": "^1.60.0" }, "publisher": "universal-developer", "categories": [ "Programming Languages", "Snippets", "Other" ], "keywords": [ "ai", "llm", "claude", "gpt", "qwen", "gemini", "prompt engineering", "symbolic commands" ], "icon": "images/icon.png", "galleryBanner": { "color": "#24292e", "theme": "dark" }, "activationEvents": [ "onLanguage:javascript", "onLanguage:typescript", "onLanguage:python", "onLanguage:markdown", "onLanguage:plaintext" ], "main": "./out/extension.js", "contributes": { "commands": [ { "command": "universal-developer.insertSymbolicCommand", "title": "Universal Developer: Insert Symbolic Command" }, { "command": "universal-developer.buildSymbolicChain", "title": "Universal Developer: Build Symbolic Command Chain" }, { "command": "universal-developer.showDocumentation", "title": "Universal Developer: Open Documentation" }, { "command": "universal-developer.getContext", "title": "Universal Developer: Get Extension Context" } ], "keybindings": [ { "command": "universal-developer.insertSymbolicCommand", "key": "ctrl+shift+/", "mac": "cmd+shift+/", "when": "editorTextFocus" }, { "command": "universal-developer.buildSymbolicChain", "key": "ctrl+shift+.", "mac": "cmd+shift+.", "when": "editorTextFocus" } ], "menus": { "editor/context": [ { "command": "universal-developer.insertSymbolicCommand", "group": "universal-developer", "when": "editorTextFocus" }, { "command": "universal-developer.buildSymbolicChain", "group": "universal-developer", "when": "editorTextFocus" } ] }, "configuration": { "title": "Universal Developer", "properties": { "universal-developer.enableTelemetry": { "type": "boolean", "default": true, "description": "Enable anonymous usage data collection to improve the extension" }, "universal-developer.defaultProvider": { "type": "string", "enum": [ "anthropic", "openai", "qwen", "gemini", "ollama" ], "default": "anthropic", "description": "Default LLM provider for command examples" }, "universal-developer.showStatusBar": { "type": "boolean", "default": true, "description": "Show Universal Developer status bar item" }, "universal-developer.telemetryEndpoint": { "type": "string", "default": "https://telemetry.universal-developer.org/v1/events", "description": "Endpoint for telemetry data collection" } } }, "snippets": [ { "language": "javascript", "path": "./snippets/javascript.json" }, { "language": "typescript", "path": "./snippets/typescript.json" }, { "language": "python", "path": "./snippets/python.json" } ] }, "scripts": { "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", "test": "node ./out/test/runTest.js", "package": "vsce package" }, "devDependencies": { "@types/glob": "^7.1.3", "@types/mocha": "^8.2.2", "@types/node": "^14.14.37", "@types/vscode": "^1.60.0", "@typescript-eslint/eslint-plugin": "^4.21.0", "@typescript-eslint/parser": "^4.21.0", "eslint": "^7.24.0", "glob": "^7.1.7", "mocha": "^8.3.2", "typescript": "^4.2.4", "vscode-test": "^1.5.2", "vsce": "^2.7.0" }, "dependencies": { "node-fetch": "^2.6.7" }, "repository": { "type": "git", "url": "https://github.com/universal-developer/vscode-extension.git" }, "homepage": "https://github.com/universal-developer/vscode-extension", "bugs": { "url": "https://github.com/universal-developer/vscode-extension/issues" }, "license": "MIT" }