claude-flow 3.64.0 → 3.65.1

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 (74) hide show
  1. package/package.json +1 -1
  2. package/v3/@claude-flow/cli/catalog-manifest.json +2 -2
  3. package/v3/@claude-flow/cli/dist/src/commands/cost.d.ts +18 -0
  4. package/v3/@claude-flow/cli/dist/src/commands/cost.js +195 -0
  5. package/v3/@claude-flow/cli/dist/src/commands/doctor-auto-approve.d.ts +9 -0
  6. package/v3/@claude-flow/cli/dist/src/commands/doctor-auto-approve.js +32 -0
  7. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +21 -3
  8. package/v3/@claude-flow/cli/dist/src/commands/hive-mind-worker.d.ts +2 -0
  9. package/v3/@claude-flow/cli/dist/src/commands/hive-mind-worker.js +9 -3
  10. package/v3/@claude-flow/cli/dist/src/commands/hive-mind.js +15 -1
  11. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +8 -2
  12. package/v3/@claude-flow/cli/dist/src/commands/index.js +2 -0
  13. package/v3/@claude-flow/cli/dist/src/commands/init.js +76 -2
  14. package/v3/@claude-flow/cli/dist/src/commands/mods.js +13 -0
  15. package/v3/@claude-flow/cli/dist/src/commands/plugins-paths.d.ts +13 -0
  16. package/v3/@claude-flow/cli/dist/src/commands/plugins-paths.js +55 -0
  17. package/v3/@claude-flow/cli/dist/src/commands/plugins-verify.d.ts +9 -0
  18. package/v3/@claude-flow/cli/dist/src/commands/plugins-verify.js +92 -0
  19. package/v3/@claude-flow/cli/dist/src/commands/plugins.js +13 -1
  20. package/v3/@claude-flow/cli/dist/src/cost/attribution.d.ts +35 -0
  21. package/v3/@claude-flow/cli/dist/src/cost/attribution.js +101 -0
  22. package/v3/@claude-flow/cli/dist/src/cost/budget-file.d.ts +57 -0
  23. package/v3/@claude-flow/cli/dist/src/cost/budget-file.js +113 -0
  24. package/v3/@claude-flow/cli/dist/src/cost/litellm.d.ts +69 -0
  25. package/v3/@claude-flow/cli/dist/src/cost/litellm.js +135 -0
  26. package/v3/@claude-flow/cli/dist/src/init/executor.d.ts +7 -2
  27. package/v3/@claude-flow/cli/dist/src/init/executor.js +64 -10
  28. package/v3/@claude-flow/cli/dist/src/init/helper-commands.d.ts +16 -0
  29. package/v3/@claude-flow/cli/dist/src/init/helper-commands.js +73 -0
  30. package/v3/@claude-flow/cli/dist/src/init/risky-settings-gate.d.ts +39 -0
  31. package/v3/@claude-flow/cli/dist/src/init/risky-settings-gate.js +130 -0
  32. package/v3/@claude-flow/cli/dist/src/init/settings-risk-scanner.d.ts +35 -0
  33. package/v3/@claude-flow/cli/dist/src/init/settings-risk-scanner.js +85 -0
  34. package/v3/@claude-flow/cli/dist/src/init/types.d.ts +12 -0
  35. package/v3/@claude-flow/cli/dist/src/mcp-tools/capability-brain.d.ts +1 -1
  36. package/v3/@claude-flow/cli/dist/src/mcp-tools/capability-brain.js +1 -1
  37. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +2 -1
  38. package/v3/@claude-flow/cli/dist/src/mcp-tools/http-fetch-pinned.d.ts +44 -0
  39. package/v3/@claude-flow/cli/dist/src/mcp-tools/http-fetch-pinned.js +148 -0
  40. package/v3/@claude-flow/cli/dist/src/mcp-tools/http-fetch-tools.d.ts +11 -2
  41. package/v3/@claude-flow/cli/dist/src/mcp-tools/http-fetch-tools.js +19 -70
  42. package/v3/@claude-flow/cli/dist/src/memory/verified-guards.d.ts +70 -0
  43. package/v3/@claude-flow/cli/dist/src/memory/verified-guards.js +101 -0
  44. package/v3/@claude-flow/cli/dist/src/memory/verified-outcomes.d.ts +68 -3
  45. package/v3/@claude-flow/cli/dist/src/memory/verified-outcomes.js +88 -19
  46. package/v3/@claude-flow/cli/dist/src/memory/verified-reverify.d.ts +63 -0
  47. package/v3/@claude-flow/cli/dist/src/memory/verified-reverify.js +174 -0
  48. package/v3/@claude-flow/cli/dist/src/missions/schemas.d.ts +120 -120
  49. package/v3/@claude-flow/cli/dist/src/mods/apply.d.ts +2 -0
  50. package/v3/@claude-flow/cli/dist/src/mods/apply.js +68 -8
  51. package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +193 -193
  52. package/v3/@claude-flow/cli/dist/src/mods/compact-snapshots.d.ts +21 -0
  53. package/v3/@claude-flow/cli/dist/src/mods/compact-snapshots.js +45 -0
  54. package/v3/@claude-flow/cli/dist/src/mods/headless-check.d.ts +58 -0
  55. package/v3/@claude-flow/cli/dist/src/mods/headless-check.js +137 -0
  56. package/v3/@claude-flow/cli/dist/src/mods/headless-plugins.d.ts +44 -0
  57. package/v3/@claude-flow/cli/dist/src/mods/headless-plugins.js +92 -0
  58. package/v3/@claude-flow/cli/dist/src/mods/install-trust.d.ts +28 -0
  59. package/v3/@claude-flow/cli/dist/src/mods/install-trust.js +127 -0
  60. package/v3/@claude-flow/cli/dist/src/mods/install.d.ts +19 -0
  61. package/v3/@claude-flow/cli/dist/src/mods/install.js +38 -1
  62. package/v3/@claude-flow/cli/dist/src/mods/plugin-paths.d.ts +60 -0
  63. package/v3/@claude-flow/cli/dist/src/mods/plugin-paths.js +131 -0
  64. package/v3/@claude-flow/cli/dist/src/mods/plugin-repair.d.ts +8 -0
  65. package/v3/@claude-flow/cli/dist/src/mods/plugin-repair.js +7 -0
  66. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/scan.d.ts +23 -0
  67. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/scan.js +255 -0
  68. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/signature.d.ts +53 -0
  69. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/signature.js +140 -0
  70. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/verify-status.d.ts +42 -0
  71. package/v3/@claude-flow/cli/dist/src/plugins/marketplace-trust/verify-status.js +110 -0
  72. package/v3/@claude-flow/cli/dist/src/services/headless-worker-executor.d.ts +2 -0
  73. package/v3/@claude-flow/cli/dist/src/services/headless-worker-executor.js +13 -3
  74. package/v3/@claude-flow/cli/package.json +2 -1
