@theia/ai-ide 1.63.0-next.0 → 1.63.0-next.52

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.
Files changed (102) hide show
  1. package/lib/browser/ai-configuration/ai-configuration-view-contribution.js +1 -1
  2. package/lib/browser/ai-configuration/ai-configuration-view-contribution.js.map +1 -1
  3. package/lib/browser/ai-configuration/ai-configuration-widget.d.ts +2 -1
  4. package/lib/browser/ai-configuration/ai-configuration-widget.d.ts.map +1 -1
  5. package/lib/browser/ai-configuration/ai-configuration-widget.js +6 -1
  6. package/lib/browser/ai-configuration/ai-configuration-widget.js.map +1 -1
  7. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts +0 -1
  8. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts.map +1 -1
  9. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js +0 -1
  10. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js.map +1 -1
  11. package/lib/browser/ai-configuration/token-usage-configuration-widget.d.ts +1 -0
  12. package/lib/browser/ai-configuration/token-usage-configuration-widget.d.ts.map +1 -1
  13. package/lib/browser/ai-configuration/token-usage-configuration-widget.js +25 -3
  14. package/lib/browser/ai-configuration/token-usage-configuration-widget.js.map +1 -1
  15. package/lib/browser/ai-configuration/tools-configuration-widget.d.ts +28 -0
  16. package/lib/browser/ai-configuration/tools-configuration-widget.d.ts.map +1 -0
  17. package/lib/browser/ai-configuration/tools-configuration-widget.js +148 -0
  18. package/lib/browser/ai-configuration/tools-configuration-widget.js.map +1 -0
  19. package/lib/browser/app-tester-chat-agent.d.ts +36 -0
  20. package/lib/browser/app-tester-chat-agent.d.ts.map +1 -0
  21. package/lib/browser/app-tester-chat-agent.js +172 -0
  22. package/lib/browser/app-tester-chat-agent.js.map +1 -0
  23. package/lib/browser/architect-agent.d.ts.map +1 -1
  24. package/lib/browser/architect-agent.js +4 -1
  25. package/lib/browser/architect-agent.js.map +1 -1
  26. package/lib/browser/coder-agent.d.ts.map +1 -1
  27. package/lib/browser/coder-agent.js +3 -3
  28. package/lib/browser/coder-agent.js.map +1 -1
  29. package/lib/browser/file-changeset-functions.d.ts +25 -6
  30. package/lib/browser/file-changeset-functions.d.ts.map +1 -1
  31. package/lib/browser/file-changeset-functions.js +248 -106
  32. package/lib/browser/file-changeset-functions.js.map +1 -1
  33. package/lib/browser/frontend-module.d.ts +1 -0
  34. package/lib/browser/frontend-module.d.ts.map +1 -1
  35. package/lib/browser/frontend-module.js +21 -5
  36. package/lib/browser/frontend-module.js.map +1 -1
  37. package/lib/browser/summarize-session-command-contribution.d.ts +6 -1
  38. package/lib/browser/summarize-session-command-contribution.d.ts.map +1 -1
  39. package/lib/browser/summarize-session-command-contribution.js +53 -4
  40. package/lib/browser/summarize-session-command-contribution.js.map +1 -1
  41. package/lib/browser/task-context-file-storage-service.d.ts +4 -2
  42. package/lib/browser/task-context-file-storage-service.d.ts.map +1 -1
  43. package/lib/browser/task-context-file-storage-service.js +19 -9
  44. package/lib/browser/task-context-file-storage-service.js.map +1 -1
  45. package/lib/browser/workspace-functions.d.ts.map +1 -1
  46. package/lib/browser/workspace-functions.js +6 -10
  47. package/lib/browser/workspace-functions.js.map +1 -1
  48. package/lib/browser/workspace-preferences.d.ts +1 -0
  49. package/lib/browser/workspace-preferences.d.ts.map +1 -1
  50. package/lib/browser/workspace-preferences.js +9 -1
  51. package/lib/browser/workspace-preferences.js.map +1 -1
  52. package/lib/browser/workspace-search-provider.d.ts +7 -1
  53. package/lib/browser/workspace-search-provider.d.ts.map +1 -1
  54. package/lib/browser/workspace-search-provider.js +73 -11
  55. package/lib/browser/workspace-search-provider.js.map +1 -1
  56. package/lib/browser/workspace-search-provider.spec.d.ts +2 -0
  57. package/lib/browser/workspace-search-provider.spec.d.ts.map +1 -0
  58. package/lib/browser/workspace-search-provider.spec.js +227 -0
  59. package/lib/browser/workspace-search-provider.spec.js.map +1 -0
  60. package/lib/common/architect-prompt-template.d.ts +1 -0
  61. package/lib/common/architect-prompt-template.d.ts.map +1 -1
  62. package/lib/common/architect-prompt-template.js +166 -5
  63. package/lib/common/architect-prompt-template.js.map +1 -1
  64. package/lib/common/coder-replace-prompt-template.d.ts +4 -5
  65. package/lib/common/coder-replace-prompt-template.d.ts.map +1 -1
  66. package/lib/common/coder-replace-prompt-template.js +95 -67
  67. package/lib/common/coder-replace-prompt-template.js.map +1 -1
  68. package/lib/common/file-changeset-function-ids.d.ts +7 -0
  69. package/lib/common/file-changeset-function-ids.d.ts.map +1 -0
  70. package/lib/common/file-changeset-function-ids.js +25 -0
  71. package/lib/common/file-changeset-function-ids.js.map +1 -0
  72. package/lib/common/summarize-session-commands.d.ts +1 -0
  73. package/lib/common/summarize-session-commands.d.ts.map +1 -1
  74. package/lib/common/summarize-session-commands.js +5 -1
  75. package/lib/common/summarize-session-commands.js.map +1 -1
  76. package/lib/common/workspace-search-provider-util.d.ts +17 -0
  77. package/lib/common/workspace-search-provider-util.d.ts.map +1 -0
  78. package/lib/common/workspace-search-provider-util.js +51 -0
  79. package/lib/common/workspace-search-provider-util.js.map +1 -0
  80. package/package.json +19 -18
  81. package/src/browser/ai-configuration/ai-configuration-view-contribution.ts +1 -1
  82. package/src/browser/ai-configuration/ai-configuration-widget.tsx +6 -1
  83. package/src/browser/ai-configuration/prompt-fragments-configuration-widget.tsx +0 -1
  84. package/src/browser/ai-configuration/token-usage-configuration-widget.tsx +63 -4
  85. package/src/browser/ai-configuration/tools-configuration-widget.tsx +178 -0
  86. package/src/browser/app-tester-chat-agent.ts +178 -0
  87. package/src/browser/architect-agent.ts +5 -2
  88. package/src/browser/coder-agent.ts +5 -5
  89. package/src/browser/file-changeset-functions.ts +236 -89
  90. package/src/browser/frontend-module.ts +33 -10
  91. package/src/browser/style/index.css +84 -11
  92. package/src/browser/summarize-session-command-contribution.ts +58 -6
  93. package/src/browser/task-context-file-storage-service.ts +20 -10
  94. package/src/browser/workspace-functions.ts +7 -11
  95. package/src/browser/workspace-preferences.ts +9 -0
  96. package/src/browser/workspace-search-provider.spec.ts +255 -0
  97. package/src/browser/workspace-search-provider.ts +78 -11
  98. package/src/common/architect-prompt-template.ts +165 -5
  99. package/src/common/coder-replace-prompt-template.ts +101 -65
  100. package/src/common/file-changeset-function-ids.ts +22 -0
  101. package/src/common/summarize-session-commands.ts +5 -0
  102. package/src/common/workspace-search-provider-util.ts +50 -0
