engine7 7.1.11 → 7.1.12
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/cli.mjs +28 -16
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -118,24 +118,24 @@ function collectRecentSessions(agentsDir, days = 7) {
|
|
|
118
118
|
const files = [];
|
|
119
119
|
if (!fs.existsSync(agentsDir)) return files;
|
|
120
120
|
const cutoff = Date.now() - days * 24 * 60 * 60 * 1e3;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const stat = fs.statSync(
|
|
130
|
-
if (stat.mtimeMs > cutoff) files.push(
|
|
121
|
+
function scanSessionsDir(dir) {
|
|
122
|
+
try {
|
|
123
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
const fullPath = path.join(dir, entry.name);
|
|
126
|
+
if (entry.isDirectory()) {
|
|
127
|
+
scanSessionsDir(fullPath);
|
|
128
|
+
} else if (entry.name.endsWith(".jsonl")) {
|
|
129
|
+
const stat = fs.statSync(fullPath);
|
|
130
|
+
if (stat.mtimeMs > cutoff) files.push(fullPath);
|
|
131
|
+
} else if (entry.name === "platform-map.json" || entry.name === "session-index.json") {
|
|
132
|
+
files.push(fullPath);
|
|
131
133
|
}
|
|
132
|
-
} else if (entry.name.endsWith(".jsonl")) {
|
|
133
|
-
const stat = fs.statSync(fullPath);
|
|
134
|
-
if (stat.mtimeMs > cutoff) files.push(fullPath);
|
|
135
134
|
}
|
|
135
|
+
} catch {
|
|
136
136
|
}
|
|
137
|
-
} catch {
|
|
138
137
|
}
|
|
138
|
+
scanSessionsDir(agentsDir);
|
|
139
139
|
return files;
|
|
140
140
|
}
|
|
141
141
|
async function doExport(opts) {
|
|
@@ -198,7 +198,13 @@ async function doExport(opts) {
|
|
|
198
198
|
const relPath = path.relative(stateDir, srcFile);
|
|
199
199
|
const destFile = path.join(stagingDir, relPath);
|
|
200
200
|
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
201
|
-
|
|
201
|
+
const baseName = path.basename(srcFile);
|
|
202
|
+
if (baseName === "session-index.json" || baseName === "platform-map.json") {
|
|
203
|
+
const content = fs.readFileSync(srcFile, "utf-8");
|
|
204
|
+
fs.writeFileSync(destFile, sanitizeContent(content, dirs));
|
|
205
|
+
} else {
|
|
206
|
+
fs.copyFileSync(srcFile, destFile);
|
|
207
|
+
}
|
|
202
208
|
fileCount++;
|
|
203
209
|
totalSize += fs.statSync(srcFile).size;
|
|
204
210
|
}
|
|
@@ -307,7 +313,13 @@ async function doImport(opts) {
|
|
|
307
313
|
const relPath = path.relative(stagingDir, srcFile);
|
|
308
314
|
const destFile = path.join(stateDir, relPath);
|
|
309
315
|
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
310
|
-
|
|
316
|
+
const baseName = path.basename(srcFile);
|
|
317
|
+
if (baseName === "session-index.json" || baseName === "platform-map.json") {
|
|
318
|
+
const content = fs.readFileSync(srcFile, "utf-8");
|
|
319
|
+
fs.writeFileSync(destFile, restoreContent(content, dirs));
|
|
320
|
+
} else {
|
|
321
|
+
fs.copyFileSync(srcFile, destFile);
|
|
322
|
+
}
|
|
311
323
|
restoredCount++;
|
|
312
324
|
}
|
|
313
325
|
}
|