pumuki-ast-hooks 5.3.18 → 5.3.20
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/VIOLATIONS_RESOLUTION_PLAN.md +39 -37
- package/package.json +8 -2
- package/scripts/hooks-system/application/CompositionRoot.js +24 -73
- package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +18 -0
- package/scripts/hooks-system/application/services/ContextDetectionEngine.js +58 -0
- package/scripts/hooks-system/application/services/DynamicRulesLoader.js +12 -2
- package/scripts/hooks-system/application/services/GitFlowService.js +80 -0
- package/scripts/hooks-system/application/services/GitTreeState.js +143 -13
- package/scripts/hooks-system/application/services/HookSystemScheduler.js +47 -0
- package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +25 -0
- package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +11 -0
- package/scripts/hooks-system/application/services/PlatformAnalysisService.js +19 -0
- package/scripts/hooks-system/application/services/PlatformDetectionService.js +19 -0
- package/scripts/hooks-system/application/services/PlaybookRunner.js +22 -1
- package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +19 -0
- package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +25 -0
- package/scripts/hooks-system/application/services/RealtimeGuardService.js +41 -84
- package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +11 -0
- package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +11 -0
- package/scripts/hooks-system/application/services/commit/FeatureDetector.js +11 -0
- package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +25 -0
- package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +21 -31
- package/scripts/hooks-system/application/services/guard/GuardConfig.js +18 -15
- package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +11 -0
- package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +26 -0
- package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +20 -6
- package/scripts/hooks-system/application/services/guard/GuardLockManager.js +11 -0
- package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +25 -0
- package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +11 -0
- package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +10 -28
- package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +11 -0
- package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +18 -0
- package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +18 -0
- package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +18 -3
- package/scripts/hooks-system/application/services/installation/HookInstaller.js +19 -0
- package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +11 -0
- package/scripts/hooks-system/application/services/installation/InstallService.js +25 -1
- package/scripts/hooks-system/application/services/installation/McpConfigurator.js +19 -2
- package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +11 -0
- package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +11 -0
- package/scripts/hooks-system/application/services/logging/AuditLogger.js +90 -1
- package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +15 -13
- package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +33 -0
- package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +27 -0
- package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +26 -0
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +19 -0
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +27 -6
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +28 -0
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +26 -0
- package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +4 -0
- package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +25 -0
- package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +26 -0
- package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +26 -0
- package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +11 -0
- package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +18 -0
- package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +11 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +18 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +18 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +11 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +20 -0
- package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +19 -0
- package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +19 -0
- package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +11 -0
- package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +19 -0
- package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +4 -0
- package/scripts/hooks-system/application/services/token/CursorTokenService.js +20 -0
- package/scripts/hooks-system/application/services/token/TokenMetricsService.js +11 -13
- package/scripts/hooks-system/application/services/token/TokenMonitorService.js +19 -0
- package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +12 -0
- package/scripts/hooks-system/bin/__tests__/evidence-update.spec.js +49 -0
- package/scripts/hooks-system/bin/cli.js +1 -15
- package/scripts/hooks-system/config/project.config.json +1 -1
- package/scripts/hooks-system/domain/events/index.js +24 -31
- package/scripts/hooks-system/domain/exceptions/index.js +87 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +2 -3
- package/scripts/hooks-system/infrastructure/ast/ast-core.js +20 -12
- package/scripts/hooks-system/infrastructure/ast/ast-intelligence.js +18 -8
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +1 -2
- package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +14 -18
- package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend.js +196 -196
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSASTIntelligentAnalyzer.spec.js +66 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +2 -3
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +24 -86
- package/scripts/hooks-system/infrastructure/config/config.js +5 -0
- package/scripts/hooks-system/infrastructure/hooks/skill-activation-prompt.js +2 -3
- package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +5 -35
- package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +16 -86
- package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +54 -92
- package/scripts/hooks-system/infrastructure/telemetry/metric-scope.js +98 -0
- package/scripts/hooks-system/infrastructure/telemetry/metrics-server.js +2 -51
- package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +8 -6
|
@@ -1,17 +1,35 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createMetricScope: createMetricScope
|
|
3
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
|
+
|
|
1
5
|
class GuardHealthReminder {
|
|
2
6
|
constructor(timers, notificationHandler, config) {
|
|
7
|
+
const m_constructor = createMetricScope({
|
|
8
|
+
hook: 'guard_health_reminder',
|
|
9
|
+
operation: 'constructor'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
m_constructor.started();
|
|
3
13
|
this.timers = timers;
|
|
4
14
|
this.notificationHandler = notificationHandler;
|
|
5
15
|
this.config = config;
|
|
6
16
|
this.timer = null;
|
|
7
17
|
this.lastReminderAt = 0;
|
|
18
|
+
m_constructor.success();
|
|
8
19
|
}
|
|
9
20
|
|
|
10
21
|
start(checkHealthCallback) {
|
|
22
|
+
const m_start = createMetricScope({
|
|
23
|
+
hook: 'guard_health_reminder',
|
|
24
|
+
operation: 'start'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
m_start.started();
|
|
11
28
|
this.stop();
|
|
12
29
|
|
|
13
30
|
const { healthyReminderIntervalMs } = this.config;
|
|
14
31
|
if (!Number.isFinite(healthyReminderIntervalMs) || healthyReminderIntervalMs <= 0) {
|
|
32
|
+
m_start.success();
|
|
15
33
|
return;
|
|
16
34
|
}
|
|
17
35
|
|
|
@@ -22,13 +40,21 @@ class GuardHealthReminder {
|
|
|
22
40
|
if (this.timer && typeof this.timer.unref === 'function') {
|
|
23
41
|
this.timer.unref();
|
|
24
42
|
}
|
|
43
|
+
m_start.success();
|
|
25
44
|
}
|
|
26
45
|
|
|
27
46
|
stop() {
|
|
47
|
+
const m_stop = createMetricScope({
|
|
48
|
+
hook: 'guard_health_reminder',
|
|
49
|
+
operation: 'stop'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
m_stop.started();
|
|
28
53
|
if (this.timer) {
|
|
29
54
|
this.timers.clearInterval(this.timer);
|
|
30
55
|
this.timer = null;
|
|
31
56
|
}
|
|
57
|
+
m_stop.success();
|
|
32
58
|
}
|
|
33
59
|
|
|
34
60
|
_tick(checkHealthCallback) {
|
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
7
|
|
|
5
8
|
class GuardHeartbeatMonitor {
|
|
6
9
|
constructor({
|
|
7
10
|
repoRoot = process.cwd(),
|
|
8
11
|
logger = console,
|
|
9
|
-
fsModule = fs
|
|
12
|
+
fsModule = fs,
|
|
13
|
+
env = process.env
|
|
10
14
|
} = {}) {
|
|
15
|
+
const m_constructor = createMetricScope({
|
|
16
|
+
hook: 'guard_heartbeat_monitor',
|
|
17
|
+
operation: 'constructor'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
m_constructor.started();
|
|
11
21
|
this.repoRoot = repoRoot;
|
|
12
22
|
this.logger = logger;
|
|
13
23
|
this.fs = fsModule;
|
|
14
|
-
|
|
24
|
+
this.env = env;
|
|
25
|
+
|
|
26
|
+
const heartbeatRelative = env.HOOK_GUARD_HEARTBEAT_PATH || path.join('.audit_tmp', 'guard-heartbeat.json');
|
|
15
27
|
this.heartbeatPath = path.isAbsolute(heartbeatRelative)
|
|
16
28
|
? heartbeatRelative
|
|
17
29
|
: path.join(this.repoRoot, heartbeatRelative);
|
|
18
30
|
|
|
19
|
-
this.heartbeatMaxAgeMs =
|
|
20
|
-
env.
|
|
31
|
+
this.heartbeatMaxAgeMs = Number(
|
|
32
|
+
env.GUARD_AUTOSTART_HEARTBEAT_MAX_AGE || env.HOOK_GUARD_HEARTBEAT_MAX_AGE || 60000
|
|
33
|
+
);
|
|
21
34
|
|
|
22
35
|
this.heartbeatRestartReasons = new Set(
|
|
23
|
-
(env.
|
|
36
|
+
(env.GUARD_AUTOSTART_HEARTBEAT_RESTART || 'missing,stale,invalid,degraded')
|
|
24
37
|
.split(',')
|
|
25
38
|
.map(entry => entry.trim().toLowerCase())
|
|
26
39
|
.filter(Boolean)
|
|
27
40
|
);
|
|
41
|
+
m_constructor.success();
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
evaluate() {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
+
|
|
4
8
|
class GuardLockManager {
|
|
5
9
|
constructor({
|
|
6
10
|
repoRoot = process.cwd(),
|
|
7
11
|
logger = console,
|
|
8
12
|
fsModule = fs
|
|
9
13
|
} = {}) {
|
|
14
|
+
const m_constructor = createMetricScope({
|
|
15
|
+
hook: 'guard_lock_manager',
|
|
16
|
+
operation: 'constructor'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
m_constructor.started();
|
|
10
20
|
this.repoRoot = repoRoot;
|
|
11
21
|
this.logger = logger;
|
|
12
22
|
this.fs = fsModule;
|
|
@@ -26,6 +36,7 @@ class GuardLockManager {
|
|
|
26
36
|
this.logger.debug('GUARD_LOCK_MANAGER_INIT_DEBUG', { error: error.message });
|
|
27
37
|
}
|
|
28
38
|
}
|
|
39
|
+
m_constructor.success();
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
acquireLock() {
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createMetricScope: createMetricScope
|
|
3
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
|
+
|
|
1
5
|
class GuardMonitorLoop {
|
|
2
6
|
constructor(timers, intervalMs, tickCallback, logger) {
|
|
7
|
+
const m_constructor = createMetricScope({
|
|
8
|
+
hook: 'guard_monitor_loop',
|
|
9
|
+
operation: 'constructor'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
m_constructor.started();
|
|
3
13
|
this.timers = timers;
|
|
4
14
|
this.intervalMs = intervalMs;
|
|
5
15
|
this.tickCallback = tickCallback;
|
|
6
16
|
this.logger = logger;
|
|
7
17
|
this.timer = null;
|
|
18
|
+
m_constructor.success();
|
|
8
19
|
}
|
|
9
20
|
|
|
10
21
|
start() {
|
|
22
|
+
const m_start = createMetricScope({
|
|
23
|
+
hook: 'guard_monitor_loop',
|
|
24
|
+
operation: 'start'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
m_start.started();
|
|
11
28
|
this.stop();
|
|
12
29
|
this.timer = this.timers.setInterval(() => {
|
|
13
30
|
try {
|
|
@@ -16,13 +33,21 @@ class GuardMonitorLoop {
|
|
|
16
33
|
this.logger.log(`Monitor error: ${error.message}`);
|
|
17
34
|
}
|
|
18
35
|
}, this.intervalMs);
|
|
36
|
+
m_start.success();
|
|
19
37
|
}
|
|
20
38
|
|
|
21
39
|
stop() {
|
|
40
|
+
const m_stop = createMetricScope({
|
|
41
|
+
hook: 'guard_monitor_loop',
|
|
42
|
+
operation: 'stop'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
m_stop.started();
|
|
22
46
|
if (this.timer) {
|
|
23
47
|
this.timers.clearInterval(this.timer);
|
|
24
48
|
this.timer = null;
|
|
25
49
|
}
|
|
50
|
+
m_stop.success();
|
|
26
51
|
}
|
|
27
52
|
}
|
|
28
53
|
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createMetricScope: createMetricScope
|
|
3
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
|
+
|
|
1
5
|
class GuardNotificationHandler {
|
|
2
6
|
constructor(notificationCenter, eventLogger, config) {
|
|
7
|
+
const m_constructor = createMetricScope({
|
|
8
|
+
hook: 'guard_notification_handler',
|
|
9
|
+
operation: 'constructor'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
m_constructor.started();
|
|
3
13
|
this.notificationCenter = notificationCenter;
|
|
4
14
|
this.eventLogger = eventLogger;
|
|
5
15
|
this.config = config;
|
|
6
16
|
this.lastNotificationState = { reason: null, at: 0 };
|
|
17
|
+
m_constructor.success();
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
notify(message, level = 'info', options = {}) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { spawnSync } = require('child_process');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
6
7
|
|
|
7
8
|
class GuardProcessManager {
|
|
8
9
|
constructor({
|
|
@@ -11,6 +12,12 @@ class GuardProcessManager {
|
|
|
11
12
|
fsModule = require('fs'),
|
|
12
13
|
childProcess = { spawnSync }
|
|
13
14
|
} = {}) {
|
|
15
|
+
const m_constructor = createMetricScope({
|
|
16
|
+
hook: 'guard_process_manager',
|
|
17
|
+
operation: 'constructor'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
m_constructor.started();
|
|
14
21
|
this.repoRoot = repoRoot;
|
|
15
22
|
this.logger = logger;
|
|
16
23
|
this.fs = fsModule;
|
|
@@ -18,10 +25,7 @@ class GuardProcessManager {
|
|
|
18
25
|
|
|
19
26
|
this.supervisorPidFile = path.join(this.repoRoot, '.guard-supervisor.pid');
|
|
20
27
|
this.startScript = path.join(this.repoRoot, 'bin', 'start-guards.sh');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Initialize audit logger
|
|
24
|
-
this.auditLogger = new AuditLogger({ repoRoot, logger: this.logger });
|
|
28
|
+
m_constructor.success();
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
isSupervisorRunning() {
|
|
@@ -65,15 +69,6 @@ class GuardProcessManager {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
startSupervisor() {
|
|
68
|
-
if (this.busy) {
|
|
69
|
-
return {
|
|
70
|
-
success: false,
|
|
71
|
-
error: new Error('bulkhead_busy'),
|
|
72
|
-
stdout: '',
|
|
73
|
-
stderr: 'bulkhead_busy'
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
this.busy = true;
|
|
77
72
|
try {
|
|
78
73
|
const result = this.childProcess.spawnSync(this.startScript, ['start'], {
|
|
79
74
|
cwd: this.repoRoot,
|
|
@@ -96,21 +91,10 @@ class GuardProcessManager {
|
|
|
96
91
|
stdout: '',
|
|
97
92
|
stderr: error.message
|
|
98
93
|
};
|
|
99
|
-
} finally {
|
|
100
|
-
this.busy = false;
|
|
101
94
|
}
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
stopSupervisor() {
|
|
105
|
-
if (this.busy) {
|
|
106
|
-
return {
|
|
107
|
-
success: false,
|
|
108
|
-
error: new Error('bulkhead_busy'),
|
|
109
|
-
stdout: '',
|
|
110
|
-
stderr: 'bulkhead_busy'
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
this.busy = true;
|
|
114
98
|
try {
|
|
115
99
|
const result = this.childProcess.spawnSync(this.startScript, ['stop'], {
|
|
116
100
|
cwd: this.repoRoot,
|
|
@@ -133,8 +117,6 @@ class GuardProcessManager {
|
|
|
133
117
|
stdout: '',
|
|
134
118
|
stderr: error.message
|
|
135
119
|
};
|
|
136
|
-
} finally {
|
|
137
|
-
this.busy = false;
|
|
138
120
|
}
|
|
139
121
|
}
|
|
140
122
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createMetricScope: createMetricScope
|
|
3
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
4
|
+
|
|
1
5
|
class GuardRecoveryService {
|
|
2
6
|
constructor({
|
|
3
7
|
repoRoot,
|
|
@@ -6,12 +10,19 @@ class GuardRecoveryService {
|
|
|
6
10
|
notificationHandler,
|
|
7
11
|
restartCooldownMs = 2000
|
|
8
12
|
}) {
|
|
13
|
+
const m_constructor = createMetricScope({
|
|
14
|
+
hook: 'guard_recovery_service',
|
|
15
|
+
operation: 'constructor'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
m_constructor.started();
|
|
9
19
|
this.repoRoot = repoRoot;
|
|
10
20
|
this.logger = logger;
|
|
11
21
|
this.startScript = startScript;
|
|
12
22
|
this.notificationHandler = notificationHandler;
|
|
13
23
|
this.restartCooldownMs = restartCooldownMs;
|
|
14
24
|
this.lastEnsure = 0;
|
|
25
|
+
m_constructor.success();
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
ensureSupervisor(reason, eventLogger) {
|
package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
+
|
|
4
8
|
const COLORS = {
|
|
5
9
|
reset: '\x1b[0m',
|
|
6
10
|
green: '\x1b[32m',
|
|
@@ -10,11 +14,24 @@ const COLORS = {
|
|
|
10
14
|
|
|
11
15
|
class ConfigurationGeneratorService {
|
|
12
16
|
constructor(targetRoot, hookSystemRoot) {
|
|
17
|
+
const m_constructor = createMetricScope({
|
|
18
|
+
hook: 'configuration_generator_service',
|
|
19
|
+
operation: 'constructor'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
m_constructor.started();
|
|
13
23
|
this.targetRoot = targetRoot || process.cwd();
|
|
14
24
|
this.hookSystemRoot = hookSystemRoot;
|
|
25
|
+
m_constructor.success();
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
createProjectConfig(platforms) {
|
|
29
|
+
const m_create_project_config = createMetricScope({
|
|
30
|
+
hook: 'configuration_generator_service',
|
|
31
|
+
operation: 'create_project_config'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
m_create_project_config.started();
|
|
18
35
|
const config = {
|
|
19
36
|
version: '3.1.0',
|
|
20
37
|
project: {
|
|
@@ -73,6 +90,7 @@ class ConfigurationGeneratorService {
|
|
|
73
90
|
|
|
74
91
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
75
92
|
this.logSuccess('Configuration created');
|
|
93
|
+
m_create_project_config.success();
|
|
76
94
|
}
|
|
77
95
|
|
|
78
96
|
installESLintConfigs() {
|
package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
+
|
|
4
8
|
const COLORS = {
|
|
5
9
|
reset: '\x1b[0m',
|
|
6
10
|
green: '\x1b[32m',
|
|
@@ -9,12 +13,25 @@ const COLORS = {
|
|
|
9
13
|
|
|
10
14
|
class FileSystemInstallerService {
|
|
11
15
|
constructor(targetRoot, hookSystemRoot, logger = null) {
|
|
16
|
+
const m_constructor = createMetricScope({
|
|
17
|
+
hook: 'file_system_installer_service',
|
|
18
|
+
operation: 'constructor'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
m_constructor.started();
|
|
12
22
|
this.targetRoot = targetRoot || process.cwd();
|
|
13
23
|
this.hookSystemRoot = hookSystemRoot;
|
|
14
24
|
this.logger = logger;
|
|
25
|
+
m_constructor.success();
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
createDirectoryStructure() {
|
|
29
|
+
const m_create_directory_structure = createMetricScope({
|
|
30
|
+
hook: 'file_system_installer_service',
|
|
31
|
+
operation: 'create_directory_structure'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
m_create_directory_structure.started();
|
|
18
35
|
const dirs = [
|
|
19
36
|
'scripts/hooks-system',
|
|
20
37
|
'scripts/hooks-system/docs',
|
|
@@ -29,6 +46,7 @@ class FileSystemInstallerService {
|
|
|
29
46
|
}
|
|
30
47
|
});
|
|
31
48
|
this.logSuccess('Directory structure created');
|
|
49
|
+
m_create_directory_structure.success();
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
copySystemFiles() {
|
|
@@ -2,8 +2,9 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { execSync, spawnSync } = require('child_process');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
createMetricScope: createMetricScope
|
|
7
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
8
|
|
|
8
9
|
const COLORS = {
|
|
9
10
|
reset: '\x1b[0m',
|
|
@@ -16,8 +17,15 @@ const COLORS = {
|
|
|
16
17
|
|
|
17
18
|
class GitEnvironmentService {
|
|
18
19
|
constructor(targetRoot, version = 'unknown') {
|
|
20
|
+
const m_constructor = createMetricScope({
|
|
21
|
+
hook: 'git_environment_service',
|
|
22
|
+
operation: 'constructor'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
m_constructor.started();
|
|
19
26
|
this.targetRoot = targetRoot || process.cwd();
|
|
20
27
|
this.version = version;
|
|
28
|
+
m_constructor.success();
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
checkGitRepository() {
|
|
@@ -91,6 +99,13 @@ class GitEnvironmentService {
|
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
getPreCommitHookContent() {
|
|
102
|
+
const m_get_pre_commit_hook_content = createMetricScope({
|
|
103
|
+
hook: 'git_environment_service',
|
|
104
|
+
operation: 'get_pre_commit_hook_content'
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
m_get_pre_commit_hook_content.started();
|
|
108
|
+
m_get_pre_commit_hook_content.success();
|
|
94
109
|
return `#!/bin/bash
|
|
95
110
|
# AST Intelligence Hooks - Pre-commit
|
|
96
111
|
# Auto-generated by pumuki-ast-hooks v${this.version}
|
|
@@ -113,7 +128,7 @@ fi
|
|
|
113
128
|
|
|
114
129
|
# Try node_modules/.bin first (works with npm install)
|
|
115
130
|
if [ -f "node_modules/.bin/ast-hooks" ]; then
|
|
116
|
-
OUTPUT=$(node_modules/.bin/ast-hooks ast
|
|
131
|
+
OUTPUT=$(node_modules/.bin/ast-hooks ast 2>&1)
|
|
117
132
|
EXIT_CODE=$?
|
|
118
133
|
echo "$OUTPUT"
|
|
119
134
|
if [ $EXIT_CODE -ne 0 ]; then
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
const {
|
|
5
|
+
createMetricScope: createMetricScope
|
|
6
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
|
+
|
|
4
8
|
class HookInstaller {
|
|
5
9
|
constructor(targetRoot, hookSystemRoot, logger = null) {
|
|
10
|
+
const m_constructor = createMetricScope({
|
|
11
|
+
hook: 'hook_installer',
|
|
12
|
+
operation: 'constructor'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
m_constructor.started();
|
|
6
16
|
this.targetRoot = targetRoot;
|
|
7
17
|
this.hookSystemRoot = hookSystemRoot;
|
|
8
18
|
this.logger = logger;
|
|
@@ -12,6 +22,7 @@ class HookInstaller {
|
|
|
12
22
|
yellow: '\x1b[33m',
|
|
13
23
|
cyan: '\x1b[36m'
|
|
14
24
|
};
|
|
25
|
+
m_constructor.success();
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
install(platforms) {
|
|
@@ -128,6 +139,12 @@ class HookInstaller {
|
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
getRelevantSkills(platforms) {
|
|
142
|
+
const m_get_relevant_skills = createMetricScope({
|
|
143
|
+
hook: 'hook_installer',
|
|
144
|
+
operation: 'get_relevant_skills'
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
m_get_relevant_skills.started();
|
|
131
148
|
const allSkills = ['backend-guidelines', 'frontend-guidelines', 'ios-guidelines', 'android-guidelines'];
|
|
132
149
|
const relevantSkills = [];
|
|
133
150
|
|
|
@@ -136,6 +153,8 @@ class HookInstaller {
|
|
|
136
153
|
if (platforms.includes('ios')) relevantSkills.push('ios-guidelines');
|
|
137
154
|
if (platforms.includes('android')) relevantSkills.push('android-guidelines');
|
|
138
155
|
|
|
156
|
+
m_get_relevant_skills.success();
|
|
157
|
+
|
|
139
158
|
return relevantSkills.length > 0 ? relevantSkills : allSkills;
|
|
140
159
|
}
|
|
141
160
|
|
|
@@ -2,6 +2,10 @@ const McpConfigurator = require('./McpConfigurator');
|
|
|
2
2
|
const HookInstaller = require('./HookInstaller');
|
|
3
3
|
const VSCodeTaskConfigurator = require('./VSCodeTaskConfigurator');
|
|
4
4
|
|
|
5
|
+
const {
|
|
6
|
+
createMetricScope: createMetricScope
|
|
7
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
8
|
+
|
|
5
9
|
const COLORS = {
|
|
6
10
|
reset: '\x1b[0m',
|
|
7
11
|
green: '\x1b[32m',
|
|
@@ -11,6 +15,12 @@ const COLORS = {
|
|
|
11
15
|
|
|
12
16
|
class IdeIntegrationService {
|
|
13
17
|
constructor(targetRoot, hookSystemRoot, logger = null) {
|
|
18
|
+
const m_constructor = createMetricScope({
|
|
19
|
+
hook: 'ide_integration_service',
|
|
20
|
+
operation: 'constructor'
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
m_constructor.started();
|
|
14
24
|
this.targetRoot = targetRoot || process.cwd();
|
|
15
25
|
this.hookSystemRoot = hookSystemRoot;
|
|
16
26
|
this.logger = logger;
|
|
@@ -18,6 +28,7 @@ class IdeIntegrationService {
|
|
|
18
28
|
this.mcpConfigurator = new McpConfigurator(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
19
29
|
this.hookInstaller = new HookInstaller(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
20
30
|
this.vscodeConfigurator = new VSCodeTaskConfigurator(this.targetRoot, this.logger);
|
|
31
|
+
m_constructor.success();
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
installCursorHooks(platforms) {
|
|
@@ -8,6 +8,10 @@ const ConfigurationGeneratorService = require('./ConfigurationGeneratorService')
|
|
|
8
8
|
const IdeIntegrationService = require('./IdeIntegrationService');
|
|
9
9
|
const UnifiedLogger = require('../logging/UnifiedLogger');
|
|
10
10
|
|
|
11
|
+
const {
|
|
12
|
+
createMetricScope: createMetricScope
|
|
13
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
14
|
+
|
|
11
15
|
const COLORS = {
|
|
12
16
|
reset: '\x1b[0m',
|
|
13
17
|
blue: '\x1b[34m',
|
|
@@ -19,6 +23,12 @@ const COLORS = {
|
|
|
19
23
|
|
|
20
24
|
class InstallService {
|
|
21
25
|
constructor() {
|
|
26
|
+
const m_constructor = createMetricScope({
|
|
27
|
+
hook: 'install_service',
|
|
28
|
+
operation: 'constructor'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
m_constructor.started();
|
|
22
32
|
this.targetRoot = process.cwd();
|
|
23
33
|
// Assuming this script is located at scripts/hooks-system/application/services/installation/InstallService.js
|
|
24
34
|
this.hookSystemRoot = path.resolve(__dirname, '../../../');
|
|
@@ -30,7 +40,13 @@ class InstallService {
|
|
|
30
40
|
path.resolve(this.hookSystemRoot, '../package.json'),
|
|
31
41
|
path.resolve(this.hookSystemRoot, '../../package.json'),
|
|
32
42
|
(() => {
|
|
33
|
-
try {
|
|
43
|
+
try {
|
|
44
|
+
m_constructor.success();
|
|
45
|
+
return require.resolve('pumuki-ast-hooks/package.json');
|
|
46
|
+
} catch {
|
|
47
|
+
m_constructor.success();
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
34
50
|
})()
|
|
35
51
|
].filter(Boolean);
|
|
36
52
|
|
|
@@ -73,9 +89,16 @@ class InstallService {
|
|
|
73
89
|
this.fsInstaller = new FileSystemInstallerService(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
74
90
|
this.configGenerator = new ConfigurationGeneratorService(this.targetRoot, this.hookSystemRoot);
|
|
75
91
|
this.ideIntegration = new IdeIntegrationService(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
92
|
+
m_constructor.success();
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
async run() {
|
|
96
|
+
const m_run = createMetricScope({
|
|
97
|
+
hook: 'install_service',
|
|
98
|
+
operation: 'run'
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
m_run.started();
|
|
79
102
|
this.logger.info('INSTALLATION_STARTED', { targetRoot: this.targetRoot });
|
|
80
103
|
this.printHeader();
|
|
81
104
|
|
|
@@ -124,6 +147,7 @@ class InstallService {
|
|
|
124
147
|
|
|
125
148
|
this.logger.info('INSTALLATION_COMPLETED_SUCCESSFULLY');
|
|
126
149
|
this.printFooter();
|
|
150
|
+
m_run.success();
|
|
127
151
|
}
|
|
128
152
|
|
|
129
153
|
printHeader() {
|
|
@@ -3,7 +3,10 @@ const path = require('path');
|
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
const os = require('os');
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
createMetricScope: createMetricScope
|
|
9
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
7
10
|
|
|
8
11
|
const COLORS = {
|
|
9
12
|
reset: '\x1b[0m',
|
|
@@ -32,7 +35,7 @@ function computeRepoFingerprint(repoRoot) {
|
|
|
32
35
|
|
|
33
36
|
function computeServerIdForRepo(repoRoot) {
|
|
34
37
|
const legacyServerId = 'ast-intelligence-automation';
|
|
35
|
-
const forced = (env.
|
|
38
|
+
const forced = (process.env.MCP_SERVER_ID || '').trim();
|
|
36
39
|
if (forced.length > 0) return forced;
|
|
37
40
|
|
|
38
41
|
const repoName = path.basename(repoRoot || process.cwd());
|
|
@@ -43,12 +46,26 @@ function computeServerIdForRepo(repoRoot) {
|
|
|
43
46
|
|
|
44
47
|
class McpConfigurator {
|
|
45
48
|
constructor(targetRoot, hookSystemRoot, logger = null) {
|
|
49
|
+
const m_constructor = createMetricScope({
|
|
50
|
+
hook: 'mcp_configurator',
|
|
51
|
+
operation: 'constructor'
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
m_constructor.started();
|
|
46
55
|
this.targetRoot = targetRoot;
|
|
47
56
|
this.hookSystemRoot = hookSystemRoot;
|
|
48
57
|
this.logger = logger;
|
|
58
|
+
m_constructor.success();
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
getGlobalWindsurfConfigPath() {
|
|
62
|
+
const m_get_global_windsurf_config_path = createMetricScope({
|
|
63
|
+
hook: 'mcp_configurator',
|
|
64
|
+
operation: 'get_global_windsurf_config_path'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
m_get_global_windsurf_config_path.started();
|
|
68
|
+
m_get_global_windsurf_config_path.success();
|
|
52
69
|
return path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json');
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
const glob = require('glob');
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
createMetricScope: createMetricScope
|
|
5
|
+
} = require('../../../infrastructure/telemetry/metric-scope');
|
|
6
|
+
|
|
3
7
|
class PlatformDetectorService {
|
|
4
8
|
constructor(targetRoot) {
|
|
9
|
+
const m_constructor = createMetricScope({
|
|
10
|
+
hook: 'platform_detector_service',
|
|
11
|
+
operation: 'constructor'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
m_constructor.started();
|
|
5
15
|
this.targetRoot = targetRoot || process.cwd();
|
|
6
16
|
this.platforms = [];
|
|
17
|
+
m_constructor.success();
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
detect() {
|