@theia/ai-core 1.74.0-next.5 → 1.74.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/frontend-prompt-customization-service.d.ts +38 -0
- package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -1
- package/lib/browser/frontend-prompt-customization-service.js +189 -76
- package/lib/browser/frontend-prompt-customization-service.js.map +1 -1
- package/lib/browser/frontend-prompt-customization-service.spec.js +103 -0
- package/lib/browser/frontend-prompt-customization-service.spec.js.map +1 -1
- package/lib/common/prompt-service.d.ts +13 -3
- package/lib/common/prompt-service.d.ts.map +1 -1
- package/lib/common/prompt-service.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/frontend-prompt-customization-service.spec.ts +130 -1
- package/src/browser/frontend-prompt-customization-service.ts +204 -84
- package/src/common/prompt-service.ts +14 -3
|
@@ -424,6 +424,30 @@ export declare class DefaultPromptFragmentCustomizationService implements Prompt
|
|
|
424
424
|
* The agent id determines the folder name; the prompt body is written verbatim under the YAML frontmatter.
|
|
425
425
|
*/
|
|
426
426
|
createCustomAgentFile(parentDirectory: URI, agent: CustomAgentDescription): Promise<URI>;
|
|
427
|
+
/**
|
|
428
|
+
* Parse a `customAgents.yml` document, preserving newlines in folded-block-scalar prompts.
|
|
429
|
+
*
|
|
430
|
+
* `js-yaml` folds the single newlines of a folded scalar (`>` / `>-`) into spaces, which merges
|
|
431
|
+
* a markdown heading (`## Task`) into the paragraph below it. Markdown is newline-sensitive, so
|
|
432
|
+
* we re-interpret folded `prompt:` scalars as literal (`|`) before parsing. Only the block-scalar
|
|
433
|
+
* header is rewritten; quoted, plain and already-literal values are left untouched.
|
|
434
|
+
*
|
|
435
|
+
* Known limitation: prompts stored as a plain or quoted multi-line scalar (rare) still fold.
|
|
436
|
+
*/
|
|
437
|
+
protected parseCustomAgentsYaml(content: string): unknown;
|
|
438
|
+
/**
|
|
439
|
+
* Rewrite a folded `prompt:` block-scalar header (`>`, `>-`, `>+`, `>2-`, ...) to its literal
|
|
440
|
+
* equivalent (`|`...). The lookahead ensures only a block-scalar header is matched (indentation
|
|
441
|
+
* and chomping indicators plus an optional trailing comment), so plain/quoted prompt values and
|
|
442
|
+
* any `>` inside the prompt body are never touched.
|
|
443
|
+
*/
|
|
444
|
+
protected unfoldPromptBlockScalars(content: string): string;
|
|
445
|
+
/**
|
|
446
|
+
* Returns `true` if migration would write anything: a scope still holds a legacy
|
|
447
|
+
* `customAgents.yml`, or a previously migrated scope has `agent.md` files that can be corrected
|
|
448
|
+
* (see {@link computeScopeCorrections}). Read-only; used to decide whether to prompt the user.
|
|
449
|
+
*/
|
|
450
|
+
hasPendingCustomAgentMigration(): Promise<boolean>;
|
|
427
451
|
/**
|
|
428
452
|
* Auto-migrate every legacy `customAgents.yml` reachable from the configured scopes to the new
|
|
429
453
|
* `agents/<id>/agent.md` layout. The original content is never deleted:
|
|
@@ -437,6 +461,18 @@ export declare class DefaultPromptFragmentCustomizationService implements Prompt
|
|
|
437
461
|
migrateCustomAgentsYaml(): Promise<MigrationReport[]>;
|
|
438
462
|
protected doMigrateCustomAgentsYaml(): Promise<MigrationReport[]>;
|
|
439
463
|
protected migrateSingleScope(scopeDir: URI): Promise<MigrationReport | undefined>;
|
|
464
|
+
/**
|
|
465
|
+
* Compute the `agent.md` rewrites needed to recover headings folded by an earlier (v1.73.0)
|
|
466
|
+
* migration. The backup (`customAgents.yml.bak`) is the source that migration used: parsing it
|
|
467
|
+
* the old (folded) way reproduces the exact bytes it wrote, and parsing it the new (literal) way
|
|
468
|
+
* produces the corrected content. Only files still byte-identical to the buggy output are eligible,
|
|
469
|
+
* so files the user edited (and already-correct files) are left untouched. Read-only; used both to
|
|
470
|
+
* detect pending work and to perform the rewrite.
|
|
471
|
+
*/
|
|
472
|
+
protected computeScopeCorrections(scopeDir: URI): Promise<Array<{
|
|
473
|
+
uri: URI;
|
|
474
|
+
content: string;
|
|
475
|
+
}>>;
|
|
440
476
|
/**
|
|
441
477
|
* @deprecated Use {@link createCustomAgentFile} to author agents in the new
|
|
442
478
|
* `<scope>/agents/<id>/agent.md` layout. Retained so existing UI affordances keep
|
|
@@ -460,6 +496,8 @@ export interface MigrationReport {
|
|
|
460
496
|
yamlBackedUp: boolean;
|
|
461
497
|
/** Number of scope-root prompt customization files (`<name>_prompt.prompttemplate`) folded into agent.md and deleted. */
|
|
462
498
|
promptOverridesMigrated: number;
|
|
499
|
+
/** Number of already-migrated `agent.md` files rewritten to recover folded headings. */
|
|
500
|
+
corrected: number;
|
|
463
501
|
}
|
|
464
502
|
export {};
|
|
465
503
|
//# sourceMappingURL=frontend-prompt-customization-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontend-prompt-customization-service.d.ts","sourceRoot":"","sources":["../../src/browser/frontend-prompt-customization-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAO,OAAO,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACH,kCAAkC,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,oBAAoB,EACtK,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAG3F,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAoC,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,OAAO,EAA6B,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,aAAa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IAAI;IAa5C;;;;OAIG;IACG,wBAAwB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAWjE;;;OAGG;IACG,qBAAqB,CAAC,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC;IAa9F;;;;;;;;;OASG;IACG,uBAAuB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;cAc3C,yBAAyB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;cAevD,kBAAkB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"frontend-prompt-customization-service.d.ts","sourceRoot":"","sources":["../../src/browser/frontend-prompt-customization-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAO,OAAO,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACH,kCAAkC,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,oBAAoB,EACtK,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAG3F,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAoC,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,OAAO,EAA6B,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,W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mentCustomizationService = class DefaultPromptFragmentCusto
|
|
|
1298
1298
|
this.warnOnceLegacyYaml(customAgentYamlUri);
|
|
1299
1299
|
try {
|
|
1300
1300
|
const fileContent = await this.fileService.read(customAgentYamlUri, { encoding: 'utf-8' });
|
|
1301
|
-
const doc =
|
|
1301
|
+
const doc = this.parseCustomAgentsYaml(fileContent.value);
|
|
1302
1302
|
if (!Array.isArray(doc) || !doc.every(entry => common_1.CustomAgentDescription.is(entry))) {
|
|
1303
1303
|
this.logger.debug(`Invalid customAgents.yml file content in ${directoryURI.toString()}`);
|
|
1304
1304
|
return;
|
|
@@ -1357,6 +1357,44 @@ let DefaultPromptFragmentCustomizationService = class DefaultPromptFragmentCusto
|
|
|
1357
1357
|
openHandler.open(fileURI);
|
|
1358
1358
|
return fileURI;
|
|
1359
1359
|
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Parse a `customAgents.yml` document, preserving newlines in folded-block-scalar prompts.
|
|
1362
|
+
*
|
|
1363
|
+
* `js-yaml` folds the single newlines of a folded scalar (`>` / `>-`) into spaces, which merges
|
|
1364
|
+
* a markdown heading (`## Task`) into the paragraph below it. Markdown is newline-sensitive, so
|
|
1365
|
+
* we re-interpret folded `prompt:` scalars as literal (`|`) before parsing. Only the block-scalar
|
|
1366
|
+
* header is rewritten; quoted, plain and already-literal values are left untouched.
|
|
1367
|
+
*
|
|
1368
|
+
* Known limitation: prompts stored as a plain or quoted multi-line scalar (rare) still fold.
|
|
1369
|
+
*/
|
|
1370
|
+
parseCustomAgentsYaml(content) {
|
|
1371
|
+
return (0, js_yaml_1.load)(this.unfoldPromptBlockScalars(content));
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Rewrite a folded `prompt:` block-scalar header (`>`, `>-`, `>+`, `>2-`, ...) to its literal
|
|
1375
|
+
* equivalent (`|`...). The lookahead ensures only a block-scalar header is matched (indentation
|
|
1376
|
+
* and chomping indicators plus an optional trailing comment), so plain/quoted prompt values and
|
|
1377
|
+
* any `>` inside the prompt body are never touched.
|
|
1378
|
+
*/
|
|
1379
|
+
unfoldPromptBlockScalars(content) {
|
|
1380
|
+
return content.replace(/^([ \t]*prompt:[ \t]*)>(?=[-+0-9]*[ \t]*(?:#.*)?$)/mg, '$1|');
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Returns `true` if migration would write anything: a scope still holds a legacy
|
|
1384
|
+
* `customAgents.yml`, or a previously migrated scope has `agent.md` files that can be corrected
|
|
1385
|
+
* (see {@link computeScopeCorrections}). Read-only; used to decide whether to prompt the user.
|
|
1386
|
+
*/
|
|
1387
|
+
async hasPendingCustomAgentMigration() {
|
|
1388
|
+
for (const scope of await this.getCustomAgentScopes()) {
|
|
1389
|
+
if (await this.fileService.exists(scope.resolve('customAgents.yml'))) {
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
if ((await this.computeScopeCorrections(scope)).length > 0) {
|
|
1393
|
+
return true;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1360
1398
|
/**
|
|
1361
1399
|
* Auto-migrate every legacy `customAgents.yml` reachable from the configured scopes to the new
|
|
1362
1400
|
* `agents/<id>/agent.md` layout. The original content is never deleted:
|
|
@@ -1389,113 +1427,188 @@ let DefaultPromptFragmentCustomizationService = class DefaultPromptFragmentCusto
|
|
|
1389
1427
|
reports.push(report);
|
|
1390
1428
|
}
|
|
1391
1429
|
}
|
|
1392
|
-
if (reports.some(r => r.migrated > 0)) {
|
|
1430
|
+
if (reports.some(r => r.migrated > 0 || r.corrected > 0)) {
|
|
1393
1431
|
this.onDidChangeCustomAgentsEmitter.fire();
|
|
1394
1432
|
}
|
|
1395
1433
|
return reports;
|
|
1396
1434
|
}
|
|
1397
1435
|
async migrateSingleScope(scopeDir) {
|
|
1398
1436
|
const yamlURI = scopeDir.resolve('customAgents.yml');
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1402
|
-
this.logger.info(`Migrating custom agents from ${yamlURI.toString()}`);
|
|
1403
|
-
let entries;
|
|
1404
|
-
try {
|
|
1405
|
-
const fileContent = await this.fileService.read(yamlURI, { encoding: 'utf-8' });
|
|
1406
|
-
const doc = (0, js_yaml_1.load)(fileContent.value);
|
|
1407
|
-
if (!Array.isArray(doc) || !doc.every(common_1.CustomAgentDescription.is)) {
|
|
1408
|
-
this.logger.warn(`Skipping migration of ${yamlURI.toString()}: file content is not a valid CustomAgentDescription[]`);
|
|
1409
|
-
return { scope: scopeDir, yamlURI, migrated: 0, alreadyPresent: 0, failed: 0, yamlBackedUp: false, promptOverridesMigrated: 0 };
|
|
1410
|
-
}
|
|
1411
|
-
entries = doc;
|
|
1412
|
-
}
|
|
1413
|
-
catch (e) {
|
|
1414
|
-
this.logger.warn(`Skipping migration of ${yamlURI.toString()}: ${e.message}`);
|
|
1415
|
-
return { scope: scopeDir, yamlURI, migrated: 0, alreadyPresent: 0, failed: 0, yamlBackedUp: false, promptOverridesMigrated: 0 };
|
|
1416
|
-
}
|
|
1437
|
+
const backupURI = scopeDir.resolve('customAgents.yml.bak');
|
|
1438
|
+
const yamlExists = await this.fileService.exists(yamlURI);
|
|
1417
1439
|
let migrated = 0;
|
|
1418
1440
|
let alreadyPresent = 0;
|
|
1419
1441
|
let failed = 0;
|
|
1420
1442
|
let promptOverridesMigrated = 0;
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1443
|
+
let yamlBackedUp = false;
|
|
1444
|
+
const emptyReport = () => ({
|
|
1445
|
+
scope: scopeDir, yamlURI, migrated: 0, alreadyPresent: 0, failed: 0,
|
|
1446
|
+
yamlBackedUp: false, promptOverridesMigrated: 0, corrected: 0
|
|
1447
|
+
});
|
|
1448
|
+
if (yamlExists) {
|
|
1449
|
+
this.logger.info(`Migrating custom agents from ${yamlURI.toString()}`);
|
|
1450
|
+
let entries;
|
|
1451
|
+
try {
|
|
1452
|
+
const fileContent = await this.fileService.read(yamlURI, { encoding: 'utf-8' });
|
|
1453
|
+
const doc = this.parseCustomAgentsYaml(fileContent.value);
|
|
1454
|
+
if (!Array.isArray(doc) || !doc.every(common_1.CustomAgentDescription.is)) {
|
|
1455
|
+
this.logger.warn(`Skipping migration of ${yamlURI.toString()}: file content is not a valid CustomAgentDescription[]`);
|
|
1456
|
+
return emptyReport();
|
|
1457
|
+
}
|
|
1458
|
+
entries = doc;
|
|
1435
1459
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1460
|
+
catch (e) {
|
|
1461
|
+
this.logger.warn(`Skipping migration of ${yamlURI.toString()}: ${e.message}`);
|
|
1462
|
+
return emptyReport();
|
|
1463
|
+
}
|
|
1464
|
+
// A previous failed migration may have created `agents/<id>/` directories without an
|
|
1465
|
+
// `agent.md` inside. Remove those empty placeholders so this run can recreate them cleanly.
|
|
1466
|
+
await this.cleanupEmptyAgentFolders(scopeDir);
|
|
1467
|
+
// Snapshot scope-root template files once so we can match per agent without re-listing.
|
|
1468
|
+
const scopeRootTemplateFiles = await this.listScopeRootPromptTemplates(scopeDir);
|
|
1469
|
+
// Prompt-fragment files are matched by agent *name* (the fragment id is `<name>_prompt`)
|
|
1470
|
+
// while folders are keyed by the unique *id*. When two entries share a name, only the first
|
|
1471
|
+
// can own the name-based files, so track seen names and skip the move for the duplicates.
|
|
1472
|
+
const seenNames = new Set();
|
|
1473
|
+
for (const entry of entries) {
|
|
1474
|
+
const agentFolderURI = scopeDir.resolve(exports.CUSTOM_AGENTS_DIRECTORY).resolve(entry.id);
|
|
1475
|
+
const targetURI = agentFolderURI.resolve(exports.CUSTOM_AGENT_FILE_NAME);
|
|
1476
|
+
if (await this.fileService.exists(targetURI)) {
|
|
1477
|
+
alreadyPresent++;
|
|
1440
1478
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1479
|
+
else {
|
|
1480
|
+
try {
|
|
1481
|
+
await this.fileService.createFile(targetURI, buffer_1.BinaryBuffer.fromString(serializeCustomAgentFile(entry)), { overwrite: true });
|
|
1482
|
+
migrated++;
|
|
1483
|
+
}
|
|
1484
|
+
catch (e) {
|
|
1485
|
+
this.logger.warn(`Failed to migrate agent '${entry.id}' from ${yamlURI.toString()}: ${e?.message ?? e}`, e);
|
|
1486
|
+
failed++;
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
if (seenNames.has(entry.name)) {
|
|
1491
|
+
this.logger.warn(`Multiple custom agents in ${yamlURI.toString()} share the name '${entry.name}'; ` +
|
|
1492
|
+
'prompt fragment files were migrated to the first matching agent only.');
|
|
1444
1493
|
continue;
|
|
1445
1494
|
}
|
|
1495
|
+
seenNames.add(entry.name);
|
|
1496
|
+
// Move any scope-root .prompttemplate files that look like they belong to this agent
|
|
1497
|
+
// (filename stem starts with `<name>_prompt`, followed by EOF or a separator).
|
|
1498
|
+
// They become variants under `<scope>/agents/<id>/`.
|
|
1499
|
+
for (const file of scopeRootTemplateFiles) {
|
|
1500
|
+
if (!matchesAgentPromptPrefix(file.stem, entry.name)) {
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
const destURI = agentFolderURI.resolve(file.uri.path.base);
|
|
1504
|
+
if (await this.fileService.exists(destURI)) {
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
try {
|
|
1508
|
+
await this.fileService.move(file.uri, destURI);
|
|
1509
|
+
promptOverridesMigrated++;
|
|
1510
|
+
}
|
|
1511
|
+
catch (e) {
|
|
1512
|
+
this.logger.warn(`Failed to move prompt fragment ${file.uri.toString()} into ${destURI.toString()}: ${e?.message ?? e}`);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1446
1515
|
}
|
|
1447
|
-
if (
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
}
|
|
1452
|
-
seenNames.add(entry.name);
|
|
1453
|
-
// Move any scope-root .prompttemplate files that look like they belong to this agent
|
|
1454
|
-
// (filename stem starts with `<name>_prompt`, followed by EOF or a separator).
|
|
1455
|
-
// They become variants under `<scope>/agents/<id>/`.
|
|
1456
|
-
for (const file of scopeRootTemplateFiles) {
|
|
1457
|
-
if (!matchesAgentPromptPrefix(file.stem, entry.name)) {
|
|
1458
|
-
continue;
|
|
1516
|
+
if (failed === 0) {
|
|
1517
|
+
try {
|
|
1518
|
+
await this.fileService.move(yamlURI, backupURI, { overwrite: true });
|
|
1519
|
+
yamlBackedUp = true;
|
|
1459
1520
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
continue;
|
|
1521
|
+
catch (e) {
|
|
1522
|
+
this.logger.warn(`Migrated ${migrated} agents but failed to back up ${yamlURI.toString()}: ${e.message}`);
|
|
1463
1523
|
}
|
|
1524
|
+
}
|
|
1525
|
+
else {
|
|
1464
1526
|
try {
|
|
1465
|
-
await this.fileService.
|
|
1466
|
-
|
|
1527
|
+
if (!(await this.fileService.exists(backupURI))) {
|
|
1528
|
+
await this.fileService.move(yamlURI, backupURI);
|
|
1529
|
+
yamlBackedUp = true;
|
|
1530
|
+
}
|
|
1467
1531
|
}
|
|
1468
1532
|
catch (e) {
|
|
1469
|
-
this.logger.warn(`Failed to
|
|
1533
|
+
this.logger.warn(`Failed to back up ${yamlURI.toString()} to ${backupURI.toString()}: ${e.message}`);
|
|
1470
1534
|
}
|
|
1471
1535
|
}
|
|
1472
1536
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1537
|
+
// Correct any `agent.md` left with merged headings by an earlier (v1.73.0) migration. Anything
|
|
1538
|
+
// just migrated above is already correct, so only stale files from a previous run are rewritten.
|
|
1539
|
+
let corrected = 0;
|
|
1540
|
+
for (const { uri, content } of await this.computeScopeCorrections(scopeDir)) {
|
|
1476
1541
|
try {
|
|
1477
|
-
await this.fileService.
|
|
1478
|
-
|
|
1542
|
+
await this.fileService.createFile(uri, buffer_1.BinaryBuffer.fromString(content), { overwrite: true });
|
|
1543
|
+
corrected++;
|
|
1479
1544
|
}
|
|
1480
1545
|
catch (e) {
|
|
1481
|
-
this.logger.warn(`
|
|
1546
|
+
this.logger.warn(`Failed to correct migrated agent file ${uri.toString()}: ${e?.message ?? e}`);
|
|
1482
1547
|
}
|
|
1483
1548
|
}
|
|
1484
|
-
|
|
1549
|
+
if (!yamlExists && corrected === 0) {
|
|
1550
|
+
return undefined; // nothing to migrate and nothing to correct in this scope
|
|
1551
|
+
}
|
|
1552
|
+
this.logger.info(`Migration done for ${scopeDir.toString()}: migrated=${migrated}, alreadyPresent=${alreadyPresent}, ` +
|
|
1553
|
+
`failed=${failed}, yamlBackedUp=${yamlBackedUp}, promptOverridesMigrated=${promptOverridesMigrated}, corrected=${corrected}`);
|
|
1554
|
+
return { scope: scopeDir, yamlURI, migrated, alreadyPresent, failed, yamlBackedUp, promptOverridesMigrated, corrected };
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Compute the `agent.md` rewrites needed to recover headings folded by an earlier (v1.73.0)
|
|
1558
|
+
* migration. The backup (`customAgents.yml.bak`) is the source that migration used: parsing it
|
|
1559
|
+
* the old (folded) way reproduces the exact bytes it wrote, and parsing it the new (literal) way
|
|
1560
|
+
* produces the corrected content. Only files still byte-identical to the buggy output are eligible,
|
|
1561
|
+
* so files the user edited (and already-correct files) are left untouched. Read-only; used both to
|
|
1562
|
+
* detect pending work and to perform the rewrite.
|
|
1563
|
+
*/
|
|
1564
|
+
async computeScopeCorrections(scopeDir) {
|
|
1565
|
+
const backupURI = scopeDir.resolve('customAgents.yml.bak');
|
|
1566
|
+
if (!(await this.fileService.exists(backupURI))) {
|
|
1567
|
+
return [];
|
|
1568
|
+
}
|
|
1569
|
+
let oldEntries;
|
|
1570
|
+
let newEntries;
|
|
1571
|
+
try {
|
|
1572
|
+
const raw = (await this.fileService.read(backupURI, { encoding: 'utf-8' })).value;
|
|
1573
|
+
oldEntries = (0, js_yaml_1.load)(raw); // reproduces the folded (buggy) output
|
|
1574
|
+
newEntries = this.parseCustomAgentsYaml(raw); // produces the heading-preserving fix
|
|
1575
|
+
}
|
|
1576
|
+
catch {
|
|
1577
|
+
return [];
|
|
1578
|
+
}
|
|
1579
|
+
if (!Array.isArray(oldEntries) || !oldEntries.every(common_1.CustomAgentDescription.is)
|
|
1580
|
+
|| !Array.isArray(newEntries) || !newEntries.every(common_1.CustomAgentDescription.is)) {
|
|
1581
|
+
return [];
|
|
1582
|
+
}
|
|
1583
|
+
const fixedById = new Map(newEntries.map(e => [e.id, e]));
|
|
1584
|
+
const corrections = [];
|
|
1585
|
+
for (const oldEntry of oldEntries) {
|
|
1586
|
+
const fixed = fixedById.get(oldEntry.id);
|
|
1587
|
+
if (!fixed) {
|
|
1588
|
+
continue;
|
|
1589
|
+
}
|
|
1590
|
+
const buggyContent = serializeCustomAgentFile(oldEntry);
|
|
1591
|
+
const fixedContent = serializeCustomAgentFile(fixed);
|
|
1592
|
+
if (buggyContent === fixedContent) {
|
|
1593
|
+
continue; // prompt had no folded headings to recover
|
|
1594
|
+
}
|
|
1595
|
+
const agentMdURI = scopeDir.resolve(exports.CUSTOM_AGENTS_DIRECTORY).resolve(oldEntry.id).resolve(exports.CUSTOM_AGENT_FILE_NAME);
|
|
1596
|
+
if (!(await this.fileService.exists(agentMdURI))) {
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
let current;
|
|
1485
1600
|
try {
|
|
1486
|
-
|
|
1487
|
-
await this.fileService.move(yamlURI, backupURI);
|
|
1488
|
-
yamlBackedUp = true;
|
|
1489
|
-
}
|
|
1601
|
+
current = (await this.fileService.read(agentMdURI, { encoding: 'utf-8' })).value;
|
|
1490
1602
|
}
|
|
1491
|
-
catch
|
|
1492
|
-
|
|
1603
|
+
catch {
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
// Only rewrite files untouched since migration; current bytes still matching the buggy output.
|
|
1607
|
+
if (current === buggyContent) {
|
|
1608
|
+
corrections.push({ uri: agentMdURI, content: fixedContent });
|
|
1493
1609
|
}
|
|
1494
1610
|
}
|
|
1495
|
-
|
|
1496
|
-
`migrated=${migrated}, alreadyPresent=${alreadyPresent}, failed=${failed}, ` +
|
|
1497
|
-
`yamlBackedUp=${yamlBackedUp}, promptOverridesMigrated=${promptOverridesMigrated}`);
|
|
1498
|
-
return { scope: scopeDir, yamlURI, migrated, alreadyPresent, failed, yamlBackedUp, promptOverridesMigrated };
|
|
1611
|
+
return corrections;
|
|
1499
1612
|
}
|
|
1500
1613
|
/**
|
|
1501
1614
|
* @deprecated Use {@link createCustomAgentFile} to author agents in the new
|