@fuzdev/fuz_util 0.42.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -12
  3. package/dist/async.d.ts +2 -2
  4. package/dist/async.d.ts.map +1 -1
  5. package/dist/async.js +2 -2
  6. package/dist/benchmark.d.ts +179 -0
  7. package/dist/benchmark.d.ts.map +1 -0
  8. package/dist/benchmark.js +400 -0
  9. package/dist/benchmark_baseline.d.ts +195 -0
  10. package/dist/benchmark_baseline.d.ts.map +1 -0
  11. package/dist/benchmark_baseline.js +388 -0
  12. package/dist/benchmark_format.d.ts +87 -0
  13. package/dist/benchmark_format.d.ts.map +1 -0
  14. package/dist/benchmark_format.js +266 -0
  15. package/dist/benchmark_stats.d.ts +112 -0
  16. package/dist/benchmark_stats.d.ts.map +1 -0
  17. package/dist/benchmark_stats.js +219 -0
  18. package/dist/benchmark_types.d.ts +174 -0
  19. package/dist/benchmark_types.d.ts.map +1 -0
  20. package/dist/benchmark_types.js +1 -0
  21. package/dist/git.d.ts +12 -0
  22. package/dist/git.d.ts.map +1 -1
  23. package/dist/git.js +14 -0
  24. package/dist/library_json.d.ts +3 -3
  25. package/dist/library_json.d.ts.map +1 -1
  26. package/dist/library_json.js +1 -1
  27. package/dist/maths.d.ts +4 -0
  28. package/dist/maths.d.ts.map +1 -1
  29. package/dist/maths.js +8 -0
  30. package/dist/object.js +1 -1
  31. package/dist/source_json.d.ts +4 -4
  32. package/dist/stats.d.ts +180 -0
  33. package/dist/stats.d.ts.map +1 -0
  34. package/dist/stats.js +402 -0
  35. package/dist/string.d.ts +13 -0
  36. package/dist/string.d.ts.map +1 -1
  37. package/dist/string.js +58 -0
  38. package/dist/time.d.ts +165 -0
  39. package/dist/time.d.ts.map +1 -0
  40. package/dist/time.js +264 -0
  41. package/dist/timings.d.ts +1 -7
  42. package/dist/timings.d.ts.map +1 -1
  43. package/dist/timings.js +16 -16
  44. package/package.json +21 -19
  45. package/src/lib/async.ts +3 -3
  46. package/src/lib/benchmark.ts +498 -0
  47. package/src/lib/benchmark_baseline.ts +538 -0
  48. package/src/lib/benchmark_format.ts +314 -0
  49. package/src/lib/benchmark_stats.ts +311 -0
  50. package/src/lib/benchmark_types.ts +197 -0
  51. package/src/lib/git.ts +24 -0
  52. package/src/lib/library_json.ts +3 -3
  53. package/src/lib/maths.ts +8 -0
  54. package/src/lib/object.ts +1 -1
  55. package/src/lib/stats.ts +534 -0
  56. package/src/lib/string.ts +66 -0
  57. package/src/lib/time.ts +319 -0
  58. package/src/lib/timings.ts +17 -17
  59. package/src/lib/types.ts +2 -2
