flowlint 0.1.3 → 0.3.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 (99) hide show
  1. package/dist/{apps/cli/src/cli.d.ts → cli.d.ts} +0 -0
  2. package/dist/{apps/cli/src/cli.js → cli.js} +0 -0
  3. package/dist/{apps/cli/src/cli.js.map → cli.js.map} +0 -0
  4. package/dist/{apps/cli/src/commands → commands}/init.d.ts +0 -0
  5. package/dist/{apps/cli/src/commands → commands}/init.js +0 -0
  6. package/dist/{apps/cli/src/commands → commands}/init.js.map +0 -0
  7. package/dist/{apps/cli/src/commands → commands}/scan.d.ts +0 -0
  8. package/dist/{apps/cli/src/commands → commands}/scan.js +0 -0
  9. package/dist/{apps/cli/src/commands → commands}/scan.js.map +0 -0
  10. package/dist/{apps/cli/src/providers → providers}/local-config-provider.d.ts +0 -0
  11. package/dist/{apps/cli/src/providers → providers}/local-config-provider.js +0 -0
  12. package/dist/{apps/cli/src/providers → providers}/local-config-provider.js.map +0 -0
  13. package/dist/{apps/cli/src/providers → providers}/local-file-source.d.ts +0 -0
  14. package/dist/{apps/cli/src/providers → providers}/local-file-source.js +0 -0
  15. package/dist/{apps/cli/src/providers → providers}/local-file-source.js.map +0 -0
  16. package/dist/{apps/cli/src/reporters → reporters}/console-reporter.d.ts +0 -0
  17. package/dist/{apps/cli/src/reporters → reporters}/console-reporter.js +3 -0
  18. package/dist/{apps/cli/src/reporters → reporters}/console-reporter.js.map +1 -1
  19. package/dist/{apps/cli/src/reporters → reporters}/json-reporter.d.ts +0 -0
  20. package/dist/{apps/cli/src/reporters → reporters}/json-reporter.js +0 -0
  21. package/dist/{apps/cli/src/reporters → reporters}/json-reporter.js.map +0 -0
  22. package/package.json +26 -32
  23. package/README.md +0 -45
  24. package/dist/packages/config/flowlint-config.d.ts +0 -64
  25. package/dist/packages/config/flowlint-config.js +0 -103
  26. package/dist/packages/config/flowlint-config.js.map +0 -1
  27. package/dist/packages/config/index.d.ts +0 -4
  28. package/dist/packages/config/index.js +0 -21
  29. package/dist/packages/config/index.js.map +0 -1
  30. package/dist/packages/github/client.d.ts +0 -2
  31. package/dist/packages/github/client.js +0 -94
  32. package/dist/packages/github/client.js.map +0 -1
  33. package/dist/packages/logger/index.d.ts +0 -11
  34. package/dist/packages/logger/index.js +0 -40
  35. package/dist/packages/logger/index.js.map +0 -1
  36. package/dist/packages/observability/collectors.d.ts +0 -40
  37. package/dist/packages/observability/collectors.js +0 -75
  38. package/dist/packages/observability/collectors.js.map +0 -1
  39. package/dist/packages/observability/index.d.ts +0 -10
  40. package/dist/packages/observability/index.js +0 -35
  41. package/dist/packages/observability/index.js.map +0 -1
  42. package/dist/packages/observability/metrics.d.ts +0 -119
  43. package/dist/packages/observability/metrics.js +0 -194
  44. package/dist/packages/observability/metrics.js.map +0 -1
  45. package/dist/packages/observability/middleware.d.ts +0 -32
  46. package/dist/packages/observability/middleware.js +0 -58
  47. package/dist/packages/observability/middleware.js.map +0 -1
  48. package/dist/packages/review/analysis-engine.d.ts +0 -19
  49. package/dist/packages/review/analysis-engine.js +0 -106
  50. package/dist/packages/review/analysis-engine.js.map +0 -1
  51. package/dist/packages/review/index.d.ts +0 -12
  52. package/dist/packages/review/index.js +0 -29
  53. package/dist/packages/review/index.js.map +0 -1
  54. package/dist/packages/review/parser-n8n.d.ts +0 -2
  55. package/dist/packages/review/parser-n8n.js +0 -118
  56. package/dist/packages/review/parser-n8n.js.map +0 -1
  57. package/dist/packages/review/providers/github.d.ts +0 -62
  58. package/dist/packages/review/providers/github.js +0 -275
  59. package/dist/packages/review/providers/github.js.map +0 -1
  60. package/dist/packages/review/providers.d.ts +0 -106
  61. package/dist/packages/review/providers.js +0 -12
  62. package/dist/packages/review/providers.js.map +0 -1
  63. package/dist/packages/review/reporter.d.ts +0 -17
  64. package/dist/packages/review/reporter.js +0 -53
  65. package/dist/packages/review/reporter.js.map +0 -1
  66. package/dist/packages/review/rules/index.d.ts +0 -9
  67. package/dist/packages/review/rules/index.js +0 -313
  68. package/dist/packages/review/rules/index.js.map +0 -1
  69. package/dist/packages/review/rules/rule-utils.d.ts +0 -36
  70. package/dist/packages/review/rules/rule-utils.js +0 -75
  71. package/dist/packages/review/rules/rule-utils.js.map +0 -1
  72. package/dist/packages/review/schemas/index.d.ts +0 -17
  73. package/dist/packages/review/schemas/index.js +0 -139
  74. package/dist/packages/review/schemas/index.js.map +0 -1
  75. package/dist/packages/review/schemas/n8n-workflow.schema.json +0 -177
  76. package/dist/packages/review/sniffer.d.ts +0 -15
  77. package/dist/packages/review/sniffer.js +0 -47
  78. package/dist/packages/review/sniffer.js.map +0 -1
  79. package/dist/packages/review/types.d.ts +0 -37
  80. package/dist/packages/review/types.js +0 -3
  81. package/dist/packages/review/types.js.map +0 -1
  82. package/dist/packages/review/utils/findings.d.ts +0 -23
  83. package/dist/packages/review/utils/findings.js +0 -34
  84. package/dist/packages/review/utils/findings.js.map +0 -1
  85. package/dist/packages/review/utils/merge.d.ts +0 -12
  86. package/dist/packages/review/utils/merge.js +0 -40
  87. package/dist/packages/review/utils/merge.js.map +0 -1
  88. package/dist/packages/review/utils.d.ts +0 -58
  89. package/dist/packages/review/utils.js +0 -208
  90. package/dist/packages/review/utils.js.map +0 -1
  91. package/dist/packages/tracing/github-tracer.d.ts +0 -38
  92. package/dist/packages/tracing/github-tracer.js +0 -79
  93. package/dist/packages/tracing/github-tracer.js.map +0 -1
  94. package/dist/packages/tracing/index.d.ts +0 -81
  95. package/dist/packages/tracing/index.js +0 -240
  96. package/dist/packages/tracing/index.js.map +0 -1
  97. package/dist/packages/tracing/tracer.d.ts +0 -30
  98. package/dist/packages/tracing/tracer.js +0 -141
  99. package/dist/packages/tracing/tracer.js.map +0 -1
