@imenam/mcp-dependabot-tracker 1.0.9 → 1.0.11

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 (44) hide show
  1. package/README.md +69 -18
  2. package/dist/shared/alerts.d.ts +6 -1
  3. package/dist/shared/alerts.js +7 -0
  4. package/dist/shared/schemas/api.schema.d.ts +45 -10
  5. package/dist/shared/schemas/api.schema.js +5 -1
  6. package/dist/shared/schemas/ipc.schema.d.ts +1 -1
  7. package/dist/shared/schemas/ipc.schema.js +5 -0
  8. package/dist/shared/schemas/model.schema.d.ts +259 -7
  9. package/dist/shared/schemas/model.schema.js +95 -8
  10. package/dist/shared/schemas/settings.schema.d.ts +78 -0
  11. package/dist/shared/schemas/settings.schema.js +42 -0
  12. package/dist/src/core/analysis.d.ts +54 -0
  13. package/dist/src/core/analysis.js +180 -0
  14. package/dist/src/core/audit-all.d.ts +6 -6
  15. package/dist/src/core/audit-all.js +6 -6
  16. package/dist/src/core/claude.d.ts +45 -0
  17. package/dist/src/core/claude.js +200 -0
  18. package/dist/src/core/commands.d.ts +2 -0
  19. package/dist/src/core/commands.js +1 -1
  20. package/dist/src/core/github.js +2 -1
  21. package/dist/src/core/operations.d.ts +27 -12
  22. package/dist/src/core/operations.js +282 -42
  23. package/dist/src/core/organizer.d.ts +57 -0
  24. package/dist/src/core/organizer.js +110 -0
  25. package/dist/src/core/repair.d.ts +31 -0
  26. package/dist/src/core/repair.js +150 -0
  27. package/dist/src/core/repos.d.ts +14 -9
  28. package/dist/src/core/repos.js +45 -20
  29. package/dist/src/core/settings.d.ts +21 -0
  30. package/dist/src/core/settings.js +108 -0
  31. package/dist/src/core/store.d.ts +2 -0
  32. package/dist/src/core/store.js +20 -6
  33. package/dist/src/gui-worker.js +29 -3
  34. package/dist/src/index.js +47 -9
  35. package/dist/src/tools/format.js +20 -8
  36. package/dist/src/tools/tools.js +8 -6
  37. package/dist/src/tools/types.d.ts +2 -0
  38. package/dist/src/tools/types.js +9 -0
  39. package/gui/dist/assets/index-CPYr3dz7.css +1 -0
  40. package/gui/dist/assets/index-CSbeloLm.js +64 -0
  41. package/gui/dist/index.html +2 -2
  42. package/package.json +2 -1
  43. package/gui/dist/assets/index-BdMhGHUf.css +0 -1
  44. package/gui/dist/assets/index-CIIsKFR9.js +0 -64
