pumuki-ast-hooks 5.3.20 → 5.3.22
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.
- package/docs/RELEASE_NOTES.md +35 -0
- package/docs/VIOLATIONS_RESOLUTION_PLAN.md +60 -59
- package/package.json +3 -3
- package/scripts/hooks-system/.AI_TOKEN_STATUS.txt +1 -1
- package/scripts/hooks-system/.audit-reports/notifications.log +935 -0
- package/scripts/hooks-system/.audit-reports/token-monitor.log +2809 -0
- package/scripts/hooks-system/application/CompositionRoot.js +38 -22
- package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +0 -18
- package/scripts/hooks-system/application/services/ContextDetectionEngine.js +0 -58
- package/scripts/hooks-system/application/services/DynamicRulesLoader.js +2 -12
- package/scripts/hooks-system/application/services/GitFlowService.js +0 -80
- package/scripts/hooks-system/application/services/GitTreeState.js +2 -5
- package/scripts/hooks-system/application/services/HookSystemScheduler.js +0 -4
- package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +0 -25
- package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +0 -11
- package/scripts/hooks-system/application/services/PlatformAnalysisService.js +0 -19
- package/scripts/hooks-system/application/services/PlatformDetectionService.js +0 -19
- package/scripts/hooks-system/application/services/PlaybookRunner.js +1 -22
- package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +0 -19
- package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +0 -25
- package/scripts/hooks-system/application/services/RealtimeGuardService.js +71 -41
- package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +0 -11
- package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +0 -11
- package/scripts/hooks-system/application/services/commit/FeatureDetector.js +0 -11
- package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +0 -25
- package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +31 -21
- package/scripts/hooks-system/application/services/guard/GuardConfig.js +15 -18
- package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +0 -11
- package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +0 -26
- package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +6 -20
- package/scripts/hooks-system/application/services/guard/GuardLockManager.js +0 -11
- package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +0 -25
- package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +0 -11
- package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +23 -11
- package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +0 -11
- package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +0 -18
- package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +0 -18
- package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +1 -19
- package/scripts/hooks-system/application/services/installation/HookInstaller.js +62 -24
- package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +0 -11
- package/scripts/hooks-system/application/services/installation/InstallService.js +1 -25
- package/scripts/hooks-system/application/services/installation/McpConfigurator.js +2 -19
- package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +0 -11
- package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +0 -11
- package/scripts/hooks-system/application/services/logging/AuditLogger.js +0 -8
- package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +13 -15
- package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +0 -33
- package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +0 -27
- package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +0 -26
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +0 -18
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +4 -28
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +0 -28
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +0 -26
- package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +0 -4
- package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +0 -25
- package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +0 -26
- package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +0 -26
- package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +0 -11
- package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +0 -18
- package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +0 -11
- package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +0 -18
- package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +0 -18
- package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +0 -11
- package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +0 -20
- package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +0 -19
- package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +0 -19
- package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +0 -11
- package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +0 -19
- package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +0 -4
- package/scripts/hooks-system/application/services/token/CursorTokenService.js +0 -20
- package/scripts/hooks-system/application/services/token/TokenMetricsService.js +2 -12
- package/scripts/hooks-system/application/services/token/TokenMonitorService.js +0 -19
- package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +0 -12
- package/scripts/hooks-system/bin/cli.js +15 -1
- package/scripts/hooks-system/bin/guard-env.sh +18 -38
- package/scripts/hooks-system/bin/guard-supervisor.js +5 -515
- package/scripts/hooks-system/bin/session-loader.sh +3 -262
- package/scripts/hooks-system/bin/start-guards.sh +21 -184
- package/scripts/hooks-system/bin/update-evidence.sh +10 -1161
- package/scripts/hooks-system/config/project.config.json +1 -1
- package/scripts/hooks-system/domain/events/index.js +31 -24
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +3 -2
- package/scripts/hooks-system/infrastructure/ast/ast-core.js +12 -20
- package/scripts/hooks-system/infrastructure/ast/ast-intelligence.js +8 -18
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +2 -1
- package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +18 -14
- package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend.js +196 -196
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +3 -2
- package/scripts/hooks-system/infrastructure/hooks/skill-activation-prompt.js +3 -2
- package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +5 -4
- package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +88 -0
- package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +17 -16
- package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +92 -54
- package/scripts/hooks-system/infrastructure/telemetry/metrics-server.js +3 -2
- package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +6 -8
|
@@ -21,9 +21,11 @@ const TokenMonitor = require('./services/monitoring/TokenMonitor');
|
|
|
21
21
|
const ActivityMonitor = require('./services/monitoring/ActivityMonitor');
|
|
22
22
|
const DevDocsMonitor = require('./services/monitoring/DevDocsMonitor');
|
|
23
23
|
const AstMonitor = require('./services/monitoring/AstMonitor');
|
|
24
|
+
const AuditLogger = require('./services/logging/AuditLogger');
|
|
24
25
|
|
|
25
26
|
const path = require('path');
|
|
26
27
|
const fs = require('fs');
|
|
28
|
+
const env = require('../config/env');
|
|
27
29
|
|
|
28
30
|
class CompositionRoot {
|
|
29
31
|
constructor(repoRoot) {
|
|
@@ -51,7 +53,7 @@ class CompositionRoot {
|
|
|
51
53
|
file: {
|
|
52
54
|
enabled: true,
|
|
53
55
|
path: path.join(this.auditDir, 'guard-audit.jsonl'),
|
|
54
|
-
level:
|
|
56
|
+
level: env.get('HOOK_LOG_LEVEL', env.isProd ? 'warn' : 'info')
|
|
55
57
|
},
|
|
56
58
|
console: {
|
|
57
59
|
enabled: false,
|
|
@@ -73,6 +75,18 @@ class CompositionRoot {
|
|
|
73
75
|
return this.instances.get('notificationService');
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
getAuditLogger() {
|
|
79
|
+
if (!this.instances.has('auditLogger')) {
|
|
80
|
+
const logger = this.getLogger();
|
|
81
|
+
this.instances.set('auditLogger', new AuditLogger({
|
|
82
|
+
repoRoot: this.repoRoot,
|
|
83
|
+
filename: path.join('.audit_tmp', 'audit.log'),
|
|
84
|
+
logger
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
return this.instances.get('auditLogger');
|
|
88
|
+
}
|
|
89
|
+
|
|
76
90
|
// --- Infrastructure Adapters ---
|
|
77
91
|
|
|
78
92
|
getNotificationAdapter() {
|
|
@@ -183,9 +197,9 @@ class CompositionRoot {
|
|
|
183
197
|
getEvidenceMonitor() {
|
|
184
198
|
if (!this.instances.has('evidenceMonitor')) {
|
|
185
199
|
this.instances.set('evidenceMonitor', new EvidenceMonitor(this.repoRoot, {
|
|
186
|
-
staleThresholdMs:
|
|
187
|
-
pollIntervalMs:
|
|
188
|
-
reminderIntervalMs:
|
|
200
|
+
staleThresholdMs: env.getNumber('HOOK_GUARD_EVIDENCE_STALE_THRESHOLD', 180000),
|
|
201
|
+
pollIntervalMs: env.getNumber('HOOK_GUARD_EVIDENCE_POLL_INTERVAL', 30000),
|
|
202
|
+
reminderIntervalMs: env.getNumber('HOOK_GUARD_EVIDENCE_REMINDER_INTERVAL', 60000)
|
|
189
203
|
}));
|
|
190
204
|
}
|
|
191
205
|
return this.instances.get('evidenceMonitor');
|
|
@@ -194,11 +208,11 @@ class CompositionRoot {
|
|
|
194
208
|
getGitTreeMonitor() {
|
|
195
209
|
if (!this.instances.has('gitTreeMonitor')) {
|
|
196
210
|
this.instances.set('gitTreeMonitor', new GitTreeMonitor(this.repoRoot, {
|
|
197
|
-
stagedThreshold:
|
|
198
|
-
unstagedThreshold:
|
|
199
|
-
totalThreshold:
|
|
200
|
-
checkIntervalMs:
|
|
201
|
-
reminderMs:
|
|
211
|
+
stagedThreshold: env.getNumber('HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT', 10),
|
|
212
|
+
unstagedThreshold: env.getNumber('HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT', 15),
|
|
213
|
+
totalThreshold: env.getNumber('HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT', 20),
|
|
214
|
+
checkIntervalMs: env.getNumber('HOOK_GUARD_DIRTY_TREE_INTERVAL', 60000),
|
|
215
|
+
reminderMs: env.getNumber('HOOK_GUARD_DIRTY_TREE_REMINDER', 300000)
|
|
202
216
|
}));
|
|
203
217
|
}
|
|
204
218
|
return this.instances.get('gitTreeMonitor');
|
|
@@ -219,11 +233,11 @@ class CompositionRoot {
|
|
|
219
233
|
const github = this.getGitHubAdapter();
|
|
220
234
|
|
|
221
235
|
this.instances.set('gitFlowService', new GitFlowService(this.repoRoot, {
|
|
222
|
-
developBranch:
|
|
223
|
-
mainBranch:
|
|
224
|
-
autoSyncEnabled:
|
|
225
|
-
autoCleanEnabled:
|
|
226
|
-
requireClean:
|
|
236
|
+
developBranch: env.get('HOOK_GUARD_GITFLOW_DEVELOP_BRANCH', 'develop'),
|
|
237
|
+
mainBranch: env.get('HOOK_GUARD_GITFLOW_MAIN_BRANCH', 'main'),
|
|
238
|
+
autoSyncEnabled: env.getBool('HOOK_GUARD_GITFLOW_AUTOSYNC', true),
|
|
239
|
+
autoCleanEnabled: env.getBool('HOOK_GUARD_GITFLOW_AUTOCLEAN', true),
|
|
240
|
+
requireClean: env.getBool('HOOK_GUARD_GITFLOW_REQUIRE_CLEAN', true)
|
|
227
241
|
}, logger, gitQuery, gitCommand, github));
|
|
228
242
|
}
|
|
229
243
|
return this.instances.get('gitFlowService');
|
|
@@ -234,7 +248,7 @@ class CompositionRoot {
|
|
|
234
248
|
const logger = this.getLogger();
|
|
235
249
|
this.instances.set('activityMonitor', new ActivityMonitor({
|
|
236
250
|
repoRoot: this.repoRoot,
|
|
237
|
-
inactivityGraceMs:
|
|
251
|
+
inactivityGraceMs: env.getNumber('HOOK_GUARD_INACTIVITY_GRACE_MS', 420000),
|
|
238
252
|
logger
|
|
239
253
|
}));
|
|
240
254
|
}
|
|
@@ -247,9 +261,9 @@ class CompositionRoot {
|
|
|
247
261
|
const notificationService = this.getNotificationService();
|
|
248
262
|
this.instances.set('devDocsMonitor', new DevDocsMonitor({
|
|
249
263
|
repoRoot: this.repoRoot,
|
|
250
|
-
checkIntervalMs:
|
|
251
|
-
staleThresholdMs:
|
|
252
|
-
autoRefreshEnabled:
|
|
264
|
+
checkIntervalMs: env.getNumber('HOOK_GUARD_DEV_DOCS_CHECK_INTERVAL', 300000),
|
|
265
|
+
staleThresholdMs: env.getNumber('HOOK_GUARD_DEV_DOCS_STALE_THRESHOLD', 86400000),
|
|
266
|
+
autoRefreshEnabled: env.getBool('HOOK_GUARD_DEV_DOCS_AUTO_REFRESH', true),
|
|
253
267
|
logger,
|
|
254
268
|
notificationService
|
|
255
269
|
}));
|
|
@@ -263,9 +277,9 @@ class CompositionRoot {
|
|
|
263
277
|
const notificationService = this.getNotificationService();
|
|
264
278
|
this.instances.set('astMonitor', new AstMonitor({
|
|
265
279
|
repoRoot: this.repoRoot,
|
|
266
|
-
debounceMs:
|
|
267
|
-
cooldownMs:
|
|
268
|
-
enabled:
|
|
280
|
+
debounceMs: env.getNumber('HOOK_AST_WATCH_DEBOUNCE', 8000),
|
|
281
|
+
cooldownMs: env.getNumber('HOOK_AST_WATCH_COOLDOWN', 30000),
|
|
282
|
+
enabled: env.getBool('HOOK_AST_WATCH', true),
|
|
269
283
|
logger,
|
|
270
284
|
notificationService
|
|
271
285
|
}));
|
|
@@ -291,6 +305,7 @@ class CompositionRoot {
|
|
|
291
305
|
const notificationService = this.getNotificationService();
|
|
292
306
|
const monitors = this.getMonitors();
|
|
293
307
|
const orchestrator = this.getOrchestrator();
|
|
308
|
+
const auditLogger = this.getAuditLogger();
|
|
294
309
|
const config = {
|
|
295
310
|
debugLogPath: path.join(this.auditDir, 'guard-debug.log'),
|
|
296
311
|
repoRoot: this.repoRoot
|
|
@@ -301,7 +316,8 @@ class CompositionRoot {
|
|
|
301
316
|
notificationService,
|
|
302
317
|
monitors,
|
|
303
318
|
orchestration: orchestrator,
|
|
304
|
-
config
|
|
319
|
+
config,
|
|
320
|
+
auditLogger
|
|
305
321
|
}));
|
|
306
322
|
}
|
|
307
323
|
return this.instances.get('guardService');
|
|
@@ -3,18 +3,8 @@ const { execSync } = require('child_process');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const UnifiedLogger = require('./logging/UnifiedLogger');
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
createMetricScope: createMetricScope
|
|
8
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
9
|
-
|
|
10
6
|
class AutonomousOrchestrator {
|
|
11
7
|
constructor(contextEngine, platformDetector, rulesLoader, logger = new UnifiedLogger()) {
|
|
12
|
-
const m_constructor = createMetricScope({
|
|
13
|
-
hook: 'autonomous_orchestrator',
|
|
14
|
-
operation: 'constructor'
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
m_constructor.started();
|
|
18
8
|
this.contextEngine = contextEngine;
|
|
19
9
|
this.platformDetector = platformDetector || new PlatformDetectionService();
|
|
20
10
|
this.rulesLoader = rulesLoader;
|
|
@@ -25,7 +15,6 @@ class AutonomousOrchestrator {
|
|
|
25
15
|
};
|
|
26
16
|
this.lastAnalysis = null;
|
|
27
17
|
this.lastAnalysisTime = 0;
|
|
28
|
-
m_constructor.success();
|
|
29
18
|
}
|
|
30
19
|
|
|
31
20
|
detectFromASTSystemFiles(files) {
|
|
@@ -134,13 +123,6 @@ class AutonomousOrchestrator {
|
|
|
134
123
|
}
|
|
135
124
|
|
|
136
125
|
getLastAnalysis() {
|
|
137
|
-
const m_get_last_analysis = createMetricScope({
|
|
138
|
-
hook: 'autonomous_orchestrator',
|
|
139
|
-
operation: 'get_last_analysis'
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
m_get_last_analysis.started();
|
|
143
|
-
m_get_last_analysis.success();
|
|
144
126
|
return this.lastAnalysis;
|
|
145
127
|
}
|
|
146
128
|
}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
const crypto = require('crypto');
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
createMetricScope: createMetricScope
|
|
5
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
6
|
-
|
|
7
3
|
class ContextDetectionEngine {
|
|
8
4
|
constructor(repoRootOrGitPort = null, logger = console) {
|
|
9
|
-
const m_constructor = createMetricScope({
|
|
10
|
-
hook: 'context_detection_engine',
|
|
11
|
-
operation: 'constructor'
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
m_constructor.started();
|
|
15
5
|
if (typeof repoRootOrGitPort === 'string') {
|
|
16
6
|
this.repoRoot = repoRootOrGitPort;
|
|
17
7
|
this.git = null;
|
|
@@ -26,7 +16,6 @@ class ContextDetectionEngine {
|
|
|
26
16
|
timestamp: 0,
|
|
27
17
|
ttl: 10000
|
|
28
18
|
};
|
|
29
|
-
m_constructor.success();
|
|
30
19
|
}
|
|
31
20
|
|
|
32
21
|
async detectContext() {
|
|
@@ -65,74 +54,40 @@ class ContextDetectionEngine {
|
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
getStagedFiles() {
|
|
68
|
-
const m_get_staged_files = createMetricScope({
|
|
69
|
-
hook: 'context_detection_engine',
|
|
70
|
-
operation: 'get_staged_files'
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
m_get_staged_files.started();
|
|
74
57
|
try {
|
|
75
|
-
m_get_staged_files.success();
|
|
76
58
|
return this.git.getStagedFiles();
|
|
77
59
|
} catch (error) {
|
|
78
60
|
this.logger.error('ContextDetectionEngine: Failed to get staged files', error);
|
|
79
|
-
m_get_staged_files.success();
|
|
80
61
|
return [];
|
|
81
62
|
}
|
|
82
|
-
m_get_staged_files.success();
|
|
83
63
|
}
|
|
84
64
|
|
|
85
65
|
getStagedSignature() {
|
|
86
|
-
const m_get_staged_signature = createMetricScope({
|
|
87
|
-
hook: 'context_detection_engine',
|
|
88
|
-
operation: 'get_staged_signature'
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
m_get_staged_signature.started();
|
|
92
66
|
try {
|
|
93
67
|
const patch = this.git.getDiff(true);
|
|
94
68
|
if (!patch) return '';
|
|
95
|
-
m_get_staged_signature.success();
|
|
96
69
|
return crypto.createHash('sha1').update(patch).digest('hex');
|
|
97
70
|
} catch (error) {
|
|
98
|
-
m_get_staged_signature.success();
|
|
99
71
|
return '';
|
|
100
72
|
}
|
|
101
|
-
m_get_staged_signature.success();
|
|
102
73
|
}
|
|
103
74
|
|
|
104
75
|
getRecentlyModifiedFiles() {
|
|
105
|
-
const m_get_recently_modified_files = createMetricScope({
|
|
106
|
-
hook: 'context_detection_engine',
|
|
107
|
-
operation: 'get_recently_modified_files'
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
m_get_recently_modified_files.started();
|
|
111
76
|
try {
|
|
112
77
|
const output = this.git.getStatusShort();
|
|
113
78
|
if (!output) return [];
|
|
114
79
|
|
|
115
|
-
m_get_recently_modified_files.success();
|
|
116
|
-
|
|
117
80
|
return output
|
|
118
81
|
.split('\n')
|
|
119
82
|
.filter(Boolean)
|
|
120
83
|
.map(line => line.trim().substring(2)) // Remove status code
|
|
121
84
|
.filter(file => !file.startsWith('.git'));
|
|
122
85
|
} catch (error) {
|
|
123
|
-
m_get_recently_modified_files.success();
|
|
124
86
|
return [];
|
|
125
87
|
}
|
|
126
|
-
m_get_recently_modified_files.success();
|
|
127
88
|
}
|
|
128
89
|
|
|
129
90
|
getRecentCommitPatterns() {
|
|
130
|
-
const m_get_recent_commit_patterns = createMetricScope({
|
|
131
|
-
hook: 'context_detection_engine',
|
|
132
|
-
operation: 'get_recent_commit_patterns'
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
m_get_recent_commit_patterns.started();
|
|
136
91
|
try {
|
|
137
92
|
const output = this.git.getLog(10);
|
|
138
93
|
if (!output) return [];
|
|
@@ -161,31 +116,18 @@ class ContextDetectionEngine {
|
|
|
161
116
|
commits.push(currentCommit);
|
|
162
117
|
}
|
|
163
118
|
|
|
164
|
-
m_get_recent_commit_patterns.success();
|
|
165
|
-
|
|
166
119
|
return commits.slice(0, 10);
|
|
167
120
|
} catch (error) {
|
|
168
|
-
m_get_recent_commit_patterns.success();
|
|
169
121
|
return [];
|
|
170
122
|
}
|
|
171
|
-
m_get_recent_commit_patterns.success();
|
|
172
123
|
}
|
|
173
124
|
|
|
174
125
|
getCurrentBranch() {
|
|
175
|
-
const m_get_current_branch = createMetricScope({
|
|
176
|
-
hook: 'context_detection_engine',
|
|
177
|
-
operation: 'get_current_branch'
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
m_get_current_branch.started();
|
|
181
126
|
try {
|
|
182
|
-
m_get_current_branch.success();
|
|
183
127
|
return this.git.getCurrentBranch();
|
|
184
128
|
} catch (error) {
|
|
185
|
-
m_get_current_branch.success();
|
|
186
129
|
return 'unknown';
|
|
187
130
|
}
|
|
188
|
-
m_get_current_branch.success();
|
|
189
131
|
}
|
|
190
132
|
|
|
191
133
|
inferFromGitStatus() {
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
const {
|
|
2
|
-
createMetricScope: createMetricScope
|
|
3
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
|
-
|
|
5
1
|
const fs = require('fs').promises;
|
|
6
2
|
const path = require('path');
|
|
3
|
+
const env = require('../config/env');
|
|
7
4
|
|
|
8
5
|
class DynamicRulesLoader {
|
|
9
6
|
constructor(rulesDirectory, logger = console) {
|
|
10
|
-
const m_constructor = createMetricScope({
|
|
11
|
-
hook: 'dynamic_rules_loader',
|
|
12
|
-
operation: 'constructor'
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
m_constructor.started();
|
|
16
7
|
this.rulesDirectory = rulesDirectory || null;
|
|
17
8
|
this.logger = logger;
|
|
18
9
|
this.rulesDirectories = this.resolveRulesDirectories();
|
|
@@ -28,7 +19,6 @@ class DynamicRulesLoader {
|
|
|
28
19
|
ttl: 60000
|
|
29
20
|
};
|
|
30
21
|
this.lastLoadWarnings = [];
|
|
31
|
-
m_constructor.success();
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
resolveRulesDirectories() {
|
|
@@ -38,7 +28,7 @@ class DynamicRulesLoader {
|
|
|
38
28
|
return [this.rulesDirectory];
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
const envRaw =
|
|
31
|
+
const envRaw = env.get('AST_RULES_DIRECTORIES');
|
|
42
32
|
if (envRaw && typeof envRaw === 'string' && envRaw.trim().length > 0) {
|
|
43
33
|
return envRaw
|
|
44
34
|
.split(',')
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
const { execSync, spawnSync } = require('child_process');
|
|
2
2
|
const { ConfigurationError } = require('../../domain/errors');
|
|
3
3
|
|
|
4
|
-
const { recordMetric } = require('../../../infrastructure/telemetry/metrics-logger');
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
createMetricScope: createMetricScope
|
|
8
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
9
|
-
|
|
10
4
|
class GitFlowService {
|
|
11
5
|
constructor(repoRoot, options = {}, logger = console, gitQuery = null, gitCommand = null, githubAdapter = null) {
|
|
12
|
-
recordMetric({
|
|
13
|
-
hook: 'git_flow_service',
|
|
14
|
-
operation: 'constructor',
|
|
15
|
-
status: 'started',
|
|
16
|
-
repoRoot: repoRoot.substring(0, 100),
|
|
17
|
-
hasOptions: !!options
|
|
18
|
-
});
|
|
19
|
-
|
|
20
6
|
this.repoRoot = repoRoot;
|
|
21
7
|
this.logger = logger;
|
|
22
8
|
this.gitQuery = gitQuery;
|
|
@@ -30,16 +16,6 @@ class GitFlowService {
|
|
|
30
16
|
this.requireClean = options.requireClean !== false;
|
|
31
17
|
|
|
32
18
|
this._validateDependencies();
|
|
33
|
-
|
|
34
|
-
recordMetric({
|
|
35
|
-
hook: 'git_flow_service',
|
|
36
|
-
operation: 'constructor',
|
|
37
|
-
status: 'success',
|
|
38
|
-
developBranch: this.developBranch,
|
|
39
|
-
mainBranch: this.mainBranch,
|
|
40
|
-
autoSyncEnabled: this.autoSyncEnabled,
|
|
41
|
-
autoCleanEnabled: this.autoCleanEnabled
|
|
42
|
-
});
|
|
43
19
|
}
|
|
44
20
|
|
|
45
21
|
_validateDependencies() {
|
|
@@ -49,17 +25,9 @@ class GitFlowService {
|
|
|
49
25
|
}
|
|
50
26
|
|
|
51
27
|
getCurrentBranch() {
|
|
52
|
-
const m_get_current_branch = createMetricScope({
|
|
53
|
-
hook: 'git_flow_service',
|
|
54
|
-
operation: 'get_current_branch'
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
m_get_current_branch.started();
|
|
58
28
|
if (this.gitQuery) {
|
|
59
|
-
m_get_current_branch.success();
|
|
60
29
|
return this.gitQuery.getCurrentBranch();
|
|
61
30
|
}
|
|
62
|
-
m_get_current_branch.success();
|
|
63
31
|
return 'unknown';
|
|
64
32
|
}
|
|
65
33
|
|
|
@@ -72,31 +40,12 @@ class GitFlowService {
|
|
|
72
40
|
}
|
|
73
41
|
|
|
74
42
|
syncBranches() {
|
|
75
|
-
recordMetric({
|
|
76
|
-
hook: 'git_flow_service',
|
|
77
|
-
operation: 'sync_branches',
|
|
78
|
-
status: 'started',
|
|
79
|
-
autoSyncEnabled: this.autoSyncEnabled
|
|
80
|
-
});
|
|
81
|
-
|
|
82
43
|
if (!this.autoSyncEnabled) {
|
|
83
|
-
recordMetric({
|
|
84
|
-
hook: 'git_flow_service',
|
|
85
|
-
operation: 'sync_branches',
|
|
86
|
-
status: 'skipped',
|
|
87
|
-
reason: 'auto_sync_disabled'
|
|
88
|
-
});
|
|
89
44
|
return { success: false, message: 'Auto-sync disabled' };
|
|
90
45
|
}
|
|
91
46
|
|
|
92
47
|
if (!this.isClean()) {
|
|
93
48
|
this.logger.warn('Skipping sync: working directory not clean');
|
|
94
|
-
recordMetric({
|
|
95
|
-
hook: 'git_flow_service',
|
|
96
|
-
operation: 'sync_branches',
|
|
97
|
-
status: 'skipped',
|
|
98
|
-
reason: 'working_directory_not_clean'
|
|
99
|
-
});
|
|
100
49
|
return { success: false, message: 'Working directory not clean' };
|
|
101
50
|
}
|
|
102
51
|
|
|
@@ -115,47 +64,22 @@ class GitFlowService {
|
|
|
115
64
|
|
|
116
65
|
this.gitCommand.checkout(current);
|
|
117
66
|
} else {
|
|
118
|
-
recordMetric({
|
|
119
|
-
hook: 'git_flow_service',
|
|
120
|
-
operation: 'sync_branches',
|
|
121
|
-
status: 'failed',
|
|
122
|
-
reason: 'no_git_command_adapter'
|
|
123
|
-
});
|
|
124
67
|
throw new ConfigurationError('GitCommandAdapter is required for branch synchronization', 'gitCommand');
|
|
125
68
|
}
|
|
126
69
|
|
|
127
70
|
this.logger.info('Branches synchronized successfully', {
|
|
128
71
|
branches: [this.developBranch, this.mainBranch]
|
|
129
72
|
});
|
|
130
|
-
recordMetric({
|
|
131
|
-
hook: 'git_flow_service',
|
|
132
|
-
operation: 'sync_branches',
|
|
133
|
-
status: 'success',
|
|
134
|
-
branches: [this.developBranch, this.mainBranch].join(',')
|
|
135
|
-
});
|
|
136
73
|
return { success: true, message: 'Branches synchronized' };
|
|
137
74
|
} catch (error) {
|
|
138
75
|
this.logger.error('Branch synchronization failed', { error: error.message });
|
|
139
|
-
recordMetric({
|
|
140
|
-
hook: 'git_flow_service',
|
|
141
|
-
operation: 'sync_branches',
|
|
142
|
-
status: 'failed',
|
|
143
|
-
error: error.message.substring(0, 100)
|
|
144
|
-
});
|
|
145
76
|
return { success: false, message: error.message };
|
|
146
77
|
}
|
|
147
78
|
}
|
|
148
79
|
|
|
149
80
|
createPullRequest(sourceBranch, targetBranch, title, body) {
|
|
150
|
-
const m_create_pull_request = createMetricScope({
|
|
151
|
-
hook: 'git_flow_service',
|
|
152
|
-
operation: 'create_pull_request'
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
m_create_pull_request.started();
|
|
156
81
|
if (!this.github) {
|
|
157
82
|
this.logger.error('GitHub adapter not available');
|
|
158
|
-
m_create_pull_request.success();
|
|
159
83
|
return null;
|
|
160
84
|
}
|
|
161
85
|
|
|
@@ -170,15 +94,11 @@ class GitFlowService {
|
|
|
170
94
|
this.logger.warn('Pull Request creation failed or returned no URL');
|
|
171
95
|
}
|
|
172
96
|
|
|
173
|
-
m_create_pull_request.success();
|
|
174
|
-
|
|
175
97
|
return prUrl;
|
|
176
98
|
} catch (error) {
|
|
177
99
|
this.logger.error('[GitFlowService] Failed to create PR:', { error: error.message });
|
|
178
|
-
m_create_pull_request.success();
|
|
179
100
|
return null;
|
|
180
101
|
}
|
|
181
|
-
m_create_pull_request.success();
|
|
182
102
|
}
|
|
183
103
|
|
|
184
104
|
mergeDevelopToMain() {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const { execSync } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
2
3
|
|
|
3
4
|
// Import recordMetric for prometheus metrics
|
|
4
|
-
const { recordMetric } = require('
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
createMetricScope: createMetricScope
|
|
8
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
5
|
+
const { recordMetric } = require(path.join(__dirname, '..', '..', 'infrastructure', 'telemetry', 'metrics-logger'));
|
|
9
6
|
|
|
10
7
|
const extractFilePath = line => {
|
|
11
8
|
recordMetric({
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
const { recordMetric } = require('../../infrastructure/telemetry/metrics-logger');
|
|
2
2
|
const HookSystemStateMachine = require('../state/HookSystemStateMachine');
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
createMetricScope: createMetricScope
|
|
6
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
-
|
|
8
4
|
class HookSystemScheduler {
|
|
9
5
|
constructor({ orchestrator, contextEngine, intervalMs = 30000 }) {
|
|
10
6
|
recordMetric({
|
|
@@ -5,23 +5,12 @@ const FeatureDetector = require('./commit/FeatureDetector');
|
|
|
5
5
|
const CommitMessageGenerator = require('./commit/CommitMessageGenerator');
|
|
6
6
|
const UnifiedLogger = require('./logging/UnifiedLogger');
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
createMetricScope: createMetricScope
|
|
10
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
11
|
-
|
|
12
8
|
class IntelligentCommitAnalyzer {
|
|
13
9
|
constructor({ repoRoot = process.cwd(), logger = null } = {}) {
|
|
14
|
-
const m_constructor = createMetricScope({
|
|
15
|
-
hook: 'intelligent_commit_analyzer',
|
|
16
|
-
operation: 'constructor'
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
m_constructor.started();
|
|
20
10
|
this.repoRoot = repoRoot;
|
|
21
11
|
this.logger = logger || console;
|
|
22
12
|
this.featureDetector = new FeatureDetector(this.logger);
|
|
23
13
|
this.messageGenerator = new CommitMessageGenerator(this.logger);
|
|
24
|
-
m_constructor.success();
|
|
25
14
|
}
|
|
26
15
|
|
|
27
16
|
detectFeature(filePath) {
|
|
@@ -148,13 +137,6 @@ class IntelligentCommitAnalyzer {
|
|
|
148
137
|
* Get ready-to-commit groups (all groups are ready - no verification)
|
|
149
138
|
*/
|
|
150
139
|
getReadyCommits(suggestions) {
|
|
151
|
-
const m_get_ready_commits = createMetricScope({
|
|
152
|
-
hook: 'intelligent_commit_analyzer',
|
|
153
|
-
operation: 'get_ready_commits'
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
m_get_ready_commits.started();
|
|
157
|
-
m_get_ready_commits.success();
|
|
158
140
|
return suggestions;
|
|
159
141
|
}
|
|
160
142
|
|
|
@@ -162,13 +144,6 @@ class IntelligentCommitAnalyzer {
|
|
|
162
144
|
* Get groups that need attention (none - we don't verify)
|
|
163
145
|
*/
|
|
164
146
|
getNeedsAttention(suggestions) {
|
|
165
|
-
const m_get_needs_attention = createMetricScope({
|
|
166
|
-
hook: 'intelligent_commit_analyzer',
|
|
167
|
-
operation: 'get_needs_attention'
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
m_get_needs_attention.started();
|
|
171
|
-
m_get_needs_attention.success();
|
|
172
147
|
return [];
|
|
173
148
|
}
|
|
174
149
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
const IntelligentCommitAnalyzer = require('./IntelligentCommitAnalyzer');
|
|
2
2
|
const { getGitTreeState } = require('./GitTreeState');
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
createMetricScope: createMetricScope
|
|
6
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
-
|
|
8
4
|
class IntelligentGitTreeMonitor {
|
|
9
5
|
constructor({
|
|
10
6
|
repoRoot = process.cwd(),
|
|
@@ -12,18 +8,11 @@ class IntelligentGitTreeMonitor {
|
|
|
12
8
|
logger = console,
|
|
13
9
|
autoCommitEnabled = false
|
|
14
10
|
} = {}) {
|
|
15
|
-
const m_constructor = createMetricScope({
|
|
16
|
-
hook: 'intelligent_git_tree_monitor',
|
|
17
|
-
operation: 'constructor'
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
m_constructor.started();
|
|
21
11
|
this.repoRoot = repoRoot;
|
|
22
12
|
this.notifier = notifier;
|
|
23
13
|
this.logger = logger;
|
|
24
14
|
this.autoCommitEnabled = autoCommitEnabled;
|
|
25
15
|
this.analyzer = new IntelligentCommitAnalyzer({ repoRoot, logger });
|
|
26
|
-
m_constructor.success();
|
|
27
16
|
}
|
|
28
17
|
|
|
29
18
|
/**
|
|
@@ -2,21 +2,10 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const PlatformHeuristics = require('./platform/PlatformHeuristics');
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
createMetricScope: createMetricScope
|
|
7
|
-
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
8
|
-
|
|
9
5
|
class PlatformAnalysisService {
|
|
10
6
|
constructor(platformDetector) {
|
|
11
|
-
const m_constructor = createMetricScope({
|
|
12
|
-
hook: 'platform_analysis_service',
|
|
13
|
-
operation: 'constructor'
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
m_constructor.started();
|
|
17
7
|
this.platformDetector = platformDetector;
|
|
18
8
|
this.heuristics = new PlatformHeuristics(platformDetector);
|
|
19
|
-
m_constructor.success();
|
|
20
9
|
}
|
|
21
10
|
|
|
22
11
|
/**
|
|
@@ -141,12 +130,6 @@ class PlatformAnalysisService {
|
|
|
141
130
|
}
|
|
142
131
|
|
|
143
132
|
getScoreReasons(platform, context) {
|
|
144
|
-
const m_get_score_reasons = createMetricScope({
|
|
145
|
-
hook: 'platform_analysis_service',
|
|
146
|
-
operation: 'get_score_reasons'
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
m_get_score_reasons.started();
|
|
150
133
|
const reasons = [];
|
|
151
134
|
|
|
152
135
|
if (context.stagedFiles && context.stagedFiles.length > 0) {
|
|
@@ -183,8 +166,6 @@ class PlatformAnalysisService {
|
|
|
183
166
|
}
|
|
184
167
|
}
|
|
185
168
|
|
|
186
|
-
m_get_score_reasons.success();
|
|
187
|
-
|
|
188
169
|
return reasons;
|
|
189
170
|
}
|
|
190
171
|
}
|