@theia/ai-ide 1.62.0-next.3 → 1.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts +3 -3
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts.map +1 -1
- package/lib/browser/ai-configuration/agent-configuration-widget.js +24 -18
- package/lib/browser/ai-configuration/agent-configuration-widget.js.map +1 -1
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.js +1 -1
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.js.map +1 -1
- package/lib/browser/ai-configuration/ai-configuration-widget.d.ts +2 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.d.ts.map +1 -1
- package/lib/browser/ai-configuration/ai-configuration-widget.js +6 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.js.map +1 -1
- package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts +138 -0
- package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts.map +1 -0
- package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js +492 -0
- package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js.map +1 -0
- package/lib/browser/ai-configuration/template-settings-renderer.d.ts +4 -5
- package/lib/browser/ai-configuration/template-settings-renderer.d.ts.map +1 -1
- package/lib/browser/ai-configuration/template-settings-renderer.js +15 -31
- package/lib/browser/ai-configuration/template-settings-renderer.js.map +1 -1
- package/lib/browser/architect-agent.d.ts +1 -1
- package/lib/browser/architect-agent.d.ts.map +1 -1
- package/lib/browser/architect-agent.js +2 -2
- package/lib/browser/architect-agent.js.map +1 -1
- package/lib/browser/coder-agent.d.ts +2 -2
- package/lib/browser/coder-agent.d.ts.map +1 -1
- package/lib/browser/coder-agent.js +7 -3
- package/lib/browser/coder-agent.js.map +1 -1
- package/lib/browser/file-changeset-functions.d.ts +14 -1
- package/lib/browser/file-changeset-functions.d.ts.map +1 -1
- package/lib/browser/file-changeset-functions.js +153 -14
- package/lib/browser/file-changeset-functions.js.map +1 -1
- package/lib/browser/frontend-module.d.ts.map +1 -1
- package/lib/browser/frontend-module.js +11 -1
- package/lib/browser/frontend-module.js.map +1 -1
- package/lib/browser/template-preference-contribution.d.ts +2 -2
- package/lib/browser/template-preference-contribution.d.ts.map +1 -1
- package/lib/browser/template-preference-contribution.js +2 -2
- package/lib/browser/template-preference-contribution.js.map +1 -1
- package/lib/browser/workspace-functions.d.ts +1 -1
- package/lib/browser/workspace-functions.js +13 -13
- package/lib/common/architect-prompt-template.d.ts +2 -3
- package/lib/common/architect-prompt-template.d.ts.map +1 -1
- package/lib/common/architect-prompt-template.js +49 -11
- package/lib/common/architect-prompt-template.js.map +1 -1
- package/lib/common/coder-replace-prompt-template.d.ts +6 -3
- package/lib/common/coder-replace-prompt-template.d.ts.map +1 -1
- package/lib/common/coder-replace-prompt-template.js +148 -22
- package/lib/common/coder-replace-prompt-template.js.map +1 -1
- package/lib/common/command-chat-agents.d.ts +1 -1
- package/lib/common/command-chat-agents.d.ts.map +1 -1
- package/lib/common/command-chat-agents.js +4 -4
- package/lib/common/command-chat-agents.js.map +1 -1
- package/lib/common/command-prompt-template.d.ts +2 -2
- package/lib/common/command-prompt-template.d.ts.map +1 -1
- package/lib/common/command-prompt-template.js +18 -15
- package/lib/common/command-prompt-template.js.map +1 -1
- package/lib/common/orchestrator-chat-agent.d.ts +2 -3
- package/lib/common/orchestrator-chat-agent.d.ts.map +1 -1
- package/lib/common/orchestrator-chat-agent.js +11 -26
- package/lib/common/orchestrator-chat-agent.js.map +1 -1
- package/lib/common/orchestrator-prompt-template.d.ts +2 -2
- package/lib/common/orchestrator-prompt-template.d.ts.map +1 -1
- package/lib/common/orchestrator-prompt-template.js +4 -1
- package/lib/common/orchestrator-prompt-template.js.map +1 -1
- package/lib/common/universal-chat-agent.d.ts +5 -1
- package/lib/common/universal-chat-agent.d.ts.map +1 -1
- package/lib/common/universal-chat-agent.js +2 -2
- package/lib/common/universal-chat-agent.js.map +1 -1
- package/lib/common/universal-prompt-template.d.ts +3 -3
- package/lib/common/universal-prompt-template.d.ts.map +1 -1
- package/lib/common/universal-prompt-template.js +1 -2
- package/lib/common/universal-prompt-template.js.map +1 -1
- package/package.json +17 -17
- package/src/browser/ai-configuration/agent-configuration-widget.tsx +31 -24
- package/src/browser/ai-configuration/ai-configuration-view-contribution.ts +1 -1
- package/src/browser/ai-configuration/ai-configuration-widget.tsx +6 -0
- package/src/browser/ai-configuration/prompt-fragments-configuration-widget.tsx +710 -0
- package/src/browser/ai-configuration/template-settings-renderer.tsx +18 -38
- package/src/browser/architect-agent.ts +3 -3
- package/src/browser/coder-agent.ts +10 -5
- package/src/browser/file-changeset-functions.ts +152 -14
- package/src/browser/frontend-module.ts +14 -2
- package/src/browser/style/index.css +320 -0
- package/src/browser/template-preference-contribution.ts +4 -4
- package/src/browser/workspace-functions.ts +3 -3
- package/src/common/architect-prompt-template.ts +54 -14
- package/src/common/coder-replace-prompt-template.ts +150 -24
- package/src/common/command-chat-agents.ts +4 -4
- package/src/common/command-prompt-template.ts +21 -18
- package/src/common/orchestrator-chat-agent.ts +12 -28
- package/src/common/orchestrator-prompt-template.ts +7 -4
- package/src/common/universal-chat-agent.ts +2 -2
- package/src/common/universal-prompt-template.ts +4 -5
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// SPDX-License-Identifier: MIT
|
|
10
10
|
// *****************************************************************************
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { BasePromptFragment } from '@theia/ai-core/lib/common';
|
|
13
13
|
import { CHANGE_SET_SUMMARY_VARIABLE_ID } from '@theia/ai-chat';
|
|
14
14
|
import {
|
|
15
15
|
GET_WORKSPACE_FILE_LIST_FUNCTION_ID,
|
|
@@ -23,11 +23,129 @@ import {
|
|
|
23
23
|
import { CONTEXT_FILES_VARIABLE_ID, TASK_CONTEXT_SUMMARY_VARIABLE_ID } from './context-variables';
|
|
24
24
|
import { UPDATE_CONTEXT_FILES_FUNCTION_ID } from './context-functions';
|
|
25
25
|
|
|
26
|
+
export const CODER_SYSTEM_PROMPT_ID = 'coder-prompt';
|
|
26
27
|
export const CODER_REWRITE_PROMPT_TEMPLATE_ID = 'coder-rewrite';
|
|
27
28
|
export const CODER_REPLACE_PROMPT_TEMPLATE_ID = 'coder-search-replace';
|
|
28
29
|
export const CODER_REPLACE_PROMPT_TEMPLATE_NEXT_ID = 'coder-search-replace-next';
|
|
30
|
+
export const CODER_AGENT_MODE_TEMPLATE_ID = 'coder-agent-mode';
|
|
29
31
|
|
|
30
|
-
export function
|
|
32
|
+
export function getCoderAgentModePromptTemplate(): BasePromptFragment {
|
|
33
|
+
return {
|
|
34
|
+
id: CODER_AGENT_MODE_TEMPLATE_ID,
|
|
35
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
36
|
+
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
37
|
+
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
38
|
+
You are an **autonomous AI agent** embedded in the Theia IDE to assist developers with tasks like implementing features, fixing bugs, or improving code quality.
|
|
39
|
+
You must independently analyze, fix, validate, and finalize all changes — only yield control when all relevant tasks are completed.
|
|
40
|
+
|
|
41
|
+
# Agent Behavior
|
|
42
|
+
|
|
43
|
+
## Autonomy and Persistence
|
|
44
|
+
You are an agent. **Do not stop until** the entire task is complete:
|
|
45
|
+
- All code changes are applied
|
|
46
|
+
- All lint issues are resolved
|
|
47
|
+
- All relevant tests pass
|
|
48
|
+
- New tests are written when needed
|
|
49
|
+
|
|
50
|
+
You must act **without waiting** for user input unless explicitly required. Do not confirm intermediate steps — **only yield** when the entire problem is solved.
|
|
51
|
+
|
|
52
|
+
## Planning and Reflection
|
|
53
|
+
Before each function/tool call:
|
|
54
|
+
- Think step-by-step and explain your plan
|
|
55
|
+
- State your assumptions
|
|
56
|
+
- Justify why you're using a particular tool
|
|
57
|
+
|
|
58
|
+
After each tool call:
|
|
59
|
+
- Reflect on the result
|
|
60
|
+
- Adjust your plan if needed
|
|
61
|
+
- Continue to the next logical step
|
|
62
|
+
|
|
63
|
+
## Tool Usage Rules
|
|
64
|
+
Never guess or hallucinate file content or structure. Use tools for all workspace interactions:
|
|
65
|
+
|
|
66
|
+
### Workspace Exploration
|
|
67
|
+
- ~{getWorkspaceDirectoryStructure} — view overall structure
|
|
68
|
+
- ~{getWorkspaceFileList} — list contents of a specific directory
|
|
69
|
+
- ~{getFileContent} — retrieve the content of a file
|
|
70
|
+
- ~{context_addFile} — bookmark important files for context
|
|
71
|
+
|
|
72
|
+
### Search and Validation
|
|
73
|
+
- ~{searchInWorkspace} — locate references or patterns
|
|
74
|
+
- ~{getFileDiagnostics} — detect syntax, lint, or type errors
|
|
75
|
+
|
|
76
|
+
### ✍️ Code Editing
|
|
77
|
+
- Before editing, always retrieve file content
|
|
78
|
+
- Use:
|
|
79
|
+
- ~{changeSet_replaceContentInFile} — propose targeted code changes (multiple calls merge changes)
|
|
80
|
+
- ~{changeSet_writeChangeToFile} — completely rewrite a file when needed
|
|
81
|
+
- ~{changeSet_clearFileChanges} — clear all pending changes for a file
|
|
82
|
+
- For incremental changes, use multiple ~{changeSet_replaceContentInFile} calls
|
|
83
|
+
- Use the reset parameter with ~{changeSet_replaceContentInFile} to clear previous changes
|
|
84
|
+
|
|
85
|
+
### Testing & Tasks
|
|
86
|
+
- Use ~{listTasks} to discover available test and lint tasks
|
|
87
|
+
- Use ~{runTask} to run linting, building, or test suites
|
|
88
|
+
|
|
89
|
+
### Test Authoring
|
|
90
|
+
If no relevant tests exist:
|
|
91
|
+
- Create new test files (propose using changeSet_writeChangeToFile)
|
|
92
|
+
- Use patterns from existing tests
|
|
93
|
+
- Ensure new tests validate new behavior or prevent regressions
|
|
94
|
+
|
|
95
|
+
# Workflow Steps
|
|
96
|
+
|
|
97
|
+
## 1. Understand the Task
|
|
98
|
+
Analyze the user input, retrieve relevant files, and clarify the intent.
|
|
99
|
+
|
|
100
|
+
## 2. Investigate
|
|
101
|
+
Use directory listing, file retrieval, and search to gather all needed context.
|
|
102
|
+
|
|
103
|
+
## 3. Plan and Propose Fixes
|
|
104
|
+
Develop a step-by-step strategy. Modify relevant files via tool calls.
|
|
105
|
+
|
|
106
|
+
## 4. Run Validation Tools
|
|
107
|
+
Run linters and compilers:
|
|
108
|
+
- If issues are found, fix them and re-run
|
|
109
|
+
|
|
110
|
+
## 5. Test and Iterate
|
|
111
|
+
Run all relevant tests. If failures are found, debug and fix.
|
|
112
|
+
- If tests are missing, create them
|
|
113
|
+
- Ensure **100% success rate** before proceeding
|
|
114
|
+
|
|
115
|
+
## 6. Final Review
|
|
116
|
+
Reflect on whether all objectives are met:
|
|
117
|
+
- Code works
|
|
118
|
+
- Tests pass
|
|
119
|
+
- Code quality meets standards
|
|
120
|
+
|
|
121
|
+
Only when **everything is done**, end your turn.
|
|
122
|
+
|
|
123
|
+
# Additional Context
|
|
124
|
+
The following files have been provided for additional context. Some of them may also be referred to by the user (e.g. "this file" or "the attachment"). \
|
|
125
|
+
Always look at the relevant files to understand your task using the function ~{${FILE_CONTENT_FUNCTION_ID}}
|
|
126
|
+
{{${CONTEXT_FILES_VARIABLE_ID}}}
|
|
127
|
+
|
|
128
|
+
# Previously Proposed Changes
|
|
129
|
+
|
|
130
|
+
{{changeSetSummary}}
|
|
131
|
+
|
|
132
|
+
# Project Info
|
|
133
|
+
|
|
134
|
+
{{prompt:project-info}}
|
|
135
|
+
|
|
136
|
+
# Final Instruction
|
|
137
|
+
You are an autonomous AI agent. Do not stop until:
|
|
138
|
+
- All errors are fixed
|
|
139
|
+
- Lint and build succeed
|
|
140
|
+
- Tests pass
|
|
141
|
+
- New tests are created if needed
|
|
142
|
+
- No further action is required
|
|
143
|
+
`,
|
|
144
|
+
...({ variantOf: CODER_REPLACE_PROMPT_TEMPLATE_ID }),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function getCoderReplacePromptTemplateNext(): BasePromptFragment {
|
|
31
149
|
return {
|
|
32
150
|
id: CODER_REPLACE_PROMPT_TEMPLATE_NEXT_ID,
|
|
33
151
|
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
@@ -37,28 +155,30 @@ You are an AI assistant integrated into Theia IDE, designed to assist software d
|
|
|
37
155
|
|
|
38
156
|
## Context Retrieval
|
|
39
157
|
Use the following functions to interact with the workspace files if you require context:
|
|
40
|
-
- **~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}}
|
|
41
|
-
- **~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}}
|
|
42
|
-
- **~{${FILE_CONTENT_FUNCTION_ID}}
|
|
43
|
-
- **~{${
|
|
158
|
+
- **~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}}**
|
|
159
|
+
- **~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}}**
|
|
160
|
+
- **~{${FILE_CONTENT_FUNCTION_ID}}**
|
|
161
|
+
- **~{${SEARCH_IN_WORKSPACE_FUNCTION_ID}}**
|
|
162
|
+
|
|
163
|
+
Remember file locations that are relevant for completing your tasks using **~{${UPDATE_CONTEXT_FILES_FUNCTION_ID}}**
|
|
164
|
+
Only add files that are really relevant to look at later.
|
|
44
165
|
|
|
45
166
|
## File Validation
|
|
46
|
-
Use the following function to retrieve a list of problems in a file if the user requests fixes in a given file:
|
|
47
|
-
- **~{${GET_FILE_DIAGNOSTICS_ID}}**: Retrieves a list of problems identified in a given file by tool integrations such as language servers and linters.
|
|
167
|
+
Use the following function to retrieve a list of problems in a file if the user requests fixes in a given file: **~{${GET_FILE_DIAGNOSTICS_ID}}**
|
|
48
168
|
|
|
49
169
|
## Propose Code Changes
|
|
50
170
|
To propose code changes or any file changes to the user, never print code or new file content in your response.
|
|
51
171
|
|
|
52
172
|
Instead, for each file you want to propose changes for:
|
|
53
|
-
- **Always Retrieve Current Content**: Use ${FILE_CONTENT_FUNCTION_ID} to get the
|
|
54
|
-
- **
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
173
|
+
- **Always Retrieve Current Content**: Use ${FILE_CONTENT_FUNCTION_ID} to get the original content of the target file.
|
|
174
|
+
- **View Pending Changes**: Use ~{changeSet_getProposedFileState} to see the current proposed state of a file, including all pending changes.
|
|
175
|
+
- **Change Content**: Use one of these methods to propose changes:
|
|
176
|
+
- ~{changeSet_replaceContentInFile}: For targeted replacements of specific text sections. Multiple calls will merge changes unless you set the reset parameter to true.
|
|
177
|
+
- ~{changeSet_writeChangeToFile}: For complete file rewrites when you need to replace the entire content.
|
|
178
|
+
- If ~{changeSet_replaceContentInFile} continuously fails use ~{changeSet_writeChangeToFile}.
|
|
179
|
+
- ~{changeSet_clearFileChanges}: To clear all pending changes for a file and start fresh.
|
|
60
180
|
|
|
61
|
-
|
|
181
|
+
The changes will be presented as an applicable diff to the user in any case.
|
|
62
182
|
|
|
63
183
|
## Tasks
|
|
64
184
|
|
|
@@ -66,7 +186,7 @@ The user might want you to execute some task. You can find tasks using ~{${LIST_
|
|
|
66
186
|
|
|
67
187
|
## Additional Context
|
|
68
188
|
|
|
69
|
-
The following files have been provided for additional context. Some of them may also be referred to by the user. \
|
|
189
|
+
The following files have been provided for additional context. Some of them may also be referred to by the user (e.g. "this file" or "the attachment"). \
|
|
70
190
|
Always look at the relevant files to understand your task using the function ~{${FILE_CONTENT_FUNCTION_ID}}
|
|
71
191
|
{{${CONTEXT_FILES_VARIABLE_ID}}}
|
|
72
192
|
|
|
@@ -75,11 +195,13 @@ You have previously proposed changes for the following files. Some suggestions m
|
|
|
75
195
|
{{${CHANGE_SET_SUMMARY_VARIABLE_ID}}}
|
|
76
196
|
|
|
77
197
|
{{prompt:project-info}}
|
|
198
|
+
|
|
199
|
+
{{${TASK_CONTEXT_SUMMARY_VARIABLE_ID}}}
|
|
78
200
|
`,
|
|
79
201
|
...({ variantOf: CODER_REPLACE_PROMPT_TEMPLATE_ID }),
|
|
80
202
|
};
|
|
81
203
|
}
|
|
82
|
-
export function getCoderReplacePromptTemplate(withSearchAndReplace: boolean = false):
|
|
204
|
+
export function getCoderReplacePromptTemplate(withSearchAndReplace: boolean = false): BasePromptFragment {
|
|
83
205
|
return {
|
|
84
206
|
id: withSearchAndReplace ? CODER_REPLACE_PROMPT_TEMPLATE_ID : CODER_REWRITE_PROMPT_TEMPLATE_ID,
|
|
85
207
|
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
@@ -102,15 +224,19 @@ Use the following function to retrieve a list of problems in a file if the user
|
|
|
102
224
|
To propose code changes or any file changes to the user, never print code or new file content in your response.
|
|
103
225
|
|
|
104
226
|
Instead, for each file you want to propose changes for:
|
|
105
|
-
- **Always Retrieve Current Content**: Use ${FILE_CONTENT_FUNCTION_ID} to get the
|
|
106
|
-
- **
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
227
|
+
- **Always Retrieve Current Content**: Use ${FILE_CONTENT_FUNCTION_ID} to get the original content of the target file.
|
|
228
|
+
- **View Pending Changes**: Use ~{changeSet_getProposedFileState} to see the current proposed state of a file, including all pending changes.
|
|
229
|
+
- **Change Content**: Use one of these methods to propose changes:
|
|
230
|
+
- ~{changeSet_replaceContentInFile}: For targeted replacements of specific text sections. Multiple calls will merge changes unless you set the reset parameter to true.
|
|
231
|
+
- ~{changeSet_writeChangeToFile}: For complete file rewrites when you need to replace the entire content.
|
|
232
|
+
- If ~{changeSet_replaceContentInFile} continuously fails use ~{changeSet_writeChangeToFile}.
|
|
233
|
+
- ~{changeSet_clearFileChanges}: To clear all pending changes for a file and start fresh.
|
|
234
|
+
|
|
235
|
+
The changes will be presented as an applicable diff to the user in any case.
|
|
110
236
|
|
|
111
237
|
## Additional Context
|
|
112
238
|
|
|
113
|
-
The following files have been provided for additional context. Some of them may also be referred to by the user. \
|
|
239
|
+
The following files have been provided for additional context. Some of them may also be referred to by the user (e.g. "this file" or "the attachment"). \
|
|
114
240
|
Always look at the relevant files to understand your task using the function ~{${FILE_CONTENT_FUNCTION_ID}}
|
|
115
241
|
{{${CONTEXT_FILES_VARIABLE_ID}}}
|
|
116
242
|
|
|
@@ -57,7 +57,7 @@ export class CommandChatAgent extends AbstractTextToModelParsingChatAgent<Parsed
|
|
|
57
57
|
|
|
58
58
|
override description = 'This agent is aware of all commands that the user can execute within the Theia IDE, the tool that the user is currently working with. \
|
|
59
59
|
Based on the user request, it can find the right command and then let the user execute it.';
|
|
60
|
-
override
|
|
60
|
+
override prompts = [commandTemplate];
|
|
61
61
|
override agentSpecificVariables = [{
|
|
62
62
|
name: 'command-ids',
|
|
63
63
|
description: 'The list of available commands in Theia.',
|
|
@@ -69,13 +69,13 @@ export class CommandChatAgent extends AbstractTextToModelParsingChatAgent<Parsed
|
|
|
69
69
|
for (const command of this.commandRegistry.getAllCommands()) {
|
|
70
70
|
knownCommands.push(`${command.id}: ${command.label}`);
|
|
71
71
|
}
|
|
72
|
-
const systemPrompt = await this.promptService.
|
|
72
|
+
const systemPrompt = await this.promptService.getResolvedPromptFragment(commandTemplate.id, {
|
|
73
73
|
'command-ids': knownCommands.join('\n')
|
|
74
74
|
}, context);
|
|
75
75
|
if (systemPrompt === undefined) {
|
|
76
|
-
throw new Error('Couldn\'t get
|
|
76
|
+
throw new Error('Couldn\'t get prompt ');
|
|
77
77
|
}
|
|
78
|
-
return SystemMessageDescription.
|
|
78
|
+
return SystemMessageDescription.fromResolvedPromptFragment(systemPrompt);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -9,21 +9,23 @@
|
|
|
9
9
|
// SPDX-License-Identifier: MIT
|
|
10
10
|
// *****************************************************************************
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { PromptVariantSet } from '@theia/ai-core';
|
|
13
13
|
|
|
14
|
-
export const commandTemplate:
|
|
14
|
+
export const commandTemplate: PromptVariantSet = {
|
|
15
15
|
id: 'command-system',
|
|
16
|
-
|
|
16
|
+
defaultVariant: {
|
|
17
|
+
id: 'command-system-default',
|
|
18
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
17
19
|
Made improvements or adaptations to this prompt template? We\u2019d love for you to share it with the community! Contribute back here:
|
|
18
20
|
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
19
21
|
# System Prompt
|
|
20
22
|
|
|
21
23
|
You are a service that helps users find commands to execute in an IDE.
|
|
22
|
-
You reply with stringified JSON Objects that tell the user which command to execute and its arguments, if any.
|
|
24
|
+
You reply with stringified JSON Objects that tell the user which command to execute and its arguments, if any.
|
|
23
25
|
|
|
24
26
|
# Examples
|
|
25
27
|
|
|
26
|
-
The examples start with a short explanation of the return object.
|
|
28
|
+
The examples start with a short explanation of the return object.
|
|
27
29
|
The response can be found within the markdown \`\`\`json and \`\`\` markers.
|
|
28
30
|
Please include these markers in the reply.
|
|
29
31
|
|
|
@@ -42,7 +44,7 @@ This reply is to tell the user to execute the \`theia-ai-prompt-template:show-pr
|
|
|
42
44
|
|
|
43
45
|
## Example 2
|
|
44
46
|
|
|
45
|
-
This reply is to tell the user to execute the \`theia-ai-prompt-template:show-prompts-command\` command that is available in the theia command registry,
|
|
47
|
+
This reply is to tell the user to execute the \`theia-ai-prompt-template:show-prompts-command\` command that is available in the theia command registry,
|
|
46
48
|
when the user want to pass arguments to the command.
|
|
47
49
|
|
|
48
50
|
\`\`\`json
|
|
@@ -55,9 +57,9 @@ when the user want to pass arguments to the command.
|
|
|
55
57
|
|
|
56
58
|
## Example 3
|
|
57
59
|
|
|
58
|
-
This reply is for custom commands that are not registered in the Theia command registry.
|
|
60
|
+
This reply is for custom commands that are not registered in the Theia command registry.
|
|
59
61
|
These commands always have the command id \`ai-chat.command-chat-response.generic\`.
|
|
60
|
-
The arguments are an array and may differ, depending on the user's instructions.
|
|
62
|
+
The arguments are an array and may differ, depending on the user's instructions.
|
|
61
63
|
|
|
62
64
|
\`\`\`json
|
|
63
65
|
{
|
|
@@ -69,7 +71,7 @@ The arguments are an array and may differ, depending on the user's instructions.
|
|
|
69
71
|
|
|
70
72
|
## Example 4
|
|
71
73
|
|
|
72
|
-
This reply of type no-command is for cases where you can't find a proper command.
|
|
74
|
+
This reply of type no-command is for cases where you can't find a proper command.
|
|
73
75
|
You may use the message to explain the situation to the user.
|
|
74
76
|
|
|
75
77
|
\`\`\`json
|
|
@@ -84,17 +86,17 @@ You may use the message to explain the situation to the user.
|
|
|
84
86
|
## Theia Commands
|
|
85
87
|
|
|
86
88
|
If a user asks for a Theia command, or the context implies it is about a command in Theia, return a response with \`"type": "theia-command"\`.
|
|
87
|
-
You need to exchange the "commandId".
|
|
89
|
+
You need to exchange the "commandId".
|
|
88
90
|
The available command ids in Theia are in the list below. The list of commands is formatted like this:
|
|
89
91
|
|
|
90
92
|
command-id1: Label1
|
|
91
93
|
command-id2: Label2
|
|
92
|
-
command-id3:
|
|
94
|
+
command-id3:
|
|
93
95
|
command-id4: Label4
|
|
94
96
|
|
|
95
97
|
The Labels may be empty, but there is always a command-id.
|
|
96
98
|
|
|
97
|
-
Suggest a command that probably fits the user's message based on the label and the command ids you know.
|
|
99
|
+
Suggest a command that probably fits the user's message based on the label and the command ids you know.
|
|
98
100
|
If you have multiple commands that fit, return the one that fits best. We only want a single command in the reply.
|
|
99
101
|
If the user says that the last command was not right, try to return the next best fit based on the conversation history with the user.
|
|
100
102
|
|
|
@@ -122,7 +124,7 @@ In all other cases, return a reply of \`"type": "no-command"\`.
|
|
|
122
124
|
|
|
123
125
|
## Invalid Response Example 1
|
|
124
126
|
|
|
125
|
-
This example is invalid because it returns text and two commands.
|
|
127
|
+
This example is invalid because it returns text and two commands.
|
|
126
128
|
Only one command should be replied, and it must be parseable JSON.
|
|
127
129
|
|
|
128
130
|
### The Example
|
|
@@ -172,7 +174,7 @@ I found this command that might help you: core.close.right.tabs
|
|
|
172
174
|
|
|
173
175
|
## Invalid Response Example 4
|
|
174
176
|
|
|
175
|
-
The following example is invalid because it has an explanation string before the JSON.
|
|
177
|
+
The following example is invalid because it has an explanation string before the JSON.
|
|
176
178
|
We only want the JSON!
|
|
177
179
|
|
|
178
180
|
### The Example
|
|
@@ -188,7 +190,7 @@ You can toggle high contrast mode with this command:
|
|
|
188
190
|
|
|
189
191
|
## Invalid Response Example 5
|
|
190
192
|
|
|
191
|
-
The following example is invalid because it explains that no command was found.
|
|
193
|
+
The following example is invalid because it explains that no command was found.
|
|
192
194
|
We want a response of \`"type": "no-command"\` and have the message there.
|
|
193
195
|
|
|
194
196
|
### The Example
|
|
@@ -205,8 +207,8 @@ foo:toggle-visibility-explorer-view-container--files: Label 1
|
|
|
205
207
|
foo:toggle-visibility-explorer-view-container--plugin-view: Label 2
|
|
206
208
|
End List
|
|
207
209
|
|
|
208
|
-
The problem is that workbench.action.toggleHighContrast is not in this list.
|
|
209
|
-
theia-command types may only use commandIds from this list.
|
|
210
|
+
The problem is that workbench.action.toggleHighContrast is not in this list.
|
|
211
|
+
theia-command types may only use commandIds from this list.
|
|
210
212
|
This should have been of \`"type": "no-command"\`.
|
|
211
213
|
|
|
212
214
|
### The Example
|
|
@@ -218,4 +220,5 @@ This should have been of \`"type": "no-command"\`.
|
|
|
218
220
|
}
|
|
219
221
|
\`\`\`
|
|
220
222
|
|
|
221
|
-
`}
|
|
223
|
+
`}
|
|
224
|
+
};
|
|
@@ -17,15 +17,14 @@
|
|
|
17
17
|
import { getJsonOfText, getTextOfResponse, LanguageModel, LanguageModelMessage, LanguageModelRequirement, LanguageModelResponse } from '@theia/ai-core';
|
|
18
18
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
19
|
import { ChatAgentService } from '@theia/ai-chat/lib/common/chat-agent-service';
|
|
20
|
+
import { ChatToolRequest } from '@theia/ai-chat/lib/common/chat-tool-request-service';
|
|
20
21
|
import { AbstractStreamParsingChatAgent } from '@theia/ai-chat/lib/common/chat-agents';
|
|
21
22
|
import { MutableChatRequestModel, InformationalChatResponseContentImpl } from '@theia/ai-chat/lib/common/chat-model';
|
|
22
23
|
import { generateUuid, nls } from '@theia/core';
|
|
23
|
-
|
|
24
24
|
import { orchestratorTemplate } from './orchestrator-prompt-template';
|
|
25
|
-
import { ChatToolRequest } from '@theia/ai-chat/lib/common/chat-tool-request-service';
|
|
26
25
|
|
|
27
26
|
export const OrchestratorChatAgentId = 'Orchestrator';
|
|
28
|
-
const OrchestratorRequestIdKey = '
|
|
27
|
+
const OrchestratorRequestIdKey = 'orchestratorRequestIdKey';
|
|
29
28
|
|
|
30
29
|
@injectable()
|
|
31
30
|
export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
@@ -38,7 +37,7 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
38
37
|
protected defaultLanguageModelPurpose: string = 'agent-selection';
|
|
39
38
|
|
|
40
39
|
override variables = ['chatAgents'];
|
|
41
|
-
override
|
|
40
|
+
override prompts = [orchestratorTemplate];
|
|
42
41
|
override description = nls.localize('theia/ai/chat/orchestrator/description',
|
|
43
42
|
'This agent analyzes the user request against the description of all available chat agents and selects the best fitting agent to answer the request \
|
|
44
43
|
(by using AI).The user\'s request will be directly delegated to the selected agent without further confirmation.');
|
|
@@ -53,14 +52,13 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
53
52
|
|
|
54
53
|
override async invoke(request: MutableChatRequestModel): Promise<void> {
|
|
55
54
|
request.response.addProgressMessage({ content: 'Determining the most appropriate agent', status: 'inProgress' });
|
|
56
|
-
// We
|
|
55
|
+
// We use a dedicated id for the orchestrator request
|
|
57
56
|
const orchestratorRequestId = generateUuid();
|
|
58
57
|
request.addData(OrchestratorRequestIdKey, orchestratorRequestId);
|
|
58
|
+
|
|
59
59
|
return super.invoke(request);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
// override sendLlmRequest to modify the data sent to the recording service
|
|
63
|
-
// should no longer be needed after https://github.com/eclipse-theia/theia/issues/15221
|
|
64
62
|
protected override async sendLlmRequest(
|
|
65
63
|
request: MutableChatRequestModel,
|
|
66
64
|
messages: LanguageModelMessage[],
|
|
@@ -70,12 +68,8 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
70
68
|
const agentSettings = this.getLlmSettings();
|
|
71
69
|
const settings = { ...agentSettings, ...request.session.settings };
|
|
72
70
|
const tools = toolRequests.length > 0 ? toolRequests : undefined;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
sessionId: request.session.id,
|
|
76
|
-
requestId: request.getDataByKey<string>(OrchestratorRequestIdKey) ?? request.id,
|
|
77
|
-
request: messages
|
|
78
|
-
});
|
|
71
|
+
const subRequestId = request.getDataByKey<string>(OrchestratorRequestIdKey) ?? request.id;
|
|
72
|
+
request.removeData(OrchestratorRequestIdKey);
|
|
79
73
|
return this.languageModelService.sendRequest(
|
|
80
74
|
languageModel,
|
|
81
75
|
{
|
|
@@ -85,28 +79,15 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
85
79
|
agentId: this.id,
|
|
86
80
|
sessionId: request.session.id,
|
|
87
81
|
requestId: request.id,
|
|
82
|
+
subRequestId: subRequestId,
|
|
88
83
|
cancellationToken: request.response.cancellationToken
|
|
89
84
|
}
|
|
90
85
|
);
|
|
91
86
|
}
|
|
92
87
|
|
|
93
|
-
// override onResponseComplete to not send data to the communication service on completion
|
|
94
|
-
// should no longer be needed after https://github.com/eclipse-theia/theia/issues/15221
|
|
95
|
-
protected override async onResponseComplete(request: MutableChatRequestModel): Promise<void> {
|
|
96
|
-
return request.response.complete();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
88
|
protected override async addContentsToResponse(response: LanguageModelResponse, request: MutableChatRequestModel): Promise<void> {
|
|
100
89
|
const responseText = await getTextOfResponse(response);
|
|
101
90
|
|
|
102
|
-
// record orchestrator response
|
|
103
|
-
this.recordingService.recordResponse({
|
|
104
|
-
agentId: this.id,
|
|
105
|
-
sessionId: request.session.id,
|
|
106
|
-
requestId: request.getDataByKey<string>(OrchestratorRequestIdKey) ?? request.id,
|
|
107
|
-
response: [{ type: 'text', actor: 'ai', text: responseText }]
|
|
108
|
-
});
|
|
109
|
-
|
|
110
91
|
let agentIds: string[] = [];
|
|
111
92
|
|
|
112
93
|
try {
|
|
@@ -155,6 +136,9 @@ export class OrchestratorChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
155
136
|
if (!agent) {
|
|
156
137
|
throw new Error(`Chat agent ${delegatedToAgent} not found.`);
|
|
157
138
|
}
|
|
158
|
-
|
|
139
|
+
|
|
140
|
+
// Get the original request if available
|
|
141
|
+
const originalRequest = '__originalRequest' in request ? request.__originalRequest as MutableChatRequestModel : request;
|
|
142
|
+
await agent.invoke(originalRequest);
|
|
159
143
|
}
|
|
160
144
|
}
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
// SPDX-License-Identifier: MIT
|
|
10
10
|
// *****************************************************************************
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { PromptVariantSet } from '@theia/ai-core/lib/common';
|
|
13
13
|
|
|
14
|
-
export const orchestratorTemplate:
|
|
14
|
+
export const orchestratorTemplate: PromptVariantSet = {
|
|
15
15
|
id: 'orchestrator-system',
|
|
16
|
-
|
|
16
|
+
defaultVariant: {
|
|
17
|
+
id: 'orchestrator-system-default',
|
|
18
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
17
19
|
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
18
20
|
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
19
21
|
# Instructions
|
|
@@ -47,4 +49,5 @@ You must only use the \`id\` attribute of the agent, never the name.
|
|
|
47
49
|
## List of Currently Available Chat Agents
|
|
48
50
|
|
|
49
51
|
{{chatAgents}}
|
|
50
|
-
`}
|
|
52
|
+
`}
|
|
53
|
+
};
|
|
@@ -35,6 +35,6 @@ export class UniversalChatAgent extends AbstractStreamParsingChatAgent {
|
|
|
35
35
|
+ 'questions the user might ask. The universal agent currently does not have any context by default, i.e. it cannot '
|
|
36
36
|
+ 'access the current user context or the workspace.');
|
|
37
37
|
|
|
38
|
-
override
|
|
39
|
-
protected override systemPromptId: string =
|
|
38
|
+
override prompts = [{ id: 'universal-prompt', defaultVariant: universalTemplate, variants: [universalTemplateVariant] }];
|
|
39
|
+
protected override systemPromptId: string = 'universal-prompt';
|
|
40
40
|
}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
// SPDX-License-Identifier: MIT
|
|
10
10
|
// *****************************************************************************
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { BasePromptFragment } from '@theia/ai-core/lib/common';
|
|
13
13
|
import { CHAT_CONTEXT_DETAILS_VARIABLE_ID } from '@theia/ai-chat';
|
|
14
14
|
|
|
15
|
-
export const universalTemplate:
|
|
16
|
-
id: 'universal-system',
|
|
15
|
+
export const universalTemplate: BasePromptFragment = {
|
|
16
|
+
id: 'universal-system-default',
|
|
17
17
|
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
18
18
|
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
19
19
|
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
@@ -26,8 +26,7 @@ Some files and other pieces of data may have been added by the user to the conte
|
|
|
26
26
|
`
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const universalTemplateVariant:
|
|
29
|
+
export const universalTemplateVariant: BasePromptFragment = {
|
|
30
30
|
id: 'universal-system-empty',
|
|
31
31
|
template: '',
|
|
32
|
-
variantOf: universalTemplate.id,
|
|
33
32
|
};
|