@theia/ai-chat 1.74.0-next.0 → 1.74.0-next.10

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.
@@ -1,7 +1,8 @@
1
1
  import { PromptFragmentCustomizationService } from '@theia/ai-core';
2
2
  import { Command, CommandContribution, CommandRegistry, ILogger, MessageService } from '@theia/core';
3
- import { FrontendApplicationContribution } from '@theia/core/lib/browser';
3
+ import { FrontendApplicationContribution, LocalStorageService } from '@theia/core/lib/browser';
4
4
  import { CustomAgentFactory } from './custom-agent-factory';
5
+ type CustomAgentMigrationReports = Awaited<ReturnType<PromptFragmentCustomizationService['migrateCustomAgentsYaml']>>;
5
6
  export declare const RERUN_CUSTOM_AGENT_MIGRATION_COMMAND: Command;
6
7
  export declare class AICustomAgentsFrontendApplicationContribution implements FrontendApplicationContribution, CommandContribution {
7
8
  protected readonly customAgentFactory: CustomAgentFactory;
@@ -9,11 +10,31 @@ export declare class AICustomAgentsFrontendApplicationContribution implements Fr
9
10
  private readonly agentService;
10
11
  private readonly chatAgentService;
11
12
  protected readonly messageService?: MessageService;
13
+ protected readonly storageService: LocalStorageService;
12
14
  protected readonly logger: ILogger;
13
15
  private knownCustomAgents;
16
+ /** Ensures the migration consent prompt is shown at most once per session. */
17
+ protected migrationPromptShown: boolean;
18
+ /** Guards against concurrent pending-migration checks from re-entrant refreshes. */
19
+ protected migrationCheckInFlight: boolean;
14
20
  registerCommands(commands: CommandRegistry): void;
15
21
  onStart(): void;
16
22
  protected refreshCustomAgents(): Promise<void>;
23
+ /**
24
+ * Prompts the user once per session before migrating legacy `customAgents.yml` files (and before
25
+ * correcting agents migrated with merged headings by an earlier Theia version). Nothing is written
26
+ * until the user confirms. Declining is safe: legacy `customAgents.yml` files keep being loaded, so
27
+ * agents continue to work unmigrated, and the prompt reappears next session until they migrate or
28
+ * pick "Don't Show Again".
29
+ *
30
+ * This is intentionally not backed by a preference: the whole migration path is transitional and
31
+ * will be removed once the legacy format is no longer supported. The "don't show again" choice is
32
+ * persisted in local storage (like the dev-container suggestion), so there is no setting to retire.
33
+ */
34
+ protected maybeMigrate(): Promise<void>;
35
+ protected promptAndMigrate(): Promise<void>;
36
+ protected showMigrationSummary(reports: CustomAgentMigrationReports): void;
17
37
  onStop(): void;
18
38
  }
39
+ export {};
19
40
  //# sourceMappingURL=custom-agent-frontend-application-contribution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-agent-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAwC,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAO,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,eAAO,MAAM,oCAAoC,EAAE,OAQlD,CAAC;AAEF,qBACa,6CAA8C,YAAW,+BAA+B,EAAE,mBAAmB;IAEtH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,kCAAkC,CAAC;IAG5E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAG5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IAGpD,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IAGnD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,OAAO,CAAC,iBAAiB,CAAkD;IAE3E,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAoBjD,OAAO,IAAI,IAAI;cAKC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCpD,MAAM,IAAI,IAAI;CAEjB"}
1
+ {"version":3,"file":"custom-agent-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAwC,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAO,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAI/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,KAAK,2BAA2B,GAAG,OAAO,CAAC,UAAU,CAAC,kCAAkC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAKtH,eAAO,MAAM,oCAAoC,EAAE,OAQlD,CAAC;AAEF,qBACa,6CAA8C,YAAW,+BAA+B,EAAE,mBAAmB;IAEtH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,kCAAkC,CAAC;IAG5E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAG5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IAGpD,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IAGnD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAGvD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,OAAO,CAAC,iBAAiB,CAAkD;IAE3E,8EAA8E;IAC9E,SAAS,CAAC,oBAAoB,UAAS;IACvC,oFAAoF;IACpF,SAAS,CAAC,sBAAsB,UAAS;IAEzC,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAWjD,OAAO,IAAI,IAAI;cAKC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BpD;;;;;;;;;;OAUG;cACa,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAyB7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCjD,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAmB1E,MAAM,IAAI,IAAI;CAEjB"}
@@ -19,9 +19,13 @@ exports.AICustomAgentsFrontendApplicationContribution = exports.RERUN_CUSTOM_AGE
19
19
  const tslib_1 = require("tslib");
