codeflow-hook 1.4.0 → 2.1.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.
@@ -0,0 +1,175 @@
1
+ export enum StageStatus {
2
+ Pending = 'PENDING',
3
+ Running = 'RUNNING',
4
+ Success = 'SUCCESS',
5
+ Failed = 'FAILED',
6
+ Skipped = 'SKIPPED',
7
+ }
8
+
9
+ export enum SimulationMode {
10
+ Realistic = 'REALISTIC',
11
+ Fast = 'FAST',
12
+ Deterministic = 'DETERMINISTIC',
13
+ Chaotic = 'CHAOTIC'
14
+ }
15
+
16
+ export interface PipelineStageInfo {
17
+ id: string;
18
+ name: string;
19
+ description: string;
20
+ }
21
+
22
+ export interface StageExecution {
23
+ id: string;
24
+ status: StageStatus;
25
+ logs: string[];
26
+ duration?: number;
27
+ metrics?: StageMetrics;
28
+ errors?: ErrorInfo[];
29
+ }
30
+
31
+ export interface CodeReviewIssue {
32
+ line: number;
33
+ type: string; // Changed to string to accommodate ESLint rule IDs
34
+ description: string;
35
+ link?: string;
36
+ }
37
+
38
+ export interface CodeReviewFileResult {
39
+ fileName: string;
40
+ status: 'PASS' | 'FAIL';
41
+ score: number;
42
+ issues: CodeReviewIssue[];
43
+ suggestions: string[];
44
+ }
45
+
46
+ export interface CodeReviewResult {
47
+ overallStatus: 'PASS' | 'FAIL';
48
+ summary: string;
49
+ files: CodeReviewFileResult[];
50
+ }
51
+
52
+ // Enhanced simulation types
53
+ export interface RetryPolicy {
54
+ maxAttempts: number;
55
+ backoffMultiplier: number;
56
+ initialDelay: number;
57
+ }
58
+
59
+ export interface StageConfig {
60
+ id: string;
61
+ name: string;
62
+ type: string;
63
+ description: string;
64
+ config: Record<string, any>;
65
+ dependencies: string[];
66
+ timeout: number;
67
+ retryPolicy: RetryPolicy;
68
+ successRate: number; // 0.0 to 1.0
69
+ durationRange: {
70
+ min: number;
71
+ max: number;
72
+ baseMultiplier: number; // Multiplier based on codebase size
73
+ };
74
+ failureModes: FailureMode[];
75
+ }
76
+
77
+ export interface FailureMode {
78
+ type: string;
79
+ probability: number;
80
+ message: string;
81
+ recoverable: boolean;
82
+ recoveryTime?: number;
83
+ }
84
+
85
+ export interface PipelineConfig {
86
+ id: string;
87
+ name: string;
88
+ description: string;
89
+ version: string;
90
+ stages: StageConfig[];
91
+ environment: Record<string, any>;
92
+ settings: PipelineSettings;
93
+ metadata: PipelineMetadata;
94
+ }
95
+
96
+ export interface PipelineSettings {
97
+ mode: SimulationMode;
98
+ maxConcurrency: number;
99
+ failFast: boolean;
100
+ enableMetrics: boolean;
101
+ enableArtifacts: boolean;
102
+ timeout: number;
103
+ }
104
+
105
+ export interface PipelineMetadata {
106
+ author: string;
107
+ created: string;
108
+ updated: string;
109
+ tags: string[];
110
+ category: string;
111
+ }
112
+
113
+ export interface StageMetrics {
114
+ cpuUsage: number;
115
+ memoryUsage: number;
116
+ networkIO: number;
117
+ diskIO: number;
118
+ duration: number;
119
+ success: boolean;
120
+ }
121
+
122
+ export interface PipelineMetrics {
123
+ totalDuration: number;
124
+ stageCount: number;
125
+ successCount: number;
126
+ failureCount: number;
127
+ skippedCount: number;
128
+ averageStageDuration: number;
129
+ bottleneckStage?: string;
130
+ resourceUtilization: {
131
+ avgCpu: number;
132
+ avgMemory: number;
133
+ peakCpu: number;
134
+ peakMemory: number;
135
+ };
136
+ }
137
+
138
+ export interface ErrorInfo {
139
+ type: string;
140
+ message: string;
141
+ timestamp: number;
142
+ recoverable: boolean;
143
+ context: Record<string, any>;
144
+ }
145
+
146
+ export interface SimulationResult {
147
+ id: string;
148
+ pipelineId: string;
149
+ executionId: string;
150
+ startTime: Date;
151
+ endTime: Date;
152
+ status: 'success' | 'failed' | 'partial' | 'cancelled';
153
+ stages: StageExecution[];
154
+ metrics: PipelineMetrics;
155
+ artifacts: ArtifactInfo[];
156
+ config: PipelineConfig;
157
+ logs: string[];
158
+ }
159
+
160
+ export interface ArtifactInfo {
161
+ name: string;
162
+ type: string;
163
+ size: number;
164
+ path: string;
165
+ metadata: Record<string, any>;
166
+ }
167
+
168
+ export interface SimulationContext {
169
+ pipelineId: string;
170
+ executionId: string;
171
+ startTime: number;
172
+ config: PipelineConfig;
173
+ variables: Record<string, any>;
174
+ artifacts: Map<string, ArtifactInfo>;
175
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
+
1
2
  {
2
3
  "name": "codeflow-hook",
3
- "version": "1.4.0",
4
+ "version": "2.1.0",
4
5
  "description": "An interactive CI/CD simulator and lightweight pre-push code reviewer using Gemini AI",
5
6
  "type": "module",
6
7
  "main": "index.js",
@@ -9,10 +10,12 @@
9
10
  },
10
11
  "files": [
11
12
  "README.md",
12
- "bin/"
13
+ "bin/",
14
+ "lib/"
13
15
  ],
14
16
  "scripts": {
15
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "build": "tsc",
18
+ "test": "jest"
16
19
  },
17
20
  "keywords": [
18
21
  "git",
@@ -29,10 +32,15 @@
29
32
  "commander": "^11.1.0",
30
33
  "axios": "^1.6.0",
31
34
  "chalk": "^5.3.0",
32
- "ora": "^7.0.1"
35
+ "ora": "^7.0.1",
36
+ "simple-git": "^3.20.0",
37
+ "winston": "^3.11.0",
38
+ "dotenv": "^16.3.1"
33
39
  },
34
40
  "devDependencies": {
35
- "@types/node": "^18.0.0"
41
+ "@types/node": "^18.0.0",
42
+ "typescript": "^5.0.0",
43
+ "jest": "^29.7.0"
36
44
  },
37
45
  "engines": {
38
46
  "node": ">=16.0.0"