@kb-labs/quality-entry 2.93.0 → 2.96.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 (98) hide show
  1. package/dist/cli/commands/build-order.d.ts +5 -12
  2. package/dist/cli/commands/build-order.js +45 -97
  3. package/dist/cli/commands/build-order.js.map +1 -1
  4. package/dist/cli/commands/check-layers.d.ts +9 -0
  5. package/dist/cli/commands/check-layers.js +48 -0
  6. package/dist/cli/commands/check-layers.js.map +1 -0
  7. package/dist/cli/commands/context.d.ts +9 -0
  8. package/dist/cli/commands/context.js +94 -0
  9. package/dist/cli/commands/context.js.map +1 -0
  10. package/dist/cli/commands/coupling.d.ts +9 -0
  11. package/dist/cli/commands/coupling.js +35 -0
  12. package/dist/cli/commands/coupling.js.map +1 -0
  13. package/dist/cli/commands/dead-code.d.ts +4 -5
  14. package/dist/cli/commands/dead-code.js +41 -197
  15. package/dist/cli/commands/dead-code.js.map +1 -1
  16. package/dist/cli/commands/fix-deps.d.ts +2 -5
  17. package/dist/cli/commands/fix-deps.js +74 -83
  18. package/dist/cli/commands/fix-deps.js.map +1 -1
  19. package/dist/cli/commands/flags.d.ts +115 -1
  20. package/dist/cli/commands/flags.js +46 -1
  21. package/dist/cli/commands/flags.js.map +1 -1
  22. package/dist/cli/commands/gate.d.ts +9 -0
  23. package/dist/cli/commands/gate.js +59 -0
  24. package/dist/cli/commands/gate.js.map +1 -0
  25. package/dist/cli/commands/health.d.ts +4 -5
  26. package/dist/cli/commands/health.js +42 -191
  27. package/dist/cli/commands/health.js.map +1 -1
  28. package/dist/cli/commands/history.d.ts +9 -0
  29. package/dist/cli/commands/history.js +55 -0
  30. package/dist/cli/commands/history.js.map +1 -0
  31. package/dist/cli/commands/index.d.ts +6 -2
  32. package/dist/cli/commands/index.js +411 -828
  33. package/dist/cli/commands/index.js.map +1 -1
  34. package/dist/cli/commands/snapshot.d.ts +9 -0
  35. package/dist/cli/commands/snapshot.js +91 -0
  36. package/dist/cli/commands/snapshot.js.map +1 -0
  37. package/dist/cli/commands/stats.d.ts +4 -5
  38. package/dist/cli/commands/stats.js +17 -265
  39. package/dist/cli/commands/stats.js.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +198 -306
  42. package/dist/index.js.map +1 -1
  43. package/dist/manifest.d.ts +95 -82
  44. package/dist/manifest.js +198 -306
  45. package/dist/manifest.js.map +1 -1
  46. package/dist/rest/handlers/build-order-handler.d.ts +5 -13
  47. package/dist/rest/handlers/build-order-handler.js +14 -17
  48. package/dist/rest/handlers/build-order-handler.js.map +1 -1
  49. package/dist/rest/handlers/builds-handler.js +10 -6
  50. package/dist/rest/handlers/builds-handler.js.map +1 -1
  51. package/dist/rest/handlers/coupling-handler.d.ts +8 -0
  52. package/dist/rest/handlers/coupling-handler.js +28 -0
  53. package/dist/rest/handlers/coupling-handler.js.map +1 -0
  54. package/dist/rest/handlers/cycles-handler.js +16 -12
  55. package/dist/rest/handlers/cycles-handler.js.map +1 -1
  56. package/dist/rest/handlers/dependencies-handler.js +12 -8
  57. package/dist/rest/handlers/dependencies-handler.js.map +1 -1
  58. package/dist/rest/handlers/graph-handler.js +77 -73
  59. package/dist/rest/handlers/graph-handler.js.map +1 -1
  60. package/dist/rest/handlers/health-handler.d.ts +4 -11
  61. package/dist/rest/handlers/health-handler.js +35 -9
  62. package/dist/rest/handlers/health-handler.js.map +1 -1
  63. package/dist/rest/handlers/history-handler.d.ts +7 -0
  64. package/dist/rest/handlers/history-handler.js +21 -0
  65. package/dist/rest/handlers/history-handler.js.map +1 -0
  66. package/dist/rest/handlers/knip-handler.d.ts +8 -0
  67. package/dist/rest/handlers/knip-handler.js +31 -0
  68. package/dist/rest/handlers/knip-handler.js.map +1 -0
  69. package/dist/rest/handlers/layers-handler.d.ts +8 -0
  70. package/dist/rest/handlers/layers-handler.js +28 -0
  71. package/dist/rest/handlers/layers-handler.js.map +1 -0
  72. package/dist/rest/handlers/snapshot-handler.d.ts +7 -0
  73. package/dist/rest/handlers/snapshot-handler.js +67 -0
  74. package/dist/rest/handlers/snapshot-handler.js.map +1 -0
  75. package/dist/rest/handlers/stale-handler.js +13 -9
  76. package/dist/rest/handlers/stale-handler.js.map +1 -1
  77. package/dist/rest/handlers/stats-handler.d.ts +4 -9
  78. package/dist/rest/handlers/stats-handler.js +22 -18
  79. package/dist/rest/handlers/stats-handler.js.map +1 -1
  80. package/dist/rest/handlers/tests-handler.js +12 -8
  81. package/dist/rest/handlers/tests-handler.js.map +1 -1
  82. package/dist/rest/handlers/types-handler.js +10 -6
  83. package/dist/rest/handlers/types-handler.js.map +1 -1
  84. package/dist/widgets/117.js +24 -1
  85. package/dist/widgets/117.js.map +1 -1
  86. package/dist/widgets/370.js +1 -1
  87. package/dist/widgets/370.js.map +1 -1
  88. package/dist/widgets/62.js +97 -0
  89. package/dist/widgets/62.js.map +1 -0
  90. package/dist/widgets/__federation_expose_QualityOverview.js +1 -1
  91. package/dist/widgets/__federation_expose_QualityOverview.js.map +1 -1
  92. package/dist/widgets/mf-manifest.json +27 -27
  93. package/dist/widgets/mf-stats.json +27 -27
  94. package/dist/widgets/remoteEntry.js +2 -2
  95. package/dist/widgets/remoteEntry.js.map +1 -1
  96. package/package.json +9 -8
  97. package/dist/widgets/418.js +0 -39
  98. package/dist/widgets/418.js.map +0 -1