@@ -73,56 +73,56 @@ export declare const missionRecordSchema: z.ZodObject<{
73
73
  createdAt: z.ZodString;
74
74
  updatedAt: z.ZodString;
75
75
  }, "strict", z.ZodTypeAny, {
76
- createdAt: string;
77
- updatedAt: string;
78
- schemaVersion: 1;
79
- state: "completed" | "cancelled" | "failed" | "blocked" | "running" | "paused" | "queued" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "verifying" | "cancelRequested";
80
- acceptance: {
81
- revision: number;
82
- criteriaDigest: string;
83
- };
84
- plan: {
85
- revision: number;
86
- digest: string;
87
- taskGraphRef: string;
88
- };
76
+ state: "draft" | "planned" | "awaitingAuthorization" | "queued" | "running" | "pauseRequested" | "paused" | "blocked" | "verifying" | "completed" | "failed" | "cancelRequested" | "cancelled";
89
77
  objective: string;
78
+ schemaVersion: 1;
90
79
  missionId: string;
91
80
  tenantId: string;
92
81
  workspaceId: string;
93
82
  ownerPrincipalId: string;
94
83
  revision: number;
84
+ plan: {
85
+ revision: number;
86
+ digest: string;
87
+ taskGraphRef: string;
88
+ };
95
89
  policyRef: string;
96
90
  budgetRef: string;
97
91
  executionMode: "durable-executor" | "session-bound";
98
92
  evidenceRefs: string[];
99
- lastEventSequence: number;
100
- authorizationRef?: string | undefined;
101
- }, {
102
- createdAt: string;
103
- updatedAt: string;
104
- schemaVersion: 1;
105
- state: "completed" | "cancelled" | "failed" | "blocked" | "running" | "paused" | "queued" | "draft" | "planned" | "awaitingAuthorization" | "pauseRequested" | "verifying" | "cancelRequested";
106
93
  acceptance: {
107
94
  revision: number;
108
95
  criteriaDigest: string;
109
96
  };
110
- plan: {
111
- revision: number;
112
- digest: string;
113
- taskGraphRef: string;
114
- };
97
+ lastEventSequence: number;
98
+ createdAt: string;
99
+ updatedAt: string;
100
+ authorizationRef?: string | undefined;
101
+ }, {
102
+ state: "draft" | "planned" | "awaitingAuthorization" | "queued" | "running" | "pauseRequested" | "paused" | "blocked" | "verifying" | "completed" | "failed" | "cancelRequested" | "cancelled";
115
103
  objective: string;
104
+ schemaVersion: 1;
116
105
  missionId: string;
117
106
  tenantId: string;
118
107
  workspaceId: string;
119
108
  ownerPrincipalId: string;
120
109
  revision: number;
110
+ plan: {
111
+ revision: number;
112
+ digest: string;
113
+ taskGraphRef: string;
114
+ };
121
115
  policyRef: string;
122
116
  budgetRef: string;
123
117
  executionMode: "durable-executor" | "session-bound";
124
118
  evidenceRefs: string[];
119
+ acceptance: {
120
+ revision: number;
121
+ criteriaDigest: string;
122
+ };
125
123
  lastEventSequence: number;
124
+ createdAt: string;
125
+ updatedAt: string;
126
126
  authorizationRef?: string | undefined;
127
127
  }>;