20
20
  const ai_core_1 = require("@theia/ai-core");
21
21
  const core_1 = require("@theia/core");
22
+ const browser_1 = require("@theia/core/lib/browser");
23
+ const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
22
24
  const inversify_1 = require("@theia/core/shared/inversify");
23
25
  const common_1 = require("../common");
24
26
  const custom_agent_factory_1 = require("./custom-agent-factory");
27
+ /** Local-storage key recording that the user dismissed the custom-agent migration prompt for good. */
28
+ const MIGRATION_DONT_SHOW_AGAIN_KEY = 'ai-chat.customAgents.migration.dontShowAgain';
25
29
  exports.RERUN_CUSTOM_AGENT_MIGRATION_COMMAND = core_1.Command.toLocalizedCommand({
26
30
  id: 'ai-chat.customAgents.rerunMigration',
27
31
  label: 'Re-run custom-agent migration',
@@ -30,6 +34,10 @@ exports.RERUN_CUSTOM_AGENT_MIGRATION_COMMAND = core_1.Command.toLocalizedCommand
30
34
  let AICustomAgentsFrontendApplicationContribution = class AICustomAgentsFrontendApplicationContribution {
31
35
  constructor() {
32
36
  this.knownCustomAgents = new Map();
37
+ /** Ensures the migration consent prompt is shown at most once per session. */
38
+ this.migrationPromptShown = false;
39
+ /** Guards against concurrent pending-migration checks from re-entrant refreshes. */
40
+ this.migrationCheckInFlight = false;
33
41
  }
34
42
  registerCommands(commands) {
35
43
  commands.registerCommand(exports.RERUN_CUSTOM_AGENT_MIGRATION_COMMAND, {
@@ -39,12 +47,7 @@ let AICustomAgentsFrontendApplicationContribution = class AICustomAgentsFrontend
39
47
  return;
40
48
  }
41
49
  const reports = await this.customizationService.migrateCustomAgentsYaml();
42
- const migrated = reports.reduce((sum, r) => sum + r.migrated, 0);
43
- const failed = reports.reduce((sum, r) => sum + r.failed, 0);
44
- const backedUp = reports.filter(r => r.yamlBackedUp).length;
45
- const overrides = reports.reduce((sum, r) => sum + r.promptOverridesMigrated, 0);
46
- const message = core_1.nls.localize('theia/ai/chat/customAgents/migrationResult', 'Custom-agent migration: {0} migrated, {1} failed, {2} legacy customAgents.yml backed up to .bak, {3} prompt overrides folded into agent.md.', migrated, failed, backedUp, overrides);
47
- this.messageService?.info(message);
50
+ this.showMigrationSummary(reports);
48
51
  }
49
52
  });
50
53
  }
@@ -58,14 +61,8 @@ let AICustomAgentsFrontendApplicationContribution = class AICustomAgentsFrontend
58
61
  }
59
62
  // Migration must run on the refresh path (not just at onStart) because the workspace's
60
63
  // additional template directories are populated asynchronously by TemplatePreferenceContribution
61
- // after preferences/workspace/trust are ready. Migration is idempotent: if a customAgents.yml has
62
- // already been migrated (or never existed), the call is a no-op.
63
- try {
64
- await this.customizationService.migrateCustomAgentsYaml();
65
- }
66
- catch (e) {
67
- this.logger.warn('Custom-agent auto-migration failed; continuing without migration', e);
68
- }
64
+ // after preferences/workspace/trust are ready.
65
+ await this.maybeMigrate();
69
66
  const customAgents = await this.customizationService.getCustomAgents();
