@theia/ai-ide 1.77.0-next.7 → 1.77.0-next.71

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 (190) hide show
  1. package/lib/browser/{project-info-agent.d.ts → agents-md-agent.d.ts} +2 -2
  2. package/lib/browser/agents-md-agent.d.ts.map +1 -0
  3. package/lib/browser/{project-info-agent.js → agents-md-agent.js} +16 -15
  4. package/lib/browser/agents-md-agent.js.map +1 -0
  5. package/lib/browser/ai-configuration/ai-configuration-label-provider-contribution.js +1 -1
  6. package/lib/browser/ai-configuration/ai-configuration-label-provider-contribution.js.map +1 -1
  7. package/lib/browser/ai-configuration/ai-configuration-resource.js +2 -1
  8. package/lib/browser/ai-configuration/ai-configuration-resource.js.map +1 -1
  9. package/lib/browser/ai-configuration/ai-configuration-search-widget.js +1 -1
  10. package/lib/browser/ai-configuration/ai-configuration-search-widget.js.map +1 -1
  11. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.d.ts +11 -3
  12. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.d.ts.map +1 -1
  13. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.js +64 -29
  14. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.js.map +1 -1
  15. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.spec.js +480 -1
  16. package/lib/browser/ai-configuration/categories/agent-capabilities-settings.spec.js.map +1 -1
  17. package/lib/browser/ai-configuration/categories/agent-detail-model.d.ts +10 -0
  18. package/lib/browser/ai-configuration/categories/agent-detail-model.d.ts.map +1 -1
  19. package/lib/browser/ai-configuration/categories/agent-detail-model.js +8 -0
  20. package/lib/browser/ai-configuration/categories/agent-detail-model.js.map +1 -1
  21. package/lib/browser/ai-configuration/categories/agent-detail-model.spec.d.ts +2 -0
  22. package/lib/browser/ai-configuration/categories/agent-detail-model.spec.d.ts.map +1 -0
  23. package/lib/browser/ai-configuration/categories/agent-detail-model.spec.js +74 -0
  24. package/lib/browser/ai-configuration/categories/agent-detail-model.spec.js.map +1 -0
  25. package/lib/browser/ai-configuration/categories/agent-detail-view.d.ts.map +1 -1
  26. package/lib/browser/ai-configuration/categories/agent-detail-view.js +3 -2
  27. package/lib/browser/ai-configuration/categories/agent-detail-view.js.map +1 -1
  28. package/lib/browser/ai-configuration/categories/agents-configuration-category.d.ts +6 -1
  29. package/lib/browser/ai-configuration/categories/agents-configuration-category.d.ts.map +1 -1
  30. package/lib/browser/ai-configuration/categories/agents-configuration-category.js +20 -2
  31. package/lib/browser/ai-configuration/categories/agents-configuration-category.js.map +1 -1
  32. package/lib/browser/ai-configuration/categories/provider-model-discovery-section.js +5 -4
  33. package/lib/browser/ai-configuration/categories/provider-model-discovery-section.js.map +1 -1
  34. package/lib/browser/ai-configuration/categories/provider-model-discovery-section.spec.js +2 -1
  35. package/lib/browser/ai-configuration/categories/provider-model-discovery-section.spec.js.map +1 -1
  36. package/lib/browser/ai-configuration/categories/token-usage-configuration-category.js +2 -2
  37. package/lib/browser/ai-configuration/categories/token-usage-configuration-category.js.map +1 -1
  38. package/lib/browser/ai-configuration/categories/tools-configuration-category.js +1 -1
  39. package/lib/browser/ai-configuration/categories/tools-configuration-category.js.map +1 -1
  40. package/lib/browser/ai-configuration/categories/variables-configuration-category.js +1 -1
  41. package/lib/browser/ai-configuration/categories/variables-configuration-category.js.map +1 -1
  42. package/lib/browser/ai-configuration/language-model-renderer.d.ts.map +1 -1
  43. package/lib/browser/ai-configuration/language-model-renderer.js +8 -15
  44. package/lib/browser/ai-configuration/language-model-renderer.js.map +1 -1
  45. package/lib/browser/ai-configuration/language-model-renderer.spec.js +40 -1
  46. package/lib/browser/ai-configuration/language-model-renderer.spec.js.map +1 -1
  47. package/lib/browser/ai-sessions-widget.js +1 -1
  48. package/lib/browser/ai-sessions-widget.js.map +1 -1
  49. package/lib/browser/app-tester-prompt-template.d.ts.map +1 -1
  50. package/lib/browser/app-tester-prompt-template.js +4 -6
  51. package/lib/browser/app-tester-prompt-template.js.map +1 -1
  52. package/lib/browser/architect-prompt-template.d.ts.map +1 -1
  53. package/lib/browser/architect-prompt-template.js +20 -3
  54. package/lib/browser/architect-prompt-template.js.map +1 -1
  55. package/lib/browser/chat-session-item.js +2 -1
  56. package/lib/browser/chat-session-item.js.map +1 -1
  57. package/lib/browser/chat-sessions-welcome-message-provider.js +1 -1
  58. package/lib/browser/chat-sessions-welcome-message-provider.js.map +1 -1
  59. package/lib/browser/code-reviewer-prompt-template.d.ts.map +1 -1
  60. package/lib/browser/code-reviewer-prompt-template.js +2 -1
  61. package/lib/browser/code-reviewer-prompt-template.js.map +1 -1
  62. package/lib/browser/commit-message-agent.spec.js +2 -1
  63. package/lib/browser/commit-message-agent.spec.js.map +1 -1
  64. package/lib/browser/commit-message-runner.spec.js +2 -1
  65. package/lib/browser/commit-message-runner.spec.js.map +1 -1
  66. package/lib/browser/context-file-validation-service-impl.spec.js +2 -1
  67. package/lib/browser/context-file-validation-service-impl.spec.js.map +1 -1
  68. package/lib/browser/explore-prompt-template.d.ts.map +1 -1
  69. package/lib/browser/explore-prompt-template.js +2 -1
  70. package/lib/browser/explore-prompt-template.js.map +1 -1
  71. package/lib/browser/file-changeset-functions.d.ts +3 -1
  72. package/lib/browser/file-changeset-functions.d.ts.map +1 -1
  73. package/lib/browser/file-changeset-functions.js +60 -6
  74. package/lib/browser/file-changeset-functions.js.map +1 -1
  75. package/lib/browser/file-changeset-functions.spec.js +73 -9
  76. package/lib/browser/file-changeset-functions.spec.js.map +1 -1
  77. package/lib/browser/frontend-module.js +4 -4
  78. package/lib/browser/frontend-module.js.map +1 -1
  79. package/lib/browser/git-changes-tool.d.ts +3 -3
  80. package/lib/browser/git-changes-tool.d.ts.map +1 -1
  81. package/lib/browser/git-changes-tool.js +7 -11
  82. package/lib/browser/git-changes-tool.js.map +1 -1
  83. package/lib/browser/git-changes-tool.spec.js +16 -3
  84. package/lib/browser/git-changes-tool.spec.js.map +1 -1
  85. package/lib/browser/multi-root-paths.spec.d.ts +2 -0
  86. package/lib/browser/multi-root-paths.spec.d.ts.map +1 -0
  87. package/lib/browser/multi-root-paths.spec.js +293 -0
  88. package/lib/browser/multi-root-paths.spec.js.map +1 -0
  89. package/lib/browser/remember-command-contribution.d.ts +2 -2
  90. package/lib/browser/remember-command-contribution.js +6 -6
  91. package/lib/browser/remember-command-contribution.js.map +1 -1
  92. package/lib/browser/review/pr-review-prompt-template.d.ts.map +1 -1
  93. package/lib/browser/review/pr-review-prompt-template.js +3 -2
  94. package/lib/browser/review/pr-review-prompt-template.js.map +1 -1
  95. package/lib/browser/task-context-file-storage-service.d.ts.map +1 -1
  96. package/lib/browser/task-context-file-storage-service.js +1 -2
  97. package/lib/browser/task-context-file-storage-service.js.map +1 -1
  98. package/lib/browser/task-context-file-storage-service.spec.d.ts +2 -0
  99. package/lib/browser/task-context-file-storage-service.spec.d.ts.map +1 -0
  100. package/lib/browser/task-context-file-storage-service.spec.js +111 -0
  101. package/lib/browser/task-context-file-storage-service.spec.js.map +1 -0
  102. package/lib/browser/user-interaction-tool-renderer.js +1 -1
  103. package/lib/browser/user-interaction-tool-renderer.js.map +1 -1
  104. package/lib/browser/user-interaction-tool.d.ts +12 -1
  105. package/lib/browser/user-interaction-tool.d.ts.map +1 -1
  106. package/lib/browser/user-interaction-tool.js +35 -9
  107. package/lib/browser/user-interaction-tool.js.map +1 -1
  108. package/lib/browser/user-interaction-tool.spec.js +15 -2
  109. package/lib/browser/user-interaction-tool.spec.js.map +1 -1
  110. package/lib/browser/workspace-functions.d.ts +20 -17
  111. package/lib/browser/workspace-functions.d.ts.map +1 -1
  112. package/lib/browser/workspace-functions.js +77 -115
  113. package/lib/browser/workspace-functions.js.map +1 -1
  114. package/lib/browser/workspace-functions.spec.js +54 -60
  115. package/lib/browser/workspace-functions.spec.js.map +1 -1
  116. package/lib/browser/workspace-launch-provider.js +1 -1
  117. package/lib/browser/workspace-launch-provider.js.map +1 -1
  118. package/lib/browser/workspace-launch-provider.spec.js +5 -3
  119. package/lib/browser/workspace-launch-provider.spec.js.map +1 -1
  120. package/lib/browser/workspace-search-provider.spec.js +2 -1
  121. package/lib/browser/workspace-search-provider.spec.js.map +1 -1
  122. package/lib/browser/workspace-task-provider.js +1 -1
  123. package/lib/browser/workspace-task-provider.js.map +1 -1
  124. package/lib/browser/workspace-task-provider.spec.js +6 -4
  125. package/lib/browser/workspace-task-provider.spec.js.map +1 -1
  126. package/lib/common/agents-md-prompt-template.d.ts +6 -0
  127. package/lib/common/agents-md-prompt-template.d.ts.map +1 -0
  128. package/lib/common/agents-md-prompt-template.js +165 -0
  129. package/lib/common/agents-md-prompt-template.js.map +1 -0
  130. package/lib/common/coder-replace-prompt-template.d.ts.map +1 -1
  131. package/lib/common/coder-replace-prompt-template.js +4 -6
  132. package/lib/common/coder-replace-prompt-template.js.map +1 -1
  133. package/lib/common/command-prompt-template.js +1 -1
  134. package/lib/common/command-prompt-template.js.map +1 -1
  135. package/lib/common/orchestrator-prompt-template.js +1 -1
  136. package/lib/common/orchestrator-prompt-template.js.map +1 -1
  137. package/lib/common/universal-prompt-template.js +1 -1
  138. package/lib/common/universal-prompt-template.js.map +1 -1
  139. package/lib/common/workspace-preferences.d.ts +1 -0
  140. package/lib/common/workspace-preferences.d.ts.map +1 -1
  141. package/lib/common/workspace-preferences.js +10 -1
  142. package/lib/common/workspace-preferences.js.map +1 -1
  143. package/lib/package.spec.js +1 -0
  144. package/lib/package.spec.js.map +1 -1
  145. package/package.json +27 -28
  146. package/src/browser/{project-info-agent.ts → agents-md-agent.ts} +11 -10
  147. package/src/browser/ai-configuration/categories/agent-capabilities-settings.spec.ts +508 -2
  148. package/src/browser/ai-configuration/categories/agent-capabilities-settings.tsx +92 -33
  149. package/src/browser/ai-configuration/categories/agent-detail-model.spec.ts +78 -0
  150. package/src/browser/ai-configuration/categories/agent-detail-model.ts +18 -0
  151. package/src/browser/ai-configuration/categories/agent-detail-view.tsx +15 -12
  152. package/src/browser/ai-configuration/categories/agents-configuration-category.tsx +18 -3
  153. package/src/browser/ai-configuration/categories/provider-model-discovery-section.tsx +3 -3
  154. package/src/browser/ai-configuration/categories/token-usage-configuration-category.tsx +2 -2
  155. package/src/browser/ai-configuration/language-model-renderer.spec.ts +38 -0
  156. package/src/browser/ai-configuration/language-model-renderer.tsx +6 -15
  157. package/src/browser/app-tester-prompt-template.ts +4 -7
  158. package/src/browser/architect-prompt-template.ts +4 -4
  159. package/src/browser/code-reviewer-prompt-template.ts +2 -2
  160. package/src/browser/context-file-validation-service-impl.spec.ts +2 -1
  161. package/src/browser/explore-prompt-template.ts +2 -2
  162. package/src/browser/file-changeset-functions.spec.ts +91 -9
  163. package/src/browser/file-changeset-functions.ts +62 -7
  164. package/src/browser/frontend-module.ts +4 -4
  165. package/src/browser/git-changes-tool.spec.ts +16 -1
  166. package/src/browser/git-changes-tool.ts +6 -10
  167. package/src/browser/multi-root-paths.spec.ts +340 -0
  168. package/src/browser/remember-command-contribution.ts +7 -7
  169. package/src/browser/review/pr-review-prompt-template.ts +3 -3
  170. package/src/browser/style/index.css +15 -0
  171. package/src/browser/task-context-file-storage-service.spec.ts +125 -0
  172. package/src/browser/task-context-file-storage-service.ts +3 -4
  173. package/src/browser/user-interaction-tool.spec.ts +18 -1
  174. package/src/browser/user-interaction-tool.ts +34 -9
  175. package/src/browser/workspace-functions.spec.ts +54 -60
  176. package/src/browser/workspace-functions.ts +80 -125
  177. package/src/browser/workspace-launch-provider.spec.ts +3 -2
  178. package/src/browser/workspace-task-provider.spec.ts +4 -3
  179. package/src/common/{project-info-prompt-template.ts → agents-md-prompt-template.ts} +54 -46
  180. package/src/common/coder-replace-prompt-template.ts +5 -7
  181. package/src/common/command-prompt-template.ts +1 -1
  182. package/src/common/orchestrator-prompt-template.ts +1 -1
  183. package/src/common/universal-prompt-template.ts +1 -1
  184. package/src/common/workspace-preferences.ts +10 -0
  185. package/lib/browser/project-info-agent.d.ts.map +0 -1
  186. package/lib/browser/project-info-agent.js.map +0 -1
  187. package/lib/common/project-info-prompt-template.d.ts +0 -6
  188. package/lib/common/project-info-prompt-template.d.ts.map +0 -1
  189. package/lib/common/project-info-prompt-template.js +0 -146
  190. package/lib/common/project-info-prompt-template.js.map +0 -1
