@saferun/cli 0.6.14 → 0.6.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/dist/utils/logger.js +21 -2
- package/dist/utils/logger.js.map +1 -1
- package/package.json +1 -1
package/dist/utils/logger.js
CHANGED
|
@@ -7,11 +7,21 @@ exports.logOperation = logOperation;
|
|
|
7
7
|
exports.readLogEntries = readLogEntries;
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
10
12
|
const ai_detection_1 = require("./ai-detection");
|
|
13
|
+
/**
|
|
14
|
+
* Get the global log directory for a specific repo
|
|
15
|
+
* Logs are stored in ~/.saferun/logs/<hash>/ to survive git reset --hard
|
|
16
|
+
*/
|
|
17
|
+
function getLogDir(repoRoot) {
|
|
18
|
+
const hash = crypto_1.default.createHash('md5').update(repoRoot).digest('hex').slice(0, 12);
|
|
19
|
+
return path_1.default.join(os_1.default.homedir(), '.saferun', 'logs', hash);
|
|
20
|
+
}
|
|
11
21
|
async function logOperation(repoRoot, entry) {
|
|
12
22
|
var _a;
|
|
13
23
|
try {
|
|
14
|
-
const logDir =
|
|
24
|
+
const logDir = getLogDir(repoRoot);
|
|
15
25
|
await fs_1.default.promises.mkdir(logDir, { recursive: true });
|
|
16
26
|
// Auto-detect AI agent if not explicitly provided
|
|
17
27
|
let aiFields = {};
|
|
@@ -36,10 +46,19 @@ async function logOperation(repoRoot, entry) {
|
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
async function readLogEntries(repoRoot) {
|
|
39
|
-
const
|
|
49
|
+
const logDir = getLogDir(repoRoot);
|
|
50
|
+
const logFile = path_1.default.join(logDir, 'operations.log');
|
|
40
51
|
if (!fs_1.default.existsSync(logFile)) {
|
|
52
|
+
// Fallback: try reading from old location for migration
|
|
53
|
+
const oldLogFile = path_1.default.join(repoRoot, '.saferun', 'logs', 'operations.log');
|
|
54
|
+
if (fs_1.default.existsSync(oldLogFile)) {
|
|
55
|
+
return readLogFile(oldLogFile);
|
|
56
|
+
}
|
|
41
57
|
return [];
|
|
42
58
|
}
|
|
59
|
+
return readLogFile(logFile);
|
|
60
|
+
}
|
|
61
|
+
async function readLogFile(logFile) {
|
|
43
62
|
const lines = (await fs_1.default.promises.readFile(logFile, 'utf-8')).split(/\r?\n/);
|
|
44
63
|
const entries = [];
|
|
45
64
|
for (const line of lines) {
|
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;AA4BA,oCA8BC;AAED,wCAYC;AAxED,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AACpB,oDAA4B;AAC5B,iDAA+D;AAe/D;;;GAGG;AACH,SAAS,SAAS,CAAC,QAAgB;IACjC,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClF,OAAO,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,KAAe;;IAClE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAErD,kDAAkD;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