70
67
  const customAgentsToAdd = customAgents.filter(agent => !this.knownCustomAgents.has(agent.id) || !ai_core_1.CustomAgentDescription.equals(this.knownCustomAgents.get(agent.id), agent));
71
68
  const customAgentIdsToRemove = [...this.knownCustomAgents.values()].filter(agent => !customAgents.find(a => ai_core_1.CustomAgentDescription.equals(a, agent))).map(a => a.id);
@@ -80,6 +77,87 @@ let AICustomAgentsFrontendApplicationContribution = class AICustomAgentsFrontend
80
77
  this.knownCustomAgents.set(agent.id, agent);
81
78
  });
82
79
  }
80
+ /**
81
+ * Prompts the user once per session before migrating legacy `customAgents.yml` files (and before
82
+ * correcting agents migrated with merged headings by an earlier Theia version). Nothing is written
83
+ * until the user confirms. Declining is safe: legacy `customAgents.yml` files keep being loaded, so
84
+ * agents continue to work unmigrated, and the prompt reappears next session until they migrate or
85
+ * pick "Don't Show Again".
86
+ *
87
+ * This is intentionally not backed by a preference: the whole migration path is transitional and
88
+ * will be removed once the legacy format is no longer supported. The "don't show again" choice is
89
+ * persisted in local storage (like the dev-container suggestion), so there is no setting to retire.
90
+ */
91
+ async maybeMigrate() {
92
+ if (!this.customizationService || !this.messageService) {
93
+ return;
94
+ }
95
+ if (this.migrationPromptShown || this.migrationCheckInFlight) {
96
+ return;
97
+ }
98
+ this.migrationCheckInFlight = true;
99
+ try {
100
+ if (await this.storageService.getData(MIGRATION_DONT_SHOW_AGAIN_KEY)) {
101
+ this.migrationPromptShown = true; // suppress further checks for this session too
102
+ return;
103
+ }
104
+ if (!(await this.customizationService.hasPendingCustomAgentMigration())) {
105
+ return;
106
+ }
107
+ this.migrationPromptShown = true;
108
+ await this.promptAndMigrate();
109
+ }
110
+ catch (e) {
111
+ this.logger.warn('Custom-agent migration check failed; continuing without migration', e);
112
+ }
113
+ finally {
114
+ this.migrationCheckInFlight = false;
115
+ }
116
+ }
117
+ async promptAndMigrate() {
118
+ if (!this.customizationService || !this.messageService) {
119
+ return;
120
+ }
121
+ const migrate = core_1.nls.localizeByDefault('Migrate');
122
+ const notNow = core_1.nls.localizeByDefault('Not Now');
123
+ const dontShowAgain = core_1.nls.localizeByDefault("Don't Show Again");
124
+ const message = core_1.nls.localize('theia/ai/chat/customAgents/migratePrompt/message', 'Your custom agents still use the older `customAgents.yml` format. '
125
+ + 'We recommend migrating them to the new per-agent format (`agents/<id>/agent.md`), which {0} uses going forward. '
126
+ + 'Each agent gets its own file next to your `customAgents.yml`, and the original is kept as a `customAgents.yml.bak` backup.', frontend_application_config_provider_1.FrontendApplicationConfigProvider.get().applicationName);
127
+ const choice = await this.messageService.info(message, migrate, notNow, dontShowAgain);
128
+ if (choice === migrate) {
129
+ try {
130
+ const reports = await this.customizationService.migrateCustomAgentsYaml();
131
+ this.showMigrationSummary(reports);
132
+ }
133
+ catch (e) {
134
+ this.logger.warn('Custom-agent migration failed', e);
135
+ }
136
+ }
137
+ else if (choice === dontShowAgain) {
138
+ try {
139
+ await this.storageService.setData(MIGRATION_DONT_SHOW_AGAIN_KEY, true);
140
+ }
141
+ catch (e) {
142
+ this.logger.warn('Failed to persist custom-agent migration prompt state', e);
143
+ }
144
+ }
145
+ // 'Not Now' or dismissal: do nothing; the prompt reappears next session until migrated or dismissed for good.
146
+ }
147
+ showMigrationSummary(reports) {
148
+ if (reports.length === 0) {
149
+ this.messageService?.info(core_1.nls.localize('theia/ai/chat/customAgents/migrationResult/empty', 'Custom-agent migration: nothing to migrate.'));
150
+ return;
151
+ }
152
+ const migrated = reports.reduce((sum, r) => sum + r.migrated, 0);
153
+ const corrected = reports.reduce((sum, r) => sum + r.corrected, 0);
154
+ const failed = reports.reduce((sum, r) => sum + r.failed, 0);
155
+ const backedUp = reports.filter(r => r.yamlBackedUp).length;
156
+ const overrides = reports.reduce((sum, r) => sum + r.promptOverridesMigrated, 0);
157
+ const message = core_1.nls.localize('theia/ai/chat/customAgents/migrationResult', 'Custom-agent migration: {0} migrated, {1} corrected, {2} failed, {3} legacy customAgents.yml backed up to .bak, {4} prompt overrides folded into agent.md.', migrated, corrected, failed, backedUp, overrides);
158
+ // Keep the result visible until the user dismisses it (no auto-hide timeout).
159
+ this.messageService?.info(message, { timeout: 0 });
160
+ }
83
161
  onStop() {
84
162
  }