@@ -70,7 +70,8 @@ const CONTENT_REF_SCHEMA: ToolRequestParameterProperty = {
70
70
  properties: {
71
71
  path: {
72
72
  type: 'string',
73
- description: 'Workspace-relative file path. Required unless "empty" is true.'
73
+ description: 'File path, in the format of the workspace tools: workspace-relative (\'rootName/path\') or absolute. ' +
74
+ 'Required unless "empty" is true.'
74
75
  },
75
76
  gitRef: {
76
77
  type: 'string',
@@ -308,9 +309,11 @@ export class UserInteractionTool implements ToolProvider {
308
309
  }
309
310
  const left = resolveContentRef(link.ref) as PathContentRef;
310
311
  if (left.gitRef) {
311
- const uri = this.resolveUri(left);
312
+ const uri = await this.resolveUriOrNotFound(left);
312
313
  let targetUri: URI;
313
- if (uri === undefined) {
314
+ if (uri === 'notFound') {
315
+ targetUri = this.fileNotFoundUri(left.path);
316
+ } else if (uri === undefined) {
314
317
  targetUri = this.errorContentUri(left.path, left.gitRef);
315
318
  } else if (await this.canResolveUri(uri)) {
316
319
  targetUri = uri;
@@ -321,8 +324,8 @@ export class UserInteractionTool implements ToolProvider {
321
324
  }
322
325
  await open(this.openerService, targetUri);
323
326
  } else {
324
- const fileUri = this.workspaceScope.resolveRelativePath(left.path);
325
- if (!(await this.canResolveUri(fileUri))) {
327
+ const fileUri = await this.resolveUriOrNotFound(left);
328
+ if (fileUri === 'notFound' || fileUri === undefined || !(await this.canResolveUri(fileUri))) {
326
329
  await open(this.openerService, this.fileNotFoundUri(left.path));
327
330
  return;
328
331
  }
@@ -334,10 +337,29 @@ export class UserInteractionTool implements ToolProvider {
334
337
  }
335
338
  }
336
339
 
337
- protected resolveUri(
340
+ /**
341
+ * Resolves a content reference like {@link resolveUri}, or returns `'notFound'` if its path cannot
342
+ * be resolved, e.g. because it lacks the root name in a multi-root workspace.
343
+ */
344
+ protected async resolveUriOrNotFound(ref: PathContentRef): Promise<URI | undefined | 'notFound'> {
345
+ try {
346
+ return await this.resolveUri(ref);
347
+ } catch (error) {
348
+ this.logger.warn(`Could not resolve '${ref.path}': ${error.message}`);
349
+ return 'notFound';
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Resolves a content reference with the same parsing and access checks as the workspace tools.
355
+ *
356
+ * @returns `undefined` if the reference has a git ref that no SCM repository can resolve.
357
+ * @throws if the path cannot be resolved or may not be accessed.
358
+ */
359
+ protected async resolveUri(
338
360
  ref: PathContentRef
339
- ): URI | undefined {
340
- const fileUri = this.workspaceScope.resolveRelativePath(ref.path);
361
+ ): Promise<URI | undefined> {
362
+ const fileUri = await this.workspaceScope.resolveAccessiblePath(ref.path);
341
363
  if (ref.gitRef) {
342
364
  const repo = this.scmService.findRepository(fileUri);
343
365
  if (repo) {
@@ -421,7 +443,10 @@ export class UserInteractionTool implements ToolProvider {
421
443
  return this.emptyContentUri(ref.label || '');
422
444
  }
423
445
  const resolved = resolveContentRef(ref) as PathContentRef;
424
- const uri = this.resolveUri(resolved);
446
+ const uri = await this.resolveUriOrNotFound(resolved);
447
+ if (uri === 'notFound') {
448
+ return this.fileNotFoundUri(resolved.path);
449
+ }
425
450
  if (uri === undefined) {
426
451
  // No SCM provider could resolve the gitRef — surface as an actionable error.
427
452
  return this.errorContentUri(resolved.path, resolved.gitRef!);
@@ -44,6 +44,7 @@ import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';
44
44
  import { FileSearchService } from '@theia/file-search/lib/common/file-search-service';
45
45
  import { Minimatch } from 'minimatch';
46
46
  import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
47
+ import { withWorkspaceServiceDefaults } from '@theia/workspace/lib/browser/test/with-workspace-service-defaults';
47
48
 
48
49
  const makeFileSearchService = (
49
50
  impl?: (searchPattern: string, options: FileSearchService.Options) => Promise<string[]>
@@ -168,7 +169,7 @@ describe('Workspace Functions Cancellation Tests', () => {
168
169
 
169
170
  // Register mocks in the container
170
171
  container.bind(ILogger).to(MockLogger);
171
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
172
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
172
173
  container.bind(FileService).toConstantValue(mockFileService);
173
174
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
174
175
  container.bind(MonacoWorkspace).toConstantValue(mockMonacoWorkspace);
@@ -294,7 +295,7 @@ describe('FileContentFunction.getArgumentsShortLabel', () => {
294
295
  } as unknown as MonacoWorkspace;
295
296
 
296
297
  container.bind(ILogger).to(MockLogger);
297
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
298
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
298
299
  container.bind(FileService).toConstantValue(mockFileService);
299
300
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
300
301
  container.bind(MonacoWorkspace).toConstantValue(mockMonacoWorkspace);
@@ -413,7 +414,7 @@ describe('FileContentFunction handler', () => {
413
414
  } as unknown as MonacoWorkspace;
414
415
 
415
416
  container.bind(ILogger).to(MockLogger);
416
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
417
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
417
418
  container.bind(FileService).toConstantValue(mockFileService);
418
419
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
419
420
  container.bind(MonacoWorkspace).toConstantValue(mockMonacoWorkspace);
@@ -779,7 +780,7 @@ describe('FindFilesByPattern.getArgumentsShortLabel', () => {
779
780
  };
780
781
 
781
782
  container.bind(ILogger).to(MockLogger);
782
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
783
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
783
784
  container.bind(FileService).toConstantValue(mockFileService);
784
785
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
785
786
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -872,7 +873,7 @@ describe('FindFilesByPattern.findFiles', () => {
872
873
  fileSearchService = makeFileSearchService(async () => searchResults);
873
874
 
874
875
  container.bind(ILogger).to(MockLogger);
875
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
876
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
876
877
  container.bind(FileService).toConstantValue(mockFileService);
877
878
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
878
879
  container.bind(AiConfigurationService).toConstantValue(trustAwareReader);
@@ -1023,7 +1024,7 @@ describe('WorkspaceFunctionScope gitignore caching', () => {
1023
1024
  };
1024
1025
 
1025
1026
  container.bind(ILogger).to(MockLogger);
1026
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1027
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1027
1028
  container.bind(FileService).toConstantValue(mockFileService);
1028
1029
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1029
1030
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1093,7 +1094,7 @@ describe('GetWorkspaceFileList resolves the target directory once', () => {
1093
1094
  const mockPreferenceService = { get: <T>(_path: string, def: T) => def };
1094
1095
 
1095
1096
  container.bind(ILogger).to(MockLogger);
1096
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1097
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1097
1098
  container.bind(FileService).toConstantValue(mockFileService);
1098
1099
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1099
1100
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1157,7 +1158,7 @@ describe('GetWorkspaceDirectoryStructure preserves empty folders', () => {
1157
1158
  };
1158
1159
 
1159
1160
  container.bind(ILogger).to(MockLogger);
1160
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1161
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1161
1162
  container.bind(FileService).toConstantValue(mockFileService);
1162
1163
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1163
1164
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1229,7 +1230,7 @@ describe('FileContentFunction external paths', () => {
1229
1230
  } as unknown as AiConfigurationService;
1230
1231
 
1231
1232
  container.bind(ILogger).to(MockLogger);
1232
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1233
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1233
1234
  container.bind(FileService).toConstantValue(mockFileService);
1234
1235
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1235
1236
  container.bind(MonacoWorkspace).toConstantValue(mockMonacoWorkspace);
@@ -1375,7 +1376,7 @@ describe('WorkspaceFunctionScope accessible root contributions', () => {
1375
1376
  }
1376
1377
  };
1377
1378
 
1378
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1379
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1379
1380
  container.bind(FileService).toConstantValue(mockFileService);
1380
1381
  container.bind(PreferenceService).toConstantValue({ get: <T>(_path: string, defaultValue: T) => defaultValue });
1381
1382
  container.bind(MonacoWorkspace).toConstantValue({ getTextDocument: () => undefined } as unknown as MonacoWorkspace);
@@ -1497,7 +1498,7 @@ describe('GetWorkspaceFileList / GetWorkspaceDirectoryStructure with external pa
1497
1498
  } as unknown as AiConfigurationService;
1498
1499
 
1499
1500
  container.bind(ILogger).to(MockLogger);
1500
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1501
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1501
1502
  container.bind(FileService).toConstantValue(mockFileService);
1502
1503
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1503
1504
  container.bind(AiConfigurationService).toConstantValue(trustAwareReader);
@@ -1597,7 +1598,7 @@ describe('FindFilesByPattern with searchRoot', () => {
1597
1598
  } as unknown as AiConfigurationService;
1598
1599
 
1599
1600
  container.bind(ILogger).to(MockLogger);
1600
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1601
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1601
1602
  container.bind(FileService).toConstantValue(mockFileService);
1602
1603
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1603
1604
  container.bind(AiConfigurationService).toConstantValue(trustAwareReader);
@@ -1693,7 +1694,7 @@ describe('WorkspaceFunctionScope path-traversal hardening', () => {
1693
1694
  } as unknown as AiConfigurationService;
1694
1695
 
1695
1696
  container.bind(ILogger).to(MockLogger);
1696
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1697
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1697
1698
  container.bind(FileService).toConstantValue(mockFileService);
1698
1699
  container.bind(PreferenceService).toConstantValue(mockPreferenceService);
1699
1700
  container.bind(MonacoWorkspace).toConstantValue(mockMonacoWorkspace);
@@ -1867,7 +1868,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1867
1868
  onWorkspaceChanged: () => ({ dispose: () => { } })
1868
1869
  } as unknown as WorkspaceService;
1869
1870
 
1870
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1871
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1871
1872
  container.bind(FileService).toConstantValue({} as FileService);
1872
1873
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1873
1874
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1890,7 +1891,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1890
1891
  onWorkspaceChanged: () => ({ dispose: () => { } })
1891
1892
  } as unknown as WorkspaceService;
1892
1893
 
1893
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1894
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1894
1895
  container.bind(FileService).toConstantValue({} as FileService);
1895
1896
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1896
1897
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1905,7 +1906,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1905
1906
  expect(mapping.get('shared')?.toString()).to.equal('file:///home/user/shared');
1906
1907
  });
1907
1908
 
1908
- it('uses first-wins for duplicate basenames (sorted by URI)', () => {
1909
+ it('names roots sharing a basename as peers', () => {
1909
1910
  const mockWorkspaceService = {
1910
1911
  tryGetRoots: () => [
1911
1912
  { resource: new URI('file:///alice/app') },
@@ -1914,7 +1915,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1914
1915
  onWorkspaceChanged: () => ({ dispose: () => { } })
1915
1916
  } as unknown as WorkspaceService;
1916
1917
 
1917
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1918
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1918
1919
  container.bind(FileService).toConstantValue({} as FileService);
1919
1920
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1920
1921
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1923,10 +1924,9 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1923
1924
  workspaceScope = container.get(WorkspaceFunctionScope);
1924
1925
 
1925
1926
  const mapping = workspaceScope.getRootMapping();
1926
- // Only one entry for 'app' — the first by URI sort order wins.
1927
- // The other root is still reachable via resolveRelativePath fallback.
1928
- expect(mapping.size).to.equal(1);
1929
- expect(mapping.get('app')?.toString()).to.equal('file:///alice/app');
1927
+ expect(mapping.size).to.equal(2);
1928
+ expect(mapping.get('alice/app')?.toString()).to.equal('file:///alice/app');
1929
+ expect(mapping.get('bob/app')?.toString()).to.equal('file:///bob/app');
1930
1930
  });
1931
1931
  });
1932
1932
 
@@ -1937,7 +1937,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1937
1937
  onWorkspaceChanged: () => ({ dispose: () => { } })
1938
1938
  } as unknown as WorkspaceService;
1939
1939
 
1940
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1940
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1941
1941
  container.bind(FileService).toConstantValue({} as FileService);
1942
1942
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1943
1943
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1959,7 +1959,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1959
1959
  onWorkspaceChanged: () => ({ dispose: () => { } })
1960
1960
  } as unknown as WorkspaceService;
1961
1961
 
1962
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1962
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1963
1963
  container.bind(FileService).toConstantValue({} as FileService);
1964
1964
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1965
1965
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1980,7 +1980,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1980
1980
  onWorkspaceChanged: () => ({ dispose: () => { } })
1981
1981
  } as unknown as WorkspaceService;
1982
1982
 
1983
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
1983
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
1984
1984
  container.bind(FileService).toConstantValue({} as FileService);
1985
1985
  container.bind(PreferenceService).toConstantValue({ get: () => false });
1986
1986
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -1999,7 +1999,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
1999
1999
  onWorkspaceChanged: () => ({ dispose: () => { } })
2000
2000
  } as unknown as WorkspaceService;
2001
2001
 
2002
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2002
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2003
2003
  container.bind(FileService).toConstantValue({} as FileService);
2004
2004
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2005
2005
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2021,7 +2021,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2021
2021
  tryGetRoots: () => rootObjects,
2022
2022
  onWorkspaceChanged: () => ({ dispose: () => { } })
2023
2023
  } as unknown as WorkspaceService;
2024
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2024
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2025
2025
  container.bind(FileService).toConstantValue({} as FileService);
2026
2026
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2027
2027
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2152,45 +2152,41 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2152
2152
  });
2153
2153
 
2154
2154
  describe('duplicate root basenames', () => {
2155
- it('round-trips the mapped root correctly', () => {
2155
+ it('names all roots sharing a basename as peers and round-trips each of them', () => {
2156
2156
  workspaceScope = createScope(['file:///workspace/a/app', 'file:///workspace/b/app']);
2157
2157
  const mapping = workspaceScope.getRootMapping();
2158
- expect(mapping.size).to.equal(1);
2159
- expect(mapping.get('app')?.toString()).to.equal('file:///workspace/a/app');
2158
+ expect(Array.from(mapping.keys())).to.deep.equal(['a/app', 'b/app']);
2160
2159
 
2161
- // Round-trip for the mapped root
2162
- const uri = mapping.get('app')!.resolve('src/index.ts');
2163
- const relPath = workspaceScope.toWorkspaceRelativePath(uri)!;
2164
- expect(relPath).to.equal('app/src/index.ts');
2165
- const resolved = workspaceScope.resolveRelativePath(relPath);
2166
- expect(resolved.toString()).to.equal(uri.toString());
2160
+ for (const [name, rootUri] of mapping) {
2161
+ const uri = rootUri.resolve('src/index.ts');
2162
+ const relPath = workspaceScope.toWorkspaceRelativePath(uri)!;
2163
+ expect(relPath).to.equal(`${name}/src/index.ts`);
2164
+ expect(workspaceScope.resolveRelativePath(relPath).toString()).to.equal(uri.toString());
2165
+ }
2167
2166
  });
2168
2167
 
2169
- it('unmapped root returns undefined from toWorkspaceRelativePath', () => {
2168
+ it('rejects the shared basename as ambiguous', () => {
2170
2169
  workspaceScope = createScope(['file:///workspace/a/app', 'file:///workspace/b/app']);
2171
- const uri = new URI('file:///workspace/b/app/src/index.ts');
2172
- const relPath = workspaceScope.toWorkspaceRelativePath(uri);
2173
- expect(relPath).to.be.undefined;
2170
+ expect(() => workspaceScope.resolveRelativePath('app/src/index.ts')).to.throw(/ambiguous.*a\/app.*b\/app/);
2174
2171
  });
2175
2172
 
2176
- it('resolves app/path to the mapped root (Phase 1)', () => {
2173
+ it('resolves a longer parent-qualified path (Phase 2)', () => {
2177
2174
  workspaceScope = createScope(['file:///workspace/a/app', 'file:///workspace/b/app']);
2178
- // 'app' maps to file:///workspace/a/app (first by URI sort)
2179
- const result = workspaceScope.resolveRelativePath('app/src/index.ts');
2180
- expect(result.toString()).to.equal('file:///workspace/a/app/src/index.ts');
2175
+ const result = workspaceScope.resolveRelativePath('workspace/b/app/src/index.ts');
2176
+ expect(result.toString()).to.equal('file:///workspace/b/app/src/index.ts');
2181
2177
  });
2182
2178
 
2183
- // The forms the external file change notice names files by: a root name for the mapped root, a uri for the other.
2184
- it('resolves a uri for the unmapped root', async () => {
2179
+ // The external file change notice names files by a uri when roots share a basename.
2180
+ it('resolves a uri for a root sharing its basename', async () => {
2185
2181
  workspaceScope = createScope(['file:///workspace/a/app', 'file:///workspace/b/app']);
2186
- const unmapped = 'file:///workspace/b/app/src/index.ts';
2187
- expect((await workspaceScope.resolveAccessiblePath(unmapped)).toString()).to.equal(unmapped);
2182
+ const uri = 'file:///workspace/b/app/src/index.ts';
2183
+ expect((await workspaceScope.resolveAccessiblePath(uri)).toString()).to.equal(uri);
2188
2184
  });
2189
2185
  });
2190
2186
  });
2191
2187
 
2192
2188
  describe('getRootMapping duplicate basename stability', () => {
2193
- it('assigns the same root to a name regardless of tryGetRoots order', () => {
2189
+ it('assigns the same name to a root regardless of tryGetRoots order', () => {
2194
2190
  // First ordering
2195
2191
  const mockWorkspaceServiceA = {
2196
2192
  tryGetRoots: () => [
@@ -2200,7 +2196,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2200
2196
  onWorkspaceChanged: () => ({ dispose: () => { } })
2201
2197
  } as unknown as WorkspaceService;
2202
2198
 
2203
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceServiceA);
2199
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceServiceA));
2204
2200
  container.bind(FileService).toConstantValue({} as FileService);
2205
2201
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2206
2202
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2220,7 +2216,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2220
2216
  } as unknown as WorkspaceService;
2221
2217
 
2222
2218
  container2.bind(ILogger).to(MockLogger);
2223
- container2.bind(WorkspaceService).toConstantValue(mockWorkspaceServiceB);
2219
+ container2.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceServiceB));
2224
2220
  container2.bind(FileService).toConstantValue({} as FileService);
2225
2221
  container2.bind(PreferenceService).toConstantValue({ get: () => false });
2226
2222
  container2.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2229,12 +2225,10 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2229
2225
  const scopeB = container2.get(WorkspaceFunctionScope);
2230
2226
  const mappingB = scopeB.getRootMapping();
2231
2227
 
2232
- // Both orderings should produce the same winner for 'app'
2233
- // (first by URI sort order: file:///workspace/a/app)
2234
- expect(mappingA.size).to.equal(1);
2235
- expect(mappingB.size).to.equal(1);
2236
- expect(mappingA.get('app')?.toString()).to.equal(mappingB.get('app')?.toString());
2237
- expect(mappingA.get('app')?.toString()).to.equal('file:///workspace/a/app');
2228
+ for (const name of ['a/app', 'b/app']) {
2229
+ expect(mappingA.get(name)?.toString()).to.equal(mappingB.get(name)?.toString());
2230
+ }
2231
+ expect(mappingA.get('a/app')?.toString()).to.equal('file:///workspace/a/app');
2238
2232
  });
2239
2233
  });
2240
2234
 
@@ -2248,7 +2242,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2248
2242
  onWorkspaceChanged: () => ({ dispose: () => { } })
2249
2243
  } as unknown as WorkspaceService;
2250
2244
 
2251
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2245
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2252
2246
  container.bind(FileService).toConstantValue({} as FileService);
2253
2247
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2254
2248
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2275,7 +2269,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2275
2269
  onWorkspaceChanged: () => ({ dispose: () => { } })
2276
2270
  } as unknown as WorkspaceService;
2277
2271
 
2278
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2272
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2279
2273
  container.bind(FileService).toConstantValue({} as FileService);
2280
2274
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2281
2275
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2299,7 +2293,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2299
2293
  onWorkspaceChanged: () => ({ dispose: () => { } })
2300
2294
  } as unknown as WorkspaceService;
2301
2295
 
2302
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2296
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2303
2297
  container.bind(FileService).toConstantValue({} as FileService);
2304
2298
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2305
2299
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());
@@ -2323,7 +2317,7 @@ describe('WorkspaceFunctionScope Multi-Root Tests', () => {
2323
2317
  onWorkspaceChanged: () => ({ dispose: () => { } })
2324
2318
  } as unknown as WorkspaceService;
2325
2319
 
2326
- container.bind(WorkspaceService).toConstantValue(mockWorkspaceService);
2320
+ container.bind(WorkspaceService).toConstantValue(withWorkspaceServiceDefaults(mockWorkspaceService));
2327
2321
  container.bind(FileService).toConstantValue({} as FileService);
2328
2322
  container.bind(PreferenceService).toConstantValue({ get: () => false });
2329
2323
  container.bind(AiConfigurationService).toConstantValue(makeTrustAwareReader());