@@ -0,0 +1,538 @@
1
+ /**
2
+ * Benchmark baseline storage and comparison utilities.
3
+ * Save benchmark results to disk and compare against baselines for regression detection.
4
+ */
5
+
6
+ import {readFile, writeFile, mkdir, rm} from 'node:fs/promises';
7
+ import {join} from 'node:path';
8
+ import {z} from 'zod';
9
+
10
+ import {fs_exists} from './fs.js';
11
+ import {git_info_get} from './git.js';
12
+ import type {BenchmarkResult} from './benchmark_types.js';
13
+ import {
14
+ benchmark_stats_compare,
15
+ type BenchmarkComparison,
16
+ type BenchmarkStatsComparable,
17
+ } from './benchmark_stats.js';
18
+ import {stats_confidence_interval_from_summary} from './stats.js';
19
+
20
+ // Version for forward compatibility - increment when schema changes
21
+ const BASELINE_VERSION = 1;
22
+
23
+ /**
24
+ * Schema for a single benchmark entry in the baseline.
25
+ */
26
+ export const BenchmarkBaselineEntry = z.object({
27
+ name: z.string(),
28
+ mean_ns: z.number(),
29
+ median_ns: z.number(),
30
+ std_dev_ns: z.number(),
31
+ min_ns: z.number(),
32
+ max_ns: z.number(),
33
+ p75_ns: z.number(),
34
+ p90_ns: z.number(),
35
+ p95_ns: z.number(),
36
+ p99_ns: z.number(),
37
+ ops_per_second: z.number(),
38
+ sample_size: z.number(),
39
+ });
40
+ export type BenchmarkBaselineEntry = z.infer<typeof BenchmarkBaselineEntry>;
41
+
42
+ /**
43
+ * Schema for the complete baseline file.
44
+ */
45
+ export const BenchmarkBaseline = z.object({
46
+ version: z.number(),
47
+ timestamp: z.string(),
48
+ git_commit: z.string().nullable(),
49
+ git_branch: z.string().nullable(),
50
+ node_version: z.string(),
51
+ entries: z.array(BenchmarkBaselineEntry),
52
+ });
53
+ export type BenchmarkBaseline = z.infer<typeof BenchmarkBaseline>;
54
+
55
+ /**
56
+ * Options for saving a baseline.
57
+ */
58
+ export interface BenchmarkBaselineSaveOptions {
59
+ /** Directory to store baselines (default: '.gro/benchmarks') */
60
+ path?: string;
61
+ /** Git commit hash (auto-detected if not provided) */
62
+ git_commit?: string | null;
63
+ /** Git branch name (auto-detected if not provided) */
64
+ git_branch?: string | null;
65
+ }
66
+
67
+ /**
68
+ * Options for loading a baseline.
69
+ */
70
+ export interface BenchmarkBaselineLoadOptions {
71
+ /** Directory to load baseline from (default: '.gro/benchmarks') */
72
+ path?: string;
73
+ }
74
+
75
+ /**
76
+ * Options for comparing against a baseline.
77
+ */
78
+ export interface BenchmarkBaselineCompareOptions extends BenchmarkBaselineLoadOptions {
79
+ /**
80
+ * Minimum speedup ratio to consider a regression.
81
+ * For example, 1.05 means only flag regressions that are 5% or more slower.
82
+ * Default: 1.0 (any statistically significant slowdown is a regression)
83
+ */
84
+ regression_threshold?: number;
85
+ /**
86
+ * Number of days after which to warn about stale baseline.
87
+ * Default: undefined (no staleness warning)
88
+ */
89
+ staleness_warning_days?: number;
90
+ }
91
+
92
+ /**
93
+ * Result of comparing current results against a baseline.
94
+ */
95
+ export interface BenchmarkBaselineComparisonResult {
96
+ /** Whether a baseline was found */
97
+ baseline_found: boolean;
98
+ /** Timestamp of the baseline */
99
+ baseline_timestamp: string | null;
100
+ /** Git commit of the baseline */
101
+ baseline_commit: string | null;
102
+ /** Age of the baseline in days */
103
+ baseline_age_days: number | null;
104
+ /** Whether the baseline is considered stale based on staleness_warning_days option */
105
+ baseline_stale: boolean;
106
+ /** Individual task comparisons */
107
+ comparisons: Array<BenchmarkBaselineTaskComparison>;
108
+ /** Tasks that regressed (slower with statistical significance), sorted by effect size (largest first) */
109
+ regressions: Array<BenchmarkBaselineTaskComparison>;
110
+ /** Tasks that improved (faster with statistical significance), sorted by effect size (largest first) */
111
+ improvements: Array<BenchmarkBaselineTaskComparison>;
112
+ /** Tasks with no significant change */
113
+ unchanged: Array<BenchmarkBaselineTaskComparison>;
114
+ /** Tasks in current run but not in baseline */
115
+ new_tasks: Array<string>;
116
+ /** Tasks in baseline but not in current run */
117
+ removed_tasks: Array<string>;
118
+ }
119
+
120
+ /**
121
+ * Comparison result for a single task.
122
+ */
123
+ export interface BenchmarkBaselineTaskComparison {
124
+ name: string;
125
+ baseline: BenchmarkBaselineEntry;
126
+ current: BenchmarkBaselineEntry;
127
+ comparison: BenchmarkComparison;
128
+ }
129
+
130
+ const DEFAULT_BASELINE_PATH = '.gro/benchmarks';
131
+ const BASELINE_FILENAME = 'baseline.json';
132
+
133
+ /**
134
+ * Convert benchmark results to baseline entries.
135
+ */
136
+ const results_to_entries = (results: Array<BenchmarkResult>): Array<BenchmarkBaselineEntry> => {
137
+ return results.map((r) => ({
138
+ name: r.name,
139
+ mean_ns: r.stats.mean_ns,
140
+ median_ns: r.stats.median_ns,
141
+ std_dev_ns: r.stats.std_dev_ns,
142
+ min_ns: r.stats.min_ns,
143
+ max_ns: r.stats.max_ns,
144
+ p75_ns: r.stats.p75_ns,
145
+ p90_ns: r.stats.p90_ns,
146
+ p95_ns: r.stats.p95_ns,
147
+ p99_ns: r.stats.p99_ns,
148
+ ops_per_second: r.stats.ops_per_second,
149
+ sample_size: r.stats.sample_size,
150
+ }));
151
+ };
152
+
153
+ /**
154
+ * Save benchmark results as the current baseline.
155
+ *
156
+ * @param results - Benchmark results to save
157
+ * @param options - Save options
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * const bench = new Benchmark();
162
+ * bench.add('test', () => fn());
163
+ * await bench.run();
164
+ * await benchmark_baseline_save(bench.results());
165
+ * ```
166
+ */
167
+ export const benchmark_baseline_save = async (
168
+ results: Array<BenchmarkResult>,
169
+ options: BenchmarkBaselineSaveOptions = {},
170
+ ): Promise<void> => {
171
+ const base_path = options.path ?? DEFAULT_BASELINE_PATH;
172
+
173
+ // Get git info if not provided
174
+ let git_commit = options.git_commit;
175
+ let git_branch = options.git_branch;
176
+ if (git_commit === undefined || git_branch === undefined) {
177
+ const git_info = await git_info_get();
178
+ git_commit ??= git_info.commit;
179
+ git_branch ??= git_info.branch;
180
+ }
181
+
182
+ const baseline: BenchmarkBaseline = {
183
+ version: BASELINE_VERSION,
184
+ timestamp: new Date().toISOString(),
185
+ git_commit,
186
+ git_branch,
187
+ node_version: process.version,
188
+ entries: results_to_entries(results),
189
+ };
190
+
191
+ await mkdir(base_path, {recursive: true});
192
+ const filepath = join(base_path, BASELINE_FILENAME);
193
+ await writeFile(filepath, JSON.stringify(baseline, null, '\t'), 'utf-8');
194
+ };
195
+
196
+ /**
197
+ * Load the current baseline from disk.
198
+ *
199
+ * @param options - Load options
200
+ * @returns The baseline, or null if not found or invalid
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const baseline = await benchmark_baseline_load();
205
+ * if (baseline) {
206
+ * console.log(`Baseline from ${baseline.timestamp}`);
207
+ * }
208
+ * ```
209
+ */
210
+ export const benchmark_baseline_load = async (
211
+ options: BenchmarkBaselineLoadOptions = {},
212
+ ): Promise<BenchmarkBaseline | null> => {
213
+ const base_path = options.path ?? DEFAULT_BASELINE_PATH;
214
+ const filepath = join(base_path, BASELINE_FILENAME);
215
+
216
+ if (!(await fs_exists(filepath))) {
217
+ return null;
218
+ }
219
+
220
+ try {
221
+ const contents = await readFile(filepath, 'utf-8');
222
+ const parsed = JSON.parse(contents);
223
+ const baseline = BenchmarkBaseline.parse(parsed);
224
+
225
+ // Check version compatibility
226
+ if (baseline.version !== BASELINE_VERSION) {
227
+ // eslint-disable-next-line no-console
228
+ console.warn(
229
+ `Benchmark baseline version mismatch (got ${baseline.version}, expected ${BASELINE_VERSION}). Removing stale baseline: ${filepath}`,
230
+ );
231
+ await rm(filepath, {force: true});
232
+ return null;
233
+ }
234
+
235
+ return baseline;
236
+ } catch (err) {
237
+ // eslint-disable-next-line no-console
238
+ console.warn(
239
+ `Invalid or corrupted benchmark baseline file. Removing: ${filepath}`,
240
+ err instanceof Error ? err.message : err,
241
+ );
242
+ await rm(filepath, {force: true});
243
+ return null;
244
+ }
245
+ };
246
+
247
+ /**
248
+ * Compare benchmark results against the stored baseline.
249
+ *
250
+ * @param results - Current benchmark results
251
+ * @param options - Comparison options including regression threshold and staleness warning
252
+ * @returns Comparison result with regressions, improvements, and unchanged tasks
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * const bench = new Benchmark();
257
+ * bench.add('test', () => fn());
258
+ * await bench.run();
259
+ *
260
+ * const comparison = await benchmark_baseline_compare(bench.results(), {
261
+ * regression_threshold: 1.05, // Only flag regressions 5% or more slower
262
+ * staleness_warning_days: 7, // Warn if baseline is older than 7 days
263
+ * });
264
+ * if (comparison.regressions.length > 0) {
265
+ * console.log('Performance regressions detected!');
266
+ * for (const r of comparison.regressions) {
267
+ * console.log(` ${r.name}: ${r.comparison.speedup_ratio.toFixed(2)}x slower`);
268
+ * }
269
+ * process.exit(1);
270
+ * }
271
+ * ```
272
+ */
273
+ export const benchmark_baseline_compare = async (
274
+ results: Array<BenchmarkResult>,
275
+ options: BenchmarkBaselineCompareOptions = {},
276
+ ): Promise<BenchmarkBaselineComparisonResult> => {
277
+ const baseline = await benchmark_baseline_load(options);
278
+ const regression_threshold = options.regression_threshold ?? 1.0;
279
+
280
+ if (!baseline) {
281
+ return {
282
+ baseline_found: false,
283
+ baseline_timestamp: null,
284
+ baseline_commit: null,
285
+ baseline_age_days: null,
286
+ baseline_stale: false,
287
+ comparisons: [],
288
+ regressions: [],
289
+ improvements: [],
290
+ unchanged: [],
291
+ new_tasks: results.map((r) => r.name),
292
+ removed_tasks: [],
293
+ };
294
+ }
295
+
296
+ // Calculate baseline age
297
+ const baseline_date = new Date(baseline.timestamp);
298
+ const now = new Date();
299
+ const baseline_age_days = (now.getTime() - baseline_date.getTime()) / (1000 * 60 * 60 * 24);
300
+ const baseline_stale =
301
+ options.staleness_warning_days !== undefined &&
302
+ baseline_age_days > options.staleness_warning_days;
303
+
304
+ const current_entries = results_to_entries(results);
305
+ const baseline_map = new Map(baseline.entries.map((e) => [e.name, e]));
306
+ const current_map = new Map(current_entries.map((e) => [e.name, e]));
307
+
308
+ const comparisons: Array<BenchmarkBaselineTaskComparison> = [];
309
+ const regressions: Array<BenchmarkBaselineTaskComparison> = [];
310
+ const improvements: Array<BenchmarkBaselineTaskComparison> = [];
311
+ const unchanged: Array<BenchmarkBaselineTaskComparison> = [];
312
+ const new_tasks: Array<string> = [];
313
+ const removed_tasks: Array<string> = [];
314
+
315
+ // Compare tasks that exist in both
316
+ for (const current of current_entries) {
317
+ const baseline_entry = baseline_map.get(current.name);
318
+ if (!baseline_entry) {
319
+ new_tasks.push(current.name);
320
+ continue;
321
+ }
322
+
323
+ // Create minimal stats objects for comparison
324
+ const baseline_stats: BenchmarkStatsComparable = {
325
+ mean_ns: baseline_entry.mean_ns,
326
+ std_dev_ns: baseline_entry.std_dev_ns,
327
+ sample_size: baseline_entry.sample_size,
328
+ confidence_interval_ns: stats_confidence_interval_from_summary(
329
+ baseline_entry.mean_ns,
330
+ baseline_entry.std_dev_ns,
331
+ baseline_entry.sample_size,
332
+ ),
333
+ };
334
+ const current_stats: BenchmarkStatsComparable = {
335
+ mean_ns: current.mean_ns,
336
+ std_dev_ns: current.std_dev_ns,
337
+ sample_size: current.sample_size,
338
+ confidence_interval_ns: stats_confidence_interval_from_summary(
339
+ current.mean_ns,
340
+ current.std_dev_ns,
341
+ current.sample_size,
342
+ ),
343
+ };
344
+
345
+ const comparison = benchmark_stats_compare(baseline_stats, current_stats);
346
+
347
+ const task_comparison: BenchmarkBaselineTaskComparison = {
348
+ name: current.name,
349
+ baseline: baseline_entry,
350
+ current,
351
+ comparison,
352
+ };
353
+
354
+ comparisons.push(task_comparison);
355
+
356
+ // Categorize based on comparison result
357
+ // Note: comparison.faster is 'a' (baseline) or 'b' (current)
358
+ if (comparison.significant && comparison.effect_magnitude !== 'negligible') {
359
+ if (comparison.faster === 'a') {
360
+ // Baseline was faster = potential regression
361
+ // Only count as regression if it exceeds the threshold
362
+ if (comparison.speedup_ratio >= regression_threshold) {
363
+ regressions.push(task_comparison);
364
+ } else {
365
+ unchanged.push(task_comparison);
366
+ }
367
+ } else if (comparison.faster === 'b') {
368
+ // Current is faster = improvement
369
+ improvements.push(task_comparison);
370
+ } else {
371
+ unchanged.push(task_comparison);
372
+ }
373
+ } else {
374
+ unchanged.push(task_comparison);
375
+ }
376
+ }
377
+
378
+ // Find removed tasks
379
+ for (const baseline_entry of baseline.entries) {
380
+ if (!current_map.has(baseline_entry.name)) {
381
+ removed_tasks.push(baseline_entry.name);
382
+ }
383
+ }
384
+
385
+ // Sort regressions and improvements by effect size (largest first)
386
+ const sort_by_effect_size = (
387
+ a: BenchmarkBaselineTaskComparison,
388
+ b: BenchmarkBaselineTaskComparison,
389
+ ) => b.comparison.effect_size - a.comparison.effect_size;
390
+
391
+ regressions.sort(sort_by_effect_size);
392
+ improvements.sort(sort_by_effect_size);
393
+
394
+ return {
395
+ baseline_found: true,
396
+ baseline_timestamp: baseline.timestamp,
397
+ baseline_commit: baseline.git_commit,
398
+ baseline_age_days,
399
+ baseline_stale,
400
+ comparisons,
401
+ regressions,
402
+ improvements,
403
+ unchanged,
404
+ new_tasks,
405
+ removed_tasks,
406
+ };
407
+ };
408
+
409
+ /**
410
+ * Format a baseline comparison result as a human-readable string.
411
+ *
412
+ * @param result - Comparison result from benchmark_baseline_compare
413
+ * @returns Formatted string summary
414
+ */
415
+ export const benchmark_baseline_format = (result: BenchmarkBaselineComparisonResult): string => {
416
+ if (!result.baseline_found) {
417
+ return 'No baseline found. Call benchmark_baseline_save() to create one.';
418
+ }
419
+
420
+ const lines: Array<string> = [];
421
+
422
+ lines.push(`Comparing against baseline from ${result.baseline_timestamp}`);
423
+ if (result.baseline_commit) {
424
+ lines.push(`Baseline commit: ${result.baseline_commit.slice(0, 8)}`);
425
+ }
426
+ if (result.baseline_age_days !== null) {
427
+ const age_str =
428
+ result.baseline_age_days < 1
429
+ ? 'less than a day'
430
+ : result.baseline_age_days < 2
431
+ ? '1 day'
432
+ : `${Math.floor(result.baseline_age_days)} days`;
433
+ lines.push(`Baseline age: ${age_str}${result.baseline_stale ? ' (STALE)' : ''}`);
434
+ }
435
+ lines.push('');
436
+
437
+ if (result.regressions.length > 0) {
438
+ lines.push(`Regressions (${result.regressions.length}):`);
439
+ for (const r of result.regressions) {
440
+ const ratio = r.comparison.speedup_ratio.toFixed(2);
441
+ const p = r.comparison.p_value.toFixed(3);
442
+ lines.push(` ${r.name}: ${ratio}x slower (p=${p}, ${r.comparison.effect_magnitude})`);
443
+ }
444
+ lines.push('');
445
+ }
446
+
447
+ if (result.improvements.length > 0) {
448
+ lines.push(`Improvements (${result.improvements.length}):`);
449
+ for (const r of result.improvements) {
450
+ const ratio = r.comparison.speedup_ratio.toFixed(2);
451
+ const p = r.comparison.p_value.toFixed(3);
452
+ lines.push(` ${r.name}: ${ratio}x faster (p=${p}, ${r.comparison.effect_magnitude})`);
453
+ }
454
+ lines.push('');
455
+ }
456
+
457
+ if (result.unchanged.length > 0) {
458
+ lines.push(`Unchanged (${result.unchanged.length}):`);
459
+ for (const r of result.unchanged) {
460
+ lines.push(` ${r.name}`);
461
+ }
462
+ lines.push('');
463
+ }
464
+
465
+ if (result.new_tasks.length > 0) {
466
+ lines.push(`New tasks (${result.new_tasks.length}): ${result.new_tasks.join(', ')}`);
467
+ }
468
+
469
+ if (result.removed_tasks.length > 0) {
470
+ lines.push(
471
+ `Removed tasks (${result.removed_tasks.length}): ${result.removed_tasks.join(', ')}`,
472
+ );
473
+ }
474
+
475
+ // Summary line
476
+ const total = result.comparisons.length;
477
+ const summary_parts: Array<string> = [];
478
+ if (result.regressions.length > 0) summary_parts.push(`${result.regressions.length} regressions`);
479
+ if (result.improvements.length > 0)
480
+ summary_parts.push(`${result.improvements.length} improvements`);
481
+ if (result.unchanged.length > 0) summary_parts.push(`${result.unchanged.length} unchanged`);
482
+
483
+ lines.push('');
484
+ lines.push(`Summary: ${summary_parts.join(', ')} (${total} total)`);
485
+
486
+ return lines.join('\n');
487
+ };
488
+
489
+ /**
490
+ * Format a baseline comparison result as JSON for programmatic consumption.
491
+ *
492
+ * @param result - Comparison result from benchmark_baseline_compare
493
+ * @param options - Formatting options
494
+ * @returns JSON string
495
+ */
496
+ export const benchmark_baseline_format_json = (
497
+ result: BenchmarkBaselineComparisonResult,
498
+ options: {pretty?: boolean} = {},
499
+ ): string => {
500
+ const output = {
501
+ baseline_found: result.baseline_found,
502
+ baseline_timestamp: result.baseline_timestamp,
503
+ baseline_commit: result.baseline_commit,
504
+ baseline_age_days: result.baseline_age_days,
505
+ baseline_stale: result.baseline_stale,
506
+ summary: {
507
+ total: result.comparisons.length,
508
+ regressions: result.regressions.length,
509
+ improvements: result.improvements.length,
510
+ unchanged: result.unchanged.length,
511
+ new_tasks: result.new_tasks.length,
512
+ removed_tasks: result.removed_tasks.length,
513
+ },
514
+ regressions: result.regressions.map((r) => ({
515
+ name: r.name,
516
+ speedup_ratio: r.comparison.speedup_ratio,
517
+ effect_size: r.comparison.effect_size,
518
+ effect_magnitude: r.comparison.effect_magnitude,
519
+ p_value: r.comparison.p_value,
520
+ baseline_mean_ns: r.baseline.mean_ns,
521
+ current_mean_ns: r.current.mean_ns,
522
+ })),
523
+ improvements: result.improvements.map((r) => ({
524
+ name: r.name,
525
+ speedup_ratio: r.comparison.speedup_ratio,
526
+ effect_size: r.comparison.effect_size,
527
+ effect_magnitude: r.comparison.effect_magnitude,
528
+ p_value: r.comparison.p_value,
529
+ baseline_mean_ns: r.baseline.mean_ns,
530
+ current_mean_ns: r.current.mean_ns,
531
+ })),
532
+ unchanged: result.unchanged.map((r) => r.name),
533
+ new_tasks: result.new_tasks,
534
+ removed_tasks: result.removed_tasks,
535
+ };
536
+
537
+ return options.pretty ? JSON.stringify(output, null, '\t') : JSON.stringify(output);
538
+ };