pumuki-ast-hooks 6.1.7 → 6.1.9

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 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 plan = buildUninstallPlan(projectRoot);
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 plan = buildUninstallPlan(projectRoot);
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.7",
3
+ "version": "6.1.9",
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": {
@@ -39,3 +39,5 @@
39
39
  {"timestamp":"2026-01-14T22:23:58.130Z","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":{}}
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
+ {"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":{}}
@@ -166,3 +166,11 @@
166
166
  {"timestamp":"2026-01-15T07:49:00.931Z","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":{}}
167
167
  {"timestamp":"2026-01-15T07:49:00.931Z","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":{}}
168
168
  {"timestamp":"2026-01-15T07:49:00.931Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
169
+ {"timestamp":"2026-01-15T09:57:40.584Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_START","data":{"repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"},"context":{}}
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
+ {"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
+ {"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":{}}
@@ -1250,3 +1250,51 @@
1250
1250
  {"timestamp":1768463340777,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1251
1251
  {"timestamp":1768463340777,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1252
1252
  {"timestamp":1768463340777,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1253
+ {"timestamp":1768471060475,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1254
+ {"timestamp":1768471060475,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1255
+ {"timestamp":1768471060475,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1256
+ {"timestamp":1768471060475,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1257
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1258
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1259
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1260
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1261
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1262
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1263
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1264
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1265
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1266
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1267
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1268
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1269
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1270
+ {"timestamp":1768471060476,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1271
+ {"timestamp":1768471060477,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
1272
+ {"timestamp":1768471060477,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1273
+ {"timestamp":1768471060477,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
1274
+ {"timestamp":1768471060477,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
1275
+ {"timestamp":1768471060477,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
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"}
@@ -118,15 +118,15 @@ class ConfigurationGeneratorService {
118
118
  ? 'scripts/hooks-system'
119
119
  : 'node_modules/pumuki-ast-hooks/scripts/hooks-system';
120
120
 
121
- packageJson.scripts['ast:refresh'] = `node ${base}/bin/update-evidence.sh`;
122
- packageJson.scripts['ast:audit'] = `node ${base}/infrastructure/ast/ast-intelligence.js`;
123
- packageJson.scripts['ast:guard:start'] = `bash ${base}/bin/evidence-guard start`;
124
- packageJson.scripts['ast:guard:stop'] = `bash ${base}/bin/evidence-guard stop`;
125
- packageJson.scripts['ast:guard:restart'] = `bash ${base}/bin/evidence-guard restart`;
126
- packageJson.scripts['ast:guard:status'] = `bash ${base}/bin/evidence-guard status`;
127
- packageJson.scripts['ast:guard:logs'] = `bash ${base}/bin/evidence-guard logs`;
128
- packageJson.scripts['ast:check-version'] = `node ${base}/bin/check-version.js`;
129
- packageJson.scripts['ast:gitflow'] = `node ${base}/bin/gitflow-cycle.js`;
121
+ packageJson.scripts['ast:refresh'] = `node "${base}/bin/update-evidence.sh"`;
122
+ packageJson.scripts['ast:audit'] = `node "${base}/infrastructure/ast/ast-intelligence.js"`;
123
+ packageJson.scripts['ast:guard:start'] = `bash "${base}/bin/evidence-guard" start`;
124
+ packageJson.scripts['ast:guard:stop'] = `bash "${base}/bin/evidence-guard" stop`;
125
+ packageJson.scripts['ast:guard:restart'] = `bash "${base}/bin/evidence-guard" restart`;
126
+ packageJson.scripts['ast:guard:status'] = `bash "${base}/bin/evidence-guard" status`;
127
+ packageJson.scripts['ast:guard:logs'] = `bash "${base}/bin/evidence-guard" logs`;
128
+ packageJson.scripts['ast:check-version'] = `node "${base}/bin/check-version.js"`;
129
+ packageJson.scripts['ast:gitflow'] = `node "${base}/bin/gitflow-cycle.js"`;
130
130
 
131
131
  fs.writeFileSync(projectPackageJsonPath, JSON.stringify(packageJson, null, 2));
132
132
  this.logSuccess('npm scripts added');
@@ -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
+ });
@@ -0,0 +1,43 @@
1
+ const { execFileSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const path = require('path');
5
+
6
+ function makeSUT() {
7
+ const workspaceRoot = path.resolve(__dirname, '../../../..');
8
+ const guardScriptPath = path.join(workspaceRoot, 'scripts', 'hooks-system', 'bin', 'evidence-guard');
9
+
10
+ const projectRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pumuki evidence guard project '));
11
+ fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify({ name: 'tmp', version: '0.0.0' }));
12
+
13
+ const pidFilePath = path.join(projectRoot, '.evidence-guard.pid');
14
+ fs.writeFileSync(pidFilePath, String(process.pid));
15
+
16
+ return { guardScriptPath, projectRoot, pidFilePath };
17
+ }
18
+
19
+ describe('evidence-guard wrapper', () => {
20
+ it('should resolve project root from cwd (supports paths with spaces)', () => {
21
+ const { guardScriptPath, projectRoot } = makeSUT();
22
+
23
+ const output = execFileSync('bash', [guardScriptPath, 'status'], {
24
+ cwd: projectRoot,
25
+ encoding: 'utf8'
26
+ });
27
+
28
+ expect(output).toContain('Evidence guard is running');
29
+ });
30
+
31
+ it('should find PID file in project root with spaces in path', () => {
32
+ const { guardScriptPath, projectRoot, pidFilePath } = makeSUT();
33
+
34
+ expect(fs.existsSync(pidFilePath)).toBe(true);
35
+
36
+ const output = execFileSync('bash', [guardScriptPath, 'status'], {
37
+ cwd: projectRoot,
38
+ encoding: 'utf8'
39
+ });
40
+
41
+ expect(output).toContain(`PID: ${process.pid}`);
42
+ });
43
+ });
@@ -1,7 +1,15 @@
1
1
  #!/bin/bash
2
2
 
3
3
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
4
+
5
+ PROJECT_ROOT="$(pwd)"
6
+ while [ "$PROJECT_ROOT" != "/" ] && [ ! -f "$PROJECT_ROOT/package.json" ]; do
7
+ PROJECT_ROOT="$(dirname "$PROJECT_ROOT")"
8
+ done
9
+ if [ ! -f "$PROJECT_ROOT/package.json" ]; then
10
+ PROJECT_ROOT="$(pwd)"
11
+ fi
12
+
5
13
  GUARD_SCRIPT="$SCRIPT_DIR/../infrastructure/daemons/evidence-guard.js"
6
14
  PID_FILE="$PROJECT_ROOT/.evidence-guard.pid"
7
15
  LOG_FILE="$PROJECT_ROOT/.evidence-guard.log"
@@ -121,3 +121,9 @@
121
121
  {"timestamp":"2026-01-15T07:49:02.751Z","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"}}
122
122
  {"timestamp":"2026-01-15T07:49:02.752Z","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"}}
123
123
  {"timestamp":"2026-01-15T07:49:02.753Z","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)"}}
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
+ {"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
+ {"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)"}}