agentic-api 2.0.646 → 2.0.885

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 (59) hide show
  1. package/dist/src/agents/prompts.d.ts +2 -3
  2. package/dist/src/agents/prompts.js +21 -118
  3. package/dist/src/agents/reducer.loaders.d.ts +103 -1
  4. package/dist/src/agents/reducer.loaders.js +164 -2
  5. package/dist/src/agents/reducer.types.d.ts +34 -3
  6. package/dist/src/agents/simulator.d.ts +32 -2
  7. package/dist/src/agents/simulator.executor.d.ts +15 -5
  8. package/dist/src/agents/simulator.executor.js +134 -67
  9. package/dist/src/agents/simulator.js +251 -8
  10. package/dist/src/agents/simulator.prompts.d.ts +55 -10
  11. package/dist/src/agents/simulator.prompts.js +305 -61
  12. package/dist/src/agents/simulator.types.d.ts +62 -1
  13. package/dist/src/agents/simulator.types.js +5 -0
  14. package/dist/src/agents/subagent.d.ts +128 -0
  15. package/dist/src/agents/subagent.js +231 -0
  16. package/dist/src/agents/worker.executor.d.ts +48 -0
  17. package/dist/src/agents/worker.executor.js +152 -0
  18. package/dist/src/execute/helpers.d.ts +3 -0
  19. package/dist/src/execute/helpers.js +222 -16
  20. package/dist/src/execute/responses.js +81 -55
  21. package/dist/src/execute/shared.d.ts +5 -0
  22. package/dist/src/execute/shared.js +27 -0
  23. package/dist/src/index.d.ts +2 -1
  24. package/dist/src/index.js +3 -1
  25. package/dist/src/llm/openai.js +8 -1
  26. package/dist/src/llm/pricing.js +2 -0
  27. package/dist/src/llm/xai.js +11 -6
  28. package/dist/src/prompts.d.ts +14 -0
  29. package/dist/src/prompts.js +41 -1
  30. package/dist/src/rag/rag.manager.d.ts +18 -3
  31. package/dist/src/rag/rag.manager.js +114 -12
  32. package/dist/src/rag/types.d.ts +3 -1
  33. package/dist/src/rules/git/git.e2e.helper.js +51 -4
  34. package/dist/src/rules/git/git.health.js +89 -56
  35. package/dist/src/rules/git/index.d.ts +2 -2
  36. package/dist/src/rules/git/index.js +22 -5
  37. package/dist/src/rules/git/repo.d.ts +64 -6
  38. package/dist/src/rules/git/repo.js +572 -141
  39. package/dist/src/rules/git/repo.pr.d.ts +11 -18
  40. package/dist/src/rules/git/repo.pr.js +82 -94
  41. package/dist/src/rules/git/repo.tools.d.ts +5 -0
  42. package/dist/src/rules/git/repo.tools.js +6 -1
  43. package/dist/src/rules/types.d.ts +0 -2
  44. package/dist/src/rules/utils.matter.js +1 -5
  45. package/dist/src/scrapper.d.ts +138 -25
  46. package/dist/src/scrapper.js +538 -160
  47. package/dist/src/stategraph/stategraph.d.ts +6 -2
  48. package/dist/src/stategraph/stategraph.js +21 -6
  49. package/dist/src/stategraph/types.d.ts +14 -6
  50. package/dist/src/types.d.ts +22 -0
  51. package/dist/src/utils.d.ts +24 -0
  52. package/dist/src/utils.js +84 -86
  53. package/package.json +3 -2
  54. package/dist/src/agents/semantic.d.ts +0 -4
  55. package/dist/src/agents/semantic.js +0 -19
  56. package/dist/src/execute/legacy.d.ts +0 -46
  57. package/dist/src/execute/legacy.js +0 -460
  58. package/dist/src/pricing.llm.d.ts +0 -5
  59. package/dist/src/pricing.llm.js +0 -14
