-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathcustomAgentProvider.ts
More file actions
41 lines (30 loc) · 1.32 KB
/
customAgentProvider.ts
File metadata and controls
41 lines (30 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as vscode from 'vscode';
import { getChatResourceFileSystem } from './chatResourceFileSystem';
const AGENT_PATH = 'agents/workspace-helper.agent.md';
export function createCustomAgentProvider(context: vscode.ExtensionContext): vscode.ChatCustomAgentProvider {
const fs = getChatResourceFileSystem(context);
const agentUri = fs.registerResource(AGENT_PATH, generateDynamicAgentContent);
return {
async provideCustomAgents(_context, _token): Promise<vscode.ChatResource[]> {
return [{ uri: agentUri }];
}
};
}
function generateDynamicAgentContent(): string {
const workspaceFolders = vscode.workspace.workspaceFolders;
const folderCount = workspaceFolders?.length || 0;
const folderNames = workspaceFolders?.map(f => f.name).join(', ') || 'none';
return `# Workspace Helper Agent
This is a dynamically generated agent that provides workspace-specific assistance.
## Current Workspace Information
- **Workspace Folders**: ${folderCount}
- **Folder Names**: ${folderNames}
- **Generated At**: ${new Date().toISOString()}
## Instructions
I can help you with tasks specific to your current workspace. I have access to information about your workspace structure and can provide context-aware assistance.
Use me for:
- Workspace-specific queries
- Context-aware code suggestions
- Understanding your project structure
`;
}