agentic-api 2.0.26 → 2.0.314
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/README.md +224 -60
- package/dist/src/agents/agents.example.js +21 -22
- package/dist/src/agents/authentication.js +1 -2
- package/dist/src/agents/prompts.d.ts +5 -4
- package/dist/src/agents/prompts.js +42 -87
- package/dist/src/agents/reducer.core.d.ts +24 -2
- package/dist/src/agents/reducer.core.js +125 -35
- package/dist/src/agents/reducer.loaders.d.ts +55 -1
- package/dist/src/agents/reducer.loaders.js +114 -1
- package/dist/src/agents/reducer.types.d.ts +45 -2
- package/dist/src/agents/semantic.js +1 -2
- package/dist/src/agents/simulator.d.ts +4 -0
- package/dist/src/agents/simulator.executor.d.ts +5 -1
- package/dist/src/agents/simulator.executor.js +41 -9
- package/dist/src/agents/simulator.js +86 -28
- package/dist/src/agents/simulator.prompts.d.ts +3 -2
- package/dist/src/agents/simulator.prompts.js +52 -78
- package/dist/src/agents/simulator.types.d.ts +20 -5
- package/dist/src/agents/simulator.utils.d.ts +7 -2
- package/dist/src/agents/simulator.utils.js +33 -11
- package/dist/src/agents/system.js +1 -2
- package/dist/src/execute.d.ts +17 -3
- package/dist/src/execute.js +156 -158
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/{princing.openai.d.ts → pricing.llm.d.ts} +6 -0
- package/dist/src/pricing.llm.js +234 -0
- package/dist/src/prompts.d.ts +13 -4
- package/dist/src/prompts.js +221 -114
- package/dist/src/rag/embeddings.d.ts +36 -18
- package/dist/src/rag/embeddings.js +125 -128
- package/dist/src/rag/index.d.ts +5 -5
- package/dist/src/rag/index.js +14 -17
- package/dist/src/rag/parser.d.ts +2 -1
- package/dist/src/rag/parser.js +11 -14
- package/dist/src/rag/rag.examples.d.ts +27 -0
- package/dist/src/rag/rag.examples.js +151 -0
- package/dist/src/rag/rag.manager.d.ts +383 -0
- package/dist/src/rag/rag.manager.js +1378 -0
- package/dist/src/rag/types.d.ts +128 -12
- package/dist/src/rag/types.js +100 -1
- package/dist/src/rag/usecase.d.ts +37 -0
- package/dist/src/rag/usecase.js +96 -7
- package/dist/src/rules/git/git.e2e.helper.js +1 -0
- package/dist/src/rules/git/git.health.d.ts +57 -0
- package/dist/src/rules/git/git.health.js +281 -1
- package/dist/src/rules/git/index.d.ts +2 -2
- package/dist/src/rules/git/index.js +12 -1
- package/dist/src/rules/git/repo.d.ts +117 -0
- package/dist/src/rules/git/repo.js +536 -0
- package/dist/src/rules/git/repo.tools.d.ts +22 -1
- package/dist/src/rules/git/repo.tools.js +50 -1
- package/dist/src/rules/types.d.ts +16 -14
- package/dist/src/rules/utils.matter.d.ts +0 -4
- package/dist/src/rules/utils.matter.js +26 -7
- package/dist/src/scrapper.d.ts +15 -22
- package/dist/src/scrapper.js +57 -110
- package/dist/src/stategraph/index.d.ts +1 -1
- package/dist/src/stategraph/stategraph.d.ts +31 -2
- package/dist/src/stategraph/stategraph.js +93 -6
- package/dist/src/stategraph/stategraph.storage.js +4 -0
- package/dist/src/stategraph/types.d.ts +22 -0
- package/dist/src/types.d.ts +4 -2
- package/dist/src/types.js +1 -1
- package/dist/src/usecase.d.ts +11 -2
- package/dist/src/usecase.js +27 -35
- package/dist/src/utils.d.ts +32 -18
- package/dist/src/utils.js +60 -126
- package/package.json +7 -2
- package/dist/src/agents/digestor.test.d.ts +0 -1
- package/dist/src/agents/digestor.test.js +0 -45
- package/dist/src/agents/reducer.example.d.ts +0 -28
- package/dist/src/agents/reducer.example.js +0 -118
- package/dist/src/agents/reducer.process.d.ts +0 -16
- package/dist/src/agents/reducer.process.js +0 -143
- package/dist/src/agents/reducer.tools.d.ts +0 -29
- package/dist/src/agents/reducer.tools.js +0 -157
- package/dist/src/agents/simpleExample.d.ts +0 -3
- package/dist/src/agents/simpleExample.js +0 -38
- package/dist/src/agents/system-review.d.ts +0 -5
- package/dist/src/agents/system-review.js +0 -181
- package/dist/src/agents/systemReview.d.ts +0 -4
- package/dist/src/agents/systemReview.js +0 -22
- package/dist/src/princing.openai.js +0 -54
- package/dist/src/rag/tools.d.ts +0 -76
- package/dist/src/rag/tools.js +0 -196
- package/dist/src/rules/user.mapper.d.ts +0 -61
- package/dist/src/rules/user.mapper.js +0 -160
- package/dist/src/rules/utils/slug.d.ts +0 -22
- package/dist/src/rules/utils/slug.js +0 -35
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GitHealthManager = void 0;
|
|
4
4
|
const git_1 = require("../git");
|
|
5
|
+
const utils_matter_1 = require("../utils.matter");
|
|
6
|
+
const repo_1 = require("./repo");
|
|
5
7
|
/**
|
|
6
8
|
* Git Repository Health Manager
|
|
7
9
|
*
|
|
@@ -173,7 +175,7 @@ class GitHealthManager {
|
|
|
173
175
|
*/
|
|
174
176
|
displayHealthSummary(health) {
|
|
175
177
|
if (health.healthy) {
|
|
176
|
-
console.log(`✅ ${health.branch}`);
|
|
178
|
+
//console.log(`✅ ${health.branch}`);
|
|
177
179
|
}
|
|
178
180
|
else {
|
|
179
181
|
console.log(`⚠️ ${health.branch}: ${health.issues.slice(0, 2).join(', ')}${health.issues.length > 2 ? '...' : ''}`);
|
|
@@ -350,5 +352,283 @@ class GitHealthManager {
|
|
|
350
352
|
console.log(`✅ Migration des notes terminée: ${migratedCount} migrées, ${alreadyOkCount} déjà OK`);
|
|
351
353
|
}
|
|
352
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Analyse les IDs des documents Markdown dans une branche
|
|
357
|
+
*
|
|
358
|
+
* @param branch Branche à analyser (par défaut: toutes les branches)
|
|
359
|
+
* @returns Rapport d'analyse avec les fichiers problématiques
|
|
360
|
+
*/
|
|
361
|
+
async analyseSafeIDs(branch) {
|
|
362
|
+
const isValidInteger = (value) => {
|
|
363
|
+
return typeof value === 'number' && value > 0 && value % 1 === 0;
|
|
364
|
+
};
|
|
365
|
+
// Vérifier si la validation des IDs est activée
|
|
366
|
+
if (!this.config.withID) {
|
|
367
|
+
console.log('ℹ️ La validation des IDs est désactivée (withID: false)');
|
|
368
|
+
return {
|
|
369
|
+
scanned: 0,
|
|
370
|
+
valid: 0,
|
|
371
|
+
missingID: [],
|
|
372
|
+
missingTitle: [],
|
|
373
|
+
invalidID: [],
|
|
374
|
+
duplicateID: [],
|
|
375
|
+
errors: []
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
console.log(`🔍 Analyse des documents Markdown pour validation des IDs...`);
|
|
379
|
+
//
|
|
380
|
+
// First time we check if the ID registry exists, and force the strictID mode
|
|
381
|
+
this.config.strictID = !(0, repo_1.gitIDRegistryExists)(this.config) || this.config.strictID;
|
|
382
|
+
if (this.config.strictID) {
|
|
383
|
+
console.log(` Mode strict activé: documents sans ID seront rejetés`);
|
|
384
|
+
}
|
|
385
|
+
const report = {
|
|
386
|
+
scanned: 0,
|
|
387
|
+
valid: 0,
|
|
388
|
+
missingID: [],
|
|
389
|
+
missingTitle: [],
|
|
390
|
+
invalidID: [],
|
|
391
|
+
duplicateID: [],
|
|
392
|
+
errors: []
|
|
393
|
+
};
|
|
394
|
+
try {
|
|
395
|
+
// Déterminer les branches à scanner
|
|
396
|
+
const branchesToScan = branch
|
|
397
|
+
? [branch]
|
|
398
|
+
: await (0, git_1.gitGetAllBranches)(this.git);
|
|
399
|
+
console.log(`📂 Branches à scanner: ${branchesToScan.length} (${branchesToScan.join(', ')})`);
|
|
400
|
+
for (const branchName of branchesToScan) {
|
|
401
|
+
try {
|
|
402
|
+
// Lister tous les fichiers .md dans la branche
|
|
403
|
+
const allFiles = await (0, git_1.gitListFilesInBranch)(this.git, branchName);
|
|
404
|
+
const mdFiles = allFiles.filter(f => f.endsWith('.md'));
|
|
405
|
+
// Variables pour suivre les problèmes dans cette branche
|
|
406
|
+
let branchHasIssues = false;
|
|
407
|
+
const branchIssues = [];
|
|
408
|
+
for (const file of mdFiles) {
|
|
409
|
+
report.scanned++;
|
|
410
|
+
try {
|
|
411
|
+
// ✅ OPTIMISATION: Lecture rapide du matter (id + title uniquement)
|
|
412
|
+
// Utilise le cache, évite de parser tout le fichier
|
|
413
|
+
const matter = await (0, git_1.gitFileStrictMatter)(this.git, file, branchName, this.config);
|
|
414
|
+
// Vérification de l'ID et du titre
|
|
415
|
+
let hasValidID = false;
|
|
416
|
+
let hasValidTitle = false;
|
|
417
|
+
const fileRef = `${branchName}:${file}`;
|
|
418
|
+
if (!isValidInteger(matter.id)) {
|
|
419
|
+
report.missingID.push(fileRef);
|
|
420
|
+
branchHasIssues = true;
|
|
421
|
+
branchIssues.push(` ⚠️ ${file}: ID manquant`);
|
|
422
|
+
}
|
|
423
|
+
else if (matter.id <= 999) {
|
|
424
|
+
report.invalidID.push(`${fileRef} (id=${matter.id})`);
|
|
425
|
+
branchHasIssues = true;
|
|
426
|
+
branchIssues.push(` ⚠️ ${file}: ID invalide (${matter.id} <= 999)`);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
hasValidID = true;
|
|
430
|
+
// Enregistrer l'ID existant dans le registry
|
|
431
|
+
// ✅ Passer branch et file pour vérifier si l'ID appartient au même fichier
|
|
432
|
+
try {
|
|
433
|
+
(0, git_1.gitRegisterExistingID)(matter.id, branchName, file, this.config);
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
if (error.code === 'id_already_used') {
|
|
437
|
+
// Compter les doublons mais ne pas les ajouter aux erreurs (seront réparés)
|
|
438
|
+
report.duplicateID.push(`${fileRef} (id=${matter.id})`);
|
|
439
|
+
hasValidID = false;
|
|
440
|
+
branchHasIssues = true;
|
|
441
|
+
branchIssues.push(` ⚠️ ${file}: ID ${matter.id} déjà utilisé`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
// Vérification du titre
|
|
446
|
+
if (!matter.title || matter.title.trim() === '') {
|
|
447
|
+
report.missingTitle.push(fileRef);
|
|
448
|
+
branchHasIssues = true;
|
|
449
|
+
branchIssues.push(` ⚠️ ${file}: Titre manquant`);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
hasValidTitle = true;
|
|
453
|
+
}
|
|
454
|
+
// Si le document est valide (ID + titre)
|
|
455
|
+
if (hasValidID && hasValidTitle) {
|
|
456
|
+
report.valid++;
|
|
457
|
+
}
|
|
458
|
+
// Mode strict sans auto-fix : rejeter
|
|
459
|
+
if (!hasValidID && this.config.strictID) {
|
|
460
|
+
report.errors.push(`${fileRef} - Document rejeté (strictID: true, ID invalide)`);
|
|
461
|
+
branchIssues.push(` ❌ ${file}: REJETÉ (mode strict)`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
catch (parseError) {
|
|
465
|
+
const fileRef = `${branchName}:${file}`;
|
|
466
|
+
report.errors.push(`${fileRef} - Erreur de parsing: ${parseError.message}`);
|
|
467
|
+
branchIssues.push(` ❌ ${file}: Erreur de parsing: ${parseError.message}`);
|
|
468
|
+
branchHasIssues = true;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// Afficher les problèmes de la branche seulement s'il y en a
|
|
472
|
+
if (branchHasIssues) {
|
|
473
|
+
console.log(`\n📂 Scan de la branche: ${branchName} (${mdFiles.length} fichiers)`);
|
|
474
|
+
branchIssues.forEach(issue => console.log(issue));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
catch (branchError) {
|
|
478
|
+
report.errors.push(`${branchName} - Erreur lors du scan: ${branchError.message}`);
|
|
479
|
+
console.error(` ❌ Erreur lors du scan de ${branchName}:`, branchError.message);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// Résumé
|
|
483
|
+
console.log(`\n📊 Résumé de l'analyse:`);
|
|
484
|
+
console.log(` Documents scannés: ${report.scanned}`);
|
|
485
|
+
console.log(` ✅ Valides: ${report.valid}`);
|
|
486
|
+
if (report.missingID.length > 0)
|
|
487
|
+
console.log(` ⚠️ IDs manquants: ${report.missingID.length}`);
|
|
488
|
+
if (report.missingTitle.length > 0)
|
|
489
|
+
console.log(` ⚠️ Titres manquants: ${report.missingTitle.length}`);
|
|
490
|
+
if (report.invalidID.length > 0)
|
|
491
|
+
console.log(` ⚠️ IDs invalides: ${report.invalidID.length}`);
|
|
492
|
+
if (report.duplicateID.length > 0)
|
|
493
|
+
console.log(` ⚠️ IDs en doublon: ${report.duplicateID.length}`);
|
|
494
|
+
if (report.errors.length > 0)
|
|
495
|
+
console.log(` ❌ Erreurs: ${report.errors.length}`);
|
|
496
|
+
return report;
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
console.error('❌ Erreur lors de l\'analyse des documents:', error);
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Répare les IDs problématiques identifiés dans un rapport d'analyse
|
|
505
|
+
*
|
|
506
|
+
* @param report Rapport d'analyse généré par analyseSafeIDs
|
|
507
|
+
* @param options Options de réparation
|
|
508
|
+
* @param options.dryRun Mode simulation (affiche les réparations sans modifier)
|
|
509
|
+
* @returns Rapport mis à jour avec les fichiers réparés
|
|
510
|
+
*/
|
|
511
|
+
async repairSafeIDs(report, options = {}) {
|
|
512
|
+
const { dryRun = false } = options;
|
|
513
|
+
console.log(`\n🔧 ${dryRun ? 'SIMULATION' : 'RÉPARATION'} des IDs problématiques...`);
|
|
514
|
+
const updatedReport = {
|
|
515
|
+
scanned: report.scanned,
|
|
516
|
+
valid: report.valid,
|
|
517
|
+
missingID: [...report.missingID],
|
|
518
|
+
missingTitle: [...report.missingTitle],
|
|
519
|
+
invalidID: [...report.invalidID],
|
|
520
|
+
duplicateID: [...report.duplicateID],
|
|
521
|
+
errors: [...report.errors]
|
|
522
|
+
};
|
|
523
|
+
// Collecter tous les fichiers à réparer
|
|
524
|
+
const filesToFix = [
|
|
525
|
+
...report.missingID,
|
|
526
|
+
...report.missingTitle,
|
|
527
|
+
...report.invalidID.map(e => e.split(' (id=')[0]),
|
|
528
|
+
...report.duplicateID.map(e => e.split(' (id=')[0])
|
|
529
|
+
];
|
|
530
|
+
let fixed = 0;
|
|
531
|
+
const fixedFiles = new Set();
|
|
532
|
+
for (const fileRef of filesToFix) {
|
|
533
|
+
// Éviter de réparer deux fois le même fichier
|
|
534
|
+
if (fixedFiles.has(fileRef)) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
const [branchName, ...fileParts] = fileRef.split(':');
|
|
538
|
+
const file = fileParts.join(':');
|
|
539
|
+
try {
|
|
540
|
+
if (!dryRun) {
|
|
541
|
+
// Lire le contenu complet pour réparer
|
|
542
|
+
const fileData = await (0, git_1.gitGetFileContent)(this.git, file, branchName);
|
|
543
|
+
if (!fileData || !fileData.content) {
|
|
544
|
+
updatedReport.errors.push(`${fileRef} - Fichier inaccessible pour réparation`);
|
|
545
|
+
console.log(` ❌ ${file}: Fichier inaccessible`);
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
// Parser le matter complet
|
|
549
|
+
const parsed = (0, utils_matter_1.matterParse)(fileData.content);
|
|
550
|
+
const { matter: fullMatter, content } = parsed;
|
|
551
|
+
// Générer un nouvel ID
|
|
552
|
+
fullMatter.id = (0, git_1.gitGenerateNextID)(this.config);
|
|
553
|
+
console.log(` 🔧 ${file}: Génération d'un nouvel ID: ${fullMatter.id}`);
|
|
554
|
+
// Re-sérialiser et sauvegarder
|
|
555
|
+
const updatedContent = (0, utils_matter_1.matterSerialize)(content, fullMatter);
|
|
556
|
+
// ✅ IMPORTANT: Désactiver withID car l'ID est déjà généré et enregistré
|
|
557
|
+
// Évite la double validation qui cause "ID déjà utilisé"
|
|
558
|
+
await (0, repo_1.gitCreateOrEditFile)(this.git, file, branchName, updatedContent, { name: 'GitHealthManager', email: 'health@system' }, { ...this.config, canForce: true, withID: false });
|
|
559
|
+
fixed++;
|
|
560
|
+
fixedFiles.add(fileRef);
|
|
561
|
+
console.log(` ✅ ${file}: Réparé avec ID ${fullMatter.id}`);
|
|
562
|
+
// Retirer des listes de problèmes
|
|
563
|
+
updatedReport.missingID = updatedReport.missingID.filter(f => f !== fileRef);
|
|
564
|
+
updatedReport.missingTitle = updatedReport.missingTitle.filter(f => f !== fileRef);
|
|
565
|
+
updatedReport.invalidID = updatedReport.invalidID.filter(f => !f.startsWith(fileRef));
|
|
566
|
+
updatedReport.duplicateID = updatedReport.duplicateID.filter(f => !f.startsWith(fileRef));
|
|
567
|
+
updatedReport.valid++;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
// Mode simulation
|
|
571
|
+
console.log(` 🔍 ${file}: Nécessite réparation (simulation)`);
|
|
572
|
+
fixed++;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
catch (fixError) {
|
|
576
|
+
updatedReport.errors.push(`${fileRef} - Erreur de réparation: ${fixError.message}`);
|
|
577
|
+
console.log(` ❌ ${file}: Erreur de réparation: ${fixError.message}`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
// Résumé
|
|
581
|
+
console.log(`\n📊 Résumé de la réparation:`);
|
|
582
|
+
console.log(` ${dryRun ? 'Fichiers à réparer' : 'Fichiers réparés'}: ${fixed}`);
|
|
583
|
+
if (!dryRun) {
|
|
584
|
+
console.log(` ✅ Valides après réparation: ${updatedReport.valid}`);
|
|
585
|
+
if (updatedReport.missingID.length > 0)
|
|
586
|
+
console.log(` ⚠️ IDs manquants restants: ${updatedReport.missingID.length}`);
|
|
587
|
+
if (updatedReport.missingTitle.length > 0)
|
|
588
|
+
console.log(` ⚠️ Titres manquants restants: ${updatedReport.missingTitle.length}`);
|
|
589
|
+
if (updatedReport.invalidID.length > 0)
|
|
590
|
+
console.log(` ⚠️ IDs invalides restants: ${updatedReport.invalidID.length}`);
|
|
591
|
+
if (updatedReport.duplicateID.length > 0)
|
|
592
|
+
console.log(` ⚠️ IDs en doublon restants: ${updatedReport.duplicateID.length}`);
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
console.log(`\nℹ️ Mode simulation: Utilisez { dryRun: false } pour réparer effectivement`);
|
|
596
|
+
}
|
|
597
|
+
return updatedReport;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Vérifie et répare les IDs manquants dans tous les documents Markdown du repository
|
|
601
|
+
*
|
|
602
|
+
* Cette méthode orchestre l'analyse et la réparation :
|
|
603
|
+
* 1. Analyse les documents avec analyseSafeIDs()
|
|
604
|
+
* 2. Si autoFix est activé, répare avec repairSafeIDs()
|
|
605
|
+
*
|
|
606
|
+
* @param options Options de scan et réparation
|
|
607
|
+
* @param options.branch Branche spécifique à scanner (par défaut: toutes les branches)
|
|
608
|
+
* @param options.autoFix Active la réparation automatique (par défaut: false)
|
|
609
|
+
* @param options.dryRun Mode simulation (affiche les problèmes sans modifier)
|
|
610
|
+
* @returns Résumé des documents scannés et réparés
|
|
611
|
+
*/
|
|
612
|
+
async ensureSafeIDS(options = {}) {
|
|
613
|
+
const { branch, autoFix = false, dryRun = false } = options;
|
|
614
|
+
// Étape 1: Analyser
|
|
615
|
+
const report = await this.analyseSafeIDs(branch);
|
|
616
|
+
let finalReport = report;
|
|
617
|
+
// Étape 2: Réparer si demandé
|
|
618
|
+
if (autoFix && (report.missingID.length > 0 || report.missingTitle.length > 0 || report.invalidID.length > 0 || report.duplicateID.length > 0)) {
|
|
619
|
+
finalReport = await this.repairSafeIDs(report, { dryRun });
|
|
620
|
+
}
|
|
621
|
+
// Retourner dans l'ancien format pour compatibilité
|
|
622
|
+
return {
|
|
623
|
+
scanned: finalReport.scanned,
|
|
624
|
+
valid: finalReport.valid,
|
|
625
|
+
missingID: finalReport.missingID.length,
|
|
626
|
+
missingTitle: finalReport.missingTitle.length,
|
|
627
|
+
invalidID: finalReport.invalidID.length,
|
|
628
|
+
duplicateID: finalReport.duplicateID.length,
|
|
629
|
+
fixed: report.scanned - finalReport.scanned + finalReport.valid - report.valid,
|
|
630
|
+
errors: finalReport.errors
|
|
631
|
+
};
|
|
632
|
+
}
|
|
353
633
|
}
|
|
354
634
|
exports.GitHealthManager = GitHealthManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { lock, unlock, gitLoad, 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, gitCreateOrEditFile, gitEditFile, gitRenameFile, gitDeleteFile, } from './repo';
|
|
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, gitCreateOrEditFile, gitEditFile, gitRenameFile, gitDeleteFile, gitGenerateNextID, gitReloadIDRegistry, gitRegisterExistingID, gitEnsureMatterID, gitFileStrictMatter, gitIDRegistryExists, gitIDRegistryRename, } from './repo';
|
|
3
3
|
export { gitSyncPR, gitIsPRClosed, gitIsPRClosedRobust, gitGetPRMetadata, gitGetAllPR, gitGetClosedPRs, gitLoadPR, gitPRUpdateComments, gitClosePR, gitClosePRRobust, gitGetNextPRNumber, gitNewValidationRequest, gitNewPR, } from './repo.pr';
|
|
4
4
|
export * from './git.e2e.helper';
|
|
5
5
|
export * from './git.health';
|
|
@@ -14,7 +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.
|
|
17
|
+
exports.gitNewValidationRequest = 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.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 = void 0;
|
|
18
19
|
// === OPÉRATIONS GIT BAS NIVEAU ===
|
|
19
20
|
// Fonctions atomiques pour manipuler Git directement
|
|
20
21
|
var repo_tools_1 = require("./repo.tools");
|
|
@@ -23,6 +24,8 @@ Object.defineProperty(exports, "lock", { enumerable: true, get: function () { re
|
|
|
23
24
|
Object.defineProperty(exports, "unlock", { enumerable: true, get: function () { return repo_tools_1.unlock; } });
|
|
24
25
|
// Configuration
|
|
25
26
|
Object.defineProperty(exports, "gitLoad", { enumerable: true, get: function () { return repo_tools_1.gitLoad; } });
|
|
27
|
+
// Validation
|
|
28
|
+
Object.defineProperty(exports, "isValidInt", { enumerable: true, get: function () { return repo_tools_1.isValidInt; } });
|
|
26
29
|
// Lecture de fichiers
|
|
27
30
|
Object.defineProperty(exports, "gitIsFileMerged", { enumerable: true, get: function () { return repo_tools_1.gitIsFileMerged; } });
|
|
28
31
|
Object.defineProperty(exports, "gitLastCommit", { enumerable: true, get: function () { return repo_tools_1.gitLastCommit; } });
|
|
@@ -54,6 +57,14 @@ Object.defineProperty(exports, "gitCreateOrEditFile", { enumerable: true, get: f
|
|
|
54
57
|
Object.defineProperty(exports, "gitEditFile", { enumerable: true, get: function () { return repo_1.gitEditFile; } });
|
|
55
58
|
Object.defineProperty(exports, "gitRenameFile", { enumerable: true, get: function () { return repo_1.gitRenameFile; } });
|
|
56
59
|
Object.defineProperty(exports, "gitDeleteFile", { enumerable: true, get: function () { return repo_1.gitDeleteFile; } });
|
|
60
|
+
// ID Management & Matter Cache
|
|
61
|
+
Object.defineProperty(exports, "gitGenerateNextID", { enumerable: true, get: function () { return repo_1.gitGenerateNextID; } });
|
|
62
|
+
Object.defineProperty(exports, "gitReloadIDRegistry", { enumerable: true, get: function () { return repo_1.gitReloadIDRegistry; } });
|
|
63
|
+
Object.defineProperty(exports, "gitRegisterExistingID", { enumerable: true, get: function () { return repo_1.gitRegisterExistingID; } });
|
|
64
|
+
Object.defineProperty(exports, "gitEnsureMatterID", { enumerable: true, get: function () { return repo_1.gitEnsureMatterID; } });
|
|
65
|
+
Object.defineProperty(exports, "gitFileStrictMatter", { enumerable: true, get: function () { return repo_1.gitFileStrictMatter; } });
|
|
66
|
+
Object.defineProperty(exports, "gitIDRegistryExists", { enumerable: true, get: function () { return repo_1.gitIDRegistryExists; } });
|
|
67
|
+
Object.defineProperty(exports, "gitIDRegistryRename", { enumerable: true, get: function () { return repo_1.gitIDRegistryRename; } });
|
|
57
68
|
// === GESTION DES PULL REQUESTS (repo.pr.ts) ===
|
|
58
69
|
var repo_pr_1 = require("./repo.pr");
|
|
59
70
|
// Synchronisation et statut
|
|
@@ -1,5 +1,122 @@
|
|
|
1
1
|
import { SimpleGit } from 'simple-git';
|
|
2
2
|
import { RulesGitConfig, GitCommitHistory, RuleUser, GitHealthStatus } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Vérifie si le fichier de registre d'IDs existe dans le repository Git
|
|
5
|
+
*
|
|
6
|
+
* Cette fonction est utile pour détecter si le système d'ID natif a été initialisé
|
|
7
|
+
* dans le repository. Le fichier `with-ids.json` est créé automatiquement lors du
|
|
8
|
+
* premier appel à `gitGenerateNextID()` ou `gitEnsureMatterID()`.
|
|
9
|
+
*
|
|
10
|
+
* @param config Configuration Git optionnelle (utilise la config par défaut si non fournie)
|
|
11
|
+
* @returns `true` si le fichier `.git/with-ids.json` existe, `false` sinon
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const config = gitLoad({ repoPath: './my-repo' });
|
|
16
|
+
*
|
|
17
|
+
* if (gitIDRegistryExists(config)) {
|
|
18
|
+
* console.log('Le registre d\'IDs existe déjà');
|
|
19
|
+
* // On peut charger le registre existant
|
|
20
|
+
* gitReloadIDRegistry(config);
|
|
21
|
+
* } else {
|
|
22
|
+
* console.log('Première utilisation du système d\'IDs');
|
|
23
|
+
* // Le registre sera créé au premier gitGenerateNextID()
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function gitIDRegistryExists(config?: RulesGitConfig): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Génère un nouvel ID unique en incrémentant de +20
|
|
30
|
+
* @param config Configuration Git optionnelle
|
|
31
|
+
* @returns Un nouvel ID unique
|
|
32
|
+
*/
|
|
33
|
+
export declare function gitGenerateNextID(config?: RulesGitConfig): number;
|
|
34
|
+
/**
|
|
35
|
+
* Force le rechargement du registre d'IDs depuis le disque
|
|
36
|
+
*
|
|
37
|
+
* **Utilisé principalement pour les tests qui simulent un redémarrage du serveur.**
|
|
38
|
+
*
|
|
39
|
+
* En production, cette fonction n'est pas nécessaire car le singleton est
|
|
40
|
+
* réinitialisé à chaque redémarrage du process Node.js.
|
|
41
|
+
*
|
|
42
|
+
* @param config Configuration Git optionnelle
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Dans un test : simuler un redémarrage
|
|
47
|
+
* await gitCreateOrEditFile(...); // Modifie le registre
|
|
48
|
+
* gitReloadIDRegistry(); // Force le rechargement depuis le disque
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function gitReloadIDRegistry(config?: RulesGitConfig): void;
|
|
52
|
+
/**
|
|
53
|
+
* Enregistre un ID existant dans le registre
|
|
54
|
+
*
|
|
55
|
+
* @param id L'ID à enregistrer
|
|
56
|
+
* @param branch Branche du fichier (optionnel, pour vérification de propriété)
|
|
57
|
+
* @param file Nom du fichier (optionnel, pour vérification de propriété)
|
|
58
|
+
* @param config Configuration Git optionnelle
|
|
59
|
+
* @throws GitOperationError si l'ID est déjà utilisé par un autre fichier
|
|
60
|
+
*
|
|
61
|
+
* **Note:** Si `branch` et `file` sont fournis, la fonction vérifie si l'ID appartient
|
|
62
|
+
* déjà au même fichier. Si oui, aucune erreur n'est levée (cas de re-scan).
|
|
63
|
+
*/
|
|
64
|
+
export declare function gitRegisterExistingID(id: number, branch?: string, file?: string, config?: RulesGitConfig): void;
|
|
65
|
+
/**
|
|
66
|
+
* Renomme un fichier dans le cache du registre d'IDs
|
|
67
|
+
*
|
|
68
|
+
* Cette fonction met à jour le cache lorsqu'un fichier est renommé:
|
|
69
|
+
* - Supprime l'entrée avec l'ancien nom
|
|
70
|
+
* - Crée une nouvelle entrée avec le nouveau nom
|
|
71
|
+
* - Préserve l'ID et les métadonnées
|
|
72
|
+
*
|
|
73
|
+
* @param oldFile Ancien nom du fichier
|
|
74
|
+
* @param newFile Nouveau nom du fichier
|
|
75
|
+
* @param branch Branche concernée
|
|
76
|
+
* @param config Configuration Git optionnelle
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* // Après un rename dans Git
|
|
81
|
+
* gitIDRegistryRename('procedure-old.md', 'procedure-new.md', 'rule-validation-1');
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function gitIDRegistryRename(oldFile: string, newFile: string, branch: string, config?: RulesGitConfig): void;
|
|
85
|
+
/**
|
|
86
|
+
* Valide et assure qu'un matter a un ID valide
|
|
87
|
+
* @param matter Le matter à valider/compléter
|
|
88
|
+
* @param config Configuration Git optionnelle
|
|
89
|
+
* @returns Le matter mis à jour avec un ID valide
|
|
90
|
+
*/
|
|
91
|
+
export declare function gitEnsureMatterID(matter: any, config?: RulesGitConfig): any;
|
|
92
|
+
/**
|
|
93
|
+
* Lecture rapide et stricte du matter d'un fichier (id + title uniquement)
|
|
94
|
+
*
|
|
95
|
+
* **Optimisation : Utilise le cache du registre d'IDs pour éviter de lire le fichier.**
|
|
96
|
+
*
|
|
97
|
+
* Cette fonction :
|
|
98
|
+
* 1. Vérifie d'abord le cache dans `.git/with-ids.json`
|
|
99
|
+
* 2. Si absent ou invalidé, lit le fichier avec regex (pas de parsing complet)
|
|
100
|
+
* 3. Met à jour le cache automatiquement
|
|
101
|
+
*
|
|
102
|
+
* @param git Instance SimpleGit
|
|
103
|
+
* @param filePath Chemin du fichier
|
|
104
|
+
* @param branch Nom de la branche
|
|
105
|
+
* @param config Configuration Git optionnelle
|
|
106
|
+
* @returns { id, title } ou { id: undefined, title: undefined } si absent
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const matter = await gitFileStrictMatter(git, 'doc.md', 'main');
|
|
111
|
+
* console.log(matter.id); // 1234
|
|
112
|
+
* console.log(matter.title); // "Mon Document"
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function gitFileStrictMatter(git: SimpleGit, filePath: string, branch: string, config?: RulesGitConfig): Promise<{
|
|
116
|
+
id?: number;
|
|
117
|
+
title?: string;
|
|
118
|
+
oldfile?: string;
|
|
119
|
+
}>;
|
|
3
120
|
/**
|
|
4
121
|
* Vérifie et configure un repository Git existant pour s'assurer qu'il a la configuration requise
|
|
5
122
|
* @param git Instance SimpleGit
|