agentic-api 2.0.646 → 2.0.684
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/dist/src/agents/prompts.d.ts +1 -1
- package/dist/src/agents/prompts.js +8 -9
- package/dist/src/agents/reducer.loaders.d.ts +71 -0
- package/dist/src/agents/reducer.loaders.js +108 -1
- package/dist/src/agents/reducer.types.d.ts +5 -1
- package/dist/src/agents/simulator.d.ts +30 -1
- package/dist/src/agents/simulator.executor.d.ts +7 -3
- package/dist/src/agents/simulator.executor.js +81 -50
- package/dist/src/agents/simulator.js +161 -7
- package/dist/src/agents/simulator.prompts.d.ts +18 -0
- package/dist/src/agents/simulator.prompts.js +81 -4
- package/dist/src/agents/simulator.types.d.ts +29 -0
- package/dist/src/agents/simulator.types.js +5 -0
- package/dist/src/execute/helpers.js +1 -1
- package/dist/src/execute/responses.js +4 -5
- package/dist/src/rag/rag.manager.js +23 -7
- package/dist/src/rag/types.d.ts +3 -1
- package/dist/src/rules/git/git.e2e.helper.js +48 -4
- package/dist/src/rules/git/git.health.js +6 -4
- package/dist/src/rules/git/index.d.ts +2 -2
- package/dist/src/rules/git/index.js +11 -2
- package/dist/src/rules/git/repo.d.ts +39 -0
- package/dist/src/rules/git/repo.js +155 -8
- package/dist/src/rules/git/repo.pr.d.ts +11 -18
- package/dist/src/rules/git/repo.pr.js +37 -81
- package/dist/src/rules/types.d.ts +1 -1
- package/dist/src/stategraph/stategraph.d.ts +2 -2
- package/dist/src/stategraph/stategraph.js +5 -6
- package/dist/src/stategraph/types.d.ts +2 -6
- package/dist/src/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ 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.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.gitAllocateNextPRNumber = 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
18
|
exports.gitNewPR = exports.gitNewValidationRequest = void 0;
|
|
19
19
|
// === OPÉRATIONS GIT BAS NIVEAU ===
|
|
20
20
|
// Fonctions atomiques pour manipuler Git directement
|
|
@@ -55,33 +55,42 @@ Object.defineProperty(exports, "gitCheckConfiguration", { enumerable: true, get:
|
|
|
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
57
|
Object.defineProperty(exports, "gitCreateOrEditFile", { enumerable: true, get: function () { return repo_1.gitCreateOrEditFile; } });
|
|
58
|
+
// deprecated: use gitCreateOrEditFile
|
|
58
59
|
Object.defineProperty(exports, "gitEditFile", { enumerable: true, get: function () { return repo_1.gitEditFile; } });
|
|
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; } });
|
|
61
62
|
// ID Management & Matter Cache
|
|
62
63
|
Object.defineProperty(exports, "gitGenerateNextID", { enumerable: true, get: function () { return repo_1.gitGenerateNextID; } });
|
|
64
|
+
Object.defineProperty(exports, "gitAllocateNextPRNumber", { enumerable: true, get: function () { return repo_1.gitAllocateNextPRNumber; } });
|
|
65
|
+
// deprecated: low-level test helper only
|
|
63
66
|
Object.defineProperty(exports, "gitReloadIDRegistry", { enumerable: true, get: function () { return repo_1.gitReloadIDRegistry; } });
|
|
64
67
|
Object.defineProperty(exports, "gitRegisterExistingID", { enumerable: true, get: function () { return repo_1.gitRegisterExistingID; } });
|
|
65
68
|
Object.defineProperty(exports, "gitEnsureMatterID", { enumerable: true, get: function () { return repo_1.gitEnsureMatterID; } });
|
|
66
69
|
Object.defineProperty(exports, "gitFileStrictMatter", { enumerable: true, get: function () { return repo_1.gitFileStrictMatter; } });
|
|
70
|
+
// deprecated: avoid pre-checks, rely on gitEnsureMatterID / gitFileStrictMatter
|
|
67
71
|
Object.defineProperty(exports, "gitIDRegistryExists", { enumerable: true, get: function () { return repo_1.gitIDRegistryExists; } });
|
|
68
72
|
Object.defineProperty(exports, "gitIDRegistryRename", { enumerable: true, get: function () { return repo_1.gitIDRegistryRename; } });
|
|
69
73
|
// === GESTION DES PULL REQUESTS (repo.pr.ts) ===
|
|
70
74
|
var repo_pr_1 = require("./repo.pr");
|
|
71
75
|
// Synchronisation et statut
|
|
76
|
+
// deprecated: prefer workflow-level sync orchestration
|
|
72
77
|
Object.defineProperty(exports, "gitSyncPR", { enumerable: true, get: function () { return repo_pr_1.gitSyncPR; } });
|
|
78
|
+
// deprecated: use gitIsPRClosedRobust
|
|
73
79
|
Object.defineProperty(exports, "gitIsPRClosed", { enumerable: true, get: function () { return repo_pr_1.gitIsPRClosed; } });
|
|
74
80
|
Object.defineProperty(exports, "gitIsPRClosedRobust", { enumerable: true, get: function () { return repo_pr_1.gitIsPRClosedRobust; } });
|
|
81
|
+
// deprecated: use gitLoadPR for full metadata
|
|
75
82
|
Object.defineProperty(exports, "gitGetPRMetadata", { enumerable: true, get: function () { return repo_pr_1.gitGetPRMetadata; } });
|
|
76
83
|
Object.defineProperty(exports, "gitGetAllPR", { enumerable: true, get: function () { return repo_pr_1.gitGetAllPR; } });
|
|
84
|
+
// deprecated: use gitGetAllPR(..., { closed: true })
|
|
77
85
|
Object.defineProperty(exports, "gitGetClosedPRs", { enumerable: true, get: function () { return repo_pr_1.gitGetClosedPRs; } });
|
|
78
86
|
Object.defineProperty(exports, "gitLoadPR", { enumerable: true, get: function () { return repo_pr_1.gitLoadPR; } });
|
|
79
87
|
// Opérations sur les PRs
|
|
80
88
|
Object.defineProperty(exports, "gitPRUpdateComments", { enumerable: true, get: function () { return repo_pr_1.gitPRUpdateComments; } });
|
|
89
|
+
// deprecated: use gitClosePRRobust
|
|
81
90
|
Object.defineProperty(exports, "gitClosePR", { enumerable: true, get: function () { return repo_pr_1.gitClosePR; } });
|
|
82
91
|
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
92
|
Object.defineProperty(exports, "gitNewValidationRequest", { enumerable: true, get: function () { return repo_pr_1.gitNewValidationRequest; } });
|
|
93
|
+
// deprecated: alias of gitNewValidationRequest
|
|
85
94
|
Object.defineProperty(exports, "gitNewPR", { enumerable: true, get: function () { return repo_pr_1.gitNewPR; } });
|
|
86
95
|
__exportStar(require("./git.e2e.helper"), exports);
|
|
87
96
|
__exportStar(require("./git.health"), exports);
|
|
@@ -16,6 +16,9 @@ interface MatterStrict {
|
|
|
16
16
|
* dans le repository. Le fichier `with-ids.json` est créé automatiquement lors du
|
|
17
17
|
* premier appel à `gitGenerateNextID()` ou `gitEnsureMatterID()`.
|
|
18
18
|
*
|
|
19
|
+
* @deprecated API utilitaire de compatibilité. Préférer la résolution via
|
|
20
|
+
* gitEnsureMatterID() / gitFileStrictMatter() sans dépendre d'un check préalable.
|
|
21
|
+
*
|
|
19
22
|
* @param config Configuration Git optionnelle (utilise la config par défaut si non fournie)
|
|
20
23
|
* @returns `true` si le fichier `.git/with-ids.json` existe, `false` sinon
|
|
21
24
|
*
|
|
@@ -40,6 +43,33 @@ export declare function gitIDRegistryExists(config?: RulesGitConfig): boolean;
|
|
|
40
43
|
* @returns Un nouvel ID unique
|
|
41
44
|
*/
|
|
42
45
|
export declare function gitGenerateNextID(config?: RulesGitConfig): number;
|
|
46
|
+
/**
|
|
47
|
+
* Génère le prochain numéro de PR via le registre `.git/with-ids.json`.
|
|
48
|
+
* Cette séquence est indépendante des IDs documentaires.
|
|
49
|
+
*
|
|
50
|
+
* @param config Configuration Git optionnelle
|
|
51
|
+
* @param minValue Valeur plancher du compteur PR (60 par défaut)
|
|
52
|
+
* @returns Prochain numéro de PR
|
|
53
|
+
*/
|
|
54
|
+
export declare function gitGenerateNextPRNumber(config?: RulesGitConfig, minValue?: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Réaligne le compteur PR du registre sur une borne minimale sans allouer de numéro.
|
|
57
|
+
*
|
|
58
|
+
* @param minCounter Valeur minimale à garantir pour `lastPR`
|
|
59
|
+
* @param config Configuration Git optionnelle
|
|
60
|
+
*/
|
|
61
|
+
export declare function gitEnsureMinimumPRCounter(minCounter: number, config?: RulesGitConfig): void;
|
|
62
|
+
/**
|
|
63
|
+
* Alloue le prochain numéro de PR en réalignant d'abord le compteur registre
|
|
64
|
+
* sur les branches de validation existantes.
|
|
65
|
+
*
|
|
66
|
+
* @param git Instance Git
|
|
67
|
+
* @param validationPrefix Préfixe des branches de validation
|
|
68
|
+
* @param config Configuration Git optionnelle
|
|
69
|
+
* @param minValue Valeur plancher du compteur PR (60 par défaut)
|
|
70
|
+
* @returns Prochain numéro de PR
|
|
71
|
+
*/
|
|
72
|
+
export declare function gitAllocateNextPRNumber(git: SimpleGit, validationPrefix: string, config?: RulesGitConfig, minValue?: number): Promise<number>;
|
|
43
73
|
/**
|
|
44
74
|
* Force le rechargement du registre d'IDs depuis le disque
|
|
45
75
|
*
|
|
@@ -56,6 +86,8 @@ export declare function gitGenerateNextID(config?: RulesGitConfig): number;
|
|
|
56
86
|
* await gitCreateOrEditFile(...); // Modifie le registre
|
|
57
87
|
* gitReloadIDRegistry(); // Force le rechargement depuis le disque
|
|
58
88
|
* ```
|
|
89
|
+
*
|
|
90
|
+
* @deprecated Réservé aux tests de bas niveau. Ne pas utiliser dans le workflow applicatif.
|
|
59
91
|
*/
|
|
60
92
|
export declare function gitReloadIDRegistry(config?: RulesGitConfig): void;
|
|
61
93
|
/**
|
|
@@ -214,6 +246,9 @@ export declare function gitCheckConfiguration(git?: SimpleGit): Promise<any>;
|
|
|
214
246
|
export declare function gitCreateOrEditFile(git: SimpleGit, filePath: string, PR: string, content: string, user: RuleUser, config?: RulesGitConfig): Promise<GitCommitHistory>;
|
|
215
247
|
/**
|
|
216
248
|
* Modifie un fichier dans la branche draft (opération bas niveau)
|
|
249
|
+
*
|
|
250
|
+
* @deprecated Utiliser gitCreateOrEditFile() qui couvre création + édition.
|
|
251
|
+
*
|
|
217
252
|
* @param git Instance Git
|
|
218
253
|
* @param filePath Chemin du fichier
|
|
219
254
|
* @param PR Nom de la branche de Pull Request
|
|
@@ -249,6 +284,8 @@ export declare function gitDeleteFile(git: SimpleGit, filePath: string, branch:
|
|
|
249
284
|
/**
|
|
250
285
|
* Diagnostique l'état de santé d'une branche Git et détecte les problèmes bloquants.
|
|
251
286
|
*
|
|
287
|
+
* @deprecated Utiliser GitHealthManager pour les diagnostics et réparations.
|
|
288
|
+
*
|
|
252
289
|
* **Problèmes bloquants détectés :**
|
|
253
290
|
* - ❌ **Branche inexistante** : La branche spécifiée n'existe pas dans le dépôt
|
|
254
291
|
* - ❌ **Branche inaccessible** : Impossible de faire un checkout vers la branche
|
|
@@ -272,6 +309,8 @@ export declare function gitGetBranchHealth(git: SimpleGit, branch?: string): Pro
|
|
|
272
309
|
/**
|
|
273
310
|
* Version optimisée de gitGetBranchHealth pour les branches de validation
|
|
274
311
|
*
|
|
312
|
+
* @deprecated Utiliser GitHealthManager.diagnoseValidationBranches() / repairValidationBranches().
|
|
313
|
+
*
|
|
275
314
|
* Cette fonction utilise une approche en cascade pour diagnostiquer rapidement
|
|
276
315
|
* l'état d'une branche de validation sans effectuer de checkout coûteux.
|
|
277
316
|
*
|
|
@@ -35,6 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.gitIDRegistryExists = gitIDRegistryExists;
|
|
37
37
|
exports.gitGenerateNextID = gitGenerateNextID;
|
|
38
|
+
exports.gitGenerateNextPRNumber = gitGenerateNextPRNumber;
|
|
39
|
+
exports.gitEnsureMinimumPRCounter = gitEnsureMinimumPRCounter;
|
|
40
|
+
exports.gitAllocateNextPRNumber = gitAllocateNextPRNumber;
|
|
38
41
|
exports.gitReloadIDRegistry = gitReloadIDRegistry;
|
|
39
42
|
exports.gitRegisterExistingID = gitRegisterExistingID;
|
|
40
43
|
exports.gitIDRegistryRename = gitIDRegistryRename;
|
|
@@ -59,7 +62,6 @@ const errors_1 = require("../errors");
|
|
|
59
62
|
const path_1 = require("path");
|
|
60
63
|
const fs = __importStar(require("fs/promises"));
|
|
61
64
|
const repo_tools_1 = require("./repo.tools");
|
|
62
|
-
const repo_pr_1 = require("./repo.pr");
|
|
63
65
|
const utils_matter_1 = require("../utils.matter");
|
|
64
66
|
/**
|
|
65
67
|
* Service singleton pour gérer le registre d'IDs en mémoire
|
|
@@ -122,6 +124,7 @@ class IDRegistryService {
|
|
|
122
124
|
if (!(0, fs_1.existsSync)(registryPath)) {
|
|
123
125
|
return {
|
|
124
126
|
last: 980,
|
|
127
|
+
lastPR: 60,
|
|
125
128
|
used: [],
|
|
126
129
|
updated: new Date().toISOString(),
|
|
127
130
|
matters: {}
|
|
@@ -133,12 +136,17 @@ class IDRegistryService {
|
|
|
133
136
|
if (!data.matters) {
|
|
134
137
|
data.matters = {};
|
|
135
138
|
}
|
|
139
|
+
// Migration : compteur PR indépendant (valeur initiale explicite)
|
|
140
|
+
if (!Number.isInteger(data.lastPR)) {
|
|
141
|
+
data.lastPR = 60;
|
|
142
|
+
}
|
|
136
143
|
return data;
|
|
137
144
|
}
|
|
138
145
|
catch (error) {
|
|
139
146
|
console.warn('⚠️ Registre d\'IDs corrompu, création d\'un nouveau');
|
|
140
147
|
return {
|
|
141
148
|
last: 980,
|
|
149
|
+
lastPR: 60,
|
|
142
150
|
used: [],
|
|
143
151
|
updated: new Date().toISOString(),
|
|
144
152
|
matters: {}
|
|
@@ -146,7 +154,8 @@ class IDRegistryService {
|
|
|
146
154
|
}
|
|
147
155
|
}
|
|
148
156
|
/**
|
|
149
|
-
* Sauvegarde le registre sur le disque (seulement si modifié)
|
|
157
|
+
* Sauvegarde le registre sur le disque (seulement si modifié).
|
|
158
|
+
* L'échec est fatal: on propage une erreur pour éviter un état incohérent.
|
|
150
159
|
*/
|
|
151
160
|
save() {
|
|
152
161
|
if (!this.registry || !this.isDirty) {
|
|
@@ -165,8 +174,7 @@ class IDRegistryService {
|
|
|
165
174
|
this.isDirty = false;
|
|
166
175
|
}
|
|
167
176
|
catch (error) {
|
|
168
|
-
|
|
169
|
-
// Ne pas propager l'erreur, le registre est une optimisation
|
|
177
|
+
throw new errors_1.GitOperationError(`Failed to save ID registry: ${error}`, 'id_registry_save');
|
|
170
178
|
}
|
|
171
179
|
}
|
|
172
180
|
/**
|
|
@@ -191,6 +199,35 @@ class IDRegistryService {
|
|
|
191
199
|
this.isDirty = true;
|
|
192
200
|
return newID;
|
|
193
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Génère le prochain numéro de PR (séquence indépendante des IDs documents)
|
|
204
|
+
*/
|
|
205
|
+
generateNextPRNumber(minValue = 60) {
|
|
206
|
+
if (!this.registry) {
|
|
207
|
+
throw new Error('IDRegistryService not initialized. Call init() first.');
|
|
208
|
+
}
|
|
209
|
+
const baseline = Math.max(Number.isInteger(this.registry.lastPR) ? this.registry.lastPR : minValue, minValue);
|
|
210
|
+
const newPR = baseline + 1;
|
|
211
|
+
this.registry.lastPR = newPR;
|
|
212
|
+
this.isDirty = true;
|
|
213
|
+
return newPR;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Force le compteur PR à une borne minimale (sans allouer de numéro).
|
|
217
|
+
* Utile pour réaligner le registre avec des branches déjà présentes.
|
|
218
|
+
*/
|
|
219
|
+
ensureMinimumPRCounter(minCounter) {
|
|
220
|
+
if (!this.registry) {
|
|
221
|
+
throw new Error('IDRegistryService not initialized. Call init() first.');
|
|
222
|
+
}
|
|
223
|
+
const normalized = Number.isInteger(minCounter) ? minCounter : 60;
|
|
224
|
+
const current = Number.isInteger(this.registry.lastPR) ? this.registry.lastPR : 60;
|
|
225
|
+
const next = Math.max(current, normalized, 60);
|
|
226
|
+
if (next !== this.registry.lastPR) {
|
|
227
|
+
this.registry.lastPR = next;
|
|
228
|
+
this.isDirty = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
194
231
|
/**
|
|
195
232
|
* Obtient l'ID d'un fichier (peu importe la branche)
|
|
196
233
|
*
|
|
@@ -304,7 +341,8 @@ class IDRegistryService {
|
|
|
304
341
|
id: cached.id,
|
|
305
342
|
title: cached.title,
|
|
306
343
|
service: cached.service,
|
|
307
|
-
|
|
344
|
+
// FIXME(oldfile): compat temporaire; ne pas utiliser oldfile comme identité documentaire.
|
|
345
|
+
oldfile: cached.oldfile
|
|
308
346
|
};
|
|
309
347
|
}
|
|
310
348
|
/**
|
|
@@ -319,7 +357,8 @@ class IDRegistryService {
|
|
|
319
357
|
id: matter.id,
|
|
320
358
|
title: matter.title,
|
|
321
359
|
service: matter.service,
|
|
322
|
-
oldfile:
|
|
360
|
+
// FIXME(oldfile): compat temporaire; à retirer quand le client ne dépend plus de ce signal.
|
|
361
|
+
oldfile: matter.oldfile,
|
|
323
362
|
updated: new Date().toISOString()
|
|
324
363
|
};
|
|
325
364
|
this.isDirty = true;
|
|
@@ -389,6 +428,9 @@ const idRegistryService = IDRegistryService.get();
|
|
|
389
428
|
* dans le repository. Le fichier `with-ids.json` est créé automatiquement lors du
|
|
390
429
|
* premier appel à `gitGenerateNextID()` ou `gitEnsureMatterID()`.
|
|
391
430
|
*
|
|
431
|
+
* @deprecated API utilitaire de compatibilité. Préférer la résolution via
|
|
432
|
+
* gitEnsureMatterID() / gitFileStrictMatter() sans dépendre d'un check préalable.
|
|
433
|
+
*
|
|
392
434
|
* @param config Configuration Git optionnelle (utilise la config par défaut si non fournie)
|
|
393
435
|
* @returns `true` si le fichier `.git/with-ids.json` existe, `false` sinon
|
|
394
436
|
*
|
|
@@ -426,6 +468,60 @@ function gitGenerateNextID(config) {
|
|
|
426
468
|
idRegistryService.save();
|
|
427
469
|
return newID;
|
|
428
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Génère le prochain numéro de PR via le registre `.git/with-ids.json`.
|
|
473
|
+
* Cette séquence est indépendante des IDs documentaires.
|
|
474
|
+
*
|
|
475
|
+
* @param config Configuration Git optionnelle
|
|
476
|
+
* @param minValue Valeur plancher du compteur PR (60 par défaut)
|
|
477
|
+
* @returns Prochain numéro de PR
|
|
478
|
+
*/
|
|
479
|
+
function gitGenerateNextPRNumber(config, minValue = 60) {
|
|
480
|
+
const gitConf = (0, repo_tools_1.gitLoad)(config);
|
|
481
|
+
idRegistryService.init(gitConf.repoPath);
|
|
482
|
+
const newPR = idRegistryService.generateNextPRNumber(minValue);
|
|
483
|
+
idRegistryService.save();
|
|
484
|
+
return newPR;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Réaligne le compteur PR du registre sur une borne minimale sans allouer de numéro.
|
|
488
|
+
*
|
|
489
|
+
* @param minCounter Valeur minimale à garantir pour `lastPR`
|
|
490
|
+
* @param config Configuration Git optionnelle
|
|
491
|
+
*/
|
|
492
|
+
function gitEnsureMinimumPRCounter(minCounter, config) {
|
|
493
|
+
const gitConf = (0, repo_tools_1.gitLoad)(config);
|
|
494
|
+
idRegistryService.init(gitConf.repoPath);
|
|
495
|
+
idRegistryService.ensureMinimumPRCounter(minCounter);
|
|
496
|
+
idRegistryService.save();
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Alloue le prochain numéro de PR en réalignant d'abord le compteur registre
|
|
500
|
+
* sur les branches de validation existantes.
|
|
501
|
+
*
|
|
502
|
+
* @param git Instance Git
|
|
503
|
+
* @param validationPrefix Préfixe des branches de validation
|
|
504
|
+
* @param config Configuration Git optionnelle
|
|
505
|
+
* @param minValue Valeur plancher du compteur PR (60 par défaut)
|
|
506
|
+
* @returns Prochain numéro de PR
|
|
507
|
+
*/
|
|
508
|
+
async function gitAllocateNextPRNumber(git, validationPrefix, config, minValue = 60) {
|
|
509
|
+
const gitConf = (0, repo_tools_1.gitLoad)(config);
|
|
510
|
+
idRegistryService.init(gitConf.repoPath);
|
|
511
|
+
const allBranches = await (0, repo_tools_1.gitGetAllBranches)(git);
|
|
512
|
+
const numbers = allBranches
|
|
513
|
+
.filter((branch) => branch.startsWith(validationPrefix))
|
|
514
|
+
.map((branch) => {
|
|
515
|
+
const numberPart = branch.substring(validationPrefix.length);
|
|
516
|
+
return parseInt(numberPart.split('-')[0], 10);
|
|
517
|
+
})
|
|
518
|
+
.filter((num) => !isNaN(num));
|
|
519
|
+
const maxBranchNumber = numbers.length > 0 ? Math.max(...numbers) : minValue;
|
|
520
|
+
idRegistryService.ensureMinimumPRCounter(maxBranchNumber);
|
|
521
|
+
const nextPR = idRegistryService.generateNextPRNumber(minValue);
|
|
522
|
+
idRegistryService.save();
|
|
523
|
+
return nextPR;
|
|
524
|
+
}
|
|
429
525
|
/**
|
|
430
526
|
* Force le rechargement du registre d'IDs depuis le disque
|
|
431
527
|
*
|
|
@@ -442,6 +538,8 @@ function gitGenerateNextID(config) {
|
|
|
442
538
|
* await gitCreateOrEditFile(...); // Modifie le registre
|
|
443
539
|
* gitReloadIDRegistry(); // Force le rechargement depuis le disque
|
|
444
540
|
* ```
|
|
541
|
+
*
|
|
542
|
+
* @deprecated Réservé aux tests de bas niveau. Ne pas utiliser dans le workflow applicatif.
|
|
445
543
|
*/
|
|
446
544
|
function gitReloadIDRegistry(config) {
|
|
447
545
|
const gitConf = (0, repo_tools_1.gitLoad)(config);
|
|
@@ -616,7 +714,7 @@ function extractMatterFromContent(content) {
|
|
|
616
714
|
const serviceMatch = content.match(/^service:\s*["']?([^"'\n]+)["']?/m);
|
|
617
715
|
const service = serviceMatch ? serviceMatch[1].trim() : undefined;
|
|
618
716
|
//
|
|
619
|
-
//
|
|
717
|
+
// FIXME(oldfile): extraction legacy pour compat UI rename; migration cible: ID-only.
|
|
620
718
|
const oldfileMatch = content.match(/^oldfile:\s*["']?([^"'\n]+)["']?/m);
|
|
621
719
|
const oldfile = oldfileMatch ? oldfileMatch[1].trim() : undefined;
|
|
622
720
|
return { id, title, service, oldfile };
|
|
@@ -1180,6 +1278,9 @@ async function gitCreateOrEditFile(git, filePath, PR, content, user, config) {
|
|
|
1180
1278
|
}
|
|
1181
1279
|
/**
|
|
1182
1280
|
* Modifie un fichier dans la branche draft (opération bas niveau)
|
|
1281
|
+
*
|
|
1282
|
+
* @deprecated Utiliser gitCreateOrEditFile() qui couvre création + édition.
|
|
1283
|
+
*
|
|
1183
1284
|
* @param git Instance Git
|
|
1184
1285
|
* @param filePath Chemin du fichier
|
|
1185
1286
|
* @param PR Nom de la branche de Pull Request
|
|
@@ -1353,7 +1454,7 @@ async function gitRenameFile(git, oldFileName, newFileName, branch, user, config
|
|
|
1353
1454
|
result = await gitRenameFile_git(git, oldFileName, newFileName, branch, user, config);
|
|
1354
1455
|
if (branch !== 'NEW' && branch.startsWith(gitConf.validationPrefix)) {
|
|
1355
1456
|
try {
|
|
1356
|
-
await
|
|
1457
|
+
await gitPRReplaceFile(git, branch, { remove: oldFileName, add: newFileName }, gitConf);
|
|
1357
1458
|
}
|
|
1358
1459
|
catch (metadataError) {
|
|
1359
1460
|
if (gitConf.verbose) {
|
|
@@ -1370,6 +1471,48 @@ async function gitRenameFile(git, oldFileName, newFileName, branch, user, config
|
|
|
1370
1471
|
throw error;
|
|
1371
1472
|
}
|
|
1372
1473
|
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Met à jour la liste des fichiers d'une PR après un renommage.
|
|
1476
|
+
* Helper local pour éviter une dépendance circulaire avec repo.pr.ts.
|
|
1477
|
+
*/
|
|
1478
|
+
async function gitPRReplaceFile(git, branch, options = {}, config) {
|
|
1479
|
+
const { remove, add } = options;
|
|
1480
|
+
if (!remove && !add) {
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
const gitConf = (0, repo_tools_1.gitLoad)(config);
|
|
1484
|
+
const metadata = await (0, repo_tools_1.gitReadNote)(git, branch, gitConf.gitNotes.namespace, 20);
|
|
1485
|
+
if (!metadata) {
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
const currentFiles = Array.isArray(metadata.files) ? metadata.files : [];
|
|
1489
|
+
const seen = new Set();
|
|
1490
|
+
const nextFiles = [];
|
|
1491
|
+
for (const file of currentFiles) {
|
|
1492
|
+
if (!file) {
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
if (remove && file === remove) {
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
if (seen.has(file)) {
|
|
1499
|
+
continue;
|
|
1500
|
+
}
|
|
1501
|
+
seen.add(file);
|
|
1502
|
+
nextFiles.push(file);
|
|
1503
|
+
}
|
|
1504
|
+
if (add && !seen.has(add)) {
|
|
1505
|
+
nextFiles.push(add);
|
|
1506
|
+
}
|
|
1507
|
+
const changed = currentFiles.length !== nextFiles.length ||
|
|
1508
|
+
currentFiles.some((file, idx) => file !== nextFiles[idx]);
|
|
1509
|
+
if (!changed) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
metadata.files = nextFiles;
|
|
1513
|
+
const headCommitHash = (await git.revparse([branch])).trim();
|
|
1514
|
+
await (0, repo_tools_1.gitWriteNote)(git, headCommitHash, metadata, gitConf.gitNotes.namespace);
|
|
1515
|
+
}
|
|
1373
1516
|
/**
|
|
1374
1517
|
* Supprime un fichier d'une branche Git (opération bas niveau)
|
|
1375
1518
|
* @param git Instance Git
|
|
@@ -1468,6 +1611,8 @@ const _writeFileAndCommit = async (git, filePath, content, user, config, commitM
|
|
|
1468
1611
|
/**
|
|
1469
1612
|
* Diagnostique l'état de santé d'une branche Git et détecte les problèmes bloquants.
|
|
1470
1613
|
*
|
|
1614
|
+
* @deprecated Utiliser GitHealthManager pour les diagnostics et réparations.
|
|
1615
|
+
*
|
|
1471
1616
|
* **Problèmes bloquants détectés :**
|
|
1472
1617
|
* - ❌ **Branche inexistante** : La branche spécifiée n'existe pas dans le dépôt
|
|
1473
1618
|
* - ❌ **Branche inaccessible** : Impossible de faire un checkout vers la branche
|
|
@@ -1593,6 +1738,8 @@ async function gitGetBranchHealth(git, branch) {
|
|
|
1593
1738
|
/**
|
|
1594
1739
|
* Version optimisée de gitGetBranchHealth pour les branches de validation
|
|
1595
1740
|
*
|
|
1741
|
+
* @deprecated Utiliser GitHealthManager.diagnoseValidationBranches() / repairValidationBranches().
|
|
1742
|
+
*
|
|
1596
1743
|
* Cette fonction utilise une approche en cascade pour diagnostiquer rapidement
|
|
1597
1744
|
* l'état d'une branche de validation sans effectuer de checkout coûteux.
|
|
1598
1745
|
*
|
|
@@ -3,6 +3,9 @@ import { RulesGitConfig, PRMetadata, PRInfo, RuleUser, PRMergeResult, RulePullRe
|
|
|
3
3
|
/**
|
|
4
4
|
* Synchronise une branche PR avec son mergeBase pour corriger les références orphelines
|
|
5
5
|
*
|
|
6
|
+
* @deprecated Utiliser le workflow applicatif (RulesWorkflow.syncPullRequest) et
|
|
7
|
+
* les opérations robustes orientées Git Notes. API conservée pour compatibilité.
|
|
8
|
+
*
|
|
6
9
|
* FIXME: Cette fonction a un problème de gestion des métadonnées manquantes.
|
|
7
10
|
*
|
|
8
11
|
* PROBLÈME IDENTIFIÉ:
|
|
@@ -38,12 +41,14 @@ export declare function gitSyncPR(git: SimpleGit, branch: string, user: RuleUser
|
|
|
38
41
|
* @param branch Nom de la branche PR
|
|
39
42
|
* @param validationToken Token utilisé pour marquer la fermeture (optionnel, utilise la config par défaut)
|
|
40
43
|
* @returns true si le PR est fermé (dernier commit contient le token de validation)
|
|
41
|
-
*
|
|
44
|
+
* @deprecated Utiliser gitIsPRClosedRobust.
|
|
42
45
|
*/
|
|
43
46
|
export declare function gitIsPRClosed(git: SimpleGit, branch: string): Promise<boolean>;
|
|
44
47
|
/**
|
|
45
48
|
* Vérifie si une branche PR est fermée en utilisant Git Notes (avec fallback)
|
|
46
49
|
* Version robuste qui remplace gitIsPRClosed
|
|
50
|
+
* @deprecated Préférer gitLoadPR() pour récupérer l'état PR complet.
|
|
51
|
+
*
|
|
47
52
|
* @param git Instance Git
|
|
48
53
|
* @param branch Nom de la branche PR
|
|
49
54
|
* @param validationToken Token utilisé pour marquer la fermeture (optionnel, utilise la config par défaut)
|
|
@@ -73,23 +78,18 @@ export declare function gitGetAllPR(git: SimpleGit, options?: {
|
|
|
73
78
|
}): Promise<PRInfo[]>;
|
|
74
79
|
/**
|
|
75
80
|
* Finds closed PRs by scanning the history of the draft branch for merge commits with PR metadata.
|
|
81
|
+
* @deprecated Utiliser gitGetAllPR(git, { closed: true }) pour unifier le listing PR.
|
|
82
|
+
*
|
|
76
83
|
* @param git SimpleGit instance
|
|
77
84
|
* @param gitConfig The git configuration
|
|
78
85
|
* @returns A list of PRInfo objects for closed PRs.
|
|
79
86
|
*/
|
|
80
87
|
export declare function gitGetClosedPRs(git: SimpleGit, gitConfig: RulesGitConfig): Promise<PRInfo[]>;
|
|
81
88
|
export declare function gitLoadPR(git: SimpleGit, branch: string): Promise<PRInfo>;
|
|
82
|
-
/**
|
|
83
|
-
* Remplace explicitement un nom de fichier dans les métadonnées d'une PR.
|
|
84
|
-
* Utilisé pour refléter immédiatement les renames sans dépendre de git diff.
|
|
85
|
-
*/
|
|
86
|
-
export declare function gitPRReplaceFile(git: SimpleGit, branch: string, options?: {
|
|
87
|
-
remove?: string;
|
|
88
|
-
add?: string;
|
|
89
|
-
}, config?: RulesGitConfig): Promise<void>;
|
|
90
89
|
export declare function gitPRUpdateComments(git: SimpleGit, branch: string, details: RulePullRequestDetails, config?: RulesGitConfig): Promise<PRInfo>;
|
|
91
90
|
/**
|
|
92
|
-
*
|
|
91
|
+
* @deprecated Utiliser gitClosePRRobust.
|
|
92
|
+
*
|
|
93
93
|
* Ferme un PR en ajoutant un commit avec le token de validation
|
|
94
94
|
* @param git Instance Git
|
|
95
95
|
* @param branch Branche PR à fermer
|
|
@@ -111,13 +111,6 @@ export declare function gitClosePR(git: SimpleGit, branch: string, author: RuleU
|
|
|
111
111
|
* @returns Hash du commit de fermeture ou référence de la note
|
|
112
112
|
*/
|
|
113
113
|
export declare function gitClosePRRobust(git: SimpleGit, branch: string, closedBy: RuleUser, message?: string, config?: RulesGitConfig): Promise<PRMergeResult>;
|
|
114
|
-
/**
|
|
115
|
-
* Trouve le prochain numéro de PR disponible (protégé contre la concurrence)
|
|
116
|
-
* @param git Instance Git
|
|
117
|
-
* @param validationPrefix Préfixe des branches de validation
|
|
118
|
-
* @returns Prochain numéro de PR
|
|
119
|
-
*/
|
|
120
|
-
export declare function gitGetNextPRNumber(git: SimpleGit, validationPrefix: string): Promise<number>;
|
|
121
114
|
/**
|
|
122
115
|
* Crée une nouvelle branche de validation (pour un PR vers rule-editor)
|
|
123
116
|
* à partir d'une branche source (typiquement rule-editor).
|
|
@@ -136,7 +129,7 @@ export declare function gitNewValidationRequest(git: SimpleGit, files: string[],
|
|
|
136
129
|
validationBranchPrefix?: string;
|
|
137
130
|
}): Promise<PRInfo>;
|
|
138
131
|
/**
|
|
139
|
-
*
|
|
132
|
+
* @deprecated Utiliser gitNewValidationRequest().
|
|
140
133
|
*/
|
|
141
134
|
export declare function gitNewPR(git: SimpleGit, files: string[], description: string, author: RuleUser, options?: {
|
|
142
135
|
content?: string[];
|