128
128
  export type MissionRecord = z.infer<typeof missionRecordSchema>;
@@ -163,10 +163,10 @@ export declare const taskSpecSchema: z.ZodObject<{
163
163
  mode: "durable-executor" | "session-bound";
164
164
  requirement: string;
165
165
  };
166
- checkpoint?: string | undefined;
167
166
  dependsOn?: string[] | undefined;
168
167
  capabilityCeiling?: string[] | undefined;
169
168
  estimatedCostMinor?: number | undefined;
169
+ checkpoint?: string | undefined;
170
170
  acceptanceEvidence?: string[] | undefined;
171
171
  }>;
172
172
  export declare const acceptanceCriterionSchema: z.ZodObject<{
@@ -185,15 +185,15 @@ export declare const acceptanceCriterionSchema: z.ZodObject<{
185
185
  producer: string;
186
186
  independent: boolean;
187
187
  mandatory: boolean;
188
- threshold?: string | undefined;
189
188
  baseline?: string | undefined;
189
+ threshold?: string | undefined;
190
190
  }, {
191
191
  id: string;
192
192
  check: string;
193
193
  producer: string;
194
- threshold?: string | undefined;
195
- baseline?: string | undefined;
196
194
  inputs?: string[] | undefined;
195
+ baseline?: string | undefined;
196
+ threshold?: string | undefined;
197
197
  independent?: boolean | undefined;
198
198
  mandatory?: boolean | undefined;
199
199
  }>;
@@ -207,15 +207,15 @@ export declare const budgetSpecSchema: z.ZodObject<{
207
207
  }, "strict", z.ZodTypeAny, {
208
208
  currency: string;
209
209
  ceilingMinor: number;
210
- concurrency?: number | undefined;
211
210
  tokens?: number | undefined;
211
+ concurrency?: number | undefined;
212
212
  wallTimeSeconds?: number | undefined;
213
213
  retries?: number | undefined;
214
214
  }, {
215
215
  currency: string;
216
216
  ceilingMinor: number;
217
- concurrency?: number | undefined;
218
217
  tokens?: number | undefined;
218
+ concurrency?: number | undefined;
219
219
  wallTimeSeconds?: number | undefined;
220
220
  retries?: number | undefined;
221
221
  }>;
@@ -257,10 +257,10 @@ export declare const planBodySchema: z.ZodObject<{
257
257
  mode: "durable-executor" | "session-bound";
258
258
  requirement: string;
259
259
  };
260
- checkpoint?: string | undefined;
261
260
  dependsOn?: string[] | undefined;
262
261
  capabilityCeiling?: string[] | undefined;
263
262
  estimatedCostMinor?: number | undefined;
263
+ checkpoint?: string | undefined;
264
264
  acceptanceEvidence?: string[] | undefined;
265
265
  }>, "many">;