@@ -1,75 +0,0 @@
1
- "use strict";
2
- /**
3
- * Metric Collectors for FlowLint
4
- *
5
- * This module implements periodic metric collectors that query external systems
6
- * (e.g., BullMQ queue) and update gauge metrics.
7
- *
8
- * @module packages/observability/collectors
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.startQueueMetricsCollector = startQueueMetricsCollector;
12
- exports.stopQueueMetricsCollector = stopQueueMetricsCollector;
13
- const metrics_1 = require("./metrics");
14
- const logger_1 = require("../logger");
15
- const logger = (0, logger_1.createChildLogger)({ component: 'observability:collectors' });
16
- /**
17
- * Queue Metrics Collector
18
- *
19
- * Periodically queries BullMQ queue for depth by state and updates Prometheus gauges.
20
- * Runs every 10 seconds to provide near-real-time queue visibility.
21
- *
22
- * @param queue - BullMQ queue instance
23
- * @returns Interval timer (for cleanup)
24
- *
25
- * @example
26
- * import { Queue } from 'bullmq';
27
- * import { startQueueMetricsCollector } from './packages/observability/collectors';
28
- *
29
- * const queue = new Queue('pr-review', { connection: redis });
30
- * const collectorInterval = startQueueMetricsCollector(queue);
31
- *
32
- * // Later, to stop collector:
33
- * clearInterval(collectorInterval);
34
- */
35
- function startQueueMetricsCollector(queue) {
36
- logger.info('Starting queue metrics collector (10s interval)');
37
- const updateQueueMetrics = async () => {
38
- try {
39
- // Get job counts from BullMQ queue
40
- // getJobCounts() returns: { waiting, active, completed, failed, delayed, paused }
41
- const counts = await queue.getJobCounts();
42
- // Update gauges for each state
43
- metrics_1.queueDepthGauge.set({ state: 'waiting' }, counts.waiting || 0);
44
- metrics_1.queueDepthGauge.set({ state: 'active' }, counts.active || 0);
45
- metrics_1.queueDepthGauge.set({ state: 'failed' }, counts.failed || 0);
46
- metrics_1.queueDepthGauge.set({ state: 'delayed' }, counts.delayed || 0);
47
- metrics_1.queueDepthGauge.set({ state: 'paused' }, counts.paused || 0);
48
- logger.debug({ counts }, 'Queue metrics updated');
49
- }
50
- catch (error) {
51
- // Don't crash if queue is temporarily unavailable
52
- logger.warn({ error }, 'Failed to update queue metrics');
53
- }
54
- };
55
- // Initial update (don't wait 10 seconds for first metrics)
56
- updateQueueMetrics();
57
- // Update every 10 seconds
58
- const interval = setInterval(updateQueueMetrics, 10000);
59
- return interval;
60
- }
61
- /**
62
- * Stop queue metrics collector
63
- *
64
- * Clears the interval timer to stop metric collection.
65
- *
66
- * @param interval - Interval timer from startQueueMetricsCollector
67
- *
68
- * @example
69
- * stopQueueMetricsCollector(collectorInterval);
70
- */
71
- function stopQueueMetricsCollector(interval) {
72
- logger.info('Stopping queue metrics collector');
73
- clearInterval(interval);
74
- }
75
- //# sourceMappingURL=collectors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collectors.js","sourceRoot":"","sources":["../../../packages/observability/collectors.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA2BH,gEA8BC;AAYD,8DAGC;AArED,uCAA4C;AAC5C,sCAA8C;AAE9C,MAAM,MAAM,GAAG,IAAA,0BAAiB,EAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,0BAA0B,CAAC,KAAiB;IAC1D,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAE/D,MAAM,kBAAkB,GAAG,KAAK,IAAI,EAAE;QACpC,IAAI,CAAC;YACH,mCAAmC;YACnC,kFAAkF;YAClF,MAAM,MAAM,GAAG,MAAO,KAAa,CAAC,YAAY,EAAE,CAAC;YAEnD,+BAA+B;YAC/B,yBAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;YAC/D,yBAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;YAC7D,yBAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;YAC7D,yBAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;YAC/D,yBAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;YAE7D,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kDAAkD;YAClD,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,gCAAgC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC;IAEF,2DAA2D;IAC3D,kBAAkB,EAAE,CAAC;IAErB,0BAA0B;IAC1B,MAAM,QAAQ,GAAG,WAAW,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAExD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,yBAAyB,CAAC,QAAwB;IAChE,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAChD,aAAa,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * FlowLint Observability Package
3
- *
4
- * Provides Prometheus metrics collection and exposure for FlowLint.
5
- *
6
- * @module packages/observability
7
- */
8
- export { register, webhookCounter, jobsQueuedCounter, jobsCompletedCounter, jobDurationHistogram, queueDepthGauge, githubApiCallsCounter, findingsGeneratedCounter, redisOpsCounter, httpRequestDuration, getMetrics, getContentType, clearMetrics, getMetric } from './metrics';
9
- export { metricsMiddleware, metricsErrorHandler } from './middleware';
10
- export { startQueueMetricsCollector, stopQueueMetricsCollector } from './collectors';
@@ -1,35 +0,0 @@
1
- "use strict";
2
- /**
3
- * FlowLint Observability Package
4
- *
5
- * Provides Prometheus metrics collection and exposure for FlowLint.
6
- *
7
- * @module packages/observability
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.stopQueueMetricsCollector = exports.startQueueMetricsCollector = exports.metricsErrorHandler = exports.metricsMiddleware = exports.getMetric = exports.clearMetrics = exports.getContentType = exports.getMetrics = exports.httpRequestDuration = exports.redisOpsCounter = exports.findingsGeneratedCounter = exports.githubApiCallsCounter = exports.queueDepthGauge = exports.jobDurationHistogram = exports.jobsCompletedCounter = exports.jobsQueuedCounter = exports.webhookCounter = exports.register = void 0;
11
- // Export all metrics
12
- var metrics_1 = require("./metrics");
13
- Object.defineProperty(exports, "register", { enumerable: true, get: function () { return metrics_1.register; } });
14
- Object.defineProperty(exports, "webhookCounter", { enumerable: true, get: function () { return metrics_1.webhookCounter; } });
15
- Object.defineProperty(exports, "jobsQueuedCounter", { enumerable: true, get: function () { return metrics_1.jobsQueuedCounter; } });
16
- Object.defineProperty(exports, "jobsCompletedCounter", { enumerable: true, get: function () { return metrics_1.jobsCompletedCounter; } });
17
- Object.defineProperty(exports, "jobDurationHistogram", { enumerable: true, get: function () { return metrics_1.jobDurationHistogram; } });
18
- Object.defineProperty(exports, "queueDepthGauge", { enumerable: true, get: function () { return metrics_1.queueDepthGauge; } });
19
- Object.defineProperty(exports, "githubApiCallsCounter", { enumerable: true, get: function () { return metrics_1.githubApiCallsCounter; } });
20
- Object.defineProperty(exports, "findingsGeneratedCounter", { enumerable: true, get: function () { return metrics_1.findingsGeneratedCounter; } });
21
- Object.defineProperty(exports, "redisOpsCounter", { enumerable: true, get: function () { return metrics_1.redisOpsCounter; } });
22
- Object.defineProperty(exports, "httpRequestDuration", { enumerable: true, get: function () { return metrics_1.httpRequestDuration; } });
23
- Object.defineProperty(exports, "getMetrics", { enumerable: true, get: function () { return metrics_1.getMetrics; } });
24
- Object.defineProperty(exports, "getContentType", { enumerable: true, get: function () { return metrics_1.getContentType; } });
25
- Object.defineProperty(exports, "clearMetrics", { enumerable: true, get: function () { return metrics_1.clearMetrics; } });
26
- Object.defineProperty(exports, "getMetric", { enumerable: true, get: function () { return metrics_1.getMetric; } });
27
- // Export middleware
28
- var middleware_1 = require("./middleware");
29
- Object.defineProperty(exports, "metricsMiddleware", { enumerable: true, get: function () { return middleware_1.metricsMiddleware; } });
30
- Object.defineProperty(exports, "metricsErrorHandler", { enumerable: true, get: function () { return middleware_1.metricsErrorHandler; } });
31
- // Export collectors
32
- var collectors_1 = require("./collectors");
33
- Object.defineProperty(exports, "startQueueMetricsCollector", { enumerable: true, get: function () { return collectors_1.startQueueMetricsCollector; } });
34
- Object.defineProperty(exports, "stopQueueMetricsCollector", { enumerable: true, get: function () { return collectors_1.stopQueueMetricsCollector; } });
35
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/observability/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,qBAAqB;AACrB,qCAemB;AAdjB,mGAAA,QAAQ,OAAA;AACR,yGAAA,cAAc,OAAA;AACd,4GAAA,iBAAiB,OAAA;AACjB,+GAAA,oBAAoB,OAAA;AACpB,+GAAA,oBAAoB,OAAA;AACpB,0GAAA,eAAe,OAAA;AACf,gHAAA,qBAAqB,OAAA;AACrB,mHAAA,wBAAwB,OAAA;AACxB,0GAAA,eAAe,OAAA;AACf,8GAAA,mBAAmB,OAAA;AACnB,qGAAA,UAAU,OAAA;AACV,yGAAA,cAAc,OAAA;AACd,uGAAA,YAAY,OAAA;AACZ,oGAAA,SAAS,OAAA;AAGX,oBAAoB;AACpB,2CAAsE;AAA7D,+GAAA,iBAAiB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAE/C,oBAAoB;AACpB,2CAAqF;AAA5E,wHAAA,0BAA0B,OAAA;AAAE,uHAAA,yBAAyB,OAAA"}
@@ -1,119 +0,0 @@
1
- /**
2
- * Prometheus Metrics Definitions for FlowLint
3
- *
4
- * This module defines all custom Prometheus metrics for FlowLint observability.
5
- * Metrics follow Prometheus naming conventions and are designed for low cardinality.
6
- *
7
- * @module packages/observability/metrics
8
- */
9
- import { Registry, Counter, Histogram, Gauge } from 'prom-client';
10
- export declare const register: Registry<"text/plain; version=0.0.4; charset=utf-8">;
11
- /**
12
- * Metric 1: Webhook Counter
13
- *
14
- * Tracks total webhooks received from GitHub, labeled by event type and action.
15
- *
16
- * Example usage:
17
- * webhookCounter.labels('pull_request', 'opened').inc();
18
- */
19
- export declare const webhookCounter: Counter<"event_type" | "action">;
20
- /**
21
- * Metric 2: Jobs Queued Counter
22
- *
23
- * Tracks total review jobs added to BullMQ queue.
24
- *
25
- * Example usage:
26
- * jobsQueuedCounter.labels('acme-corp/api-gateway').inc();
27
- */
28
- export declare const jobsQueuedCounter: Counter<"repo">;
29
- /**
30
- * Metric 3: Jobs Completed Counter
31
- *
32
- * Tracks total review jobs completed (success or failure).
33
- *
34
- * Example usage:
35
- * jobsCompletedCounter.labels('success', 'acme-corp/api-gateway').inc();
36
- */
37
- export declare const jobsCompletedCounter: Counter<"repo" | "status">;
38
- /**
39
- * Metric 4: Job Duration Histogram
40
- *
41
- * Distribution of job processing time in seconds.
42
- * Buckets optimized for typical workflow review times (0.1s to 120s).
43
- *
44
- * Example usage:
45
- * const timer = jobDurationHistogram.startTimer({ repo: 'acme-corp/api-gateway' });
46
- * // ... process job
47
- * timer(); // Records duration
48
- */
49
- export declare const jobDurationHistogram: Histogram<"repo">;
50
- /**
51
- * Metric 5: Queue Depth Gauge
52
- *
53
- * Current number of jobs in queue by state.
54
- * Updated periodically by collector (every 10 seconds).
55
- *
56
- * Example usage:
57
- * queueDepthGauge.set({ state: 'waiting' }, 10);
58
- */
59
- export declare const queueDepthGauge: Gauge<"state">;
60
- /**
61
- * Metric 6: GitHub API Calls Counter
62
- *
63
- * Tracks GitHub API calls made by FlowLint, labeled by method and status.
64
- *
65
- * Example usage:
66
- * githubApiCallsCounter.labels('GET', '200', '/repos/:owner/:repo/pulls/:number/files').inc();
67
- */
68
- export declare const githubApiCallsCounter: Counter<"status" | "method" | "endpoint">;
69
- /**
70
- * Metric 7: Findings Generated Counter
71
- *
72
- * Tracks lint findings generated, labeled by rule and severity.
73
- *
74
- * Example usage:
75
- * findingsGeneratedCounter.labels('rate_limit_retry', 'must').inc();
76
- */
77
- export declare const findingsGeneratedCounter: Counter<"rule" | "severity">;
78
- /**
79
- * Metric 8: Redis Operations Counter (Optional)
80
- *
81
- * Tracks Redis operations performed by BullMQ.
82
- *
83
- * Example usage:
84
- * redisOpsCounter.labels('zadd', 'success').inc();
85
- */
86
- export declare const redisOpsCounter: Counter<"status" | "operation">;
87
- /**
88
- * HTTP Request Duration Histogram
89
- *
90
- * Automatically populated by metricsMiddleware.
91
- * Tracks HTTP request latency by method, route, and status.
92
- */
93
- export declare const httpRequestDuration: Histogram<"status" | "method" | "route">;
94
- /**
95
- * Get all metrics in Prometheus exposition format
96
- *
97
- * @returns Prometheus-formatted metrics string
98
- */
99
- export declare function getMetrics(): Promise<string>;
100
- /**
101
- * Get metrics content type header
102
- *
103
- * @returns Prometheus content type string
104
- */
105
- export declare function getContentType(): string;
106
- /**
107
- * Clear all metrics (useful for testing)
108
- *
109
- * WARNING: This removes all metrics from the registry.
110
- * Only use in test environments.
111
- */
112
- export declare function clearMetrics(): void;
113
- /**
114
- * Get single metric by name (for testing)
115
- *
116
- * @param name - Metric name
117
- * @returns Metric instance or undefined
118
- */
119
- export declare function getMetric(name: string): import("prom-client").Metric<string> | undefined;
@@ -1,194 +0,0 @@
1
- "use strict";
2
- /**
3
- * Prometheus Metrics Definitions for FlowLint
4
- *
5
- * This module defines all custom Prometheus metrics for FlowLint observability.
6
- * Metrics follow Prometheus naming conventions and are designed for low cardinality.
7
- *
8
- * @module packages/observability/metrics
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.httpRequestDuration = exports.redisOpsCounter = exports.findingsGeneratedCounter = exports.githubApiCallsCounter = exports.queueDepthGauge = exports.jobDurationHistogram = exports.jobsCompletedCounter = exports.jobsQueuedCounter = exports.webhookCounter = exports.register = void 0;
12
- exports.getMetrics = getMetrics;
13
- exports.getContentType = getContentType;
14
- exports.clearMetrics = clearMetrics;
15
- exports.getMetric = getMetric;
16
- const prom_client_1 = require("prom-client");
17
- // Create dedicated registry for FlowLint metrics
18
- exports.register = new prom_client_1.Registry();
19
- // Enable default process and Node.js metrics
20
- (0, prom_client_1.collectDefaultMetrics)({ register: exports.register });
21
- // ============================================================================
22
- // Custom Application Metrics
23
- // ============================================================================
24
- /**
25
- * Metric 1: Webhook Counter
26
- *
27
- * Tracks total webhooks received from GitHub, labeled by event type and action.
28
- *
29
- * Example usage:
30
- * webhookCounter.labels('pull_request', 'opened').inc();
31
- */
32
- exports.webhookCounter = new prom_client_1.Counter({
33
- name: 'flowlint_webhook_received_total',
34
- help: 'Total number of webhooks received from GitHub',
35
- labelNames: ['event_type', 'action'],
36
- registers: [exports.register]
37
- });
38
- /**
39
- * Metric 2: Jobs Queued Counter
40
- *
41
- * Tracks total review jobs added to BullMQ queue.
42
- *
43
- * Example usage:
44
- * jobsQueuedCounter.labels('acme-corp/api-gateway').inc();
45
- */
46
- exports.jobsQueuedCounter = new prom_client_1.Counter({
47
- name: 'flowlint_jobs_queued_total',
48
- help: 'Total number of review jobs queued for processing',
49
- labelNames: ['repo'],
50
- registers: [exports.register]
51
- });
52
- /**
53
- * Metric 3: Jobs Completed Counter
54
- *
55
- * Tracks total review jobs completed (success or failure).
56
- *
57
- * Example usage:
58
- * jobsCompletedCounter.labels('success', 'acme-corp/api-gateway').inc();
59
- */
60
- exports.jobsCompletedCounter = new prom_client_1.Counter({
61
- name: 'flowlint_jobs_completed_total',
62
- help: 'Total number of review jobs completed',
63
- labelNames: ['status', 'repo'],
64
- registers: [exports.register]
65
- });
66
- /**
67
- * Metric 4: Job Duration Histogram
68
- *
69
- * Distribution of job processing time in seconds.
70
- * Buckets optimized for typical workflow review times (0.1s to 120s).
71
- *
72
- * Example usage:
73
- * const timer = jobDurationHistogram.startTimer({ repo: 'acme-corp/api-gateway' });
74
- * // ... process job
75
- * timer(); // Records duration
76
- */
77
- exports.jobDurationHistogram = new prom_client_1.Histogram({
78
- name: 'flowlint_job_duration_seconds',
79
- help: 'Duration of job processing in seconds',
80
- labelNames: ['repo'],
81
- buckets: [0.1, 0.5, 1, 2, 5, 10, 30, 60, 120],
82
- registers: [exports.register]
83
- });
84
- /**
85
- * Metric 5: Queue Depth Gauge
86
- *
87
- * Current number of jobs in queue by state.
88
- * Updated periodically by collector (every 10 seconds).
89
- *
90
- * Example usage:
91
- * queueDepthGauge.set({ state: 'waiting' }, 10);
92
- */
93
- exports.queueDepthGauge = new prom_client_1.Gauge({
94
- name: 'flowlint_queue_depth',
95
- help: 'Current number of jobs in queue by state',
96
- labelNames: ['state'],
97
- registers: [exports.register]
98
- });
99
- /**
100
- * Metric 6: GitHub API Calls Counter
101
- *
102
- * Tracks GitHub API calls made by FlowLint, labeled by method and status.
103
- *
104
- * Example usage:
105
- * githubApiCallsCounter.labels('GET', '200', '/repos/:owner/:repo/pulls/:number/files').inc();
106
- */
107
- exports.githubApiCallsCounter = new prom_client_1.Counter({
108
- name: 'flowlint_github_api_calls_total',
109
- help: 'Total GitHub API calls made by FlowLint',
110
- labelNames: ['method', 'status', 'endpoint'],
111
- registers: [exports.register]
112
- });
113
- /**
114
- * Metric 7: Findings Generated Counter
115
- *
116
- * Tracks lint findings generated, labeled by rule and severity.
117
- *
118
- * Example usage:
119
- * findingsGeneratedCounter.labels('rate_limit_retry', 'must').inc();
120
- */
121
- exports.findingsGeneratedCounter = new prom_client_1.Counter({
122
- name: 'flowlint_findings_generated_total',
123
- help: 'Total lint findings generated by rule and severity',
124
- labelNames: ['rule', 'severity'],
125
- registers: [exports.register]
126
- });
127
- /**
128
- * Metric 8: Redis Operations Counter (Optional)
129
- *
130
- * Tracks Redis operations performed by BullMQ.
131
- *
132
- * Example usage:
133
- * redisOpsCounter.labels('zadd', 'success').inc();
134
- */
135
- exports.redisOpsCounter = new prom_client_1.Counter({
136
- name: 'flowlint_redis_operations_total',
137
- help: 'Total Redis operations performed',
138
- labelNames: ['operation', 'status'],
139
- registers: [exports.register]
140
- });
141
- // ============================================================================
142
- // HTTP Metrics (Automatic via middleware)
143
- // ============================================================================
144
- /**
145
- * HTTP Request Duration Histogram
146
- *
147
- * Automatically populated by metricsMiddleware.
148
- * Tracks HTTP request latency by method, route, and status.
149
- */
150
- exports.httpRequestDuration = new prom_client_1.Histogram({
151
- name: 'http_request_duration_seconds',
152
- help: 'Duration of HTTP requests in seconds',
153
- labelNames: ['method', 'route', 'status'],
154
- buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5],
155
- registers: [exports.register]
156
- });
157
- // ============================================================================
158
- // Utility Functions
159
- // ============================================================================
160
- /**
161
- * Get all metrics in Prometheus exposition format
162
- *
163
- * @returns Prometheus-formatted metrics string
164
- */
165
- async function getMetrics() {
166
- return exports.register.metrics();
167
- }
168
- /**
169
- * Get metrics content type header
170
- *
171
- * @returns Prometheus content type string
172
- */
173
- function getContentType() {
174
- return exports.register.contentType;
175
- }
176
- /**
177
- * Clear all metrics (useful for testing)
178
- *
179
- * WARNING: This removes all metrics from the registry.
180
- * Only use in test environments.
181
- */
182
- function clearMetrics() {
183
- exports.register.clear();
184
- }
185
- /**
186
- * Get single metric by name (for testing)
187
- *
188
- * @param name - Metric name
189
- * @returns Metric instance or undefined
190
- */
191
- function getMetric(name) {
192
- return exports.register.getSingleMetric(name);
193
- }
194
- //# sourceMappingURL=metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../packages/observability/metrics.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAsKH,gCAEC;AAOD,wCAEC;AAQD,oCAEC;AAQD,8BAEC;AAnMD,6CAAyF;AAEzF,iDAAiD;AACpC,QAAA,QAAQ,GAAG,IAAI,sBAAQ,EAAE,CAAC;AAEvC,6CAA6C;AAC7C,IAAA,mCAAqB,EAAC,EAAE,QAAQ,EAAR,gBAAQ,EAAE,CAAC,CAAC;AAEpC,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;;;;;;GAOG;AACU,QAAA,cA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CAAC,WAAW,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY;IAC1B,gBAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,gBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Express Middleware for HTTP Metrics Collection
3
- *
4
- * This middleware automatically tracks HTTP request metrics including:
5
- * - Request duration (latency)
6
- * - Request count by method, route, status
7
- *
8
- * @module packages/observability/middleware
9
- */
10
- import { Request, Response, NextFunction } from 'express';
11
- /**
12
- * Express middleware to collect HTTP request metrics
13
- *
14
- * Automatically instruments all HTTP requests with Prometheus metrics.
15
- * Metrics are labeled by HTTP method, route path, and response status code.
16
- *
17
- * Usage:
18
- * import { metricsMiddleware } from './packages/observability/middleware';
19
- * app.use(metricsMiddleware);
20
- *
21
- * @param req - Express request object
22
- * @param res - Express response object
23
- * @param next - Express next function
24
- */
25
- export declare function metricsMiddleware(req: Request, res: Response, next: NextFunction): void;
26
- /**
27
- * Middleware error handler
28
- *
29
- * Ensures metrics failures don't crash the application.
30
- * Logs errors and continues processing.
31
- */
32
- export declare function metricsErrorHandler(err: Error, req: Request, res: Response, next: NextFunction): void;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- /**
3
- * Express Middleware for HTTP Metrics Collection
4
- *
5
- * This middleware automatically tracks HTTP request metrics including:
6
- * - Request duration (latency)
7
- * - Request count by method, route, status
8
- *
9
- * @module packages/observability/middleware
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.metricsMiddleware = metricsMiddleware;
13
- exports.metricsErrorHandler = metricsErrorHandler;
14
- const metrics_1 = require("./metrics");
15
- /**
16
- * Express middleware to collect HTTP request metrics
17
- *
18
- * Automatically instruments all HTTP requests with Prometheus metrics.
19
- * Metrics are labeled by HTTP method, route path, and response status code.
20
- *
21
- * Usage:
22
- * import { metricsMiddleware } from './packages/observability/middleware';
23
- * app.use(metricsMiddleware);
24
- *
25
- * @param req - Express request object
26
- * @param res - Express response object
27
- * @param next - Express next function
28
- */
29
- function metricsMiddleware(req, res, next) {
30
- // Start timer for this request
31
- const timer = metrics_1.httpRequestDuration.startTimer({
32
- method: req.method,
33
- route: req.route?.path || req.path,
34
- status: '0' // Will be updated on response finish
35
- });
36
- // Record duration when response finishes
37
- res.on('finish', () => {
38
- try {
39
- timer({ status: res.statusCode.toString() });
40
- }
41
- catch (error) {
42
- // Don't let metrics errors crash the application
43
- console.error('Failed to record HTTP metrics:', error);
44
- }
45
- });
46
- next();
47
- }
48
- /**
49
- * Middleware error handler
50
- *
51
- * Ensures metrics failures don't crash the application.
52
- * Logs errors and continues processing.
53
- */
54
- function metricsErrorHandler(err, req, res, next) {
55
- console.error('Metrics middleware error:', err);
56
- next(err); // Pass error to next error handler
57
- }
58
- //# sourceMappingURL=middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../packages/observability/middleware.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAmBH,8CAmBC;AAQD,kDAGC;AA9CD,uCAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;IAC/E,+BAA+B;IAC/B,MAAM,KAAK,GAAG,6BAAmB,CAAC,UAAU,CAAC;QAC3C,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,IAAI,GAAG,CAAC,IAAI;QAClC,MAAM,EAAE,GAAG,CAAC,qCAAqC;KAClD,CAAC,CAAC;IAEH,yCAAyC;IACzC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACpB,IAAI,CAAC;YACH,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iDAAiD;YACjD,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,EAAE,CAAC;AACT,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB;IAC7F,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,mCAAmC;AAChD,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * FlowLint Analysis Engine
3
- *
4
- * Orchestrates the linting workflow:
5
- * 1. Load configuration
6
- * 2. Fetch files to analyze
7
- * 3. Parse each file into a graph
8
- * 4. Run rules against the graph
9
- * 5. Report results
10
- */
11
- import type { AnalysisEngine, AnalysisSummary, ConfigProvider, FileSource, Reporter } from './providers';
12
- export declare class DefaultAnalysisEngine implements AnalysisEngine {
13
- private fileSource;
14
- private configProvider;
15
- private reporter;
16
- constructor(fileSource: FileSource, configProvider: ConfigProvider, reporter: Reporter);
17
- analyze(): Promise<AnalysisSummary>;
18
- private formatParseError;
19
- }
@@ -1,106 +0,0 @@
1
- "use strict";
2
- /**
3
- * FlowLint Analysis Engine
4
- *
5
- * Orchestrates the linting workflow:
6
- * 1. Load configuration
7
- * 2. Fetch files to analyze
8
- * 3. Parse each file into a graph
9
- * 4. Run rules against the graph
10
- * 5. Report results
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.DefaultAnalysisEngine = void 0;
14
- const parser_n8n_1 = require("./parser-n8n");
15
- const rules_1 = require("./rules");
16
- const schemas_1 = require("./schemas");
17
- const logger_1 = require("../logger");
18
- const findings_1 = require("./utils/findings");
19
- class DefaultAnalysisEngine {
20
- constructor(fileSource, configProvider, reporter) {
21
- this.fileSource = fileSource;
22
- this.configProvider = configProvider;
23
- this.reporter = reporter;
24
- }
25
- async analyze() {
26
- // 1. Load configuration
27
- const cfg = await this.configProvider.load();
28
- logger_1.logger.debug({ rules: Object.keys(cfg.rules) }, 'loaded configuration');
29
- // 2. Fetch files to analyze
30
- const files = await this.fileSource.getFiles(cfg.files);
31
- logger_1.logger.info({ count: files.length }, 'fetched files for analysis');
32
- // 3. Analyze each file
33
- const results = [];
34
- let errorCount = 0;
35
- for (const file of files) {
36
- try {
37
- // Parse file to graph
38
- const graph = (0, parser_n8n_1.parseN8n)(file.content);
39
- logger_1.logger.debug({ file: file.path, nodes: graph.nodes.length }, 'parsed file');
40
- // Run all rules
41
- const findings = (0, rules_1.runAllRules)(graph, {
42
- path: file.path,
43
- cfg,
44
- nodeLines: graph.meta.nodeLines,
45
- });
46
- results.push({
47
- file,
48
- graph,
49
- findings,
50
- });
51
- }
52
- catch (error) {
53
- errorCount++;
54
- const message = error instanceof Error ? error.message : String(error);
55
- const raw_details = this.formatParseError(error);
56
- logger_1.logger.warn({ file: file.path, error: message }, 'failed to parse file');
57
- // Add error finding
58
- const errorFinding = {
59
- rule: 'PARSE',
60
- severity: 'must',
61
- path: file.path,
62
- message,
63
- raw_details,
64
- line: 1,
65
- };
66
- results.push({
67
- file,
68
- graph: { nodes: [], edges: [], meta: {} },
69
- findings: [errorFinding],
70
- errors: [{ error: message, details: raw_details }],
71
- });
72
- }
73
- }
74
- // 4. Calculate summary
75
- const allFindings = results.flatMap((r) => r.findings);
76
- const summary = (0, findings_1.countFindingsBySeverity)(allFindings);
77
- // 5. Report results
78
- logger_1.logger.info({ totalResults: results.length, totalFindings: summary.total }, 'reporting results');
79
- await this.reporter.report(results);
80
- // 6. Return summary
81
- return {
82
- totalFiles: files.length,
83
- totalFindings: summary.total,
84
- findingsBySeverity: { must: summary.must, should: summary.should, nit: summary.nit },
85
- errors: errorCount,
86
- hasBlockingIssues: summary.must > 0,
87
- };
88
- }
89
- formatParseError(error) {
90
- if (error instanceof schemas_1.ValidationError && Array.isArray(error.errors) && error.errors.length > 0) {
91
- return error.errors
92
- .map((err) => {
93
- const suggestion = err.suggestion ? ` (suggestion: ${err.suggestion})` : '';
94
- return `- ${err.path}: ${err.message}${suggestion}`;
95
- })
96
- .join('\n')
97
- .slice(0, 64000);
98
- }
99
- if (error instanceof Error && error.stack) {
100
- return error.stack.slice(0, 64000);
101
- }
102
- return undefined;
103
- }
104
- }
105
- exports.DefaultAnalysisEngine = DefaultAnalysisEngine;
106
- //# sourceMappingURL=analysis-engine.js.map