package/dist/index.js CHANGED
@@ -42,6 +42,11 @@ var healthFlags = {
42
42
  description: "Show detailed breakdown",
43
43
  default: false,
44
44
  alias: "d"
45
+ },
46
+ refresh: {
47
+ type: "boolean",
48
+ description: "Bypass cache and recompute",
49
+ default: false
45
50
  }
46
51
  };
47
52
  var fixDepsFlags = {
@@ -223,6 +228,22 @@ var checkTestsFlags = {
223
228
  default: false
224
229
  }
225
230
  };
231
+ var checkLayersFlags = {
232
+ json: { type: "boolean", description: "Output JSON format", default: false },
233
+ package: { type: "string", description: "Filter violations by package name", alias: "p" }
234
+ };
235
+ var couplingFlags = {
236
+ json: { type: "boolean", description: "Output JSON format", default: false },
237
+ sort: { type: "string", description: "Sort by: instability | coupled", default: "instability" },
238
+ top: { type: "number", description: "Show top N packages", default: 10 }
239
+ };
240
+ var snapshotFlags = {
241
+ json: { type: "boolean", description: "Output JSON format", default: false }
242
+ };
243
+ var historyFlags = {
244
+ json: { type: "boolean", description: "Output JSON format", default: false },
245
+ limit: { type: "number", description: "Number of entries to show", default: 10 }
246
+ };
226
247
  var deadCodeFlags = {
227
248
  package: {
228
249
  type: "string",
@@ -265,375 +286,246 @@ var deadCodeFlags = {
265
286
  default: false
266
287
  }
267
288
  };
289
+ var contextFlags = {
290
+ package: {
291
+ type: "string",
292
+ description: "Package name to get context for",
293
+ alias: "p"
294
+ },
295
+ json: {
296
+ type: "boolean",
297
+ description: "Output JSON format",
298
+ default: false
299
+ }
300
+ };
301
+ var gateFlags = {
302
+ json: {
303
+ type: "boolean",
304
+ description: "Output JSON format",
305
+ default: false
306
+ },
307
+ strict: {
308
+ type: "boolean",
309
+ description: "Fail even on pre-existing violations (not just new ones)",
310
+ default: false
311
+ }
312
+ };
268
313
 
269
314
  // src/manifest.ts
270
- var pluginPermissions = combinePermissions().with(kbPlatformPreset).withFs({
271
- mode: "readWrite",
272
- allow: ["**"]
273
- // Access to entire monorepo
274
- }).withPlatform({
275
- cache: ["quality:"],
276
- // Cache namespace prefix
277
- analytics: true
278
- // Track command usage
279
- }).withQuotas({
280
- timeoutMs: 3e5,
281
- // 5 minutes for long-running operations
282
- memoryMb: 1024
283
- // 1GB memory
284
- }).build();
285
- var heavyOperationsPermissions = combinePermissions().with(kbPlatformPreset).withFs({
286
- mode: "readWrite",
287
- allow: ["**"]
288
- }).withPlatform({
289
- cache: ["quality:"],
290
- analytics: true
291
- }).withQuotas({
292
- timeoutMs: 6e5,
293
- // 10 minutes for heavy operations
294
- memoryMb: 2048
295
- // 2GB memory
296
- }).build();
315
+ var pluginPermissions = combinePermissions().with(kbPlatformPreset).withFs({ mode: "readWrite", allow: ["**"] }).withShell({ allow: ["pnpm", "git"] }).withPlatform({ cache: ["quality:"], analytics: true }).withQuotas({ timeoutMs: 3e5, memoryMb: 1024 }).build();
316
+ var heavyPermissions = combinePermissions().with(kbPlatformPreset).withFs({ mode: "readWrite", allow: ["**"] }).withShell({ allow: ["pnpm", "git"] }).withPlatform({ cache: ["quality:"], analytics: true }).withQuotas({ timeoutMs: 6e5, memoryMb: 2048 }).build();
297
317
  var manifest = {
298
318
  schema: "kb.plugin/3",
299
319
  id: "@kb-labs/quality",
300
320
  version: "0.1.0",
321
+ configSection: "quality",
301
322
  display: {
302
- name: "Quality Tools",
303
- description: "Monorepo quality analysis and automated fixes",
304
- tags: ["quality", "monorepo", "analysis", "devtools"]
323
+ name: "Quality",
324
+ description: "Code quality, architecture analysis, and trend tracking",
325
+ tags: ["quality", "architecture", "coupling", "monorepo"]
305
326
  },
306
327
  platform: {
307
328
  requires: ["storage", "cache"],
308
329
  optional: ["analytics", "logger"]
309
330
  },
310
331
  cli: {
332
+ groupMeta: [
333
+ { path: "quality", describe: "Code quality, architecture analysis, and trend tracking." },
334
+ { path: "quality check", describe: "Static analysis checks (layers, types, builds, tests)" },
335
+ { path: "quality fix", describe: "Auto-fix quality issues" }
336
+ ],
311
337
  commands: [
312
- // ======================================================================
313
- // quality:stats - Monorepo statistics and health score
314
- // ======================================================================
338
+ // ── Overview ────────────────────────────────────────────────────────────
315
339
  {
316
- id: "stats",
317
- group: "quality",
318
- describe: "Get monorepo statistics and health score",
319
- longDescription: "Analyzes monorepo structure, collects package statistics, dependency info, and calculates health score. Results are cached for 5 minutes.",
340
+ path: "quality stats",
341
+ category: "Overview",
342
+ operationType: "read",
343
+ describe: "Monorepo statistics",
320
344
  handler: "./cli/commands/stats.js#default",
321
- handlerPath: "./cli/commands/stats.js",
322
345
  flags: defineCommandFlags(statsFlags),
323
- examples: [
324
- "kb quality:stats",
325
- "kb quality:stats --health",
326
- "kb quality:stats --json",
327
- "kb quality:stats --md"
328
- ],
346
+ examples: ["kb quality stats", "kb quality stats --json"],
329
347
  permissions: pluginPermissions
330
348
  },
331
- // ======================================================================
332
- // quality:health - Monorepo health check
333
- // ======================================================================
334
349
  {
335
- id: "health",
336
- group: "quality",
337
- describe: "Check monorepo health score",
338
- longDescription: "Analyzes monorepo health including dependency issues, structure problems, and build health. Returns health score (0-100) with grade (A-F) and actionable recommendations.",
350
+ path: "quality health",
351
+ category: "Overview",
352
+ operationType: "analyze",
353
+ describe: "Multidimensional health score (architecture, TypeScript, dead code, deps)",
339
354
  handler: "./cli/commands/health.js#default",
340
- handlerPath: "./cli/commands/health.js",
341
355
  flags: defineCommandFlags(healthFlags),
342
- examples: [
343
- "kb quality:health",
344
- "kb quality:health --detailed",
345
- "kb quality:health --package @kb-labs/core",
346
- "kb quality:health --json"
347
- ],
356
+ examples: ["kb quality health", "kb quality health --json", "kb quality health --detailed"],
348
357
  permissions: pluginPermissions
349
358
  },
350
- // ======================================================================
351
- // quality:fix-deps - Dependency auto-fixer
352
- // ======================================================================
353
359
  {
354
- id: "fix-deps",
355
- group: "quality",
356
- describe: "Auto-fix dependency issues",
357
- longDescription: "Automatically fixes dependency issues including removing unused deps, adding missing workspace deps, and aligning duplicate versions. Supports --dry-run for previewing changes.",
358
- handler: "./cli/commands/fix-deps.js#default",
359
- handlerPath: "./cli/commands/fix-deps.js",
360
- flags: defineCommandFlags(fixDepsFlags),
361
- examples: [
362
- "kb quality:fix-deps --stats",
363
- "kb quality:fix-deps --remove-unused --dry-run",
364
- "kb quality:fix-deps --align-versions",
365
- "kb quality:fix-deps --all --dry-run"
366
- ],
360
+ path: "quality snapshot",
361
+ category: "Overview",
362
+ operationType: "mutate",
363
+ describe: "Collect all metrics and save a snapshot for trend tracking",
364
+ handler: "./cli/commands/snapshot.js#default",
365
+ flags: defineCommandFlags(snapshotFlags),
366
+ examples: ["kb quality snapshot", "kb quality snapshot --json"],
367
367
  permissions: pluginPermissions
368
368
  },
369
- // ======================================================================
370
- // quality:build-order - Calculate build order with topological sort
371
- // ======================================================================
372
369
  {
373
- id: "build-order",
374
- group: "quality",
375
- describe: "Calculate build order using topological sort",
376
- longDescription: "Analyzes package dependencies and calculates correct build order using topological sort. Shows build layers where each layer can be built in parallel. Detects circular dependencies.",
377
- handler: "./cli/commands/build-order.js#default",
378
- handlerPath: "./cli/commands/build-order.js",
379
- flags: defineCommandFlags(buildOrderFlags),
380
- examples: [
381
- "kb quality:build-order",
382
- "kb quality:build-order --layers",
383
- "kb quality:build-order --package @kb-labs/core",
384
- "kb quality:build-order --script > build.sh"
385
- ],
370
+ path: "quality history",
371
+ category: "Overview",
372
+ operationType: "read",
373
+ describe: "Show quality snapshot history and delta trends",
374
+ handler: "./cli/commands/history.js#default",
375
+ flags: defineCommandFlags(historyFlags),
376
+ examples: ["kb quality history", "kb quality history --json", "kb quality history --limit 20"],
386
377
  permissions: pluginPermissions
387
378
  },
388
- // ======================================================================
389
- // quality:cycles - Detect circular dependencies
390
- // ======================================================================
379
+ // ── Agent ────────────────────────────────────────────────────────────────
391
380
  {
392
- id: "cycles",
393
- group: "quality",
394
- describe: "Detect circular dependencies",
395
- longDescription: "Uses DFS to find all circular dependency chains in the monorepo. Shows complete dependency cycles with recommendations for breaking them.",
396
- handler: "./cli/commands/cycles.js#default",
397
- handlerPath: "./cli/commands/cycles.js",
398
- flags: defineCommandFlags(cyclesFlags),
381
+ path: "quality context",
382
+ category: "Agent",
383
+ operationType: "read",
384
+ describe: "Package context for agents: layer, dependents, dependencies (fast, stateless)",
385
+ handler: "./cli/commands/context.js#default",
386
+ flags: defineCommandFlags(contextFlags),
399
387
  examples: [
400
- "kb quality:cycles",
401
- "kb quality:cycles --json"
388
+ "kb quality context --package @kb-labs/sdk",
389
+ "kb quality context --package @kb-labs/sdk --json",
390
+ "kb quality context --json"
402
391
  ],
403
392
  permissions: pluginPermissions
404
393
  },
405
- // ======================================================================
406
- // quality:visualize - Visualize dependency graph
407
- // ======================================================================
408
394
  {
409
- id: "visualize",
410
- group: "quality",
411
- describe: "Visualize dependency graph",
412
- longDescription: "Visualize monorepo dependency graph in various formats: tree view, DOT format for graphviz, reverse dependencies (who depends on this), impact analysis (what will be affected by changes), and comprehensive graph statistics.",
413
- handler: "./cli/commands/visualize.js#default",
414
- handlerPath: "./cli/commands/visualize.js",
415
- flags: defineCommandFlags(visualizeFlags),
395
+ path: "quality gate",
396
+ category: "Agent",
397
+ operationType: "analyze",
398
+ describe: "Architecture gate: fail if new layering violations introduced",
399
+ handler: "./cli/commands/gate.js#default",
400
+ flags: defineCommandFlags(gateFlags),
416
401
  examples: [
417
- "kb quality:visualize --stats",
418
- "kb quality:visualize --tree --package @kb-labs/core",
419
- "kb quality:visualize --reverse --package @kb-labs/sdk",
420
- "kb quality:visualize --impact --package @kb-labs/core",
421
- "kb quality:visualize --dot > deps.dot"
402
+ "kb quality gate",
403
+ "kb quality gate --json",
404
+ "kb quality gate --strict"
422
405
  ],
423
406
  permissions: pluginPermissions
424
407
  },
425
- // ======================================================================
426
- // quality:check-builds - Check build status across monorepo
427
- // ======================================================================
428
- {
429
- id: "check-builds",
430
- group: "quality",
431
- describe: "Check build status across monorepo",
432
- longDescription: "Analyzes build status across all packages with build scripts. Detects build failures with error messages and stale builds (dist/ older than src/). Results are cached for 10 minutes.",
433
- handler: "./cli/commands/check-builds.js#default",
434
- handlerPath: "./cli/commands/check-builds.js",
435
- flags: defineCommandFlags(checkBuildsFlags),
436
- examples: [
437
- "kb quality:check-builds",
438
- "kb quality:check-builds --package @kb-labs/core",
439
- "kb quality:check-builds --timeout 60000",
440
- "kb quality:check-builds --json",
441
- "kb quality:check-builds --refresh"
442
- ],
443
- permissions: heavyOperationsPermissions
444
- },
445
- // ======================================================================
446
- // quality:check-types - TypeScript type safety analysis
447
- // ======================================================================
408
+ // ── Architecture ─────────────────────────────────────────────────────────
448
409
  {
449
- id: "check-types",
450
- group: "quality",
451
- describe: "Analyze TypeScript type safety across monorepo",
452
- longDescription: "Analyzes TypeScript type errors, warnings, and type coverage using TypeScript Compiler API. Detects any usage, @ts-ignore comments, and calculates type coverage percentage. Results are cached for 10 minutes.",
453
- handler: "./cli/commands/check-types.js#default",
454
- handlerPath: "./cli/commands/check-types.js",
455
- flags: defineCommandFlags(checkTypesFlags),
456
- examples: [
457
- "kb quality:check-types",
458
- "kb quality:check-types --package @kb-labs/core",
459
- "kb quality:check-types --errors-only",
460
- "kb quality:check-types --json",
461
- "kb quality:check-types --refresh"
462
- ],
463
- permissions: heavyOperationsPermissions
464
- },
465
- // ======================================================================
466
- // quality:check-tests - Test execution and coverage tracking
467
- // ======================================================================
468
- {
469
- id: "check-tests",
470
- group: "quality",
471
- describe: "Run tests and track coverage across monorepo",
472
- longDescription: "Runs tests across all packages with test scripts and collects coverage statistics. Parses test output (vitest/jest) to extract test counts and reads coverage-summary.json. Results are cached for 5 minutes.",
473
- handler: "./cli/commands/check-tests.js#default",
474
- handlerPath: "./cli/commands/check-tests.js",
475
- flags: defineCommandFlags(checkTestsFlags),
476
- examples: [
477
- "kb quality:check-tests",
478
- "kb quality:check-tests --package @kb-labs/core",
479
- "kb quality:check-tests --with-coverage",
480
- "kb quality:check-tests --coverage-only",
481
- "kb quality:check-tests --timeout 120000",
482
- "kb quality:check-tests --json"
483
- ],
484
- permissions: heavyOperationsPermissions
485
- },
486
- // ======================================================================
487
- // quality:dead-code - Dead code file detection
488
- // ======================================================================
489
- {
490
- id: "dead-code",
491
- group: "quality",
492
- describe: "Detect dead (unreachable) source files",
493
- longDescription: "Analyzes import graph to find source files not reachable from any entry point (package.json, tsup.config.ts, manifest.ts). Supports automated removal with backup and restore capabilities. Zero false positives by design.",
494
- handler: "./cli/commands/dead-code.js#default",
495
- handlerPath: "./cli/commands/dead-code.js",
496
- flags: defineCommandFlags(deadCodeFlags),
497
- examples: [
498
- "kb quality:dead-code",
499
- "kb quality:dead-code --package @kb-labs/core",
500
- "kb quality:dead-code --auto-remove --dry-run",
501
- "kb quality:dead-code --auto-remove",
502
- "kb quality:dead-code --list-backups",
503
- "kb quality:dead-code --restore 2026-02-15T10-30-00",
504
- "kb quality:dead-code --json"
505
- ],
410
+ path: "quality check layers",
411
+ category: "Architecture",
412
+ operationType: "analyze",
413
+ describe: "Detect layering violations (lower layer importing higher layer)",
414
+ handler: "./cli/commands/check-layers.js#default",
415
+ flags: defineCommandFlags(checkLayersFlags),
416
+ examples: ["kb quality check layers", "kb quality check layers --json", "kb quality check layers --package @kb-labs/plugins-qa"],
506
417
  permissions: pluginPermissions
507
- }
508
- ]
509
- },
510
- // REST API routes
511
- rest: {
512
- basePath: QUALITY_BASE_PATH,
513
- routes: [
514
- // GET /stats
515
- {
516
- method: "GET",
517
- path: QUALITY_ROUTES.STATS,
518
- handler: "./rest/handlers/stats-handler.js#default",
519
- input: {
520
- zod: "@kb-labs/quality-contracts#StatsRequestSchema"
521
- },
522
- output: {
523
- zod: "@kb-labs/quality-contracts#StatsResponseSchema"
524
- }
525
418
  },
526
- // GET /health
527
419
  {
528
- method: "GET",
529
- path: QUALITY_ROUTES.HEALTH,
530
- handler: "./rest/handlers/health-handler.js#default",
531
- input: {
532
- zod: "@kb-labs/quality-contracts#HealthRequestSchema"
533
- },
534
- output: {
535
- zod: "@kb-labs/quality-contracts#HealthResponseSchema"
536
- }
420
+ path: "quality coupling",
421
+ category: "Architecture",
422
+ operationType: "analyze",
423
+ describe: "Show coupling metrics per package (Ca/Ce/instability)",
424
+ handler: "./cli/commands/coupling.js#default",
425
+ flags: defineCommandFlags(couplingFlags),
426
+ examples: ["kb quality coupling", "kb quality coupling --json", "kb quality coupling --sort coupled --top 20"],
427
+ permissions: pluginPermissions
537
428
  },
538
- // GET /dependencies
539
429
  {
540
- method: "GET",
541
- path: QUALITY_ROUTES.DEPENDENCIES,
542
- handler: "./rest/handlers/dependencies-handler.js#default",
543
- input: {
544
- zod: "@kb-labs/quality-contracts#DependenciesRequestSchema"
545
- },
546
- output: {
547
- zod: "@kb-labs/quality-contracts#DependenciesResponseSchema"
548
- }
430
+ path: "quality build order",
431
+ category: "Architecture",
432
+ operationType: "analyze",
433
+ describe: "Topological build order",
434
+ handler: "./cli/commands/build-order.js#default",
435
+ flags: defineCommandFlags(buildOrderFlags),
436
+ examples: ["kb quality build order", "kb quality build order --json"],
437
+ permissions: pluginPermissions
549
438
  },
550
- // GET /build-order
551
439
  {
552
- method: "GET",
553
- path: QUALITY_ROUTES.BUILD_ORDER,
554
- handler: "./rest/handlers/build-order-handler.js#default",
555
- input: {
556
- zod: "@kb-labs/quality-contracts#BuildOrderRequestSchema"
557
- },
558
- output: {
559
- zod: "@kb-labs/quality-contracts#BuildOrderResponseSchema"
560
- }
440
+ path: "quality cycles",
441
+ category: "Architecture",
442
+ operationType: "analyze",
443
+ describe: "Detect circular dependencies",
444
+ handler: "./cli/commands/cycles.js#default",
445
+ flags: defineCommandFlags(cyclesFlags),
446
+ examples: ["kb quality cycles", "kb quality cycles --json"],
447
+ permissions: pluginPermissions
561
448
  },
562
- // GET /cycles
449
+ // ── Checks ───────────────────────────────────────────────────────────────
563
450
  {
564
- method: "GET",
565
- path: QUALITY_ROUTES.CYCLES,
566
- handler: "./rest/handlers/cycles-handler.js#default",
567
- input: {
568
- zod: "@kb-labs/quality-contracts#CyclesRequestSchema"
569
- },
570
- output: {
571
- zod: "@kb-labs/quality-contracts#CyclesResponseSchema"
572
- }
451
+ path: "quality dead code",
452
+ category: "Checks",
453
+ operationType: "analyze",
454
+ describe: "Detect unused files, exports, and deps via knip",
455
+ handler: "./cli/commands/dead-code.js#default",
456
+ flags: defineCommandFlags(deadCodeFlags),
457
+ examples: ["kb quality dead code", "kb quality dead code --json"],
458
+ permissions: pluginPermissions
573
459
  },
574
- // GET /graph
575
460
  {
576
- method: "GET",
577
- path: QUALITY_ROUTES.GRAPH,
578
- handler: "./rest/handlers/graph-handler.js#default",
579
- input: {
580
- zod: "@kb-labs/quality-contracts#GraphRequestSchema"
581
- },
582
- output: {
583
- zod: "@kb-labs/quality-contracts#GraphResponseSchema"
584
- }
461
+ path: "quality check types",
462
+ category: "Checks",
463
+ operationType: "analyze",
464
+ describe: "TypeScript type safety analysis (any count, ts-ignore, errors)",
465
+ handler: "./cli/commands/check-types.js#default",
466
+ flags: defineCommandFlags(checkTypesFlags),
467
+ examples: ["kb quality check types", "kb quality check types --json"],
468
+ permissions: heavyPermissions
585
469
  },
586
- // GET /stale
587
470
  {
588
- method: "GET",
589
- path: QUALITY_ROUTES.STALE,
590
- handler: "./rest/handlers/stale-handler.js#default",
591
- input: {
592
- zod: "@kb-labs/quality-contracts#StaleRequestSchema"
593
- },
594
- output: {
595
- zod: "@kb-labs/quality-contracts#StaleResponseSchema"
596
- }
471
+ path: "quality check builds",
472
+ category: "Checks",
473
+ operationType: "analyze",
474
+ describe: "Build status across monorepo",
475
+ handler: "./cli/commands/check-builds.js#default",
476
+ flags: defineCommandFlags(checkBuildsFlags),
477
+ examples: ["kb quality check builds", "kb quality check builds --json"],
478
+ permissions: heavyPermissions
597
479
  },
598
- // GET /builds
599
480
  {
600
- method: "GET",
601
- path: QUALITY_ROUTES.BUILDS,
602
- handler: "./rest/handlers/builds-handler.js#default",
603
- input: {
604
- zod: "@kb-labs/quality-contracts#BuildsRequestSchema"
605
- },
606
- output: {
607
- zod: "@kb-labs/quality-contracts#BuildsResponseSchema"
608
- }
481
+ path: "quality check tests",
482
+ category: "Checks",
483
+ operationType: "execute",
484
+ describe: "Run tests and track coverage",
485
+ handler: "./cli/commands/check-tests.js#default",
486
+ flags: defineCommandFlags(checkTestsFlags),
487
+ examples: ["kb quality check tests", "kb quality check tests --with-coverage"],
488
+ permissions: heavyPermissions
609
489
  },
610
- // GET /types
611
490
  {
612
- method: "GET",
613
- path: QUALITY_ROUTES.TYPES,
614
- handler: "./rest/handlers/types-handler.js#default",
615
- input: {
616
- zod: "@kb-labs/quality-contracts#TypesRequestSchema"
617
- },
618
- output: {
619
- zod: "@kb-labs/quality-contracts#TypesResponseSchema"
620
- }
491
+ path: "quality fix deps",
492
+ category: "Fixes",
493
+ operationType: "mutate",
494
+ describe: "Auto-fix dependency issues",
495
+ handler: "./cli/commands/fix-deps.js#default",
496
+ flags: defineCommandFlags(fixDepsFlags),
497
+ examples: ["kb quality fix deps --dry-run", "kb quality fix deps --all"],
498
+ permissions: pluginPermissions
621
499
  },
622
- // GET /tests
623
500
  {
624
- method: "GET",
625
- path: QUALITY_ROUTES.TESTS,
626
- handler: "./rest/handlers/tests-handler.js#default",
627
- input: {
628
- zod: "@kb-labs/quality-contracts#TestsRequestSchema"
629
- },
630
- output: {
631
- zod: "@kb-labs/quality-contracts#TestsResponseSchema"
632
- }
501
+ path: "quality visualize",
502
+ category: "Fixes",
503
+ operationType: "analyze",
504
+ describe: "Visualize dependency graph",
505
+ handler: "./cli/commands/visualize.js#default",
506
+ flags: defineCommandFlags(visualizeFlags),
507
+ examples: ["kb quality visualize --tree", "kb quality visualize --dot"],
508
+ permissions: pluginPermissions
633
509
  }
634
510
  ]
635
511
  },
636
- // Studio V2 — Module Federation pages
512
+ rest: {
513
+ basePath: QUALITY_BASE_PATH,
514
+ routes: [
515
+ { method: "GET", path: QUALITY_ROUTES.STATS, handler: "./rest/handlers/stats-handler.js#default", timeoutMs: 12e4 },
516
+ { method: "GET", path: QUALITY_ROUTES.HEALTH, handler: "./rest/handlers/health-handler.js#default" },
517
+ { method: "GET", path: QUALITY_ROUTES.LAYERS, handler: "./rest/handlers/layers-handler.js#default" },
518
+ { method: "GET", path: QUALITY_ROUTES.COUPLING, handler: "./rest/handlers/coupling-handler.js#default" },
519
+ { method: "GET", path: QUALITY_ROUTES.DEAD_CODE, handler: "./rest/handlers/knip-handler.js#default" },
520
+ { method: "GET", path: QUALITY_ROUTES.HISTORY, handler: "./rest/handlers/history-handler.js#default" },
521
+ { method: "POST", path: QUALITY_ROUTES.SNAPSHOT, handler: "./rest/handlers/snapshot-handler.js#default" },
522
+ { method: "GET", path: QUALITY_ROUTES.DEPENDENCIES, handler: "./rest/handlers/dependencies-handler.js#default" },
523
+ { method: "GET", path: QUALITY_ROUTES.BUILD_ORDER, handler: "./rest/handlers/build-order-handler.js#default" },
524
+ { method: "GET", path: QUALITY_ROUTES.CYCLES, handler: "./rest/handlers/cycles-handler.js#default" },
525
+ { method: "GET", path: QUALITY_ROUTES.GRAPH, handler: "./rest/handlers/graph-handler.js#default" },
526
+ { method: "GET", path: QUALITY_ROUTES.STALE, handler: "./rest/handlers/stale-handler.js#default" }
527
+ ]
528
+ },
637
529
  studio: {
638
530
  version: 2,
639
531
  remoteName: "qualityPlugin",