85
163
  };
@@ -106,6 +184,10 @@ tslib_1.__decorate([
106
184
  (0, inversify_1.optional)(),
107
185
  tslib_1.__metadata("design:type", core_1.MessageService)
108
186
  ], AICustomAgentsFrontendApplicationContribution.prototype, "messageService", void 0);
187
+ tslib_1.__decorate([
188
+ (0, inversify_1.inject)(browser_1.LocalStorageService),
189
+ tslib_1.__metadata("design:type", browser_1.LocalStorageService)
190
+ ], AICustomAgentsFrontendApplicationContribution.prototype, "storageService", void 0);
109
191
  tslib_1.__decorate([
110
192
  (0, inversify_1.inject)(core_1.ILogger),
111
193
  (0, inversify_1.named)('ai-chat:AICustomAgentsFrontendApplicationContribution'),
@@ -1 +1 @@
1
- {"version":3,"file":"custom-agent-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4CAA0G;AAC1G,sCAA0G;AAE1G,4DAAmF;AACnF,sCAA6C;AAC7C,iEAA4D;AAE/C,QAAA,oCAAoC,GAAY,cAAO,CAAC,kBAAkB,CACnF;IACI,EAAE,EAAE,qCAAqC;IACzC,KAAK,EAAE,+BAA+B;IACtC,QAAQ,EAAE,IAAI;CACjB,EACD,2CAA2C,EAC3C,wBAAwB,CAC3B,CAAC;AAGK,IAAM,6CAA6C,GAAnD,MAAM,6CAA6C;IAAnD;QAmBK,sBAAiB,GAAwC,IAAI,GAAG,EAAE,CAAC;IA6D/E,CAAC;IA3DG,gBAAgB,CAAC,QAAyB;QACtC,QAAQ,CAAC,eAAe,CAAC,4CAAoC,EAAE;YAC3D,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB;YAC5C,OAAO,EAAE,KAAK,IAAI,EAAE;gBAChB,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;oBAAC,OAAO;gBAAC,CAAC;gBAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;gBAC1E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,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AK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;YACzI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM;IACN,CAAC;CACJ,CAAA;AAhFY,sGAA6C;AAEnC;IADlB,IAAA,kBAAM,EAAC,yCAAkB,CAAC;;yFAC+B;AAGvC;IADlB,IAAA,kBAAM,EAAC,4CAAkC,CAAC;IAAE,IAAA,oBAAQ,GAAE;;2FACqB;AAG3D;IADhB,IAAA,kBAAM,EAAC,sBAAY,CAAC;;mFACuB;AAG3B;IADhB,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;uFAC2B;AAGjC;IADlB,IAAA,kBAAM,EAAC,qBAAc,CAAC;IAAE,IAAA,oBAAQ,GAAE;sCACC,qBAAc;qFAAC;AAGhC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,uDAAuD,CAAC;;6EAC7C;wDAjB1B,6CAA6C;IADzD,IAAA,sBAAU,GAAE;GACA,6CAA6C,CAgFzD"}
1
+ {"version":3,"file":"custom-agent-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4CAA0G;AAC1G,sCAA0G;AAC1G,qDAA+F;AAC/F,uHAAiH;AACjH,4DAAmF;AACnF,sCAA6C;AAC7C,iEAA4D;AAI5D,sGAAsG;AACtG,MAAM,6BAA6B,G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Y,CAAC;;mFACuB;AAG3B;IADhB,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;uFAC2B;AAGjC;IADlB,IAAA,kBAAM,EAAC,qBAAc,CAAC;IAAE,IAAA,oBAAQ,GAAE;sCACC,qBAAc;qFAAC;AAGhC;IADlB,IAAA,kBAAM,EAAC,6BAAmB,CAAC;sCACO,6BAAmB;qFAAC;AAGpC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,uDAAuD,CAAC;;6EAC7C;wDApB1B,6CAA6C;IADzD,IAAA,sBAAU,GAAE;GACA,6CAA6C,CAiKzD"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@theia/ai-chat",
3
- "version": "1.74.0-next.0+72573426f",
3
+ "version": "1.74.0-next.10+a3326786b",
4
4
  "description": "Theia - AI Chat Extension",
5
5
  "dependencies": {
6
- "@theia/ai-core": "1.74.0-next.0+72573426f",
7
- "@theia/core": "1.74.0-next.0+72573426f",
8
- "@theia/editor": "1.74.0-next.0+72573426f",
9
- "@theia/file-search": "1.74.0-next.0+72573426f",
10
- "@theia/filesystem": "1.74.0-next.0+72573426f",
11
- "@theia/monaco": "1.74.0-next.0+72573426f",
6
+ "@theia/ai-core": "1.74.0-next.10+a3326786b",
7
+ "@theia/core": "1.74.0-next.10+a3326786b",
8
+ "@theia/editor": "1.74.0-next.10+a3326786b",
9
+ "@theia/file-search": "1.74.0-next.10+a3326786b",
10
+ "@theia/filesystem": "1.74.0-next.10+a3326786b",
11
+ "@theia/monaco": "1.74.0-next.10+a3326786b",
12
12
  "@theia/monaco-editor-core": "1.108.201",
13
- "@theia/workspace": "1.74.0-next.0+72573426f",
13
+ "@theia/workspace": "1.74.0-next.10+a3326786b",
14
14
  "js-yaml": "^4.2.0",
15
15
  "tslib": "^2.8.1"
16
16
  },
@@ -54,5 +54,5 @@
54
54
  "nyc": {
55
55
  "extends": "../../configs/nyc.json"
56
56
  },
57
- "gitHead": "72573426f320fefc89a96ba55ce05c752d182123"
57
+ "gitHead": "a3326786bf47e6e12172815eba3578ca4234bb23"
58
58
  }
@@ -16,11 +16,17 @@
16
16
 
17
17
  import { AgentService, CustomAgentDescription, PromptFragmentCustomizationService } from '@theia/ai-core';
18
18
  import { Command, CommandContribution, CommandRegistry, ILogger, MessageService, nls } from '@theia/core';
19
- import { FrontendApplicationContribution } from '@theia/core/lib/browser';
19
+ import { FrontendApplicationContribution, LocalStorageService } from '@theia/core/lib/browser';
20
+ import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
20
21
  import { inject, injectable, optional, named } from '@theia/core/shared/inversify';
21
22
  import { ChatAgentService } from '../common';
22
23
  import { CustomAgentFactory } from './custom-agent-factory';
23
24
 
25
+ type CustomAgentMigrationReports = Awaited<ReturnType<PromptFragmentCustomizationService['migrateCustomAgentsYaml']>>;
26
+
27
+ /** Local-storage key recording that the user dismissed the custom-agent migration prompt for good. */
28
+ const MIGRATION_DONT_SHOW_AGAIN_KEY = 'ai-chat.customAgents.migration.dontShowAgain';
29
+
24
30
  export const RERUN_CUSTOM_AGENT_MIGRATION_COMMAND: Command = Command.toLocalizedCommand(
25
31
  {
26
32
  id: 'ai-chat.customAgents.rerunMigration',
@@ -48,27 +54,26 @@ export class AICustomAgentsFrontendApplicationContribution implements FrontendAp
48
54
  @inject(MessageService) @optional()
49
55
  protected readonly messageService?: MessageService;
50
56
 
57
+ @inject(LocalStorageService)
58
+ protected readonly storageService: LocalStorageService;
59
+
51
60
  @inject(ILogger) @named('ai-chat:AICustomAgentsFrontendApplicationContribution')
52
61
  protected readonly logger: ILogger;
53
62
 
54
63
  private knownCustomAgents: Map<string, CustomAgentDescription> = new Map();
55
64
 
65
+ /** Ensures the migration consent prompt is shown at most once per session. */
66
+ protected migrationPromptShown = false;
67
+ /** Guards against concurrent pending-migration checks from re-entrant refreshes. */
68
+ protected migrationCheckInFlight = false;
69
+
56
70
  registerCommands(commands: CommandRegistry): void {
57
71
  commands.registerCommand(RERUN_CUSTOM_AGENT_MIGRATION_COMMAND, {
58
72
  isEnabled: () => !!this.customizationService,
59
73
  execute: async () => {
60
74
  if (!this.customizationService) { return; }
61
75
  const reports = await this.customizationService.migrateCustomAgentsYaml();
62
- const migrated = reports.reduce((sum, r) => sum + r.migrated, 0);
63
- const failed = reports.reduce((sum, r) => sum + r.failed, 0);
64
- const backedUp = reports.filter(r => r.yamlBackedUp).length;
65
- const overrides = reports.reduce((sum, r) => sum + r.promptOverridesMigrated, 0);
66
- const message = nls.localize(
67
- 'theia/ai/chat/customAgents/migrationResult',
68
- 'Custom-agent migration: {0} migrated, {1} failed, {2} legacy customAgents.yml backed up to .bak, {3} prompt overrides folded into agent.md.',
69
- migrated, failed, backedUp, overrides
70
- );
71
- this.messageService?.info(message);
76
+ this.showMigrationSummary(reports);
72
77
  }
73
78
  });
74
79
  }
@@ -84,13 +89,8 @@ export class AICustomAgentsFrontendApplicationContribution implements FrontendAp
84
89
  }
85
90
  // Migration must run on the refresh path (not just at onStart) because the workspace's
86
91
  // additional template directories are populated asynchronously by TemplatePreferenceContribution
87
- // after preferences/workspace/trust are ready. Migration is idempotent: if a customAgents.yml has
88
- // already been migrated (or never existed), the call is a no-op.
89
- try {
90
- await this.customizationService.migrateCustomAgentsYaml();
91
- } catch (e) {
92
- this.logger.warn('Custom-agent auto-migration failed; continuing without migration', e);
93
- }
92
+ // after preferences/workspace/trust are ready.
93
+ await this.maybeMigrate();
94
94
 
95
95
  const customAgents = await this.customizationService.getCustomAgents();
96
96
  const customAgentsToAdd = customAgents.filter(agent =>
@@ -110,6 +110,93 @@ export class AICustomAgentsFrontendApplicationContribution implements FrontendAp
110
110
  });
111
111
  }
112
112
 
113
+ /**
114
+ * Prompts the user once per session before migrating legacy `customAgents.yml` files (and before
115
+ * correcting agents migrated with merged headings by an earlier Theia version). Nothing is written
116
+ * until the user confirms. Declining is safe: legacy `customAgents.yml` files keep being loaded, so
117
+ * agents continue to work unmigrated, and the prompt reappears next session until they migrate or
118
+ * pick "Don't Show Again".
119
+ *
120
+ * This is intentionally not backed by a preference: the whole migration path is transitional and
121
+ * will be removed once the legacy format is no longer supported. The "don't show again" choice is
122
+ * persisted in local storage (like the dev-container suggestion), so there is no setting to retire.
123
+ */
124
+ protected async maybeMigrate(): Promise<void> {
125
+ if (!this.customizationService || !this.messageService) {
126
+ return;
127
+ }
128
+ if (this.migrationPromptShown || this.migrationCheckInFlight) {
129
+ return;
130
+ }
131
+ this.migrationCheckInFlight = true;
132
+ try {
133
+ if (await this.storageService.getData<boolean>(MIGRATION_DONT_SHOW_AGAIN_KEY)) {
134
+ this.migrationPromptShown = true; // suppress further checks for this session too
135
+ return;
136
+ }
137
+ if (!(await this.customizationService.hasPendingCustomAgentMigration())) {
138
+ return;
139
+ }
140
+ this.migrationPromptShown = true;
141
+ await this.promptAndMigrate();
142
+ } catch (e) {
143
+ this.logger.warn('Custom-agent migration check failed; continuing without migration', e);
144
+ } finally {
145
+ this.migrationCheckInFlight = false;
146
+ }
147
+ }
148
+
149
+ protected async promptAndMigrate(): Promise<void> {
150
+ if (!this.customizationService || !this.messageService) {
151
+ return;
152
+ }
153
+ const migrate = nls.localizeByDefault('Migrate');
154
+ const notNow = nls.localizeByDefault('Not Now');
155
+ const dontShowAgain = nls.localizeByDefault("Don't Show Again");
156
+ const message = nls.localize(
157
+ 'theia/ai/chat/customAgents/migratePrompt/message',
158
+ 'Your custom agents still use the older `customAgents.yml` format. '
159
+ + 'We recommend migrating them to the new per-agent format (`agents/<id>/agent.md`), which {0} uses going forward. '
160
+ + 'Each agent gets its own file next to your `customAgents.yml`, and the original is kept as a `customAgents.yml.bak` backup.',
161
+ FrontendApplicationConfigProvider.get().applicationName
162
+ );
163
+ const choice = await this.messageService.info(message, migrate, notNow, dontShowAgain);
164
+ if (choice === migrate) {
165
+ try {
166
+ const reports = await this.customizationService.migrateCustomAgentsYaml();
167
+ this.showMigrationSummary(reports);
168
+ } catch (e) {
169
+ this.logger.warn('Custom-agent migration failed', e);
170
+ }
171
+ } else if (choice === dontShowAgain) {
172
+ try {
173
+ await this.storageService.setData(MIGRATION_DONT_SHOW_AGAIN_KEY, true);
174
+ } catch (e) {
175
+ this.logger.warn('Failed to persist custom-agent migration prompt state', e);
176
+ }
177
+ }
178
+ // 'Not Now' or dismissal: do nothing; the prompt reappears next session until migrated or dismissed for good.
179
+ }
180
+
181
+ protected showMigrationSummary(reports: CustomAgentMigrationReports): void {
182
+ if (reports.length === 0) {
183
+ this.messageService?.info(nls.localize('theia/ai/chat/customAgents/migrationResult/empty', 'Custom-agent migration: nothing to migrate.'));
184
+ return;
185
+ }
186
+ const migrated = reports.reduce((sum, r) => sum + r.migrated, 0);
187
+ const corrected = reports.reduce((sum, r) => sum + r.corrected, 0);
188
+ const failed = reports.reduce((sum, r) => sum + r.failed, 0);
189
+ const backedUp = reports.filter(r => r.yamlBackedUp).length;
190
+ const overrides = reports.reduce((sum, r) => sum + r.promptOverridesMigrated, 0);
191
+ const message = nls.localize(
192
+ 'theia/ai/chat/customAgents/migrationResult',
193
+ 'Custom-agent migration: {0} migrated, {1} corrected, {2} failed, {3} legacy customAgents.yml backed up to .bak, {4} prompt overrides folded into agent.md.',
194
+ migrated, corrected, failed, backedUp, overrides
195
+ );
196
+ // Keep the result visible until the user dismisses it (no auto-hide timeout).
197
+ this.messageService?.info(message, { timeout: 0 });
198
+ }
199
+
113
200
  onStop(): void {
114
201
  }
115
202
  }