@@ -27,6 +27,7 @@ class GitHealthManager {
27
27
  async repairRepository(branch) {
28
28
  // CRITICAL FIX: Checkout sur la branche cible avant forceRepair()
29
29
  // Sinon ensureSafeBranch() vérifie la branche courante (qui peut être 'main')
30
+ const failedBranches = [];
30
31
  try {
31
32
  await this.git.checkout(branch);
32
33
  }
@@ -197,6 +198,7 @@ class GitHealthManager {
197
198
  */
198
199
  async syncValidationBranches() {
199
200
  const { validationPrefix } = this.config;
201
+ const failedBranches = [];
200
202
  if (!validationPrefix) {
201
203
  console.error("Erreur: Le préfixe de validation n'est pas configuré.");
202
204
  return;
@@ -218,6 +220,9 @@ class GitHealthManager {
218
220
  for (const branch of validationBranches) {
219
221
  try {
220
222
  await this.repairRepository(branch);
223
+ // Synchroniser explicitement la branche de validation avec son mergeBase.
224
+ // gitSyncPR préserve metadata.files et ne doit pas regonfler le scope PR.
225
+ await (0, git_1.gitSyncPR)(this.git, branch, user);
221
226
  }
222
227
  catch (error) {
223
228
  console.warn(`⚠️ Échec de la synchronisation de ${branch}: ${error.message}`);
@@ -257,7 +262,8 @@ class GitHealthManager {
257
262
  catch (repairError) {
258
263
  console.error(`❌ Impossible de réparer ${branch}: ${repairError.message}`);
259
264
  console.error(`📝 Cette branche nécessite une intervention manuelle`);
260
- throw repairError;
265
+ failedBranches.push(branch);
266
+ continue;
261
267
  }
262
268
  }
263
269
  }
@@ -285,6 +291,9 @@ class GitHealthManager {
285
291
  console.warn(`⚠️ Erreur lors du retour à la branche originale: ${error}`);
286
292
  }
287
293
  }
294
+ if (failedBranches.length > 0) {
295
+ console.warn(`⚠️ Synchronisation incomplète (${failedBranches.length} branche(s) ignorée(s)): ${failedBranches.join(', ')}`);
296
+ }
288
297
  }
289
298
  /**
290
299
  * Migrates Git notes from the first commit of validation branches to the last one.
@@ -299,7 +308,7 @@ class GitHealthManager {
299
308
  * @returns GitPrNoteMigrationReport avec le nombre de notes migrées, déjà OK, et perdues
300
309
  */
301
310
  async migrateNotes() {
302
- const { mainBranch, validationPrefix, gitNotes } = this.config;
311
+ const { draftBranch, validationPrefix, gitNotes } = this.config;
303
312
  if (!validationPrefix || !gitNotes.namespace) {
304
313
  console.error("Erreur: Le préfixe de validation ou le namespace des notes n'est pas configuré.");
305
314
  return { migrated: 0, alreadyOk: 0, lost: [] };
@@ -315,22 +324,30 @@ class GitHealthManager {
315
324
  for (const branch of validationBranches) {
316
325
  try {
317
326
  const lastCommit = (await this.git.revparse(branch)).trim();
327
+ const prNumber = parseInt(branch.split('-').pop() || '0', 10);
318
328
  // 1. Check if note is already on the last commit
319
329
  const noteOnHead = await (0, git_1.gitReadNote)(this.git, lastCommit, gitNotes.namespace, 1);
320
330
  if (noteOnHead) {
321
- alreadyOkCount++;
322
- continue;
331
+ // Valider que la note HEAD correspond bien à la PR de la branche.
332
+ // Sinon, continuer la recherche dans l'historique pour éviter les faux "already OK".
333
+ if (noteOnHead.id === prNumber) {
334
+ alreadyOkCount++;
335
+ continue;
336
+ }
337
+ console.log(` ⚠️ ${branch}: Note HEAD id=${noteOnHead.id}, attendu id=${prNumber} - recherche historique`);
323
338
  }
324
339
  // 2. Scan the branch history for a note
325
- const mergeBase = (await this.git.raw('merge-base', mainBranch, branch)).trim();
340
+ // IMPORTANT:
341
+ // Les branches de validation sont créées depuis rule-editor (draftBranch),
342
+ // pas depuis main. Utiliser main élargit artificiellement l'historique scanné
343
+ // et peut faire remonter des notes d'autres PR (faux positifs).
344
+ const mergeBase = (await this.git.raw('merge-base', draftBranch, branch)).trim();
326
345
  if (!mergeBase) {
327
- console.log(`⚠️ ${branch}: Impossible de trouver un point de merge avec '${mainBranch}'. Ignoré.`);
346
+ console.log(`⚠️ ${branch}: Impossible de trouver un point de merge avec '${draftBranch}'. Ignoré.`);
328
347
  continue;
329
348
  }
330
349
  const revListOutput = await this.git.raw('rev-list', `${mergeBase}..${branch}`);
331
350
  const branchCommits = revListOutput.split('\n').filter(Boolean);
332
- // Extract PR number from branch name (e.g., rule-validation-31 -> 31)
333
- const prNumber = parseInt(branch.split('-').pop() || '0', 10);
334
351
  let oldNoteCommit = null;
335
352
  for (const commitHash of branchCommits) {
336
353
  const note = await (0, git_1.gitReadNote)(this.git, commitHash, gitNotes.namespace, 1);
@@ -424,15 +441,20 @@ class GitHealthManager {
424
441
  // Lister tous les fichiers .md dans la branche
425
442
  const allFiles = await (0, git_1.gitListFilesInBranch)(this.git, branchName);
426
443
  const mdFiles = allFiles.filter(f => f.endsWith('.md'));
444
+ const seenIDs = new Map();
427
445
  // Variables pour suivre les problèmes dans cette branche
428
446
  let branchHasIssues = false;
429
447
  const branchIssues = [];
430
448
  for (const file of mdFiles) {
431
449
  report.scanned++;
432
450
  try {
433
- // OPTIMISATION: Lecture rapide du matter (id + title uniquement)
434
- // Utilise le cache, évite de parser tout le fichier
435
- const matter = await (0, git_1.gitFileStrictMatter)(this.git, file, branchName, this.config);
451
+ // Lecture fraîche depuis Git: évite les faux positifs liés à un cache matter obsolète.
452
+ const fileData = await (0, git_1.gitGetFileContent)(this.git, file, branchName);
453
+ const parsed = (0, utils_matter_1.matterParse)(fileData?.content || '');
454
+ const matter = {
455
+ id: parsed.matter?.id,
456
+ title: parsed.matter?.title
457
+ };
436
458
  // Vérification de l'ID et du titre
437
459
  let hasValidID = false;
438
460
  let hasValidTitle = false;
@@ -449,19 +471,15 @@ class GitHealthManager {
449
471
  }
450
472
  else {
451
473
  hasValidID = true;
452
- // Enregistrer l'ID existant dans le registry
453
- // ✅ gitRegisterExistingID() appelle maintenant setMatterCache() automatiquement si matter est fourni
454
- try {
455
- (0, git_1.gitRegisterExistingID)(matter, branchName, file, this.config);
474
+ const firstFile = seenIDs.get(matter.id);
475
+ if (firstFile && firstFile !== file) {
476
+ report.duplicateID.push(`${fileRef} (id=${matter.id})`);
477
+ hasValidID = false;
478
+ branchHasIssues = true;
479
+ branchIssues.push(` ⚠️ ${file}: ID ${matter.id} déjà utilisé`);
456
480
  }
457
- catch (error) {
458
- if (error.code === 'id_already_used') {
459
- // Compter les doublons mais ne pas les ajouter aux erreurs (seront réparés)
460
- report.duplicateID.push(`${fileRef} (id=${matter.id})`);
461
- hasValidID = false;
462
- branchHasIssues = true;
463
- branchIssues.push(` ⚠️ ${file}: ID ${matter.id} déjà utilisé`);
464
- }
481
+ else {
482
+ seenIDs.set(matter.id, file);
465
483
  }
466
484
  }
467
485
  // Vérification du titre
@@ -551,42 +569,38 @@ class GitHealthManager {
551
569
  ];
552
570
  let fixed = 0;
553
571
  const fixedFiles = new Set();
554
- // ÉTAPE CRITIQUE: Charger le cache pour toutes les branches avant la réparation
555
- // Cela permet à getFileID() de trouver l'ID existant du fichier
572
+ const usedIdsByBranch = new Map();
556
573
  if (!dryRun && filesToFix.length > 0) {
557
- console.log(` 🔍 Chargement du cache pour toutes les branches...`);
558
- const allBranches = await (0, git_1.gitGetAllBranches)(this.git);
559
- const uniqueFiles = new Set();
574
+ const uniqueBranches = new Set();
560
575
  for (const fileRef of filesToFix) {
561
- const [, ...fileParts] = fileRef.split(':');
562
- const file = fileParts.join(':');
563
- uniqueFiles.add(file);
564
- }
565
- // Mettre en cache la liste des fichiers par branche pour éviter les appels répétés
566
- const branchFilesCache = new Map();
567
- for (const branch of allBranches) {
568
- try {
569
- const filesInBranch = await (0, git_1.gitListFilesInBranch)(this.git, branch);
570
- branchFilesCache.set(branch, filesInBranch);
571
- }
572
- catch (e) {
573
- // Ignorer silencieusement les erreurs (branche peut être inaccessible)
574
- branchFilesCache.set(branch, []);
576
+ const [branchName] = fileRef.split(':');
577
+ if (branchName) {
578
+ uniqueBranches.add(branchName);
575
579
  }
576
580
  }
577
- // Charger le cache pour chaque fichier dans les branches où il existe
578
- for (const file of uniqueFiles) {
579
- for (const branch of allBranches) {
580
- try {
581
- const filesInBranch = branchFilesCache.get(branch) || [];
582
- if (filesInBranch.includes(file)) {
583
- await (0, git_1.gitFileStrictMatter)(this.git, file, branch, this.config);
581
+ for (const branchName of uniqueBranches) {
582
+ const usedIds = new Set();
583
+ try {
584
+ const filesInBranch = await (0, git_1.gitListFilesInBranch)(this.git, branchName);
585
+ const mdFiles = filesInBranch.filter((f) => f.endsWith('.md'));
586
+ for (const file of mdFiles) {
587
+ try {
588
+ const data = await (0, git_1.gitGetFileContent)(this.git, file, branchName);
589
+ const parsed = (0, utils_matter_1.matterParse)(data?.content || '');
590
+ const id = parsed.matter?.id;
591
+ if (typeof id === 'number' && id > 999) {
592
+ usedIds.add(id);
593
+ }
594
+ }
595
+ catch {
596
+ // Ignorer les fichiers inaccessibles ponctuellement
584
597
  }
585
- }
586
- catch (e) {
587
- // Ignorer silencieusement les erreurs (fichier peut ne pas exister)
588
598
  }
589
599
  }
600
+ catch {
601
+ // Ignorer les branches inaccessibles ponctuellement
602
+ }
603
+ usedIdsByBranch.set(branchName, usedIds);
590
604
  }
591
605
  }
592
606
  for (const fileRef of filesToFix) {
@@ -608,10 +622,29 @@ class GitHealthManager {
608
622
  // Parser le matter complet
609
623
  const parsed = (0, utils_matter_1.matterParse)(fileData.content);
610
624
  const { matter: fullMatter, content } = parsed;
611
- // CORRECTION: Utiliser gitEnsureMatterID() pour réutiliser l'ID existant du fichier
612
- // Si le fichier existe déjà dans une autre branche, son ID sera réutilisé
613
- // Sinon, un nouvel ID sera généré automatiquement
614
- const matterWithID = (0, git_1.gitEnsureMatterID)(fullMatter, this.config, branchName, file);
625
+ const isDuplicateIssue = report.duplicateID.some((entry) => entry.startsWith(fileRef));
626
+ // Convergence stable:
627
+ // - Cas normal: arbitrage par fichier (branch+file) pour réutiliser l'ID stable.
628
+ // - Cas doublon réel: allouer un nouvel ID libre dans la branche et l'enregistrer explicitement.
629
+ let matterWithID;
630
+ if (isDuplicateIssue) {
631
+ const usedIds = usedIdsByBranch.get(branchName) || new Set();
632
+ let nextId = Math.max(1000, ...Array.from(usedIds)) + 20;
633
+ while (usedIds.has(nextId)) {
634
+ nextId += 20;
635
+ }
636
+ fullMatter.id = nextId;
637
+ if (!fullMatter.title || fullMatter.title.trim() === '') {
638
+ fullMatter.title = file.replace(/\.md$/, '');
639
+ }
640
+ (0, git_1.gitRegisterExistingID)(fullMatter, branchName, file, this.config);
641
+ usedIds.add(nextId);
642
+ usedIdsByBranch.set(branchName, usedIds);
643
+ matterWithID = fullMatter;
644
+ }
645
+ else {
646
+ matterWithID = (0, git_1.gitEnsureMatterID)(fullMatter, this.config, branchName, file);
647
+ }
615
648
  if (matterWithID.id !== fullMatter.id) {
616
649
  if (fullMatter.id && fullMatter.id > 999) {
617
650
  console.log(` 🔧 ${file}: ID ${fullMatter.id} remplacé par ID existant ${matterWithID.id}`);
@@ -1,6 +1,6 @@
1
1
  export { lock, unlock, gitLoad, isValidInt, gitIsFileMerged, gitLastCommit, gitListFilesInBranch, gitListFilesOutsideRepo, gitFileExistsInBranch, gitGetFilesSummary, gitGetFileContent, gitGetFilePreview, gitGetFileHistory, gitReadFileOutsideRepo, gitGetUnmergedBranchesForFile, gitGetAllBranches, gitGetDiffFiles, gitReadNote, gitWriteNote, gitDeleteNote, } from './repo.tools';
2
- export { gitInit, gitEnsureRepositoryConfiguration, gitEnsureRemoteConfiguration, gitSetupRepository, gitShowConfiguration, gitCheckConfiguration, gitGetBranchHealth, gitGetValidationBranchHealth, gitCreateOrEditFile, gitEditFile, gitRenameFile, gitDeleteFile, gitGenerateNextID, gitReloadIDRegistry, gitRegisterExistingID, gitEnsureMatterID, gitFileStrictMatter, gitIDRegistryExists, gitIDRegistryRename, } from './repo';
3
- export { gitSyncPR, gitIsPRClosed, gitIsPRClosedRobust, gitGetPRMetadata, gitGetAllPR, gitGetClosedPRs, gitLoadPR, gitPRUpdateComments, gitClosePR, gitClosePRRobust, gitGetNextPRNumber, gitNewValidationRequest, gitNewPR, } from './repo.pr';
2
+ export { gitInit, gitEnsureRepositoryConfiguration, gitEnsureRemoteConfiguration, gitSetupRepository, gitShowConfiguration, gitCheckConfiguration, gitGetBranchHealth, gitGetValidationBranchHealth, gitCreateOrEditFile, gitUpdateMatter, gitRenameFile, gitDeleteFile, gitEditFile, gitGenerateNextID, gitAllocateNextPRNumber, gitFileStrictMatter, gitGetMatterCache, gitSetMatterCache, GitDocumentMutationOptions, gitReloadIDRegistry, gitRegisterExistingID, gitEnsureMatterID, gitIDRegistryExists, gitIDRegistryRename, } from './repo';
3
+ export { gitSyncPR, gitIsPRClosed, gitIsPRClosedRobust, gitGetPRMetadata, gitGetAllPR, gitGetClosedPRs, gitLoadPR, gitPRUpdateComments, gitClosePR, gitClosePRRobust, gitNewValidationRequest, gitNewPR, } from './repo.pr';
4
4
  export * from './git.e2e.helper';
5
5
  export * from './git.health';
6
6
  export * from './git.helper';
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.gitGetNextPRNumber = exports.gitClosePRRobust = exports.gitClosePR = exports.gitPRUpdateComments = exports.gitLoadPR = exports.gitGetClosedPRs = exports.gitGetAllPR = exports.gitGetPRMetadata = exports.gitIsPRClosedRobust = exports.gitIsPRClosed = exports.gitSyncPR = exports.gitIDRegistryRename = exports.gitIDRegistryExists = exports.gitFileStrictMatter = exports.gitEnsureMatterID = exports.gitRegisterExistingID = exports.gitReloadIDRegistry = exports.gitGenerateNextID = exports.gitDeleteFile = exports.gitRenameFile = exports.gitEditFile = exports.gitCreateOrEditFile = exports.gitGetValidationBranchHealth = exports.gitGetBranchHealth = exports.gitCheckConfiguration = exports.gitShowConfiguration = exports.gitSetupRepository = exports.gitEnsureRemoteConfiguration = exports.gitEnsureRepositoryConfiguration = exports.gitInit = exports.gitDeleteNote = exports.gitWriteNote = exports.gitReadNote = exports.gitGetDiffFiles = exports.gitGetAllBranches = exports.gitGetUnmergedBranchesForFile = exports.gitReadFileOutsideRepo = exports.gitGetFileHistory = exports.gitGetFilePreview = exports.gitGetFileContent = exports.gitGetFilesSummary = exports.gitFileExistsInBranch = exports.gitListFilesOutsideRepo = exports.gitListFilesInBranch = exports.gitLastCommit = exports.gitIsFileMerged = exports.isValidInt = exports.gitLoad = exports.unlock = exports.lock = void 0;
18
- exports.gitNewPR = exports.gitNewValidationRequest = void 0;
17
+ exports.gitLoadPR = exports.gitGetClosedPRs = exports.gitGetAllPR = exports.gitGetPRMetadata = exports.gitIsPRClosedRobust = exports.gitIsPRClosed = exports.gitSyncPR = exports.gitIDRegistryRename = exports.gitIDRegistryExists = exports.gitEnsureMatterID = exports.gitRegisterExistingID = exports.gitReloadIDRegistry = exports.gitSetMatterCache = exports.gitGetMatterCache = exports.gitFileStrictMatter = exports.gitAllocateNextPRNumber = exports.gitGenerateNextID = exports.gitEditFile = exports.gitDeleteFile = exports.gitRenameFile = exports.gitUpdateMatter = exports.gitCreateOrEditFile = exports.gitGetValidationBranchHealth = exports.gitGetBranchHealth = exports.gitCheckConfiguration = exports.gitShowConfiguration = exports.gitSetupRepository = exports.gitEnsureRemoteConfiguration = exports.gitEnsureRepositoryConfiguration = exports.gitInit = exports.gitDeleteNote = exports.gitWriteNote = exports.gitReadNote = exports.gitGetDiffFiles = exports.gitGetAllBranches = exports.gitGetUnmergedBranchesForFile = exports.gitReadFileOutsideRepo = exports.gitGetFileHistory = exports.gitGetFilePreview = exports.gitGetFileContent = exports.gitGetFilesSummary = exports.gitFileExistsInBranch = exports.gitListFilesOutsideRepo = exports.gitListFilesInBranch = exports.gitLastCommit = exports.gitIsFileMerged = exports.isValidInt = exports.gitLoad = exports.unlock = exports.lock = void 0;
18
+ exports.gitNewPR = exports.gitNewValidationRequest = exports.gitClosePRRobust = exports.gitClosePR = exports.gitPRUpdateComments = void 0;
19
19
  // === OPÉRATIONS GIT BAS NIVEAU ===
20
20
  // Fonctions atomiques pour manipuler Git directement
21
21
  var repo_tools_1 = require("./repo.tools");
@@ -54,34 +54,51 @@ Object.defineProperty(exports, "gitShowConfiguration", { enumerable: true, get:
54
54
  Object.defineProperty(exports, "gitCheckConfiguration", { enumerable: true, get: function () { return repo_1.gitCheckConfiguration; } });
55
55
  Object.defineProperty(exports, "gitGetBranchHealth", { enumerable: true, get: function () { return repo_1.gitGetBranchHealth; } });
56
56
  Object.defineProperty(exports, "gitGetValidationBranchHealth", { enumerable: true, get: function () { return repo_1.gitGetValidationBranchHealth; } });
57
+ // Document mutations
57
58
  Object.defineProperty(exports, "gitCreateOrEditFile", { enumerable: true, get: function () { return repo_1.gitCreateOrEditFile; } });
58
- Object.defineProperty(exports, "gitEditFile", { enumerable: true, get: function () { return repo_1.gitEditFile; } });
59
+ Object.defineProperty(exports, "gitUpdateMatter", { enumerable: true, get: function () { return repo_1.gitUpdateMatter; } });
59
60
  Object.defineProperty(exports, "gitRenameFile", { enumerable: true, get: function () { return repo_1.gitRenameFile; } });
60
61
  Object.defineProperty(exports, "gitDeleteFile", { enumerable: true, get: function () { return repo_1.gitDeleteFile; } });
62
+ // deprecated: use gitCreateOrEditFile
63
+ Object.defineProperty(exports, "gitEditFile", { enumerable: true, get: function () { return repo_1.gitEditFile; } });
61
64
  // ID Management & Matter Cache
62
65
  Object.defineProperty(exports, "gitGenerateNextID", { enumerable: true, get: function () { return repo_1.gitGenerateNextID; } });
66
+ Object.defineProperty(exports, "gitAllocateNextPRNumber", { enumerable: true, get: function () { return repo_1.gitAllocateNextPRNumber; } });
67
+ Object.defineProperty(exports, "gitFileStrictMatter", { enumerable: true, get: function () { return repo_1.gitFileStrictMatter; } });
68
+ Object.defineProperty(exports, "gitGetMatterCache", { enumerable: true, get: function () { return repo_1.gitGetMatterCache; } });
69
+ Object.defineProperty(exports, "gitSetMatterCache", { enumerable: true, get: function () { return repo_1.gitSetMatterCache; } });
70
+ // deprecated / legacy registry helpers
71
+ // deprecated: low-level test helper only
63
72
  Object.defineProperty(exports, "gitReloadIDRegistry", { enumerable: true, get: function () { return repo_1.gitReloadIDRegistry; } });
73
+ // deprecated: prefer gitCreateOrEditFile / gitUpdateMatter / gitRenameFile
64
74
  Object.defineProperty(exports, "gitRegisterExistingID", { enumerable: true, get: function () { return repo_1.gitRegisterExistingID; } });
75
+ // deprecated: prefer document mutation APIs instead of pre-mutating matter
65
76
  Object.defineProperty(exports, "gitEnsureMatterID", { enumerable: true, get: function () { return repo_1.gitEnsureMatterID; } });
66
- Object.defineProperty(exports, "gitFileStrictMatter", { enumerable: true, get: function () { return repo_1.gitFileStrictMatter; } });
77
+ // deprecated: avoid pre-checks, rely on gitEnsureMatterID / gitFileStrictMatter
67
78
  Object.defineProperty(exports, "gitIDRegistryExists", { enumerable: true, get: function () { return repo_1.gitIDRegistryExists; } });
79
+ // deprecated: cache rename is handled by gitRenameFile
68
80
  Object.defineProperty(exports, "gitIDRegistryRename", { enumerable: true, get: function () { return repo_1.gitIDRegistryRename; } });
69
81
  // === GESTION DES PULL REQUESTS (repo.pr.ts) ===
70
82
  var repo_pr_1 = require("./repo.pr");
71
83
  // Synchronisation et statut
84
+ // deprecated: prefer workflow-level sync orchestration
72
85
  Object.defineProperty(exports, "gitSyncPR", { enumerable: true, get: function () { return repo_pr_1.gitSyncPR; } });
86
+ // deprecated: use gitIsPRClosedRobust
73
87
  Object.defineProperty(exports, "gitIsPRClosed", { enumerable: true, get: function () { return repo_pr_1.gitIsPRClosed; } });
74
88
  Object.defineProperty(exports, "gitIsPRClosedRobust", { enumerable: true, get: function () { return repo_pr_1.gitIsPRClosedRobust; } });
89
+ // deprecated: use gitLoadPR for full metadata
75
90
  Object.defineProperty(exports, "gitGetPRMetadata", { enumerable: true, get: function () { return repo_pr_1.gitGetPRMetadata; } });
76
91
  Object.defineProperty(exports, "gitGetAllPR", { enumerable: true, get: function () { return repo_pr_1.gitGetAllPR; } });
92
+ // deprecated: use gitGetAllPR(..., { closed: true })
77
93
  Object.defineProperty(exports, "gitGetClosedPRs", { enumerable: true, get: function () { return repo_pr_1.gitGetClosedPRs; } });
78
94
  Object.defineProperty(exports, "gitLoadPR", { enumerable: true, get: function () { return repo_pr_1.gitLoadPR; } });
79
95
  // Opérations sur les PRs
80
96
  Object.defineProperty(exports, "gitPRUpdateComments", { enumerable: true, get: function () { return repo_pr_1.gitPRUpdateComments; } });
97
+ // deprecated: use gitClosePRRobust
81
98
  Object.defineProperty(exports, "gitClosePR", { enumerable: true, get: function () { return repo_pr_1.gitClosePR; } });
82
99
  Object.defineProperty(exports, "gitClosePRRobust", { enumerable: true, get: function () { return repo_pr_1.gitClosePRRobust; } });
83
- Object.defineProperty(exports, "gitGetNextPRNumber", { enumerable: true, get: function () { return repo_pr_1.gitGetNextPRNumber; } });
84
100
  Object.defineProperty(exports, "gitNewValidationRequest", { enumerable: true, get: function () { return repo_pr_1.gitNewValidationRequest; } });
101
+ // deprecated: alias of gitNewValidationRequest
85
102
  Object.defineProperty(exports, "gitNewPR", { enumerable: true, get: function () { return repo_pr_1.gitNewPR; } });
86
103
  __exportStar(require("./git.e2e.helper"), exports);
87
104
  __exportStar(require("./git.health"), exports);
@@ -1,5 +1,5 @@
1
1
  import { SimpleGit } from 'simple-git';
2
- import { RulesGitConfig, GitCommitHistory, RuleUser, GitHealthStatus } from '../types';
2
+ import { FrontMatter, RulesGitConfig, GitCommitHistory, RuleUser, GitHealthStatus } from '../types';
3
3
  /**
4
4
  * Structure du cache matter pour un fichier
5
5
  */
@@ -7,7 +7,10 @@ interface MatterStrict {
7
7
  id?: number;
8
8
  title?: string;
9
9
  service?: string;
10
- oldfile?: string;
10
+ }
11
+ export interface GitDocumentMutationOptions {
12
+ config?: RulesGitConfig;
13
+ matter?: Partial<FrontMatter>;
11
14
  }
12
15
  /**
13
16
  * Vérifie si le fichier de registre d'IDs existe dans le repository Git
@@ -16,6 +19,9 @@ interface MatterStrict {
16
19
  * dans le repository. Le fichier `with-ids.json` est créé automatiquement lors du
17
20
  * premier appel à `gitGenerateNextID()` ou `gitEnsureMatterID()`.
18
21
  *
22
+ * @deprecated API utilitaire de compatibilité. Préférer la résolution via
23
+ * gitEnsureMatterID() / gitFileStrictMatter() sans dépendre d'un check préalable.
24
+ *
19
25
  * @param config Configuration Git optionnelle (utilise la config par défaut si non fournie)
20
26
  * @returns `true` si le fichier `.git/with-ids.json` existe, `false` sinon
21
27
  *
@@ -40,6 +46,33 @@ export declare function gitIDRegistryExists(config?: RulesGitConfig): boolean;
40
46
  * @returns Un nouvel ID unique
41
47
  */
42
48
  export declare function gitGenerateNextID(config?: RulesGitConfig): number;
49
+ /**
50
+ * Génère le prochain numéro de PR via le registre `.git/with-ids.json`.
51
+ * Cette séquence est indépendante des IDs documentaires.
52
+ *
53
+ * @param config Configuration Git optionnelle
54
+ * @param minValue Valeur plancher du compteur PR (60 par défaut)
55
+ * @returns Prochain numéro de PR
56
+ */
57
+ export declare function gitGenerateNextPRNumber(config?: RulesGitConfig, minValue?: number): number;
58
+ /**
59
+ * Réaligne le compteur PR du registre sur une borne minimale sans allouer de numéro.
60
+ *
61
+ * @param minCounter Valeur minimale à garantir pour `lastPR`
62
+ * @param config Configuration Git optionnelle
63
+ */
64
+ export declare function gitEnsureMinimumPRCounter(minCounter: number, config?: RulesGitConfig): void;
65
+ /**
66
+ * Alloue le prochain numéro de PR en réalignant d'abord le compteur registre
67
+ * sur les branches de validation existantes.
68
+ *
69
+ * @param git Instance Git
70
+ * @param validationPrefix Préfixe des branches de validation
71
+ * @param config Configuration Git optionnelle
72
+ * @param minValue Valeur plancher du compteur PR (60 par défaut)
73
+ * @returns Prochain numéro de PR
74
+ */
75
+ export declare function gitAllocateNextPRNumber(git: SimpleGit, validationPrefix: string, config?: RulesGitConfig, minValue?: number): Promise<number>;
43
76
  /**
44
77
  * Force le rechargement du registre d'IDs depuis le disque
45
78
  *
@@ -56,11 +89,16 @@ export declare function gitGenerateNextID(config?: RulesGitConfig): number;
56
89
  * await gitCreateOrEditFile(...); // Modifie le registre
57
90
  * gitReloadIDRegistry(); // Force le rechargement depuis le disque
58
91
  * ```
92
+ *
93
+ * @deprecated Réservé aux tests de bas niveau. Ne pas utiliser dans le workflow applicatif.
59
94
  */
60
95
  export declare function gitReloadIDRegistry(config?: RulesGitConfig): void;
61
96
  /**
62
97
  * Enregistre un ID existant dans le registre
63
98
  *
99
+ * @deprecated Préférer `gitCreateOrEditFile(...)`, `gitUpdateMatter(...)` ou
100
+ * `gitRenameFile(...)` qui synchronisent le registre dans le même flux documentaire.
101
+ *
64
102
  * @param matter Le matter contenant l'ID à enregistrer
65
103
  * @param branch Branche du fichier (optionnel, pour vérification de propriété)
66
104
  * @param file Nom du fichier (optionnel, pour vérification de propriété)
@@ -77,6 +115,8 @@ export declare function gitRegisterExistingID(matter: MatterStrict, branch?: str
77
115
  /**
78
116
  * Renomme un fichier dans le cache du registre d'IDs
79
117
  *
118
+ * @deprecated Le cache de matter/ID est maintenant mis à jour par `gitRenameFile(...)`.
119
+ *
80
120
  * Cette fonction met à jour le cache lorsqu'un fichier est renommé:
81
121
  * - Supprime l'entrée avec l'ancien nom
82
122
  * - Crée une nouvelle entrée avec le nouveau nom
@@ -94,6 +134,13 @@ export declare function gitRegisterExistingID(matter: MatterStrict, branch?: str
94
134
  * ```
95
135
  */
96
136
  export declare function gitIDRegistryRename(oldFile: string, newFile: string, branch: string, config?: RulesGitConfig): void;
137
+ export declare function gitGetMatterCache(branch: string, id: number, config?: RulesGitConfig): {
138
+ id?: number;
139
+ file?: string;
140
+ title?: string;
141
+ service?: string;
142
+ } | undefined;
143
+ export declare function gitSetMatterCache(branch: string, file: string, matter: MatterStrict, config?: RulesGitConfig): void;
97
144
  /**
98
145
  * Valide et assure qu'un matter a un ID valide
99
146
  *
@@ -134,7 +181,6 @@ export declare function gitEnsureMatterID(matter: MatterStrict, config?: RulesGi
134
181
  export declare function gitFileStrictMatter(git: SimpleGit, filePath: string, branch: string, config?: RulesGitConfig): Promise<{
135
182
  id?: number;
136
183
  title?: string;
137
- oldfile?: string;
138
184
  }>;
139
185
  /**
140
186
  * Vérifie et configure un repository Git existant pour s'assurer qu'il a la configuration requise
@@ -214,6 +260,9 @@ export declare function gitCheckConfiguration(git?: SimpleGit): Promise<any>;
214
260
  export declare function gitCreateOrEditFile(git: SimpleGit, filePath: string, PR: string, content: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
215
261
  /**
216
262
  * Modifie un fichier dans la branche draft (opération bas niveau)
263
+ *
264
+ * @deprecated Utiliser gitCreateOrEditFile() qui couvre création + édition.
265
+ *
217
266
  * @param git Instance Git
218
267
  * @param filePath Chemin du fichier
219
268
  * @param PR Nom de la branche de Pull Request
@@ -223,8 +272,13 @@ export declare function gitCreateOrEditFile(git: SimpleGit, filePath: string, PR
223
272
  * @throws GitOperationError si la modification échoue
224
273
  */
225
274
  export declare function gitEditFile(git: SimpleGit, filePath: string, PR: string, content: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
226
- export declare function gitRenameFile_git(git: SimpleGit, oldFileName: string, newFileName: string, branch: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
227
- export declare function gitRenameFile_fs(git: SimpleGit, oldFileName: string, newFileName: string, branch: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
275
+ /**
276
+ * Met à jour le front-matter d'un document sans changer son nom de fichier.
277
+ *
278
+ * Cette API refuse explicitement toute mutation du `title` qui nécessiterait
279
+ * un changement de slug / filename. Dans ce cas, utiliser `gitRenameFile(...)`.
280
+ */
281
+ export declare function gitUpdateMatter(git: SimpleGit, filePath: string, branch: string, user: RuleUser, options?: GitDocumentMutationOptions | RulesGitConfig): Promise<GitCommitHistory>;
228
282
  /**
229
283
  * Renomme un fichier de manière atomique (Git ou filesystem selon le contexte)
230
284
  * @param git Instance SimpleGit
@@ -235,7 +289,7 @@ export declare function gitRenameFile_fs(git: SimpleGit, oldFileName: string, ne
235
289
  * @param config Configuration Git optionnelle
236
290
  * @returns Historique du commit de renommage
237
291
  */
238
- export declare function gitRenameFile(git: SimpleGit, oldFileName: string, newFileName: string, branch: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
292
+ export declare function gitRenameFile(git: SimpleGit, oldFileName: string, newFileName: string, branch: string, user: RuleUser, options?: GitDocumentMutationOptions | RulesGitConfig, nextContent?: string): Promise<GitCommitHistory>;
239
293
  /**
240
294
  * Supprime un fichier d'une branche Git (opération bas niveau)
241
295
  * @param git Instance Git
@@ -249,6 +303,8 @@ export declare function gitDeleteFile(git: SimpleGit, filePath: string, branch:
249
303
  /**
250
304
  * Diagnostique l'état de santé d'une branche Git et détecte les problèmes bloquants.
251
305
  *
306
+ * @deprecated Utiliser GitHealthManager pour les diagnostics et réparations.
307
+ *
252
308
  * **Problèmes bloquants détectés :**
253
309
  * - ❌ **Branche inexistante** : La branche spécifiée n'existe pas dans le dépôt
254
310
  * - ❌ **Branche inaccessible** : Impossible de faire un checkout vers la branche
@@ -272,6 +328,8 @@ export declare function gitGetBranchHealth(git: SimpleGit, branch?: string): Pro
272
328
  /**
273
329
  * Version optimisée de gitGetBranchHealth pour les branches de validation
274
330
  *
331
+ * @deprecated Utiliser GitHealthManager.diagnoseValidationBranches() / repairValidationBranches().
332
+ *
275
333
  * Cette fonction utilise une approche en cascade pour diagnostiquer rapidement
276
334
  * l'état d'une branche de validation sans effectuer de checkout coûteux.
277
335
  *