266
266
  acceptance: z.ZodArray<z.ZodObject<{
@@ -279,15 +279,15 @@ export declare const planBodySchema: z.ZodObject<{
279
279
  producer: string;
280
280
  independent: boolean;
281
281
  mandatory: boolean;
282
- threshold?: string | undefined;
283
282
  baseline?: string | undefined;
283
+ threshold?: string | undefined;
284
284
  }, {
285
285
  id: string;
286
286
  check: string;
287
287
  producer: string;
288
- threshold?: string | undefined;
289
- baseline?: string | undefined;
290
288
  inputs?: string[] | undefined;
289
+ baseline?: string | undefined;
290
+ threshold?: string | undefined;
291
291
  independent?: boolean | undefined;
292
292
  mandatory?: boolean | undefined;
293
293
  }>, "many">;
@@ -301,15 +301,15 @@ export declare const planBodySchema: z.ZodObject<{
301
301
  }, "strict", z.ZodTypeAny, {
302
302
  currency: string;
303
303
  ceilingMinor: number;
304
- concurrency?: number | undefined;
305
304
  tokens?: number | undefined;
305
+ concurrency?: number | undefined;
306
306
  wallTimeSeconds?: number | undefined;
307
307
  retries?: number | undefined;
308
308
  }, {
309
309
  currency: string;
310
310
  ceilingMinor: number;
311
- concurrency?: number | undefined;
312
311
  tokens?: number | undefined;
312
+ concurrency?: number | undefined;
313
313
  wallTimeSeconds?: number | undefined;
314
314
  retries?: number | undefined;
315
315
  }>;
@@ -334,17 +334,6 @@ export declare const planBodySchema: z.ZodObject<{
334
334
  acceptanceEvidence: string[];
335
335
  checkpoint?: string | undefined;
336
336
  }[];
337
- scope: {
338
- capabilities: string[];
339
- };
340
- budget: {
341
- currency: string;
342
- ceilingMinor: number;
343
- concurrency?: number | undefined;
344
- tokens?: number | undefined;
345
- wallTimeSeconds?: number | undefined;
346
- retries?: number | undefined;
347
- };
348
337
  acceptance: {
349
338
  id: string;
350
339
  check: string;
@@ -352,9 +341,20 @@ export declare const planBodySchema: z.ZodObject<{
352
341
  producer: string;
353
342
  independent: boolean;
354
343
  mandatory: boolean;
355
- threshold?: string | undefined;
356
344
  baseline?: string | undefined;
345
+ threshold?: string | undefined;
357
346
  }[];
347
+ budget: {
348
+ currency: string;
349
+ ceilingMinor: number;
350
+ tokens?: number | undefined;
351
+ concurrency?: number | undefined;
352
+ wallTimeSeconds?: number | undefined;
353
+ retries?: number | undefined;
354
+ };
355
+ scope: {
356
+ capabilities: string[];
357
+ };
358
358
  }, {
359
359
  tasks: {
360
360
  id: string;
@@ -363,30 +363,30 @@ export declare const planBodySchema: z.ZodObject<{
363
363
  mode: "durable-executor" | "session-bound";
364
364
  requirement: string;
365
365
  };
366
- checkpoint?: string | undefined;
367
366
  dependsOn?: string[] | undefined;
368
367
  capabilityCeiling?: string[] | undefined;
369
368
  estimatedCostMinor?: number | undefined;
369
+ checkpoint?: string | undefined;
370
370
  acceptanceEvidence?: string[] | undefined;
371
371
  }[];
372
- budget: {
373
- currency: string;
374
- ceilingMinor: number;
375
- concurrency?: number | undefined;
376
- tokens?: number | undefined;
377
- wallTimeSeconds?: number | undefined;
378
- retries?: number | undefined;
379
- };
380
372
  acceptance: {
381
373
  id: string;
382
374
  check: string;
383
375
  producer: string;
384
- threshold?: string | undefined;
385
- baseline?: string | undefined;
386
376
  inputs?: string[] | undefined;
377
+ baseline?: string | undefined;
378
+ threshold?: string | undefined;
387
379
  independent?: boolean | undefined;
388
380
  mandatory?: boolean | undefined;
389
381
  }[];
382
+ budget: {
383
+ currency: string;
384
+ ceilingMinor: number;
385
+ tokens?: number | undefined;
386
+ concurrency?: number | undefined;
387
+ wallTimeSeconds?: number | undefined;
388
+ retries?: number | undefined;
389
+ };
390
390
  scope?: {
391
391
  capabilities?: string[] | undefined;
392
392
  } | undefined;
@@ -397,11 +397,11 @@ export declare const createInputSchema: z.ZodObject<{
397
397
  requestId: z.ZodString;
398
398
  objective: z.ZodString;
399
399
  }, "strict", z.ZodTypeAny, {
400
- requestId: string;
401
400
  objective: string;
402
- }, {
403
401
  requestId: string;
402
+ }, {
404
403
  objective: string;
404
+ requestId: string;
405
405
  }>;
406
406
  export declare const planInputSchema: z.ZodObject<{
407
407
  requestId: z.ZodString;
@@ -445,10 +445,10 @@ export declare const planInputSchema: z.ZodObject<{
445
445
  mode: "durable-executor" | "session-bound";
446
446
  requirement: string;
447
447
  };
448
- checkpoint?: string | undefined;
449
448
  dependsOn?: string[] | undefined;
450
449
  capabilityCeiling?: string[] | undefined;
451
450
  estimatedCostMinor?: number | undefined;
451
+ checkpoint?: string | undefined;
452
452
  acceptanceEvidence?: string[] | undefined;
453
453
  }>, "many">;
454
454
  acceptance: z.ZodArray<z.ZodObject<{
@@ -467,15 +467,15 @@ export declare const planInputSchema: z.ZodObject<{
467
467
  producer: string;
468
468
  independent: boolean;
469
469
  mandatory: boolean;
470
- threshold?: string | undefined;
471
470
  baseline?: string | undefined;
471
+ threshold?: string | undefined;
472
472
  }, {
473
473
  id: string;
474
474
  check: string;
475
475
  producer: string;
476
- threshold?: string | undefined;
477
- baseline?: string | undefined;
478
476
  inputs?: string[] | undefined;
477
+ baseline?: string | undefined;
478
+ threshold?: string | undefined;
479
479
  independent?: boolean | undefined;
480
480
  mandatory?: boolean | undefined;
481
481
  }>, "many">;
@@ -489,15 +489,15 @@ export declare const planInputSchema: z.ZodObject<{
489
489
  }, "strict", z.ZodTypeAny, {
490
490
  currency: string;
491
491
  ceilingMinor: number;
492
- concurrency?: number | undefined;
493
492
  tokens?: number | undefined;
493
+ concurrency?: number | undefined;
494
494
  wallTimeSeconds?: number | undefined;
495
495
  retries?: number | undefined;
496
496
  }, {
497
497
  currency: string;
498
498
  ceilingMinor: number;
499
- concurrency?: number | undefined;
500
499
  tokens?: number | undefined;
500
+ concurrency?: number | undefined;
501
501
  wallTimeSeconds?: number | undefined;
502
502
  retries?: number | undefined;
503
503
  }>;
@@ -522,17 +522,6 @@ export declare const planInputSchema: z.ZodObject<{
522
522
  acceptanceEvidence: string[];
523
523
  checkpoint?: string | undefined;
524
524
  }[];
525
- scope: {
526
- capabilities: string[];
527
- };
528
- budget: {
529
- currency: string;
530
- ceilingMinor: number;
531
- concurrency?: number | undefined;
532
- tokens?: number | undefined;
533
- wallTimeSeconds?: number | undefined;
534
- retries?: number | undefined;
535
- };
536
525
  acceptance: {
537
526
  id: string;
538
527
  check: string;
@@ -540,9 +529,20 @@ export declare const planInputSchema: z.ZodObject<{
540
529
  producer: string;
541
530
  independent: boolean;
542
531
  mandatory: boolean;
543
- threshold?: string | undefined;
544
532
  baseline?: string | undefined;
533
+ threshold?: string | undefined;
545
534
  }[];
535
+ budget: {
536
+ currency: string;
537
+ ceilingMinor: number;
538
+ tokens?: number | undefined;
539
+ concurrency?: number | undefined;
540
+ wallTimeSeconds?: number | undefined;
541
+ retries?: number | undefined;
542
+ };
543
+ scope: {
544
+ capabilities: string[];
545
+ };
546
546
  }, {
547
547
  tasks: {
548
548
  id: string;
@@ -551,36 +551,37 @@ export declare const planInputSchema: z.ZodObject<{
551
551
  mode: "durable-executor" | "session-bound";
552
552
  requirement: string;
553
553
  };
554
- checkpoint?: string | undefined;
555
554
  dependsOn?: string[] | undefined;
556
555
  capabilityCeiling?: string[] | undefined;
557
556
  estimatedCostMinor?: number | undefined;
557
+ checkpoint?: string | undefined;
558
558
  acceptanceEvidence?: string[] | undefined;
559
559
  }[];
560
- budget: {
561
- currency: string;
562
- ceilingMinor: number;
563
- concurrency?: number | undefined;
564
- tokens?: number | undefined;
565
- wallTimeSeconds?: number | undefined;
566
- retries?: number | undefined;
567
- };
568
560
  acceptance: {
569
561
  id: string;
570
562
  check: string;
571
563
  producer: string;
572
- threshold?: string | undefined;
573
- baseline?: string | undefined;
574
564
  inputs?: string[] | undefined;
565
+ baseline?: string | undefined;
566
+ threshold?: string | undefined;
575
567
  independent?: boolean | undefined;
576
568
  mandatory?: boolean | undefined;
577
569
  }[];
570
+ budget: {
571
+ currency: string;
572
+ ceilingMinor: number;
573
+ tokens?: number | undefined;
574
+ concurrency?: number | undefined;
575
+ wallTimeSeconds?: number | undefined;
576
+ retries?: number | undefined;
577
+ };
578
578
  scope?: {
579
579
  capabilities?: string[] | undefined;
580
580
  } | undefined;
581
581
  }>;
582
582
  }, "strict", z.ZodTypeAny, {
583
583
  requestId: string;
584
+ missionId: string;
584
585
  plan: {
585
586
  tasks: {
586
587
  id: string;
@@ -595,17 +596,6 @@ export declare const planInputSchema: z.ZodObject<{
595
596
  acceptanceEvidence: string[];
596
597
  checkpoint?: string | undefined;
597
598
  }[];
598
- scope: {
599
- capabilities: string[];
600
- };
601
- budget: {
602
- currency: string;
603
- ceilingMinor: number;
604
- concurrency?: number | undefined;
605
- tokens?: number | undefined;
606
- wallTimeSeconds?: number | undefined;
607
- retries?: number | undefined;
608
- };
609
599
  acceptance: {
610
600
  id: string;
611
601
  check: string;
@@ -613,14 +603,25 @@ export declare const planInputSchema: z.ZodObject<{
613
603
  producer: string;
614
604
  independent: boolean;
615
605
  mandatory: boolean;
616
- threshold?: string | undefined;
617
606
  baseline?: string | undefined;
607
+ threshold?: string | undefined;
618
608
  }[];
609
+ budget: {
610
+ currency: string;
611
+ ceilingMinor: number;
612
+ tokens?: number | undefined;
613
+ concurrency?: number | undefined;
614
+ wallTimeSeconds?: number | undefined;
615
+ retries?: number | undefined;
616
+ };
617
+ scope: {
618
+ capabilities: string[];
619
+ };
619
620
  };
620
- missionId: string;
621
621
  expectedRevision: number;
622
622
  }, {
623
623
  requestId: string;
624
+ missionId: string;
624
625
  plan: {
625
626
  tasks: {
626
627
  id: string;
@@ -629,35 +630,34 @@ export declare const planInputSchema: z.ZodObject<{
629
630
  mode: "durable-executor" | "session-bound";
630
631
  requirement: string;
631
632
  };
632
- checkpoint?: string | undefined;
633
633
  dependsOn?: string[] | undefined;
634
634
  capabilityCeiling?: string[] | undefined;
635
635
  estimatedCostMinor?: number | undefined;
636
+ checkpoint?: string | undefined;
636
637
  acceptanceEvidence?: string[] | undefined;
637
638
  }[];
638
- budget: {
639
- currency: string;
640
- ceilingMinor: number;
641
- concurrency?: number | undefined;
642
- tokens?: number | undefined;
643
- wallTimeSeconds?: number | undefined;
644
- retries?: number | undefined;
645
- };
646
639
  acceptance: {
647
640
  id: string;
648
641
  check: string;
649
642
  producer: string;
650
- threshold?: string | undefined;
651
- baseline?: string | undefined;
652
643
  inputs?: string[] | undefined;
644
+ baseline?: string | undefined;
645
+ threshold?: string | undefined;
653
646
  independent?: boolean | undefined;
654
647
  mandatory?: boolean | undefined;
655
648
  }[];
649
+ budget: {
650
+ currency: string;
651
+ ceilingMinor: number;
652
+ tokens?: number | undefined;
653
+ concurrency?: number | undefined;
654
+ wallTimeSeconds?: number | undefined;
655
+ retries?: number | undefined;
656
+ };
656
657
  scope?: {
657
658
  capabilities?: string[] | undefined;
658
659
  } | undefined;
659
660
  };
660
- missionId: string;
661
661
  expectedRevision: number;
662
662
  }>;
663
663
  export declare const getInputSchema: z.ZodObject<{
@@ -672,13 +672,13 @@ export declare const eventsInputSchema: z.ZodObject<{
672
672
  afterSequence: z.ZodDefault<z.ZodNumber>;
673
673
  limit: z.ZodDefault<z.ZodNumber>;
674
674
  }, "strict", z.ZodTypeAny, {
675
- limit: number;
676
675
  missionId: string;
677
676
  afterSequence: number;
677
+ limit: number;
678
678
  }, {
679
679
  missionId: string;
680
- limit?: number | undefined;
681
680
  afterSequence?: number | undefined;
681
+ limit?: number | undefined;
682
682
  }>;
683
683
  export declare const requestActionInputSchema: z.ZodObject<{
684
684
  requestId: z.ZodString;
@@ -687,16 +687,16 @@ export declare const requestActionInputSchema: z.ZodObject<{
687
687
  action: z.ZodEnum<["pause", "resume", "cancel", "requestAuthorization", "admit"]>;
688
688
  reason: z.ZodOptional<z.ZodString>;
689
689
  }, "strict", z.ZodTypeAny, {
690
- action: "pause" | "resume" | "cancel" | "requestAuthorization" | "admit";
691
690
  requestId: string;
692
691
  missionId: string;
693
692
  expectedRevision: number;
693
+ action: "pause" | "resume" | "cancel" | "requestAuthorization" | "admit";
694
694
  reason?: string | undefined;
695
695
  }, {
696
- action: "pause" | "resume" | "cancel" | "requestAuthorization" | "admit";
697
696
  requestId: string;
698
697
  missionId: string;
699
698
  expectedRevision: number;
699
+ action: "pause" | "resume" | "cancel" | "requestAuthorization" | "admit";
700
700
  reason?: string | undefined;
701
701
  }>;
702
702
  export type CreateInput = z.infer<typeof createInputSchema>;
@@ -18,6 +18,8 @@ export interface ApplyOptions {
18
18
  skipInTestEnv?: boolean;
19
19
  /** The marketplace to declare when the settings have none (default github ruvnet/ruflo). */
20
20
  marketplace?: MarketplaceEntry;
21
+ /** ADR-509 §2.2: plugins (name or id) to install past a high scan finding; each override is recorded. */
22
+ acceptRisk?: readonly string[];
21
23
  /** Injectable for tests. */
22
24
  exec?: Exec;
23
25
  }
@@ -7,9 +7,10 @@
7
7
  import { readFileSync } from 'node:fs';
8
8
  import { homedir } from 'node:os';
9
9
  import { output } from '../output.js';
10
- import { installMod, MARKETPLACE_NAME, MARKETPLACE_SOURCE, MOD_PLUGINS, readRecord, recordClaudeInstalled, scopeOfSettingsFile, uninstallMod, } from './install.js';
10
+ import { disableBlockedPlugins, installMod, MARKETPLACE_NAME, MARKETPLACE_SOURCE, MOD_PLUGIN_IDS, MOD_PLUGINS, readRecord, readSettingsFile, settingsFileFor, recordClaudeInstalled, scopeOfSettingsFile, uninstallMod, } from './install.js';
11
11
  import { findClaudeBinary, installArgv, marketplaceArgv, repairPluginInstall, uninstallArgv, uninstallPlugins } from './plugin-repair.js';
12
12
  import { claudeConfigDir, describeSource, installedState, marketplaceState, repairCommands, resolveFindings, sameSource } from './plugin-resolve.js';
13
+ import { scanBeforeInstall, verifyAndRecord } from './install-trust.js';
13
14
  /** One line per thing a run added; empty on a re-run. */
14
15
  export function describeAdded(added) {
15
16
  return [
@@ -68,14 +69,39 @@ function noteRewrite(file, before) {
68
69
  // Not ours to judge further.
69
70
  }
70
71
  }
72
+ /** The marketplace the settings file already declares, else the requested one. */
73
+ function declaredMarketplace(root, scope, requested) {
74
+ try {
75
+ const markets = readSettingsFile(settingsFileFor(root, scope)).extraKnownMarketplaces;
76
+ return markets?.[MARKETPLACE_NAME] ?? requested;
77
+ }
78
+ catch {
79
+ return requested;
80
+ }
81
+ }
71
82
  export async function applyMods(root, opts) {
72
- const install = installMod(root, opts.scope, opts.dryRun === true, undefined, opts.marketplace ?? MARKETPLACE_SOURCE);
73
83
  const configDir = claudeConfigDir(process.env, homedir());
84
+ const acceptRisk = new Set(opts.acceptRisk ?? []);
85
+ const seen = new Set();
86
+ const blocked = new Map();
87
+ const told = new Set();
88
+ // ADR-509 §2.2: Claude Code loads an enabled plugin straight from the
89
+ // marketplace clone, install or not. So where a clone already exists, scan it
90
+ // BEFORE enabling anything from it, and never enable what the scan blocks.
91
+ const preClone = opts.dryRun ? null : marketplaceState(configDir).location;
92
+ const scannable = declaredMarketplace(root, opts.scope, opts.marketplace ?? MARKETPLACE_SOURCE).source.source !== 'directory';
93
+ if (preClone && scannable) {
94
+ for (const [id, why] of scanBeforeInstall(root, preClone, MOD_PLUGINS, acceptRisk, undefined, seen).blocked)
95
+ blocked.set(id, why);
96
+ }
97
+ const install = installMod(root, opts.scope, opts.dryRun === true, MOD_PLUGIN_IDS.filter((id) => !blocked.has(id)), opts.marketplace ?? MARKETPLACE_SOURCE);
98
+ // A blocked plugin enabled by an earlier run (or by hand) is turned off too.
99
+ turnOff(root, install, blocked, told);
74
100
  const lines = describeAdded(install.added);
75
101
  // Only what is enabled in the file: `claude plugin install` would flip a
76
102
  // plugin someone set to false back to true.
77
103
  const enabled = (install.next.enabledPlugins ?? {});
78
- const plugins = MOD_PLUGINS.filter((p) => enabled[p.id] === true);
104
+ const plugins = MOD_PLUGINS.filter((p) => enabled[p.id] === true && !blocked.has(p.id));
79
105
  // The marketplace the file declares wins: a person's own declaration is kept and used.
80
106
  const declared = install.next.extraKnownMarketplaces?.[MARKETPLACE_NAME] ?? MARKETPLACE_SOURCE;
81
107
  const market = marketplaceState(configDir);
@@ -111,16 +137,25 @@ export async function applyMods(root, opts) {
111
137
  for (const line of repairCommands(root, opts.scope, k, plugins, declared))
112
138
  output.writeln(` ${line}`);
113
139
  };
114
- if (opts.pluginInstall === false)
115
- return { install, resolvable: true, skipped: '--no-plugin-install' };
140
+ // The `claude` step may not run below: say what is enabled without a scan.
141
+ const unscanned = () => {
142
+ if (!preClone && scannable && plugins.length)
143
+ output.printWarning(`No ruflo marketplace clone yet, so nothing was scanned (ADR-509): ${plugins.map((p) => p.id).join(', ')} enabled unscanned; Claude Code clones it on the first trusted start. Run ruflo mods install again after that to scan it.`);
144
+ };
145
+ if (opts.pluginInstall === false) {
146
+ unscanned();
147
+ return { install, resolvable: blocked.size === 0, skipped: '--no-plugin-install' };
148
+ }
116
149
  if (opts.skipInTestEnv && (process.env.VITEST || process.env.CI)) {
117
150
  output.writeln(output.dim(`claude plugin step skipped (${process.env.VITEST ? 'VITEST' : 'CI'} set).`));
151
+ unscanned();
118
152
  manual();
119
153
  return { install, resolvable: false, skipped: 'test or CI environment' };
120
154
  }
121
155
  const claude = findClaudeBinary(process.env, homedir());
122
156
  if (!claude) {
123
157
  output.printWarning('No runnable claude binary on PATH: the plugins are enabled in settings, not installed.');
158
+ unscanned();
124
159
  manual();
125
160
  return { install, resolvable: false, skipped: 'no claude on PATH' };
126
161
  }
@@ -130,8 +165,21 @@ export async function applyMods(root, opts) {
130
165
  // Never claim (and so never uninstall) a plugin that was installed before, or one ruflo did not enable.
131
166
  const before = new Set(plugins.filter((p) => installedState(root, configDir, p.id).installed).map((p) => p.id));
132
167
  const textBefore = readText(install.settingsFile);
133
- const repair = await repairPluginInstall({ projectRoot: root, scope: opts.scope, configDir, claude, plugins, marketplace: declared, exec: opts.exec });
168
+ const repair = await repairPluginInstall({
169
+ projectRoot: root, scope: opts.scope, configDir, claude, plugins, marketplace: declared, exec: opts.exec,
170
+ // ADR-509 §2.2: scan the refreshed clone before any install (a directory marketplace has no install step to gate).
171
+ beforeInstall: (clone) => {
172
+ const gate = scanBeforeInstall(root, clone, plugins, acceptRisk, undefined, seen);
173
+ for (const [id, why] of gate.blocked)
174
+ blocked.set(id, why);
175
+ return gate;
176
+ },
177
+ });
134
178
  printSteps(repair.steps);
179
+ // The refresh may have brought a finding the first scan did not see: that plugin is turned off as well.
180
+ turnOff(root, install, blocked, told);
181
+ // ADR-509 §2.1: verify what Claude Code will load and leave the result for the mod's trust gate.
182
+ verifyAndRecord(configDir, marketplaceState(configDir).location, plugins.map((p) => p.id.split('@')[0]));
135
183
  if (declared.source.source === 'directory' && repair.ok)
136
184
  output.writeln(output.dim(`Directory marketplace: plugins load live from ${declared.source.path} (no clone, no install).`));
137
185
  const enabledByRuflo = new Set(readRecord(root)?.files[install.settingsFile]?.plugins ?? []);
@@ -141,8 +189,8 @@ export async function applyMods(root, opts) {
141
189
  .filter((id) => !before.has(id) && enabledByRuflo.has(id));
142
190
  recordClaudeInstalled(root, install.settingsFile, ours);
143
191
  noteRewrite(install.settingsFile, textBefore);
144
- const failed = resolveFindings(root, opts.scope, configDir, undefined, plugins.map((p) => p.id), declared).filter((f) => f.status === 'fail');
145
- if (repair.ok && failed.length === 0)
192
+ const failed = resolveFindings(root, opts.scope, configDir, undefined, plugins.filter((p) => !blocked.has(p.id)).map((p) => p.id), declared).filter((f) => f.status === 'fail');
193
+ if (repair.ok && failed.length === 0 && blocked.size === 0)
146
194
  return { install, resolvable: true };
147
195
  for (const f of failed)
148
196
  output.writeln(`${output.error('✗')} ${f.name}: ${f.message}`);
@@ -150,6 +198,18 @@ export async function applyMods(root, opts) {
150
198
  manual(now.known && sameSource(now.source, declared.source));
151
199
  return { install, resolvable: false };
152
200
  }
201
+ /** ADR-509 §2.2: turn off (enabledPlugins + install record) each blocked plugin, and say so. */
202
+ function turnOff(root, install, blocked, told) {
203
+ if (install.dryRun || blocked.size === 0)
204
+ return;
205
+ const off = disableBlockedPlugins(root, install.settingsFile, [...blocked.keys()]);
206
+ for (const [id, why] of blocked) {
207
+ if (told.has(id) && !off.includes(id))
208
+ continue; // already said, and nothing changed since
209
+ told.add(id);
210
+ output.writeln(`${output.error('✗')} ${id}: ${off.includes(id) ? `enabledPlugins["${id}"] removed from ${install.settingsFile}` : 'not enabled'}; ${why}`);
211
+ }
212
+ }
153
213
  /**
154
214
  * `ruflo mods uninstall`: `claude plugin uninstall` exactly the plugins ruflo
155
215
  * installed, then remove exactly the settings keys it added.