pumuki-ast-hooks 5.5.14 → 5.5.15
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/package.json +1 -1
- package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +5 -0
- package/scripts/hooks-system/application/services/installation/InstallService.js +42 -0
- package/scripts/hooks-system/bin/evidence-guard +110 -0
- package/scripts/hooks-system/infrastructure/daemons/evidence-guard.js +155 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumuki-ast-hooks",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.15",
|
|
4
4
|
"description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js
CHANGED
|
@@ -110,6 +110,11 @@ class ConfigurationGeneratorService {
|
|
|
110
110
|
// Add helper scripts
|
|
111
111
|
packageJson.scripts['ast:refresh'] = 'node scripts/hooks-system/bin/update-evidence.sh';
|
|
112
112
|
packageJson.scripts['ast:audit'] = 'node scripts/hooks-system/infrastructure/ast/ast-intelligence.js';
|
|
113
|
+
packageJson.scripts['ast:guard:start'] = 'bash scripts/hooks-system/bin/evidence-guard start';
|
|
114
|
+
packageJson.scripts['ast:guard:stop'] = 'bash scripts/hooks-system/bin/evidence-guard stop';
|
|
115
|
+
packageJson.scripts['ast:guard:restart'] = 'bash scripts/hooks-system/bin/evidence-guard restart';
|
|
116
|
+
packageJson.scripts['ast:guard:status'] = 'bash scripts/hooks-system/bin/evidence-guard status';
|
|
117
|
+
packageJson.scripts['ast:guard:logs'] = 'bash scripts/hooks-system/bin/evidence-guard logs';
|
|
113
118
|
|
|
114
119
|
fs.writeFileSync(projectPackageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
115
120
|
this.logSuccess('npm scripts added');
|
|
@@ -123,10 +123,48 @@ class InstallService {
|
|
|
123
123
|
this.logStep('8/8', 'Adding npm scripts to package.json...');
|
|
124
124
|
this.configGenerator.addNpmScripts();
|
|
125
125
|
|
|
126
|
+
this.logStep('8.5/8', 'Starting evidence guard daemon...');
|
|
127
|
+
this.startEvidenceGuard();
|
|
128
|
+
|
|
126
129
|
this.logger.info('INSTALLATION_COMPLETED_SUCCESSFULLY');
|
|
127
130
|
this.printFooter();
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
startEvidenceGuard() {
|
|
134
|
+
const { spawn } = require('child_process');
|
|
135
|
+
const guardScript = path.join(this.targetRoot, 'scripts/hooks-system/bin/evidence-guard');
|
|
136
|
+
|
|
137
|
+
if (!fs.existsSync(guardScript)) {
|
|
138
|
+
this.logWarning('Evidence guard script not found, skipping daemon start');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const child = spawn('bash', [guardScript, 'start'], {
|
|
144
|
+
cwd: this.targetRoot,
|
|
145
|
+
stdio: 'pipe',
|
|
146
|
+
detached: false
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
let output = '';
|
|
150
|
+
child.stdout.on('data', (data) => { output += data.toString(); });
|
|
151
|
+
child.stderr.on('data', (data) => { output += data.toString(); });
|
|
152
|
+
|
|
153
|
+
child.on('close', (code) => {
|
|
154
|
+
if (code === 0) {
|
|
155
|
+
this.logSuccess('Evidence guard daemon started');
|
|
156
|
+
} else {
|
|
157
|
+
this.logWarning('Failed to start evidence guard daemon');
|
|
158
|
+
if (output) {
|
|
159
|
+
console.log(output);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
} catch (error) {
|
|
164
|
+
this.logWarning(`Failed to start evidence guard: ${error.message}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
130
168
|
printHeader() {
|
|
131
169
|
const versionPadded = `v${this.version}`.padStart(24).padEnd(48);
|
|
132
170
|
process.stdout.write(`${COLORS.blue}
|
|
@@ -141,6 +179,10 @@ ${COLORS.reset}\n`);
|
|
|
141
179
|
process.stdout.write(`
|
|
142
180
|
${COLORS.green}✨ Installation Complete! ✨${COLORS.reset}
|
|
143
181
|
|
|
182
|
+
${COLORS.cyan}Evidence Guard Daemon:${COLORS.reset}
|
|
183
|
+
- Auto-refresh is now running in background (every 180 seconds)
|
|
184
|
+
- Manage with: ${COLORS.yellow}npm run ast:guard:{start|stop|status|logs}${COLORS.reset}
|
|
185
|
+
|
|
144
186
|
${COLORS.cyan}Next Steps:${COLORS.reset}
|
|
145
187
|
1. Review generated configuration in ${COLORS.yellow}scripts/hooks-system/config/project.config.json${COLORS.reset}
|
|
146
188
|
2. Run ${COLORS.yellow}./manage-library.sh verify${COLORS.reset} to check installation
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
4
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
5
|
+
GUARD_SCRIPT="$SCRIPT_DIR/../infrastructure/daemons/evidence-guard.js"
|
|
6
|
+
PID_FILE="$PROJECT_ROOT/.evidence-guard.pid"
|
|
7
|
+
LOG_FILE="$PROJECT_ROOT/.evidence-guard.log"
|
|
8
|
+
|
|
9
|
+
command="${1:-status}"
|
|
10
|
+
|
|
11
|
+
case "$command" in
|
|
12
|
+
start)
|
|
13
|
+
if [ -f "$PID_FILE" ]; then
|
|
14
|
+
PID=$(cat "$PID_FILE")
|
|
15
|
+
if kill -0 "$PID" 2>/dev/null; then
|
|
16
|
+
echo "Evidence guard is already running (PID: $PID)"
|
|
17
|
+
exit 0
|
|
18
|
+
else
|
|
19
|
+
rm -f "$PID_FILE"
|
|
20
|
+
fi
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
echo "Starting evidence guard..."
|
|
24
|
+
nohup node "$GUARD_SCRIPT" > "$LOG_FILE" 2>&1 &
|
|
25
|
+
sleep 1
|
|
26
|
+
|
|
27
|
+
if [ -f "$PID_FILE" ]; then
|
|
28
|
+
PID=$(cat "$PID_FILE")
|
|
29
|
+
echo "Evidence guard started (PID: $PID)"
|
|
30
|
+
echo "Log file: $LOG_FILE"
|
|
31
|
+
else
|
|
32
|
+
echo "Failed to start evidence guard"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
;;
|
|
36
|
+
|
|
37
|
+
stop)
|
|
38
|
+
if [ ! -f "$PID_FILE" ]; then
|
|
39
|
+
echo "Evidence guard is not running"
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
PID=$(cat "$PID_FILE")
|
|
44
|
+
if kill -0 "$PID" 2>/dev/null; then
|
|
45
|
+
echo "Stopping evidence guard (PID: $PID)..."
|
|
46
|
+
kill "$PID"
|
|
47
|
+
sleep 1
|
|
48
|
+
|
|
49
|
+
if kill -0 "$PID" 2>/dev/null; then
|
|
50
|
+
echo "Force killing evidence guard..."
|
|
51
|
+
kill -9 "$PID"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
rm -f "$PID_FILE"
|
|
55
|
+
echo "Evidence guard stopped"
|
|
56
|
+
else
|
|
57
|
+
echo "Evidence guard is not running (stale PID file)"
|
|
58
|
+
rm -f "$PID_FILE"
|
|
59
|
+
fi
|
|
60
|
+
;;
|
|
61
|
+
|
|
62
|
+
restart)
|
|
63
|
+
"$0" stop
|
|
64
|
+
sleep 1
|
|
65
|
+
"$0" start
|
|
66
|
+
;;
|
|
67
|
+
|
|
68
|
+
status)
|
|
69
|
+
if [ ! -f "$PID_FILE" ]; then
|
|
70
|
+
echo "Evidence guard is not running"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
PID=$(cat "$PID_FILE")
|
|
75
|
+
if kill -0 "$PID" 2>/dev/null; then
|
|
76
|
+
echo "Evidence guard is running (PID: $PID)"
|
|
77
|
+
if [ -f "$LOG_FILE" ]; then
|
|
78
|
+
echo ""
|
|
79
|
+
echo "Recent activity:"
|
|
80
|
+
tail -n 5 "$LOG_FILE"
|
|
81
|
+
fi
|
|
82
|
+
exit 0
|
|
83
|
+
else
|
|
84
|
+
echo "Evidence guard is not running (stale PID file)"
|
|
85
|
+
rm -f "$PID_FILE"
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
;;
|
|
89
|
+
|
|
90
|
+
logs)
|
|
91
|
+
if [ -f "$LOG_FILE" ]; then
|
|
92
|
+
tail -f "$LOG_FILE"
|
|
93
|
+
else
|
|
94
|
+
echo "No log file found"
|
|
95
|
+
exit 1
|
|
96
|
+
fi
|
|
97
|
+
;;
|
|
98
|
+
|
|
99
|
+
*)
|
|
100
|
+
echo "Usage: $0 {start|stop|restart|status|logs}"
|
|
101
|
+
echo ""
|
|
102
|
+
echo "Commands:"
|
|
103
|
+
echo " start - Start the evidence guard daemon"
|
|
104
|
+
echo " stop - Stop the evidence guard daemon"
|
|
105
|
+
echo " restart - Restart the evidence guard daemon"
|
|
106
|
+
echo " status - Check if the daemon is running"
|
|
107
|
+
echo " logs - Tail the daemon logs"
|
|
108
|
+
exit 1
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
const REFRESH_INTERVAL_MS = 180000;
|
|
8
|
+
const EVIDENCE_FILE = '.AI_EVIDENCE.json';
|
|
9
|
+
const PID_FILE = '.evidence-guard.pid';
|
|
10
|
+
|
|
11
|
+
class EvidenceGuard {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.projectRoot = this.findProjectRoot();
|
|
14
|
+
this.pidFile = path.join(this.projectRoot, PID_FILE);
|
|
15
|
+
this.evidenceFile = path.join(this.projectRoot, EVIDENCE_FILE);
|
|
16
|
+
this.updateScript = this.findUpdateScript();
|
|
17
|
+
this.isRunning = false;
|
|
18
|
+
this.intervalId = null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
findProjectRoot() {
|
|
22
|
+
let currentDir = process.cwd();
|
|
23
|
+
while (currentDir !== '/') {
|
|
24
|
+
if (fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
25
|
+
return currentDir;
|
|
26
|
+
}
|
|
27
|
+
currentDir = path.dirname(currentDir);
|
|
28
|
+
}
|
|
29
|
+
return process.cwd();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
findUpdateScript() {
|
|
33
|
+
const possiblePaths = [
|
|
34
|
+
path.join(this.projectRoot, 'scripts/hooks-system/bin/update-evidence.sh'),
|
|
35
|
+
path.join(this.projectRoot, 'node_modules/pumuki-ast-hooks/scripts/hooks-system/bin/update-evidence.sh'),
|
|
36
|
+
path.join(__dirname, '../../bin/update-evidence.sh')
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
for (const scriptPath of possiblePaths) {
|
|
40
|
+
if (fs.existsSync(scriptPath)) {
|
|
41
|
+
return scriptPath;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error('update-evidence.sh not found');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
writePidFile() {
|
|
49
|
+
try {
|
|
50
|
+
fs.writeFileSync(this.pidFile, process.pid.toString(), 'utf8');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('[EvidenceGuard] Failed to write PID file:', error.message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
removePidFile() {
|
|
57
|
+
try {
|
|
58
|
+
if (fs.existsSync(this.pidFile)) {
|
|
59
|
+
fs.unlinkSync(this.pidFile);
|
|
60
|
+
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('[EvidenceGuard] Failed to remove PID file:', error.message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
isAlreadyRunning() {
|
|
67
|
+
if (!fs.existsSync(this.pidFile)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const pid = parseInt(fs.readFileSync(this.pidFile, 'utf8').trim(), 10);
|
|
73
|
+
process.kill(pid, 0);
|
|
74
|
+
return true;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
this.removePidFile();
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async refreshEvidence() {
|
|
82
|
+
return new Promise((resolve) => {
|
|
83
|
+
const child = spawn('bash', [this.updateScript, '--auto'], {
|
|
84
|
+
cwd: this.projectRoot,
|
|
85
|
+
stdio: 'ignore',
|
|
86
|
+
detached: false
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
child.on('close', (code) => {
|
|
90
|
+
if (code === 0) {
|
|
91
|
+
console.log(`[EvidenceGuard] Evidence refreshed at ${new Date().toISOString()}`);
|
|
92
|
+
} else {
|
|
93
|
+
console.error(`[EvidenceGuard] Refresh failed with code ${code}`);
|
|
94
|
+
}
|
|
95
|
+
resolve();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
child.on('error', (error) => {
|
|
99
|
+
console.error('[EvidenceGuard] Refresh error:', error.message);
|
|
100
|
+
resolve();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async start() {
|
|
106
|
+
if (this.isAlreadyRunning()) {
|
|
107
|
+
console.log('[EvidenceGuard] Already running');
|
|
108
|
+
process.exit(0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.writePidFile();
|
|
112
|
+
this.isRunning = true;
|
|
113
|
+
|
|
114
|
+
console.log('[EvidenceGuard] Started');
|
|
115
|
+
console.log(`[EvidenceGuard] Project root: ${this.projectRoot}`);
|
|
116
|
+
console.log(`[EvidenceGuard] Refresh interval: ${REFRESH_INTERVAL_MS / 1000}s`);
|
|
117
|
+
|
|
118
|
+
await this.refreshEvidence();
|
|
119
|
+
|
|
120
|
+
this.intervalId = setInterval(async () => {
|
|
121
|
+
if (this.isRunning) {
|
|
122
|
+
await this.refreshEvidence();
|
|
123
|
+
}
|
|
124
|
+
}, REFRESH_INTERVAL_MS);
|
|
125
|
+
|
|
126
|
+
process.on('SIGTERM', () => this.stop());
|
|
127
|
+
process.on('SIGINT', () => this.stop());
|
|
128
|
+
process.on('exit', () => this.cleanup());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
stop() {
|
|
132
|
+
console.log('[EvidenceGuard] Stopping...');
|
|
133
|
+
this.isRunning = false;
|
|
134
|
+
if (this.intervalId) {
|
|
135
|
+
clearInterval(this.intervalId);
|
|
136
|
+
this.intervalId = null;
|
|
137
|
+
}
|
|
138
|
+
this.cleanup();
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
cleanup() {
|
|
143
|
+
this.removePidFile();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (require.main === module) {
|
|
148
|
+
const guard = new EvidenceGuard();
|
|
149
|
+
guard.start().catch((error) => {
|
|
150
|
+
console.error('[EvidenceGuard] Fatal error:', error);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
module.exports = EvidenceGuard;
|