pumuki-ast-hooks 6.1.8 → 6.1.10
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/bin/uninstall.js +58 -2
- package/package.json +1 -1
- package/scripts/hooks-system/.audit-reports/auto-recovery.log +1 -0
- package/scripts/hooks-system/.audit-reports/install-wizard.log +4 -0
- package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +24 -0
- package/scripts/hooks-system/application/services/installation/InstallManifestService.js +76 -0
- package/scripts/hooks-system/application/services/installation/InstallService.js +50 -0
- package/scripts/hooks-system/application/services/installation/__tests__/InstallManifestService.spec.js +117 -0
- package/scripts/hooks-system/application/services/installation/__tests__/McpConfigurator.mcp.spec.js +11 -2
- package/scripts/hooks-system/application/services/installation/mcp/McpServerConfigBuilder.js +21 -0
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log +3 -0
package/bin/uninstall.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
|
+
const MANIFEST_RELATIVE_PATH = '.ast-intelligence/install-manifest.json';
|
|
7
|
+
|
|
6
8
|
function findProjectRoot(startDir) {
|
|
7
9
|
let current = startDir;
|
|
8
10
|
while (current !== '/') {
|
|
@@ -14,6 +16,45 @@ function findProjectRoot(startDir) {
|
|
|
14
16
|
return startDir;
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
function loadManifest(projectRoot) {
|
|
20
|
+
const manifestPath = path.join(projectRoot, MANIFEST_RELATIVE_PATH);
|
|
21
|
+
if (!fs.existsSync(manifestPath)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function buildUninstallPlanFromManifest(projectRoot, manifest) {
|
|
32
|
+
const paths = [];
|
|
33
|
+
|
|
34
|
+
for (const relPath of manifest.createdFiles || []) {
|
|
35
|
+
const fullPath = path.join(projectRoot, relPath);
|
|
36
|
+
if (fs.existsSync(fullPath)) {
|
|
37
|
+
paths.push(fullPath);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for (const relPath of manifest.createdDirs || []) {
|
|
42
|
+
const fullPath = path.join(projectRoot, relPath);
|
|
43
|
+
if (fs.existsSync(fullPath)) {
|
|
44
|
+
paths.push(fullPath);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
paths.push(path.join(projectRoot, MANIFEST_RELATIVE_PATH));
|
|
49
|
+
|
|
50
|
+
const unique = Array.from(new Set(paths.filter(p => fs.existsSync(p))));
|
|
51
|
+
return {
|
|
52
|
+
projectRoot,
|
|
53
|
+
paths: unique.sort(),
|
|
54
|
+
fromManifest: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
17
58
|
function isPumukiHookContent(content) {
|
|
18
59
|
if (!content) return false;
|
|
19
60
|
const text = String(content);
|
|
@@ -146,11 +187,18 @@ function printUsage() {
|
|
|
146
187
|
}
|
|
147
188
|
|
|
148
189
|
function planUninstall({ projectRoot }) {
|
|
190
|
+
const manifest = loadManifest(projectRoot);
|
|
191
|
+
if (manifest) {
|
|
192
|
+
return buildUninstallPlanFromManifest(projectRoot, manifest);
|
|
193
|
+
}
|
|
149
194
|
return buildUninstallPlan(projectRoot);
|
|
150
195
|
}
|
|
151
196
|
|
|
152
197
|
function applyUninstall({ projectRoot, apply, yes }) {
|
|
153
|
-
const
|
|
198
|
+
const manifest = loadManifest(projectRoot);
|
|
199
|
+
const plan = manifest
|
|
200
|
+
? buildUninstallPlanFromManifest(projectRoot, manifest)
|
|
201
|
+
: buildUninstallPlan(projectRoot);
|
|
154
202
|
|
|
155
203
|
if (!apply) {
|
|
156
204
|
return { applied: false, plan };
|
|
@@ -182,10 +230,18 @@ function main() {
|
|
|
182
230
|
const rootFromCwd = findProjectRoot(cwd);
|
|
183
231
|
const projectRoot = options.projectRootArg ? path.resolve(options.projectRootArg) : rootFromCwd;
|
|
184
232
|
|
|
185
|
-
const
|
|
233
|
+
const manifest = loadManifest(projectRoot);
|
|
234
|
+
const plan = manifest
|
|
235
|
+
? buildUninstallPlanFromManifest(projectRoot, manifest)
|
|
236
|
+
: buildUninstallPlan(projectRoot);
|
|
186
237
|
|
|
187
238
|
if (options.dryRun) {
|
|
188
239
|
process.stdout.write(`Project root: ${projectRoot}\n`);
|
|
240
|
+
if (plan.fromManifest) {
|
|
241
|
+
process.stdout.write('Using install manifest for precise cleanup.\n');
|
|
242
|
+
} else {
|
|
243
|
+
process.stdout.write('No manifest found, using heuristic detection.\n');
|
|
244
|
+
}
|
|
189
245
|
process.stdout.write('Planned removals:\n');
|
|
190
246
|
for (const p of plan.paths) {
|
|
191
247
|
process.stdout.write(`- ${p}\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumuki-ast-hooks",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.10",
|
|
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": {
|
|
@@ -40,3 +40,4 @@
|
|
|
40
40
|
{"timestamp":"2026-01-15T07:43:05.309Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
|
|
41
41
|
{"timestamp":"2026-01-15T07:49:00.777Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
|
|
42
42
|
{"timestamp":"2026-01-15T09:57:40.478Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
|
|
43
|
+
{"timestamp":"2026-01-15T14:53:23.342Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
|
|
@@ -170,3 +170,7 @@
|
|
|
170
170
|
{"timestamp":"2026-01-15T09:57:40.597Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_CONFIG_EXISTS","data":{"configPath":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.hook-system/config.json"},"context":{}}
|
|
171
171
|
{"timestamp":"2026-01-15T09:57:40.598Z","level":"error","component":"InstallWizard","event":"INSTALL_WIZARD_SYMLINK_FAILED","data":{"error":"EEXIST: file already exists, symlink '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/scripts/hooks-system/bin/guard-supervisor.js' -> '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.git/hooks/guard-supervisor'"},"context":{}}
|
|
172
172
|
{"timestamp":"2026-01-15T09:57:40.598Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
|
|
173
|
+
{"timestamp":"2026-01-15T14:53:23.406Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_START","data":{"repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"},"context":{}}
|
|
174
|
+
{"timestamp":"2026-01-15T14:53:23.414Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_CONFIG_EXISTS","data":{"configPath":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.hook-system/config.json"},"context":{}}
|
|
175
|
+
{"timestamp":"2026-01-15T14:53:23.415Z","level":"error","component":"InstallWizard","event":"INSTALL_WIZARD_SYMLINK_FAILED","data":{"error":"EEXIST: file already exists, symlink '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/scripts/hooks-system/bin/guard-supervisor.js' -> '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.git/hooks/guard-supervisor'"},"context":{}}
|
|
176
|
+
{"timestamp":"2026-01-15T14:53:23.415Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
|
|
@@ -1274,3 +1274,27 @@
|
|
|
1274
1274
|
{"timestamp":1768471060477,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1275
1275
|
{"timestamp":1768471060477,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1276
1276
|
{"timestamp":1768471060477,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1277
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1278
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1279
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1280
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1281
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1282
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1283
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1284
|
+
{"timestamp":1768488803340,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1285
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1286
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1287
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1288
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1289
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1290
|
+
{"timestamp":1768488803341,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1291
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1292
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1293
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1294
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1295
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1296
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1297
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1298
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1299
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1300
|
+
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const MANIFEST_RELATIVE_PATH = '.ast-intelligence/install-manifest.json';
|
|
5
|
+
|
|
6
|
+
class InstallManifestService {
|
|
7
|
+
constructor(projectRoot, version = 'unknown') {
|
|
8
|
+
this.projectRoot = projectRoot;
|
|
9
|
+
this.version = version;
|
|
10
|
+
this.createdFiles = [];
|
|
11
|
+
this.modifiedFiles = [];
|
|
12
|
+
this.createdDirs = [];
|
|
13
|
+
this.installedAt = new Date().toISOString();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
recordCreatedFile(relativePath) {
|
|
17
|
+
if (!this.createdFiles.includes(relativePath)) {
|
|
18
|
+
this.createdFiles.push(relativePath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
recordModifiedFile(relativePath, backupPath) {
|
|
23
|
+
const existing = this.modifiedFiles.find(m => m.path === relativePath);
|
|
24
|
+
if (!existing) {
|
|
25
|
+
this.modifiedFiles.push({ path: relativePath, backup: backupPath });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
recordCreatedDir(relativePath) {
|
|
30
|
+
if (!this.createdDirs.includes(relativePath)) {
|
|
31
|
+
this.createdDirs.push(relativePath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getManifest() {
|
|
36
|
+
return {
|
|
37
|
+
version: this.version,
|
|
38
|
+
installedAt: this.installedAt,
|
|
39
|
+
createdFiles: [...this.createdFiles],
|
|
40
|
+
modifiedFiles: [...this.modifiedFiles],
|
|
41
|
+
createdDirs: [...this.createdDirs]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
save() {
|
|
46
|
+
const manifestPath = path.join(this.projectRoot, MANIFEST_RELATIVE_PATH);
|
|
47
|
+
const manifestDir = path.dirname(manifestPath);
|
|
48
|
+
|
|
49
|
+
if (!fs.existsSync(manifestDir)) {
|
|
50
|
+
fs.mkdirSync(manifestDir, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fs.writeFileSync(manifestPath, JSON.stringify(this.getManifest(), null, 2));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static load(projectRoot) {
|
|
57
|
+
const manifestPath = path.join(projectRoot, MANIFEST_RELATIVE_PATH);
|
|
58
|
+
|
|
59
|
+
if (!fs.existsSync(manifestPath)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const content = fs.readFileSync(manifestPath, 'utf8');
|
|
65
|
+
return JSON.parse(content);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static getManifestPath(projectRoot) {
|
|
72
|
+
return path.join(projectRoot, MANIFEST_RELATIVE_PATH);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = InstallManifestService;
|
|
@@ -8,6 +8,7 @@ const FileSystemInstallerService = require('./FileSystemInstallerService');
|
|
|
8
8
|
const ConfigurationGeneratorService = require('./ConfigurationGeneratorService');
|
|
9
9
|
const IdeIntegrationService = require('./IdeIntegrationService');
|
|
10
10
|
const CriticalDependenciesService = require('./CriticalDependenciesService');
|
|
11
|
+
const InstallManifestService = require('./InstallManifestService');
|
|
11
12
|
const UnifiedLogger = require('../logging/UnifiedLogger');
|
|
12
13
|
|
|
13
14
|
const COLORS = {
|
|
@@ -75,6 +76,7 @@ class InstallService {
|
|
|
75
76
|
this.fsInstaller = new FileSystemInstallerService(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
76
77
|
this.configGenerator = new ConfigurationGeneratorService(this.targetRoot, this.hookSystemRoot);
|
|
77
78
|
this.ideIntegration = new IdeIntegrationService(this.targetRoot, this.hookSystemRoot, this.logger);
|
|
79
|
+
this.manifest = new InstallManifestService(this.targetRoot, this.version);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
getInstallMode() {
|
|
@@ -156,10 +158,58 @@ class InstallService {
|
|
|
156
158
|
this.logStep('8.5/8', 'Starting evidence guard daemon...');
|
|
157
159
|
this.startEvidenceGuard();
|
|
158
160
|
|
|
161
|
+
this.logStep('8.75/8', 'Saving installation manifest...');
|
|
162
|
+
this.saveInstallManifest(installMode);
|
|
163
|
+
|
|
159
164
|
this.logger.info('INSTALLATION_COMPLETED_SUCCESSFULLY');
|
|
160
165
|
this.printFooter();
|
|
161
166
|
}
|
|
162
167
|
|
|
168
|
+
saveInstallManifest(installMode) {
|
|
169
|
+
this.manifest.recordCreatedDir('.ast-intelligence');
|
|
170
|
+
this.manifest.recordCreatedFile('.AI_EVIDENCE.json');
|
|
171
|
+
this.manifest.recordCreatedFile('.evidence-guard.pid');
|
|
172
|
+
this.manifest.recordCreatedFile('.evidence-guard.log');
|
|
173
|
+
|
|
174
|
+
if (installMode === 'vendored') {
|
|
175
|
+
this.manifest.recordCreatedDir('scripts/hooks-system');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const cursorMcp = path.join(this.targetRoot, '.cursor', 'mcp.json');
|
|
179
|
+
const windsurfMcp = path.join(this.targetRoot, '.windsurf', 'mcp.json');
|
|
180
|
+
if (fs.existsSync(cursorMcp)) {
|
|
181
|
+
this.manifest.recordCreatedDir('.cursor');
|
|
182
|
+
this.manifest.recordModifiedFile('.cursor/mcp.json', null);
|
|
183
|
+
}
|
|
184
|
+
if (fs.existsSync(windsurfMcp)) {
|
|
185
|
+
this.manifest.recordCreatedDir('.windsurf');
|
|
186
|
+
this.manifest.recordModifiedFile('.windsurf/mcp.json', null);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const vscodeDir = path.join(this.targetRoot, '.vscode');
|
|
190
|
+
if (fs.existsSync(vscodeDir)) {
|
|
191
|
+
this.manifest.recordCreatedDir('.vscode');
|
|
192
|
+
this.manifest.recordModifiedFile('.vscode/tasks.json', null);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const gitHooksDir = path.join(this.targetRoot, '.git', 'hooks');
|
|
196
|
+
if (fs.existsSync(path.join(gitHooksDir, 'pre-commit'))) {
|
|
197
|
+
this.manifest.recordCreatedFile('.git/hooks/pre-commit');
|
|
198
|
+
}
|
|
199
|
+
if (fs.existsSync(path.join(gitHooksDir, 'pre-push'))) {
|
|
200
|
+
this.manifest.recordCreatedFile('.git/hooks/pre-push');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.manifest.recordModifiedFile('package.json', null);
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
this.manifest.save();
|
|
207
|
+
this.logSuccess('Installation manifest saved');
|
|
208
|
+
} catch (error) {
|
|
209
|
+
this.logWarning(`Failed to save manifest: ${error.message}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
163
213
|
startEvidenceGuard() {
|
|
164
214
|
const { spawn } = require('child_process');
|
|
165
215
|
const candidates = [
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
const InstallManifestService = require('../InstallManifestService');
|
|
6
|
+
|
|
7
|
+
function makeSUT() {
|
|
8
|
+
const projectRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pumuki-manifest-test-'));
|
|
9
|
+
const manifestPath = path.join(projectRoot, '.ast-intelligence', 'install-manifest.json');
|
|
10
|
+
const sut = new InstallManifestService(projectRoot);
|
|
11
|
+
return { sut, projectRoot, manifestPath };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function cleanupSUT({ projectRoot }) {
|
|
15
|
+
fs.rmSync(projectRoot, { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('InstallManifestService', () => {
|
|
19
|
+
describe('recordCreatedFile', () => {
|
|
20
|
+
it('should add file path to manifest', () => {
|
|
21
|
+
const { sut, projectRoot, manifestPath } = makeSUT();
|
|
22
|
+
|
|
23
|
+
sut.recordCreatedFile('.ast-intelligence/skills/SKILL.md');
|
|
24
|
+
sut.save();
|
|
25
|
+
|
|
26
|
+
expect(fs.existsSync(manifestPath)).toBe(true);
|
|
27
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
28
|
+
expect(manifest.createdFiles).toContain('.ast-intelligence/skills/SKILL.md');
|
|
29
|
+
|
|
30
|
+
cleanupSUT({ projectRoot });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('recordModifiedFile', () => {
|
|
35
|
+
it('should add modified file with backup path to manifest', () => {
|
|
36
|
+
const { sut, projectRoot, manifestPath } = makeSUT();
|
|
37
|
+
|
|
38
|
+
sut.recordModifiedFile('package.json', '_package.json.bak');
|
|
39
|
+
sut.save();
|
|
40
|
+
|
|
41
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
42
|
+
expect(manifest.modifiedFiles).toEqual(
|
|
43
|
+
expect.arrayContaining([
|
|
44
|
+
expect.objectContaining({
|
|
45
|
+
path: 'package.json',
|
|
46
|
+
backup: '_package.json.bak'
|
|
47
|
+
})
|
|
48
|
+
])
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
cleanupSUT({ projectRoot });
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('recordCreatedDir', () => {
|
|
56
|
+
it('should add directory path to manifest', () => {
|
|
57
|
+
const { sut, projectRoot, manifestPath } = makeSUT();
|
|
58
|
+
|
|
59
|
+
sut.recordCreatedDir('.ast-intelligence');
|
|
60
|
+
sut.save();
|
|
61
|
+
|
|
62
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
63
|
+
expect(manifest.createdDirs).toContain('.ast-intelligence');
|
|
64
|
+
|
|
65
|
+
cleanupSUT({ projectRoot });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('getManifest', () => {
|
|
70
|
+
it('should return manifest structure with metadata', () => {
|
|
71
|
+
const { sut, projectRoot } = makeSUT();
|
|
72
|
+
|
|
73
|
+
sut.recordCreatedFile('.AI_EVIDENCE.json');
|
|
74
|
+
const manifest = sut.getManifest();
|
|
75
|
+
|
|
76
|
+
expect(manifest).toHaveProperty('version');
|
|
77
|
+
expect(manifest).toHaveProperty('installedAt');
|
|
78
|
+
expect(manifest).toHaveProperty('createdFiles');
|
|
79
|
+
expect(manifest).toHaveProperty('modifiedFiles');
|
|
80
|
+
expect(manifest).toHaveProperty('createdDirs');
|
|
81
|
+
|
|
82
|
+
cleanupSUT({ projectRoot });
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('load', () => {
|
|
87
|
+
it('should load existing manifest from disk', () => {
|
|
88
|
+
const { sut, projectRoot, manifestPath } = makeSUT();
|
|
89
|
+
|
|
90
|
+
fs.mkdirSync(path.dirname(manifestPath), { recursive: true });
|
|
91
|
+
fs.writeFileSync(manifestPath, JSON.stringify({
|
|
92
|
+
version: '6.1.8',
|
|
93
|
+
installedAt: '2026-01-15T00:00:00.000Z',
|
|
94
|
+
createdFiles: ['.AI_EVIDENCE.json'],
|
|
95
|
+
modifiedFiles: [],
|
|
96
|
+
createdDirs: ['.ast-intelligence']
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
const loaded = InstallManifestService.load(projectRoot);
|
|
100
|
+
|
|
101
|
+
expect(loaded.createdFiles).toContain('.AI_EVIDENCE.json');
|
|
102
|
+
expect(loaded.createdDirs).toContain('.ast-intelligence');
|
|
103
|
+
|
|
104
|
+
cleanupSUT({ projectRoot });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should return null if manifest does not exist', () => {
|
|
108
|
+
const { sut, projectRoot } = makeSUT();
|
|
109
|
+
|
|
110
|
+
const loaded = InstallManifestService.load(projectRoot);
|
|
111
|
+
|
|
112
|
+
expect(loaded).toBeNull();
|
|
113
|
+
|
|
114
|
+
cleanupSUT({ projectRoot });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
package/scripts/hooks-system/application/services/installation/__tests__/McpConfigurator.mcp.spec.js
CHANGED
|
@@ -49,8 +49,14 @@ describe('MCP installer (project-scoped)', () => {
|
|
|
49
49
|
expect(cursorServers.some(id => id.startsWith('ast-intelligence-automation-'))).toBe(true);
|
|
50
50
|
expect(cursorServers.some(id => id.startsWith('ai-evidence-watcher-'))).toBe(true);
|
|
51
51
|
|
|
52
|
+
expect(cursorServers).toContain('ast-intelligence-automation-hooks');
|
|
53
|
+
expect(cursorServers).toContain('ai-evidence-watcher-hooks');
|
|
54
|
+
|
|
52
55
|
expect(windsurfServers.some(id => id.startsWith('ast-intelligence-automation-'))).toBe(true);
|
|
53
56
|
expect(windsurfServers.some(id => id.startsWith('ai-evidence-watcher-'))).toBe(true);
|
|
57
|
+
|
|
58
|
+
expect(windsurfServers).toContain('ast-intelligence-automation-hooks');
|
|
59
|
+
expect(windsurfServers).toContain('ai-evidence-watcher-hooks');
|
|
54
60
|
});
|
|
55
61
|
|
|
56
62
|
it('should be idempotent and not duplicate servers across runs', () => {
|
|
@@ -65,10 +71,13 @@ describe('MCP installer (project-scoped)', () => {
|
|
|
65
71
|
const cursor = JSON.parse(fs.readFileSync(cursorPath, 'utf8'));
|
|
66
72
|
|
|
67
73
|
const ids = Object.keys(cursor.mcpServers || {});
|
|
68
|
-
const automation = ids.filter(id => id.startsWith('ast-intelligence-automation-'));
|
|
69
|
-
const evidence = ids.filter(id => id.startsWith('ai-evidence-watcher-'));
|
|
74
|
+
const automation = ids.filter(id => id.startsWith('ast-intelligence-automation-') && id !== 'ast-intelligence-automation-hooks');
|
|
75
|
+
const evidence = ids.filter(id => id.startsWith('ai-evidence-watcher-') && id !== 'ai-evidence-watcher-hooks');
|
|
70
76
|
|
|
71
77
|
expect(automation.length).toBe(1);
|
|
72
78
|
expect(evidence.length).toBe(1);
|
|
79
|
+
|
|
80
|
+
expect(ids.filter(id => id === 'ast-intelligence-automation-hooks').length).toBe(1);
|
|
81
|
+
expect(ids.filter(id => id === 'ai-evidence-watcher-hooks').length).toBe(1);
|
|
73
82
|
});
|
|
74
83
|
});
|
package/scripts/hooks-system/application/services/installation/mcp/McpServerConfigBuilder.js
CHANGED
|
@@ -27,6 +27,9 @@ class McpServerConfigBuilder {
|
|
|
27
27
|
const evidenceEntrypoint = this.resolveEvidenceWatcherEntrypoint();
|
|
28
28
|
const nodePath = this.resolveNodeBinary();
|
|
29
29
|
|
|
30
|
+
const stableAutomationAlias = 'ast-intelligence-automation-hooks';
|
|
31
|
+
const stableEvidenceAlias = 'ai-evidence-watcher-hooks';
|
|
32
|
+
|
|
30
33
|
const mcpConfig = {
|
|
31
34
|
mcpServers: {
|
|
32
35
|
[serverId]: {
|
|
@@ -46,6 +49,24 @@ class McpServerConfigBuilder {
|
|
|
46
49
|
REPO_ROOT: this.targetRoot,
|
|
47
50
|
MCP_MAC_NOTIFICATIONS: 'true'
|
|
48
51
|
}
|
|
52
|
+
},
|
|
53
|
+
[stableAutomationAlias]: {
|
|
54
|
+
command: nodePath,
|
|
55
|
+
args: [entrypoint],
|
|
56
|
+
env: {
|
|
57
|
+
REPO_ROOT: this.targetRoot,
|
|
58
|
+
AUTO_COMMIT_ENABLED: 'false',
|
|
59
|
+
AUTO_PUSH_ENABLED: 'false',
|
|
60
|
+
AUTO_PR_ENABLED: 'false'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[stableEvidenceAlias]: {
|
|
64
|
+
command: nodePath,
|
|
65
|
+
args: [evidenceEntrypoint],
|
|
66
|
+
env: {
|
|
67
|
+
REPO_ROOT: this.targetRoot,
|
|
68
|
+
MCP_MAC_NOTIFICATIONS: 'true'
|
|
69
|
+
}
|
|
49
70
|
}
|
|
50
71
|
}
|
|
51
72
|
};
|
package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log
CHANGED
|
@@ -124,3 +124,6 @@
|
|
|
124
124
|
{"timestamp":"2026-01-15T09:57:43.821Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":10,"tokensUsed":100000,"maxTokens":1000000,"source":"realtime","stale":false},"context":{"message":"Result level=ok percent=10% used=100000/1000000 source=realtime"}}
|
|
125
125
|
{"timestamp":"2026-01-15T09:57:43.823Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"warning","percentUsed":91,"tokensUsed":910000,"maxTokens":1000000,"source":"fallback","stale":false},"context":{"message":"Result level=warning percent=91% used=910000/1000000 source=fallback"}}
|
|
126
126
|
{"timestamp":"2026-01-15T09:57:43.823Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"critical","percentUsed":98,"tokensUsed":980000,"maxTokens":1000000,"source":"realtime","stale":true},"context":{"message":"Result level=critical percent=98% used=980000/1000000 source=realtime (stale)"}}
|
|
127
|
+
{"timestamp":"2026-01-15T14:53:25.770Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":10,"tokensUsed":100000,"maxTokens":1000000,"source":"realtime","stale":false},"context":{"message":"Result level=ok percent=10% used=100000/1000000 source=realtime"}}
|
|
128
|
+
{"timestamp":"2026-01-15T14:53:25.772Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"warning","percentUsed":91,"tokensUsed":910000,"maxTokens":1000000,"source":"fallback","stale":false},"context":{"message":"Result level=warning percent=91% used=910000/1000000 source=fallback"}}
|
|
129
|
+
{"timestamp":"2026-01-15T14:53:25.772Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"critical","percentUsed":98,"tokensUsed":980000,"maxTokens":1000000,"source":"realtime","stale":true},"context":{"message":"Result level=critical percent=98% used=980000/1000000 source=realtime (stale)"}}
|