@@ -17,7 +17,21 @@ export declare const RightsSchema: z.ZodObject<{
17
17
  export type Rights = z.infer<typeof RightsSchema>;
18
18
  /** Droits d'un dépôt qui vient d'être ajouté : l'audit seul. */
19
19
  export declare const DEFAULT_RIGHTS: Rights;
20
- /** Alerte Dependabot ouverte, telle que la renvoie l'API GitHub, réduite à ce qui s'affiche ; `createdAt` est sa date d'émission. */
20
+ /**
21
+ * Périmètre d'un audit et de ses corrections : `production` laisse de côté les
22
+ * devDependencies (`--omit=dev`), `all` couvre toutes les dépendances.
23
+ */
24
+ export declare const AUDIT_SCOPES: readonly ["production", "all"];
25
+ export type AuditScope = (typeof AUDIT_SCOPES)[number];
26
+ export declare const DEFAULT_AUDIT_SCOPE: AuditScope;
27
+ /** Portée d'une dépendance vulnérable selon Dependabot : exécution ou développement. */
28
+ export declare const DEPENDENCY_SCOPES: readonly ["runtime", "development"];
29
+ export type DependencyScope = (typeof DEPENDENCY_SCOPES)[number];
30
+ /**
31
+ * Alerte Dependabot ouverte, telle que la renvoie l'API GitHub, réduite à ce qui
32
+ * s'affiche ; `createdAt` est sa date d'émission, `scope` la portée de la
33
+ * dépendance, null quand GitHub ne la connaît pas.
34
+ */
21
35
  export declare const AlertSchema: z.ZodObject<{
22
36
  number: z.ZodNumber;
23
37
  severity: z.ZodEnum<{
@@ -33,6 +47,10 @@ export declare const AlertSchema: z.ZodObject<{
33
47
  url: z.ZodString;
34
48
  patchedVersion: z.ZodNullable<z.ZodString>;
35
49
  createdAt: z.ZodString;
50
+ scope: z.ZodNullable<z.ZodEnum<{
51
+ development: "development";
52
+ runtime: "runtime";
53
+ }>>;
36
54
  }, z.core.$strip>;
37
55
  export type Alert = z.infer<typeof AlertSchema>;
38
56
  /**
@@ -97,6 +115,10 @@ export declare const RepoSchema: z.ZodObject<{
97
115
  url: z.ZodString;
98
116
  patchedVersion: z.ZodNullable<z.ZodString>;
99
117
  createdAt: z.ZodString;
118
+ scope: z.ZodNullable<z.ZodEnum<{
119
+ development: "development";
120
+ runtime: "runtime";
121
+ }>>;
100
122
  }, z.core.$strip>>;
101
123
  handledAlerts: z.ZodArray<z.ZodObject<{
102
124
  number: z.ZodNumber;
@@ -148,6 +170,10 @@ export declare const ReposFileSchema: z.ZodObject<{
148
170
  url: z.ZodString;
149
171
  patchedVersion: z.ZodNullable<z.ZodString>;
150
172
  createdAt: z.ZodString;
173
+ scope: z.ZodNullable<z.ZodEnum<{
174
+ development: "development";
175
+ runtime: "runtime";
176
+ }>>;
151
177
  }, z.core.$strip>>;
152
178
  handledAlerts: z.ZodArray<z.ZodObject<{
153
179
  number: z.ZodNumber;
@@ -173,13 +199,14 @@ export type OperationKind = (typeof OPERATION_KINDS)[number];
173
199
  export declare const ORIGINS: readonly ["user", "agent"];
174
200
  export type Origin = (typeof ORIGINS)[number];
175
201
  /**
176
- * `running` : une étape s'exécute ; `waiting_force` et `waiting_push` : l'utilisateur
177
- * doit décider de la suite ; les trois derniers états sont terminaux.
202
+ * `running` : une étape s'exécute ; `waiting_force`, `waiting_repair` et
203
+ * `waiting_push` : l'utilisateur doit décider de la suite ; les trois derniers
204
+ * états sont terminaux.
178
205
  */
179
- export declare const OPERATION_STATUSES: readonly ["running", "waiting_force", "waiting_push", "done", "failed", "cancelled"];
206
+ export declare const OPERATION_STATUSES: readonly ["running", "waiting_force", "waiting_repair", "waiting_push", "done", "failed", "cancelled"];
180
207
  export type OperationStatus = (typeof OPERATION_STATUSES)[number];
181
208
  export declare const ACTIVE_STATUSES: readonly OperationStatus[];
182
- export declare const STEP_NAMES: readonly ["clone", "audit", "fix", "force", "push"];
209
+ export declare const STEP_NAMES: readonly ["clone", "audit", "fix", "analysis", "force", "repair", "push"];
183
210
  export type StepName = (typeof STEP_NAMES)[number];
184
211
  export declare const STEP_STATES: readonly ["pending", "running", "done", "skipped", "failed"];
185
212
  export type StepState = (typeof STEP_STATES)[number];
@@ -226,11 +253,149 @@ export declare const LogEntrySchema: z.ZodObject<{
226
253
  text: z.ZodString;
227
254
  }, z.core.$strip>;
228
255
  export type LogEntry = z.infer<typeof LogEntrySchema>;
256
+ /** Rapport rendu par Claude à la fin d'une analyse : résumé, corrections urgentes à la main, avis sur `--force`. */
257
+ export declare const AnalysisReportSchema: z.ZodObject<{
258
+ summary: z.ZodString;
259
+ urgent: z.ZodArray<z.ZodObject<{
260
+ package: z.ZodString;
261
+ reason: z.ZodString;
262
+ }, z.core.$strip>>;
263
+ force: z.ZodObject<{
264
+ recommended: z.ZodBoolean;
265
+ reason: z.ZodString;
266
+ }, z.core.$strip>;
267
+ }, z.core.$strip>;
268
+ export type AnalysisReport = z.infer<typeof AnalysisReportSchema>;
269
+ /** Résultat des tests lancés par Claude après ses corrections. */
270
+ export declare const TEST_OUTCOMES: readonly ["passed", "failed", "not_run"];
271
+ /**
272
+ * Rapport rendu par Claude à la fin de ses corrections : résumé, changement de
273
+ * chaque fichier, message du commit et résultat des tests.
274
+ */
275
+ export declare const RepairReportSchema: z.ZodObject<{
276
+ summary: z.ZodString;
277
+ changes: z.ZodArray<z.ZodObject<{
278
+ file: z.ZodString;
279
+ change: z.ZodString;
280
+ }, z.core.$strip>>;
281
+ commitMessage: z.ZodString;
282
+ tests: z.ZodObject<{
283
+ outcome: z.ZodEnum<{
284
+ failed: "failed";
285
+ not_run: "not_run";
286
+ passed: "passed";
287
+ }>;
288
+ detail: z.ZodString;
289
+ }, z.core.$strip>;
290
+ }, z.core.$strip>;
291
+ export type RepairReport = z.infer<typeof RepairReportSchema>;
292
+ /** Statuts d'une tâche de l'organizer. */
293
+ export declare const TASK_STATUSES: readonly ["todo", "doing", "review", "done"];
294
+ /** Tâche créée dans l'organizer par une analyse ; `url` ouvre la tâche sur le site, `status` est relu à chaque synchronisation. */
295
+ export declare const AnalysisTaskSchema: z.ZodObject<{
296
+ key: z.ZodString;
297
+ title: z.ZodString;
298
+ url: z.ZodString;
299
+ status: z.ZodEnum<{
300
+ doing: "doing";
301
+ done: "done";
302
+ review: "review";
303
+ todo: "todo";
304
+ }>;
305
+ }, z.core.$strip>;
306
+ export type AnalysisTask = z.infer<typeof AnalysisTaskSchema>;
229
307
  /**
230
- * Opération d'audit ou de correction sur un clone temporaire. `workDir` est le
308
+ * Analyse par Claude des vulnérabilités restantes après `npm audit fix`.
309
+ * `turns` et `activity` (dernières actions de Claude) suivent la session en
310
+ * cours ; `report` et `task` sont remplis à la fin, `error` en cas d'échec.
311
+ */
312
+ export declare const AnalysisSchema: z.ZodObject<{
313
+ startedAt: z.ZodString;
314
+ endedAt: z.ZodNullable<z.ZodString>;
315
+ turns: z.ZodNumber;
316
+ activity: z.ZodArray<z.ZodString>;
317
+ report: z.ZodNullable<z.ZodObject<{
318
+ summary: z.ZodString;
319
+ urgent: z.ZodArray<z.ZodObject<{
320
+ package: z.ZodString;
321
+ reason: z.ZodString;
322
+ }, z.core.$strip>>;
323
+ force: z.ZodObject<{
324
+ recommended: z.ZodBoolean;
325
+ reason: z.ZodString;
326
+ }, z.core.$strip>;
327
+ }, z.core.$strip>>;
328
+ task: z.ZodNullable<z.ZodObject<{
329
+ key: z.ZodString;
330
+ title: z.ZodString;
331
+ url: z.ZodString;
332
+ status: z.ZodEnum<{
333
+ doing: "doing";
334
+ done: "done";
335
+ review: "review";
336
+ todo: "todo";
337
+ }>;
338
+ }, z.core.$strip>>;
339
+ error: z.ZodNullable<z.ZodString>;
340
+ }, z.core.$strip>;
341
+ export type Analysis = z.infer<typeof AnalysisSchema>;
342
+ /**
343
+ * Corrections par Claude, d'après la tâche de l'analyse et les commentaires de
344
+ * l'utilisateur. `base` est le commit sur lequel repose celui de Claude : le
345
+ * commit de `npm audit fix` (`auditCommit`), ou le commit cloné quand
346
+ * `npm audit fix` n'a rien changé et que `auditCommit` est null.
347
+ * `commit` est le commit de Claude, null tant qu'il n'a rien modifié ; `task`
348
+ * la sous-tâche « rapport de développement ». `turns` et `activity` suivent la
349
+ * session en cours ; `error` est la raison de l'échec du dernier passage, les
350
+ * résultats du passage précédent restant valables.
351
+ */
352
+ export declare const RepairSchema: z.ZodObject<{
353
+ runs: z.ZodNumber;
354
+ startedAt: z.ZodString;
355
+ endedAt: z.ZodNullable<z.ZodString>;
356
+ turns: z.ZodNumber;
357
+ activity: z.ZodArray<z.ZodString>;
358
+ base: z.ZodString;
359
+ auditCommit: z.ZodNullable<z.ZodString>;
360
+ commit: z.ZodNullable<z.ZodString>;
361
+ report: z.ZodNullable<z.ZodObject<{
362
+ summary: z.ZodString;
363
+ changes: z.ZodArray<z.ZodObject<{
364
+ file: z.ZodString;
365
+ change: z.ZodString;
366
+ }, z.core.$strip>>;
367
+ commitMessage: z.ZodString;
368
+ tests: z.ZodObject<{
369
+ outcome: z.ZodEnum<{
370
+ failed: "failed";
371
+ not_run: "not_run";
372
+ passed: "passed";
373
+ }>;
374
+ detail: z.ZodString;
375
+ }, z.core.$strip>;
376
+ }, z.core.$strip>>;
377
+ task: z.ZodNullable<z.ZodObject<{
378
+ key: z.ZodString;
379
+ title: z.ZodString;
380
+ url: z.ZodString;
381
+ status: z.ZodEnum<{
382
+ doing: "doing";
383
+ done: "done";
384
+ review: "review";
385
+ todo: "todo";
386
+ }>;
387
+ }, z.core.$strip>>;
388
+ error: z.ZodNullable<z.ZodString>;
389
+ }, z.core.$strip>;
390
+ export type Repair = z.infer<typeof RepairSchema>;
391
+ /**
392
+ * Opération d'audit ou de correction sur un clone temporaire, limitée aux
393
+ * dépendances de `scope`. `workDir` est le
231
394
  * clone, présent tant que l'opération n'est pas terminée ; `pid` est le processus
232
395
  * qui exécute l'étape en cours. `found` liste les vulnérabilités du premier
233
- * audit, `remaining` celles qui restent après la dernière étape.
396
+ * audit, `remaining` celles qui restent après la dernière étape. `analysis` est
397
+ * l'analyse par Claude, null quand elle n'a pas été lancée ; `repair` ses
398
+ * corrections, null tant qu'elles n'ont pas été lancées.
234
399
  */
235
400
  export declare const OperationSchema: z.ZodObject<{
236
401
  id: z.ZodString;
@@ -243,6 +408,10 @@ export declare const OperationSchema: z.ZodObject<{
243
408
  agent: "agent";
244
409
  user: "user";
245
410
  }>;
411
+ scope: z.ZodEnum<{
412
+ all: "all";
413
+ production: "production";
414
+ }>;
246
415
  status: z.ZodEnum<{
247
416
  cancelled: "cancelled";
248
417
  done: "done";
@@ -250,6 +419,7 @@ export declare const OperationSchema: z.ZodObject<{
250
419
  running: "running";
251
420
  waiting_force: "waiting_force";
252
421
  waiting_push: "waiting_push";
422
+ waiting_repair: "waiting_repair";
253
423
  }>;
254
424
  createdAt: z.ZodString;
255
425
  updatedAt: z.ZodString;
@@ -279,6 +449,13 @@ export declare const OperationSchema: z.ZodObject<{
279
449
  running: "running";
280
450
  skipped: "skipped";
281
451
  }>;
452
+ analysis: z.ZodEnum<{
453
+ done: "done";
454
+ failed: "failed";
455
+ pending: "pending";
456
+ running: "running";
457
+ skipped: "skipped";
458
+ }>;
282
459
  force: z.ZodEnum<{
283
460
  done: "done";
284
461
  failed: "failed";
@@ -286,6 +463,13 @@ export declare const OperationSchema: z.ZodObject<{
286
463
  running: "running";
287
464
  skipped: "skipped";
288
465
  }>;
466
+ repair: z.ZodEnum<{
467
+ done: "done";
468
+ failed: "failed";
469
+ pending: "pending";
470
+ running: "running";
471
+ skipped: "skipped";
472
+ }>;
289
473
  push: z.ZodEnum<{
290
474
  done: "done";
291
475
  failed: "failed";
@@ -299,6 +483,7 @@ export declare const OperationSchema: z.ZodObject<{
299
483
  initial: z.ZodNullable<z.ZodNumber>;
300
484
  afterFix: z.ZodNullable<z.ZodNumber>;
301
485
  afterForce: z.ZodNullable<z.ZodNumber>;
486
+ afterRepair: z.ZodNullable<z.ZodNumber>;
302
487
  }, z.core.$strip>;
303
488
  found: z.ZodArray<z.ZodObject<{
304
489
  project: z.ZodString;
@@ -351,6 +536,73 @@ export declare const OperationSchema: z.ZodObject<{
351
536
  number: z.ZodNumber;
352
537
  url: z.ZodString;
353
538
  }, z.core.$strip>>;
539
+ analysis: z.ZodNullable<z.ZodObject<{
540
+ startedAt: z.ZodString;
541
+ endedAt: z.ZodNullable<z.ZodString>;
542
+ turns: z.ZodNumber;
543
+ activity: z.ZodArray<z.ZodString>;
544
+ report: z.ZodNullable<z.ZodObject<{
545
+ summary: z.ZodString;
546
+ urgent: z.ZodArray<z.ZodObject<{
547
+ package: z.ZodString;
548
+ reason: z.ZodString;
549
+ }, z.core.$strip>>;
550
+ force: z.ZodObject<{
551
+ recommended: z.ZodBoolean;
552
+ reason: z.ZodString;
553
+ }, z.core.$strip>;
554
+ }, z.core.$strip>>;
555
+ task: z.ZodNullable<z.ZodObject<{
556
+ key: z.ZodString;
557
+ title: z.ZodString;
558
+ url: z.ZodString;
559
+ status: z.ZodEnum<{
560
+ doing: "doing";
561
+ done: "done";
562
+ review: "review";
563
+ todo: "todo";
564
+ }>;
565
+ }, z.core.$strip>>;
566
+ error: z.ZodNullable<z.ZodString>;
567
+ }, z.core.$strip>>;
568
+ repair: z.ZodNullable<z.ZodObject<{
569
+ runs: z.ZodNumber;
570
+ startedAt: z.ZodString;
571
+ endedAt: z.ZodNullable<z.ZodString>;
572
+ turns: z.ZodNumber;
573
+ activity: z.ZodArray<z.ZodString>;
574
+ base: z.ZodString;
575
+ auditCommit: z.ZodNullable<z.ZodString>;
576
+ commit: z.ZodNullable<z.ZodString>;
577
+ report: z.ZodNullable<z.ZodObject<{
578
+ summary: z.ZodString;
579
+ changes: z.ZodArray<z.ZodObject<{
580
+ file: z.ZodString;
581
+ change: z.ZodString;
582
+ }, z.core.$strip>>;
583
+ commitMessage: z.ZodString;
584
+ tests: z.ZodObject<{
585
+ outcome: z.ZodEnum<{
586
+ failed: "failed";
587
+ not_run: "not_run";
588
+ passed: "passed";
589
+ }>;
590
+ detail: z.ZodString;
591
+ }, z.core.$strip>;
592
+ }, z.core.$strip>>;
593
+ task: z.ZodNullable<z.ZodObject<{
594
+ key: z.ZodString;
595
+ title: z.ZodString;
596
+ url: z.ZodString;
597
+ status: z.ZodEnum<{
598
+ doing: "doing";
599
+ done: "done";
600
+ review: "review";
601
+ todo: "todo";
602
+ }>;
603
+ }, z.core.$strip>>;
604
+ error: z.ZodNullable<z.ZodString>;
605
+ }, z.core.$strip>>;
354
606
  error: z.ZodNullable<z.ZodString>;
355
607
  log: z.ZodArray<z.ZodObject<{
356
608
  at: z.ZodString;
@@ -13,7 +13,19 @@ export const RightsSchema = z.object({
13
13
  });
14
14
  /** Droits d'un dépôt qui vient d'être ajouté : l'audit seul. */
15
15
  export const DEFAULT_RIGHTS = { audit: true, fix: false, force: false, push: false };
16
- /** Alerte Dependabot ouverte, telle que la renvoie l'API GitHub, réduite à ce qui s'affiche ; `createdAt` est sa date d'émission. */
16
+ /**
17
+ * Périmètre d'un audit et de ses corrections : `production` laisse de côté les
18
+ * devDependencies (`--omit=dev`), `all` couvre toutes les dépendances.
19
+ */
20
+ export const AUDIT_SCOPES = ["production", "all"];
21
+ export const DEFAULT_AUDIT_SCOPE = "production";
22
+ /** Portée d'une dépendance vulnérable selon Dependabot : exécution ou développement. */
23
+ export const DEPENDENCY_SCOPES = ["runtime", "development"];
24
+ /**
25
+ * Alerte Dependabot ouverte, telle que la renvoie l'API GitHub, réduite à ce qui
26
+ * s'affiche ; `createdAt` est sa date d'émission, `scope` la portée de la
27
+ * dépendance, null quand GitHub ne la connaît pas.
28
+ */
17
29
  export const AlertSchema = z.object({
18
30
  number: z.number().int(),
19
31
  severity: z.enum(ALERT_SEVERITIES),
@@ -24,6 +36,7 @@ export const AlertSchema = z.object({
24
36
  url: z.string(),
25
37
  patchedVersion: z.string().nullable(),
26
38
  createdAt: z.string(),
39
+ scope: z.enum(DEPENDENCY_SCOPES).nullable(),
27
40
  });
28
41
  /**
29
42
  * Alerte que l'utilisateur a corrigée à la main alors que Dependabot la signale
@@ -77,12 +90,13 @@ export const OPERATION_KINDS = ["audit", "fix"];
77
90
  /** Qui a lancé l'opération : l'utilisateur depuis la GUI, ou l'agent par un outil MCP. */
78
91
  export const ORIGINS = ["user", "agent"];
79
92
  /**
80
- * `running` : une étape s'exécute ; `waiting_force` et `waiting_push` : l'utilisateur
81
- * doit décider de la suite ; les trois derniers états sont terminaux.
93
+ * `running` : une étape s'exécute ; `waiting_force`, `waiting_repair` et
94
+ * `waiting_push` : l'utilisateur doit décider de la suite ; les trois derniers
95
+ * états sont terminaux.
82
96
  */
83
- export const OPERATION_STATUSES = ["running", "waiting_force", "waiting_push", "done", "failed", "cancelled"];
84
- export const ACTIVE_STATUSES = ["running", "waiting_force", "waiting_push"];
85
- export const STEP_NAMES = ["clone", "audit", "fix", "force", "push"];
97
+ export const OPERATION_STATUSES = ["running", "waiting_force", "waiting_repair", "waiting_push", "done", "failed", "cancelled"];
98
+ export const ACTIVE_STATUSES = ["running", "waiting_force", "waiting_repair", "waiting_push"];
99
+ export const STEP_NAMES = ["clone", "audit", "fix", "analysis", "force", "repair", "push"];
86
100
  export const STEP_STATES = ["pending", "running", "done", "skipped", "failed"];
87
101
  /** Correction proposée par `npm audit` : aucune, dans les plages déclarées, ou par une version majeure (`--force`). */
88
102
  export const FIX_KINDS = ["none", "available", "major"];
@@ -109,17 +123,85 @@ export const ChangeSchema = z.object({
109
123
  to: z.string().nullable(),
110
124
  });
111
125
  export const LogEntrySchema = z.object({ at: z.string(), text: z.string() });
126
+ /** Rapport rendu par Claude à la fin d'une analyse : résumé, corrections urgentes à la main, avis sur `--force`. */
127
+ export const AnalysisReportSchema = z.object({
128
+ summary: z.string(),
129
+ urgent: z.array(z.object({ package: z.string(), reason: z.string() })),
130
+ force: z.object({ recommended: z.boolean(), reason: z.string() }),
131
+ });
132
+ /** Résultat des tests lancés par Claude après ses corrections. */
133
+ export const TEST_OUTCOMES = ["passed", "failed", "not_run"];
134
+ /**
135
+ * Rapport rendu par Claude à la fin de ses corrections : résumé, changement de
136
+ * chaque fichier, message du commit et résultat des tests.
137
+ */
138
+ export const RepairReportSchema = z.object({
139
+ summary: z.string(),
140
+ changes: z.array(z.object({ file: z.string(), change: z.string() })),
141
+ commitMessage: z.string(),
142
+ tests: z.object({ outcome: z.enum(TEST_OUTCOMES), detail: z.string() }),
143
+ });
144
+ /** Statuts d'une tâche de l'organizer. */
145
+ export const TASK_STATUSES = ["todo", "doing", "review", "done"];
146
+ /** Tâche créée dans l'organizer par une analyse ; `url` ouvre la tâche sur le site, `status` est relu à chaque synchronisation. */
147
+ export const AnalysisTaskSchema = z.object({
148
+ key: z.string(),
149
+ title: z.string(),
150
+ url: z.string(),
151
+ status: z.enum(TASK_STATUSES),
152
+ });
153
+ /**
154
+ * Analyse par Claude des vulnérabilités restantes après `npm audit fix`.
155
+ * `turns` et `activity` (dernières actions de Claude) suivent la session en
156
+ * cours ; `report` et `task` sont remplis à la fin, `error` en cas d'échec.
157
+ */
158
+ export const AnalysisSchema = z.object({
159
+ startedAt: z.string(),
160
+ endedAt: z.string().nullable(),
161
+ turns: z.number().int(),
162
+ activity: z.array(z.string()),
163
+ report: AnalysisReportSchema.nullable(),
164
+ task: AnalysisTaskSchema.nullable(),
165
+ error: z.string().nullable(),
166
+ });
167
+ /**
168
+ * Corrections par Claude, d'après la tâche de l'analyse et les commentaires de
169
+ * l'utilisateur. `base` est le commit sur lequel repose celui de Claude : le
170
+ * commit de `npm audit fix` (`auditCommit`), ou le commit cloné quand
171
+ * `npm audit fix` n'a rien changé et que `auditCommit` est null.
172
+ * `commit` est le commit de Claude, null tant qu'il n'a rien modifié ; `task`
173
+ * la sous-tâche « rapport de développement ». `turns` et `activity` suivent la
174
+ * session en cours ; `error` est la raison de l'échec du dernier passage, les
175
+ * résultats du passage précédent restant valables.
176
+ */
177
+ export const RepairSchema = z.object({
178
+ runs: z.number().int(),
179
+ startedAt: z.string(),
180
+ endedAt: z.string().nullable(),
181
+ turns: z.number().int(),
182
+ activity: z.array(z.string()),
183
+ base: z.string(),
184
+ auditCommit: z.string().nullable(),
185
+ commit: z.string().nullable(),
186
+ report: RepairReportSchema.nullable(),
187
+ task: AnalysisTaskSchema.nullable(),
188
+ error: z.string().nullable(),
189
+ });
112
190
  /**
113
- * Opération d'audit ou de correction sur un clone temporaire. `workDir` est le
191
+ * Opération d'audit ou de correction sur un clone temporaire, limitée aux
192
+ * dépendances de `scope`. `workDir` est le
114
193
  * clone, présent tant que l'opération n'est pas terminée ; `pid` est le processus
115
194
  * qui exécute l'étape en cours. `found` liste les vulnérabilités du premier
116
- * audit, `remaining` celles qui restent après la dernière étape.
195
+ * audit, `remaining` celles qui restent après la dernière étape. `analysis` est
196
+ * l'analyse par Claude, null quand elle n'a pas été lancée ; `repair` ses
197
+ * corrections, null tant qu'elles n'ont pas été lancées.
117
198
  */
118
199
  export const OperationSchema = z.object({
119
200
  id: z.string(),
120
201
  repoId: z.string(),
121
202
  kind: z.enum(OPERATION_KINDS),
122
203
  origin: z.enum(ORIGINS),
204
+ scope: z.enum(AUDIT_SCOPES),
123
205
  status: z.enum(OPERATION_STATUSES),
124
206
  createdAt: z.string(),
125
207
  updatedAt: z.string(),
@@ -131,7 +213,9 @@ export const OperationSchema = z.object({
131
213
  clone: z.enum(STEP_STATES),
132
214
  audit: z.enum(STEP_STATES),
133
215
  fix: z.enum(STEP_STATES),
216
+ analysis: z.enum(STEP_STATES),
134
217
  force: z.enum(STEP_STATES),
218
+ repair: z.enum(STEP_STATES),
135
219
  push: z.enum(STEP_STATES),
136
220
  }),
137
221
  projects: z.array(z.string()),
@@ -139,6 +223,7 @@ export const OperationSchema = z.object({
139
223
  initial: z.number().int().nullable(),
140
224
  afterFix: z.number().int().nullable(),
141
225
  afterForce: z.number().int().nullable(),
226
+ afterRepair: z.number().int().nullable(),
142
227
  }),
143
228
  found: z.array(VulnerabilitySchema),
144
229
  remaining: z.array(VulnerabilitySchema),
@@ -147,6 +232,8 @@ export const OperationSchema = z.object({
147
232
  commitMessage: z.string(),
148
233
  branch: z.string().nullable(),
149
234
  pullRequest: z.object({ number: z.number().int(), url: z.string() }).nullable(),
235
+ analysis: AnalysisSchema.nullable(),
236
+ repair: RepairSchema.nullable(),
150
237
  error: z.string().nullable(),
151
238
  log: z.array(LogEntrySchema),
152
239
  });
@@ -0,0 +1,78 @@
1
+ import { z } from "zod";
2
+ /** Limites d'une analyse par Claude : tours appliqués par Claude Code, durée appliquée par le tracker. */
3
+ export declare const ANALYSIS_LIMITS: {
4
+ readonly maxTurns: {
5
+ readonly min: 1;
6
+ readonly max: 200;
7
+ };
8
+ readonly maxMinutes: {
9
+ readonly min: 1;
10
+ readonly max: 60;
11
+ };
12
+ };
13
+ export declare const AnalysisSettingsSchema: z.ZodObject<{
14
+ auto: z.ZodBoolean;
15
+ maxTurns: z.ZodNumber;
16
+ maxMinutes: z.ZodNumber;
17
+ }, z.core.$strip>;
18
+ export type AnalysisSettings = z.infer<typeof AnalysisSettingsSchema>;
19
+ /**
20
+ * Réglages enregistrés dans `<données>/settings.json`. `organizer.space` et
21
+ * `organizer.owner` sont l'espace du token et son propriétaire, relevés au
22
+ * dernier test de la connexion ; `claude.savedAt` est la date d'enregistrement
23
+ * du token Claude, valable un an.
24
+ */
25
+ export declare const SettingsSchema: z.ZodObject<{
26
+ organizer: z.ZodObject<{
27
+ url: z.ZodNullable<z.ZodString>;
28
+ token: z.ZodNullable<z.ZodString>;
29
+ space: z.ZodNullable<z.ZodString>;
30
+ owner: z.ZodNullable<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ claude: z.ZodObject<{
33
+ token: z.ZodNullable<z.ZodString>;
34
+ savedAt: z.ZodNullable<z.ZodString>;
35
+ }, z.core.$strip>;
36
+ analysis: z.ZodObject<{
37
+ auto: z.ZodBoolean;
38
+ maxTurns: z.ZodNumber;
39
+ maxMinutes: z.ZodNumber;
40
+ }, z.core.$strip>;
41
+ }, z.core.$strip>;
42
+ export type Settings = z.infer<typeof SettingsSchema>;
43
+ export declare const DEFAULT_SETTINGS: Settings;
44
+ /**
45
+ * Réglages tels que la GUI les reçoit : les tokens n'y figurent que par leurs
46
+ * quatre derniers caractères. `ready` est vrai quand l'organizer et Claude sont
47
+ * configurés, condition de l'analyse automatique.
48
+ */
49
+ export interface SettingsView {
50
+ organizer: {
51
+ url: string | null;
52
+ tokenHint: string | null;
53
+ space: string | null;
54
+ owner: string | null;
55
+ };
56
+ claude: {
57
+ tokenHint: string | null;
58
+ savedAt: string | null;
59
+ expiresAt: string | null;
60
+ };
61
+ analysis: AnalysisSettings;
62
+ ready: boolean;
63
+ }
64
+ /**
65
+ * Corps de `PUT /api/settings`. Un token absent garde la valeur enregistrée ;
66
+ * une adresse vide retire la connexion à l'organizer.
67
+ */
68
+ export declare const SaveSettingsBodySchema: z.ZodObject<{
69
+ organizerUrl: z.ZodString;
70
+ organizerToken: z.ZodOptional<z.ZodString>;
71
+ claudeToken: z.ZodOptional<z.ZodString>;
72
+ analysis: z.ZodObject<{
73
+ auto: z.ZodBoolean;
74
+ maxTurns: z.ZodNumber;
75
+ maxMinutes: z.ZodNumber;
76
+ }, z.core.$strip>;
77
+ }, z.core.$strip>;
78
+ export type SaveSettingsBody = z.infer<typeof SaveSettingsBodySchema>;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ /** Limites d'une analyse par Claude : tours appliqués par Claude Code, durée appliquée par le tracker. */
3
+ export const ANALYSIS_LIMITS = { maxTurns: { min: 1, max: 200 }, maxMinutes: { min: 1, max: 60 } };
4
+ export const AnalysisSettingsSchema = z.object({
5
+ auto: z.boolean(),
6
+ maxTurns: z.number().int().min(ANALYSIS_LIMITS.maxTurns.min).max(ANALYSIS_LIMITS.maxTurns.max),
7
+ maxMinutes: z.number().int().min(ANALYSIS_LIMITS.maxMinutes.min).max(ANALYSIS_LIMITS.maxMinutes.max),
8
+ });
9
+ /**
10
+ * Réglages enregistrés dans `<données>/settings.json`. `organizer.space` et
11
+ * `organizer.owner` sont l'espace du token et son propriétaire, relevés au
12
+ * dernier test de la connexion ; `claude.savedAt` est la date d'enregistrement
13
+ * du token Claude, valable un an.
14
+ */
15
+ export const SettingsSchema = z.object({
16
+ organizer: z.object({
17
+ url: z.string().nullable(),
18
+ token: z.string().nullable(),
19
+ space: z.string().nullable(),
20
+ owner: z.string().nullable(),
21
+ }),
22
+ claude: z.object({
23
+ token: z.string().nullable(),
24
+ savedAt: z.string().nullable(),
25
+ }),
26
+ analysis: AnalysisSettingsSchema,
27
+ });
28
+ export const DEFAULT_SETTINGS = {
29
+ organizer: { url: null, token: null, space: null, owner: null },
30
+ claude: { token: null, savedAt: null },
31
+ analysis: { auto: false, maxTurns: 40, maxMinutes: 15 },
32
+ };
33
+ /**
34
+ * Corps de `PUT /api/settings`. Un token absent garde la valeur enregistrée ;
35
+ * une adresse vide retire la connexion à l'organizer.
36
+ */
37
+ export const SaveSettingsBodySchema = z.object({
38
+ organizerUrl: z.string().trim(),
39
+ organizerToken: z.string().trim().min(1).optional(),
40
+ claudeToken: z.string().trim().min(1).optional(),
41
+ analysis: AnalysisSettingsSchema,
42
+ });