engine7 7.1.12 → 7.1.14
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 +31 -7
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -114,10 +114,10 @@ function collectAllFiles(dir) {
|
|
|
114
114
|
}
|
|
115
115
|
return files;
|
|
116
116
|
}
|
|
117
|
-
function collectRecentSessions(agentsDir,
|
|
117
|
+
function collectRecentSessions(agentsDir, _days = 7) {
|
|
118
118
|
const files = [];
|
|
119
119
|
if (!fs.existsSync(agentsDir)) return files;
|
|
120
|
-
const
|
|
120
|
+
const sessionGroups = /* @__PURE__ */ new Map();
|
|
121
121
|
function scanSessionsDir(dir) {
|
|
122
122
|
try {
|
|
123
123
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
@@ -125,17 +125,40 @@ function collectRecentSessions(agentsDir, days = 7) {
|
|
|
125
125
|
const fullPath = path.join(dir, entry.name);
|
|
126
126
|
if (entry.isDirectory()) {
|
|
127
127
|
scanSessionsDir(fullPath);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} else if (entry.name === "platform-map.json" || entry.name === "session-index.json") {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (entry.name === "platform-map.json" || entry.name === "session-index.json") {
|
|
132
131
|
files.push(fullPath);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let sessionKey = null;
|
|
135
|
+
if (entry.name.endsWith(".jsonl")) {
|
|
136
|
+
sessionKey = entry.name.slice(0, -6);
|
|
137
|
+
} else {
|
|
138
|
+
const m = entry.name.match(/^(.+)\.jsonl\.(archived|compaction)\./);
|
|
139
|
+
if (m) sessionKey = m[1];
|
|
140
|
+
}
|
|
141
|
+
if (!sessionKey) continue;
|
|
142
|
+
if (!sessionGroups.has(sessionKey)) {
|
|
143
|
+
sessionGroups.set(sessionKey, { archived: [] });
|
|
144
|
+
}
|
|
145
|
+
const group = sessionGroups.get(sessionKey);
|
|
146
|
+
if (entry.name.endsWith(".jsonl")) {
|
|
147
|
+
group.jsonl = fullPath;
|
|
148
|
+
} else {
|
|
149
|
+
const stat = fs.statSync(fullPath);
|
|
150
|
+
group.archived.push({ file: fullPath, mtime: stat.mtimeMs });
|
|
133
151
|
}
|
|
134
152
|
}
|
|
135
153
|
} catch {
|
|
136
154
|
}
|
|
137
155
|
}
|
|
138
156
|
scanSessionsDir(agentsDir);
|
|
157
|
+
for (const [, group] of sessionGroups) {
|
|
158
|
+
if (group.jsonl) files.push(group.jsonl);
|
|
159
|
+
group.archived.sort((a, b) => b.mtime - a.mtime);
|
|
160
|
+
if (group.archived.length > 0) files.push(group.archived[0].file);
|
|
161
|
+
}
|
|
139
162
|
return files;
|
|
140
163
|
}
|
|
141
164
|
async function doExport(opts) {
|
|
@@ -483,8 +506,9 @@ var init_cli_travel = __esm({
|
|
|
483
506
|
"scripts",
|
|
484
507
|
"selfie",
|
|
485
508
|
"moodboard",
|
|
486
|
-
// 状态文件
|
|
509
|
+
// 状态文件 + 目录
|
|
487
510
|
"calendar.db",
|
|
511
|
+
".calendar",
|
|
488
512
|
"nudge-state.json"
|
|
489
513
|
]);
|
|
490
514
|
WORKSPACE_OPTIONAL = /* @__PURE__ */ new Set([
|