@@ -17,10 +17,15 @@
17
17
  import { MutableChatRequestModel } from '@theia/ai-chat';
18
18
  import { ToolProvider, ToolRequest } from '@theia/ai-core';
19
19
  import { CancellationToken } from '@theia/core';
20
+ import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service';
20
21
  import { inject, injectable } from '@theia/core/shared/inversify';
22
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
21
23
  import { SearchInWorkspaceService, SearchInWorkspaceCallbacks } from '@theia/search-in-workspace/lib/browser/search-in-workspace-service';
22
24
  import { SearchInWorkspaceResult, SearchInWorkspaceOptions } from '@theia/search-in-workspace/lib/common/search-in-workspace-interface';
23
25
  import { SEARCH_IN_WORKSPACE_FUNCTION_ID } from '../common/workspace-functions';
26
+ import { WorkspaceFunctionScope } from './workspace-functions';
27
+ import { SEARCH_IN_WORKSPACE_MAX_RESULTS_PREF } from './workspace-preferences';
28
+ import { optimizeSearchResults } from '../common/workspace-search-provider-util';
24
29
 
25
30
  @injectable()
26
31
  export class WorkspaceSearchProvider implements ToolProvider {
@@ -28,7 +33,14 @@ export class WorkspaceSearchProvider implements ToolProvider {
28
33
  @inject(SearchInWorkspaceService)
29
34
  protected readonly searchService: SearchInWorkspaceService;
30
35
 
31
- private readonly MAX_RESULTS = 50;
36
+ @inject(WorkspaceFunctionScope)
37
+ protected readonly workspaceScope: WorkspaceFunctionScope;
38
+
39
+ @inject(PreferenceService)
40
+ protected readonly preferenceService: PreferenceService;
41
+
42
+ @inject(FileService)
43
+ protected readonly fileService: FileService;
32
44
 
33
45
  getTool(): ToolRequest {
34
46
  return {
@@ -38,6 +50,7 @@ export class WorkspaceSearchProvider implements ToolProvider {
38
50
  The search uses case-insensitive string matching or regular expressions (controlled by the `useRegExp` parameter). \
39
51
  It returns a list of matching files, including the file path (URI), the line number, and the full text content of each matching line. \
40
52
  Multi-word patterns must match exactly (including spaces, case-insensitively). \
53
+ For best results, use specific search terms and consider filtering by file extensions or limiting to specific subdirectories to avoid overwhelming results. \
41
54
  For complex searches, prefer multiple simpler queries over one complex query or regular expression.',
42
55
  parameters: {
43
56
  type: 'object',
@@ -49,6 +62,18 @@ export class WorkspaceSearchProvider implements ToolProvider {
49
62
  useRegExp: {
50
63
  type: 'boolean',
51
64
  description: 'Set to true if the query is a regular expression.',
65
+ },
66
+ fileExtensions: {
67
+ type: 'array',
68
+ items: {
69
+ type: 'string'
70
+ },
71
+ description: 'Optional array of file extensions to search in (e.g., ["ts", "js", "py"]). If not specified, searches all files.'
72
+ },
73
+ subDirectoryPath: {
74
+ type: 'string',
75
+ description: 'Optional subdirectory path to limit search scope. Use relative paths from workspace root ' +
76
+ '(e.g., "packages/ai-ide/src", "packages/core/src/browser"). If not specified, searches entire workspace.'
52
77
  }
53
78
  },
54
79
  required: ['query', 'useRegExp']
@@ -57,14 +82,36 @@ export class WorkspaceSearchProvider implements ToolProvider {
57
82
  };
58
83
  }
59
84
 
85
+ private async determineSearchRoots(subDirectoryPath?: string): Promise<string[]> {
86
+ const workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
87
+
88
+ if (!subDirectoryPath) {
89
+ return [workspaceRoot.toString()];
90
+ }
91
+
92
+ const subDirUri = workspaceRoot.resolve(subDirectoryPath);
93
+ this.workspaceScope.ensureWithinWorkspace(subDirUri, workspaceRoot);
94
+
95
+ try {
96
+ const stat = await this.fileService.resolve(subDirUri);
97
+ if (!stat || !stat.isDirectory) {
98
+ throw new Error(`Subdirectory '${subDirectoryPath}' does not exist or is not a directory`);
99
+ }
100
+ } catch (error) {
101
+ throw new Error(`Invalid subdirectory path '${subDirectoryPath}': ${error.message}`);
102
+ }
103
+
104
+ return [subDirUri.toString()];
105
+ }
106
+
60
107
  private async handleSearch(argString: string, cancellationToken?: CancellationToken): Promise<string> {
61
108
  try {
62
- const args: { query: string, useRegExp: boolean } = JSON.parse(argString);
109
+ const args: { query: string, useRegExp: boolean, fileExtensions?: string[], subDirectoryPath?: string } = JSON.parse(argString);
63
110
  const results: SearchInWorkspaceResult[] = [];
64
111
  let expectedSearchId: number | undefined;
65
112
  let searchCompleted = false;
66
113
 
67
- const searchPromise = new Promise<SearchInWorkspaceResult[]>((resolve, reject) => {
114
+ const searchPromise = new Promise<SearchInWorkspaceResult[]>(async (resolve, reject) => {
68
115
  const callbacks: SearchInWorkspaceCallbacks = {
69
116
  onResult: (id, result) => {
70
117
  if (expectedSearchId !== undefined && id !== expectedSearchId) {
@@ -88,21 +135,28 @@ export class WorkspaceSearchProvider implements ToolProvider {
88
135
 
89
136
  searchCompleted = true;
90
137
  if (error) {
91
- reject(new Error(`Search failed: ${error}`));
138
+ reject(new Error('Search failed: ' + error));
92
139
  } else {
93
140
  resolve(results);
94
141
  }
95
142
  }
96
143
  };
97
144
 
145
+ // Use one more than our actual maximum. this way we can determine if we have more results than our maximum and warn the user
146
+ const maxResultsForTheiaAPI = this.preferenceService.get<number>(SEARCH_IN_WORKSPACE_MAX_RESULTS_PREF, 30) + 1;
98
147
  const options: SearchInWorkspaceOptions = {
99
148
  useRegExp: args.useRegExp,
100
149
  matchCase: false,
101
150
  matchWholeWord: false,
102
- maxResults: this.MAX_RESULTS,
151
+ maxResults: maxResultsForTheiaAPI,
103
152
  };
104
153
 
105
- this.searchService.search(args.query, callbacks, options)
154
+ if (args.fileExtensions && args.fileExtensions.length > 0) {
155
+ options.include = args.fileExtensions.map(ext => `**/*.${ext}`);
156
+ }
157
+
158
+ await this.determineSearchRoots(args.subDirectoryPath)
159
+ .then(rootUris => this.searchService.searchWithCallback(args.query, rootUris, callbacks, options))
106
160
  .then(id => {
107
161
  expectedSearchId = id;
108
162
  cancellationToken?.onCancellationRequested(() => {
@@ -127,11 +181,23 @@ export class WorkspaceSearchProvider implements ToolProvider {
127
181
  });
128
182
 
129
183
  const finalResults = await Promise.race([searchPromise, timeoutPromise]);
130
-
131
- const formattedResults = finalResults.map(r => ({
132
- file: r.fileUri,
133
- matches: r.matches.map(m => ({ line: m.line, text: m.lineText }))
134
- }));
184
+ const maxResults = this.preferenceService.get<number>(SEARCH_IN_WORKSPACE_MAX_RESULTS_PREF, 30);
185
+
186
+ const workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
187
+ const formattedResults = optimizeSearchResults(finalResults, workspaceRoot);
188
+
189
+ let numberOfMatchesInFinalResults = 0;
190
+ for (const result of finalResults) {
191
+ numberOfMatchesInFinalResults += result.matches.length;
192
+ }
193
+ if (numberOfMatchesInFinalResults > maxResults) {
194
+ return JSON.stringify({
195
+ info: 'Search limit exceeded: Found ' + maxResults + '+ results. ' +
196
+ 'Please refine your search with more specific terms or use file extension filters. ' +
197
+ 'You can increase the limit in preferences under \'ai-features.workspaceFunctions.searchMaxResults\'.',
198
+ incompleteResults: formattedResults
199
+ });
200
+ }
135
201
 
136
202
  return JSON.stringify(formattedResults);
137
203
 
@@ -140,3 +206,4 @@ export class WorkspaceSearchProvider implements ToolProvider {
140
206
  }
141
207
  }
142
208
  }
209
+
@@ -17,13 +17,14 @@ import { CONTEXT_FILES_VARIABLE_ID, TASK_CONTEXT_SUMMARY_VARIABLE_ID } from './c
17
17
  import { UPDATE_CONTEXT_FILES_FUNCTION_ID } from './context-functions';
18
18
 
19
19
  export const ARCHITECT_TASK_SUMMARY_PROMPT_TEMPLATE_ID = 'architect-task-summary';
20
+ export const ARCHITECT_TASK_SUMMARY_UPDATE_PROMPT_TEMPLATE_ID = 'architect-update-task-summary';
20
21
 
21
22
  export const architectVariants = <PromptVariantSet>{
22
23
  id: 'architect-system',
23
24
  defaultVariant: {
24
25
  id: 'architect-system-default',
25
26
  template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
26
- Made improvements or adaptations to this prompt template? Wed love for you to share it with the community! Contribute back here:
27
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
27
28
  https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
28
29
  # Instructions
29
30
 
@@ -55,12 +56,13 @@ Always look at the relevant files to understand your task using the function ~{$
55
56
  {
56
57
  id: 'architect-system-next',
57
58
  template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
58
- Made improvements or adaptations to this prompt template? Wed love for you to share it with the community! Contribute back here:
59
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
59
60
  https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
60
61
  # Instructions
61
62
 
62
- You are an AI assistant integrated into Theia IDE, designed to assist software developers. You can't change any files, but you can navigate and read the users workspace using \
63
- the provided functions. Therefore describe and explain the details or procedures necessary to achieve the desired outcome. If file changes are necessary to help the user, be \
63
+ You are an AI assistant integrated into Theia IDE, designed to assist software developers. You can only change the files added to the context, but you can navigate and read the
64
+ users workspace using the provided functions.\
65
+ Therefore describe and explain the details or procedures necessary to achieve the desired outcome. If file changes are necessary to help the user, be \
64
66
  aware that there is another agent called 'Coder' that can suggest file changes. In this case you can create a description on what to do and tell the user to ask '@Coder' to \
65
67
  implement the change plan. If you refer to files, always mention the workspace-relative path.\
66
68
 
@@ -105,7 +107,165 @@ Skip irrelevant information, e.g. for discussions, only sum up the final result.
105
107
  4. If any part of the task is ambiguous, note the ambiguity so that it can be clarified later.
106
108
 
107
109
  Focus on providing actionable steps and implementation guidance. The coding agent needs practical help with this specific coding task.
110
+
111
+ Use the following format, but only include the sections that were discussed in the conversation:
112
+
113
+ # Task Context: [Title Here]
114
+
115
+ ---
116
+
117
+ ## 1. 📚 Task Definition
118
+
119
+ **Problem Statement / Goal:**
120
+ [Describe what needs to be achieved and why.]
121
+
122
+ **Scope:**
123
+ - **In Scope:**
124
+ [Features, components, or behaviors to be included.]
125
+ - **Out of Scope:**
126
+ [What explicitly won't be part of this task.]
127
+
128
+ ---
129
+
130
+ ## 2. 🧠 Design and Implementation
131
+
132
+ **Design Overview:**
133
+ [Summary of architecture and major design decisions.]
134
+
135
+ **Implementation Plan:**
136
+ 1. [First major step]
137
+ 2. [Second major step]
138
+ 3. [Third major step]
139
+
140
+ **Technology Choices:**
141
+ - [Frameworks, libraries, services, tools]
142
+
143
+ ---
144
+
145
+ ## 3. 🧪 Testing
146
+
147
+ ### 3.1 🛠️ Automated Testing (by Coder)
148
+
149
+ **Automated Test Strategy:**
150
+ [What should be covered by automated tests.]
151
+
152
+ **Test Cases Implemented:**
153
+ - [Unit test 1]
154
+ - [Integration test 1]
155
+ - [E2E test 1]
156
+
157
+ **Test Coverage Targets:**
158
+ [e.g., Minimum 80% code coverage, all workflows tested.]
159
+
160
+ ---
161
+
162
+ ### 3.2 🎯 Manual Testing (by Tester)
163
+
164
+ **Manual Testing Strategy:**
165
+ [What manual tests will focus on (e.g., usability, edge cases, exploratory testing).]
166
+
167
+ **Test Setup Instructions:**
168
+ - [Environment setup steps, accounts needed, special configurations]
169
+
170
+ **Test Cases / Test Steps:**
171
+ 1. [Action 1]
172
+ 2. [Action 2]
173
+ 3. [Action 3]
174
+
175
+ **Expected Results:**
176
+ - [Expected behavior at each step]
177
+
178
+ **Known Risks / Focus Areas:**
179
+ - [Potential weak spots, UX concerns, edge cases]
180
+
181
+ ---
182
+
183
+ ## 4. 📦 Deliverables
184
+
185
+ **Expected Artifacts:**
186
+ - [Code modules]
187
+ - [Documentation]
188
+ - [Configuration files]
189
+ - [Test reports]
190
+
191
+ **PR Information:**
192
+ - **PR Title:** [Suggested title for the pull request]
193
+ - **PR Description:** [What was implemented, high-level changes, decisions]
194
+ - **Verification Steps:** [Instructions for verifying the PR manually or automatically]
195
+
196
+ **Additional Notes:**
197
+ - [Dependencies]
198
+ - [Migration steps if needed]
199
+ - [Special reviewer instructions]
200
+
201
+ ---
202
+
203
+ ## 5. 🔄 Current Status
204
+
205
+ **Progress Summary:**
206
+ [Short free-text update about how far the task has progressed.]
207
+
208
+ **Completed Items:**
209
+ - [List of what has been fully implemented, tested, or merged.]
210
+
211
+ **Open Items:**
212
+ - [List of remaining tasks, missing parts.]
213
+
214
+ **Current Issues / Risks:**
215
+ - [Open problems, bugs found during testing, architectural blockers.]
216
+
217
+ **Next Steps:**
218
+ - [Immediate action items, who should act next.]
108
219
  `
109
- }
220
+ },
221
+ {
222
+ id: ARCHITECT_TASK_SUMMARY_UPDATE_PROMPT_TEMPLATE_ID,
223
+ template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
224
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
225
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
226
+ You are an AI assistant integrated into Theia IDE, designed to update task context files. You can interact provided task context file and propose changes.
227
+
228
+ # Task Document Update Instructions
229
+
230
+ You are an AI agent tasked with updating a technical document based on the current discussion. Your job is to provide the COMPLETE UPDATED DOCUMENT as your response, not\
231
+ commentary about the document.
232
+
233
+ ## Analysis Requirements
234
+
235
+ 1. **Review the Current Discussion**:
236
+ - Analyze the entire conversation
237
+ - Identify new information, decisions, and changes
238
+
239
+ 2. **Examine the Existing Document**:
240
+ - Understand its structure and purpose
241
+ - Identify sections that need updates
242
+
243
+ 3. **Update the Document**:
244
+ - Maintain the original structure and formatting
245
+ - Add new information from the discussion
246
+ - Update existing information
247
+ - Remove outdated information if necessary
248
+ - Ensure coherence and organization
249
+
250
+ ## IMPORTANT: Response Format
251
+
252
+ YOUR ENTIRE RESPONSE MUST BE THE UPDATED DOCUMENT ONLY. Do not include:
253
+ - Any commentary about what you changed
254
+ - Introduction or explanation text
255
+ - Markdown fences or syntax indicators
256
+ - Clarifying questions
257
+
258
+ Simply output the complete updated document as plain text, which will directly replace the existing document.
259
+
260
+ ## Guidelines
261
+
262
+ - Be thorough in capturing all relevant information
263
+ - Maintain the original document's style and tone
264
+ - Use clear, concise language
265
+ - Preserve all formatting from the original document
266
+ - Ensure technical accuracy in all updates
267
+
268
+ {{${TASK_CONTEXT_SUMMARY_VARIABLE_ID}}}
269
+ ` }
110
270
  ]
111
271
  };
@@ -22,18 +22,26 @@ import {
22
22
  } from './workspace-functions';
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
+ import {
26
+ SUGGEST_FILE_CONTENT_ID,
27
+ WRITE_FILE_CONTENT_ID,
28
+ SUGGEST_FILE_REPLACEMENTS_ID,
29
+ WRITE_FILE_REPLACEMENTS_ID,
30
+ CLEAR_FILE_CHANGES_ID,
31
+ GET_PROPOSED_CHANGES_ID
32
+ } from './file-changeset-function-ids';
25
33
 
26
34
  export const CODER_SYSTEM_PROMPT_ID = 'coder-prompt';
27
- export const CODER_REWRITE_PROMPT_TEMPLATE_ID = 'coder-rewrite';
28
- export const CODER_REPLACE_PROMPT_TEMPLATE_ID = 'coder-search-replace';
29
- export const CODER_REPLACE_PROMPT_TEMPLATE_NEXT_ID = 'coder-search-replace-next';
35
+
36
+ export const CODER_SIMPLE_EDIT_TEMPLATE_ID = 'coder-simple-edit';
37
+ export const CODER_EDIT_TEMPLATE_ID = 'coder-edit';
30
38
  export const CODER_AGENT_MODE_TEMPLATE_ID = 'coder-agent-mode';
31
39
 
32
40
  export function getCoderAgentModePromptTemplate(): BasePromptFragment {
33
41
  return {
34
42
  id: CODER_AGENT_MODE_TEMPLATE_ID,
35
43
  template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
36
- Made improvements or adaptations to this prompt template? Wed love for you to share it with the community! Contribute back here:
44
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
37
45
  https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
38
46
  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
47
  You must independently analyze, fix, validate, and finalize all changes — only yield control when all relevant tasks are completed.
@@ -43,6 +51,7 @@ You must independently analyze, fix, validate, and finalize all changes — only
43
51
  ## Autonomy and Persistence
44
52
  You are an agent. **Do not stop until** the entire task is complete:
45
53
  - All code changes are applied
54
+ - The build succeeds
46
55
  - All lint issues are resolved
47
56
  - All relevant tests pass
48
57
  - New tests are written when needed
@@ -64,31 +73,32 @@ After each tool call:
64
73
  Never guess or hallucinate file content or structure. Use tools for all workspace interactions:
65
74
 
66
75
  ### 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
76
+ - ~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}} — view overall structure
77
+ - ~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}} — list contents of a specific directory
78
+ - ~{${FILE_CONTENT_FUNCTION_ID}} — retrieve the content of a file
79
+ - ~{${SEARCH_IN_WORKSPACE_FUNCTION_ID}}}locate references or patterns (only search if you are missing information, always prefer examples that are explicitly provided, never \
80
+ search for files you already know the path for)
81
+ - ~{${UPDATE_CONTEXT_FILES_FUNCTION_ID}} bookmark important files for context
82
+
83
+ ### Code Editing
77
84
  - Before editing, always retrieve file content
78
85
  - 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
86
+ - ~{${WRITE_FILE_REPLACEMENTS_ID}}to immediately apply targeted code changes (no user review)
87
+ - ~{${WRITE_FILE_CONTENT_ID}}to immediately overwrite a file with new content (no user review)
88
+
89
+ - For incremental changes, use multiple ~{${WRITE_FILE_REPLACEMENTS_ID}} calls
90
+ - If ~{${WRITE_FILE_REPLACEMENTS_ID}} continuously fails use ~{${WRITE_FILE_CONTENT_ID}}.
91
+
92
+ ### Validation
93
+ - ~{${GET_FILE_DIAGNOSTICS_ID}} — detect syntax, lint, or type errors
84
94
 
85
95
  ### Testing & Tasks
86
- - Use ~{listTasks} to discover available test and lint tasks
87
- - Use ~{runTask} to run linting, building, or test suites
96
+ - Use ~{${LIST_TASKS_FUNCTION_ID}} to discover available test and lint tasks
97
+ - Use ~{${RUN_TASK_FUNCTION_ID}} to run linting, building, or test suites
88
98
 
89
99
  ### Test Authoring
90
100
  If no relevant tests exist:
91
- - Create new test files (propose using changeSet_writeChangeToFile)
101
+ - Create new test files (propose using suggestFileContent)
92
102
  - Use patterns from existing tests
93
103
  - Ensure new tests validate new behavior or prevent regressions
94
104
 
@@ -125,7 +135,7 @@ The following files have been provided for additional context. Some of them may
125
135
  Always look at the relevant files to understand your task using the function ~{${FILE_CONTENT_FUNCTION_ID}}
126
136
  {{${CONTEXT_FILES_VARIABLE_ID}}}
127
137
 
128
- # Previously Proposed Changes
138
+ # Previously Changed Files
129
139
 
130
140
  {{changeSetSummary}}
131
141
 
@@ -133,6 +143,8 @@ Always look at the relevant files to understand your task using the function ~{$
133
143
 
134
144
  {{prompt:project-info}}
135
145
 
146
+ {{${TASK_CONTEXT_SUMMARY_VARIABLE_ID}}}
147
+
136
148
  # Final Instruction
137
149
  You are an autonomous AI agent. Do not stop until:
138
150
  - All errors are fixed
@@ -141,48 +153,56 @@ You are an autonomous AI agent. Do not stop until:
141
153
  - New tests are created if needed
142
154
  - No further action is required
143
155
  `,
144
- ...({ variantOf: CODER_REPLACE_PROMPT_TEMPLATE_ID }),
156
+ ...({ variantOf: CODER_EDIT_TEMPLATE_ID }),
145
157
  };
146
158
  }
147
159
 
148
- export function getCoderReplacePromptTemplateNext(): BasePromptFragment {
160
+ export function getCoderPromptTemplateEdit(): BasePromptFragment {
149
161
  return {
150
- id: CODER_REPLACE_PROMPT_TEMPLATE_NEXT_ID,
162
+ id: CODER_EDIT_TEMPLATE_ID,
151
163
  template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
152
- Made improvements or adaptations to this prompt template? Wed love for you to share it with the community! Contribute back here:
164
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
153
165
  https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
154
- You are an AI assistant integrated into Theia IDE, designed to assist software developers with code tasks. You can interact with the code base and suggest changes.
166
+ You are an AI assistant integrated into Theia IDE, designed to assist software developers with code tasks. You can interact with the code base and suggest changes, \
167
+ which will be reviewed and accepted by the user.
155
168
 
156
169
  ## Context Retrieval
157
170
  Use the following functions to interact with the workspace files if you require context:
158
171
  - **~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}}**
159
172
  - **~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}}**
160
173
  - **~{${FILE_CONTENT_FUNCTION_ID}}**
161
- - **~{${SEARCH_IN_WORKSPACE_FUNCTION_ID}}**
174
+ - **~{${SEARCH_IN_WORKSPACE_FUNCTION_ID}}** (only search if you are missing information, always prefer examples that are explicitly provided, never search for files \
175
+ you already know the path for)
162
176
 
163
177
  Remember file locations that are relevant for completing your tasks using **~{${UPDATE_CONTEXT_FILES_FUNCTION_ID}}**
164
178
  Only add files that are really relevant to look at later.
165
179
 
166
- ## File Validation
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}}**
168
-
169
180
  ## Propose Code Changes
170
- To propose code changes or any file changes to the user, never print code or new file content in your response.
181
+ To propose code changes or any file changes to the user, never just output them as part of your response, but use the following functions for each file you want to propose \
182
+ changes for.
183
+ This also applies for newly created files!
171
184
 
172
- Instead, for each file you want to propose changes for:
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.
185
+ - **Always Retrieve Current Content**: Use getFileContent to get the original content of the target file.
186
+ - **View Pending Changes**: Use ~{${GET_PROPOSED_CHANGES_ID}} to see the current proposed state of a file, including all pending changes.
175
187
  - **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.
188
+ - ~{${SUGGEST_FILE_REPLACEMENTS_ID}}: For targeted replacements of specific text sections. Multiple calls will merge changes unless you set the reset parameter to true.
189
+ - ~{${SUGGEST_FILE_CONTENT_ID}}: For complete file rewrites when you need to replace the entire content.
190
+ - If ~{${SUGGEST_FILE_REPLACEMENTS_ID}} continuously fails use ~{${SUGGEST_FILE_CONTENT_ID}}.
191
+ - ~{${CLEAR_FILE_CHANGES_ID}}: To clear all pending changes for a file and start fresh.
180
192
 
181
- The changes will be presented as an applicable diff to the user in any case.
193
+ The changes will be presented as an applicable diff to the user in any case. The user can then accept or reject each change individually. Before you run tasks that depend on the \
194
+ changes beeing applied, you must wait for the user to review and accept the changes!
182
195
 
183
196
  ## Tasks
184
197
 
185
198
  The user might want you to execute some task. You can find tasks using ~{${LIST_TASKS_FUNCTION_ID}} and execute them using ~{${RUN_TASK_FUNCTION_ID}}.
199
+ Be aware that tasks operate on the workspace. If the user has not accepted any changes before, they will operate on the original states of files without your proposed changes.
200
+ Never execute a task without confirming with the user whether this is wanted!
201
+
202
+ ## File Validation
203
+
204
+ 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}}**
205
+ Be aware this function operates on the workspace. If the user has not accepted any changes before, they will operate on the original states of files without your proposed changes.
186
206
 
187
207
  ## Additional Context
188
208
 
@@ -197,42 +217,50 @@ You have previously proposed changes for the following files. Some suggestions m
197
217
  {{prompt:project-info}}
198
218
 
199
219
  {{${TASK_CONTEXT_SUMMARY_VARIABLE_ID}}}
200
- `,
201
- ...({ variantOf: CODER_REPLACE_PROMPT_TEMPLATE_ID }),
202
- };
220
+
221
+ ## Final Instruction
222
+ - Your task is to propose changes to be reviewed by the user
223
+ - Tasks such as building or liniting run on the workspace state, the user has to accept the changes beforehand
224
+ - Do not run a build or any error checking before the users asks you to
225
+ - Focus on the task that the user described
226
+ `};
203
227
  }
204
- export function getCoderReplacePromptTemplate(withSearchAndReplace: boolean = false): BasePromptFragment {
228
+
229
+ export function getCoderPromptTemplateSimpleEdit(): BasePromptFragment {
205
230
  return {
206
- id: withSearchAndReplace ? CODER_REPLACE_PROMPT_TEMPLATE_ID : CODER_REWRITE_PROMPT_TEMPLATE_ID,
231
+ id: CODER_SIMPLE_EDIT_TEMPLATE_ID,
207
232
  template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
208
- Made improvements or adaptations to this prompt template? Wed love for you to share it with the community! Contribute back here:
233
+ Made improvements or adaptations to this prompt template? We'd love for you to share it with the community! Contribute back here:
209
234
  https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
210
- You are an AI assistant integrated into Theia IDE, designed to assist software developers with code tasks. You can interact with the code base and suggest changes.
235
+ You are an AI assistant integrated into Theia IDE, designed to assist software developers with code tasks. You can interact with the code base and suggest changes \
236
+ which will be reviewed and accepted by the user.
211
237
 
212
238
  ## Context Retrieval
213
239
  Use the following functions to interact with the workspace files if you require context:
214
- - **~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}}**: Returns the complete directory structure.
215
- - **~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}}**: Lists files and directories in a specific directory.
216
- - **~{${FILE_CONTENT_FUNCTION_ID}}**: Retrieves the content of a specific file.
217
- - **~{${UPDATE_CONTEXT_FILES_FUNCTION_ID}}**: Remember file locations that are relevant for completing your tasks. Only add files that are really relevant to look at later.
240
+ - **~{${GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID}}**
241
+ - **~{${GET_WORKSPACE_FILE_LIST_FUNCTION_ID}}**
242
+ - **~{${FILE_CONTENT_FUNCTION_ID}}**
243
+ - **~{${SEARCH_IN_WORKSPACE_FUNCTION_ID}}** (only search if you are missing information, always prefer examples that are explicitly provided, never search for files \
244
+ you already know the path for)
218
245
 
219
- ## File Validation
220
- Use the following function to retrieve a list of problems in a file if the user requests fixes in a given file:
221
- - **~{${GET_FILE_DIAGNOSTICS_ID}}**: Retrieves a list of problems identified in a given file by tool integrations such as language servers and linters.
246
+ Remember file locations that are relevant for completing your tasks using **~{${UPDATE_CONTEXT_FILES_FUNCTION_ID}}**
247
+ Only add files that are really relevant to look at later.
222
248
 
223
249
  ## Propose Code Changes
224
- To propose code changes or any file changes to the user, never print code or new file content in your response.
250
+ To propose code changes or any file changes to the user, never just output them as part of your response, but use the following functions for each file you want to propose \
251
+ changes for.
252
+ This also applies for newly created files!
225
253
 
226
- Instead, for each file you want to propose changes for:
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.
254
+ - **Always Retrieve Current Content**: Use getFileContent to get the original content of the target file.
255
+ - **View Pending Changes**: Use ~{${GET_PROPOSED_CHANGES_ID}} to see the current proposed state of a file, including all pending changes.
229
256
  - **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.
257
+ - ~{${SUGGEST_FILE_REPLACEMENTS_ID}}: For targeted replacements of specific text sections. Multiple calls will merge changes unless you set the reset parameter to true.
258
+ - ~{${SUGGEST_FILE_CONTENT_ID}}: For complete file rewrites when you need to replace the entire content.
259
+ - If ~{${SUGGEST_FILE_REPLACEMENTS_ID}} continuously fails use ~{${SUGGEST_FILE_CONTENT_ID}}.
260
+ - ~{${CLEAR_FILE_CHANGES_ID}}: To clear all pending changes for a file and start fresh.
234
261
 
235
- The changes will be presented as an applicable diff to the user in any case.
262
+ The changes will be presented as an applicable diff to the user in any case. The user can then accept or reject each change individually. Before you run tasks that depend on the \
263
+ changes beeing applied, you must wait for the user to review and accept the changes!
236
264
 
237
265
  ## Additional Context
238
266
 
@@ -240,12 +268,20 @@ The following files have been provided for additional context. Some of them may
240
268
  Always look at the relevant files to understand your task using the function ~{${FILE_CONTENT_FUNCTION_ID}}
241
269
  {{${CONTEXT_FILES_VARIABLE_ID}}}
242
270
 
271
+ ## Previously Proposed Changes
272
+ You have previously proposed changes for the following files. Some suggestions may have been accepted by the user, while others may still be pending.
243
273
  {{${CHANGE_SET_SUMMARY_VARIABLE_ID}}}
244
274
 
245
275
  {{prompt:project-info}}
246
276
 
247
277
  {{${TASK_CONTEXT_SUMMARY_VARIABLE_ID}}}
278
+
279
+ ## Final Instruction
280
+ - Your task is to propose changes to be reviewed by the user
281
+ - Tasks such as building or liniting run on the workspace state, the user has to accept the changes beforehand
282
+ - Do not run a build or any error checking before the users asks you to
283
+ - Focus on the task that the user described
248
284
  `,
249
- ...(!withSearchAndReplace ? { variantOf: CODER_REPLACE_PROMPT_TEMPLATE_ID } : {}),
285
+ ...({ variantOf: CODER_EDIT_TEMPLATE_ID }),
250
286
  };
251
287
  }