engine7 7.1.10 → 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 +70 -17
- 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) {
|
|
@@ -153,8 +153,17 @@ async function doExport(opts) {
|
|
|
153
153
|
const dirs = { workspace, stateDir, engineHome };
|
|
154
154
|
const wsFiles = collectFiles(workspace, WORKSPACE_INCLUDE, WORKSPACE_OPTIONAL);
|
|
155
155
|
const sessionFiles = collectRecentSessions(path.join(stateDir, "agents"), 7);
|
|
156
|
+
const configsDir = path.join(stateDir, "configs");
|
|
157
|
+
const configFiles = [];
|
|
158
|
+
if (fs.existsSync(configsDir)) {
|
|
159
|
+
for (const f of collectAllFiles(configsDir)) {
|
|
160
|
+
if (shouldExclude(path.basename(f))) continue;
|
|
161
|
+
configFiles.push(f);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
156
164
|
console.log(` workspace \u6587\u4EF6: ${wsFiles.length}`);
|
|
157
165
|
console.log(` session jsonl: ${sessionFiles.length} (\u6700\u8FD17\u5929)`);
|
|
166
|
+
console.log(` configs: ${configFiles.length}`);
|
|
158
167
|
if (dryRun2) {
|
|
159
168
|
console.log(`
|
|
160
169
|
[DRY RUN] \u4F1A\u6253\u5305\u4EE5\u4E0B\u6587\u4EF6:`);
|
|
@@ -189,7 +198,26 @@ async function doExport(opts) {
|
|
|
189
198
|
const relPath = path.relative(stateDir, srcFile);
|
|
190
199
|
const destFile = path.join(stagingDir, relPath);
|
|
191
200
|
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
192
|
-
|
|
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
|
+
}
|
|
208
|
+
fileCount++;
|
|
209
|
+
totalSize += fs.statSync(srcFile).size;
|
|
210
|
+
}
|
|
211
|
+
for (const srcFile of configFiles) {
|
|
212
|
+
const relPath = path.relative(stateDir, srcFile);
|
|
213
|
+
const destFile = path.join(stagingDir, relPath);
|
|
214
|
+
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
215
|
+
if (isTextFile(srcFile)) {
|
|
216
|
+
const content = fs.readFileSync(srcFile, "utf-8");
|
|
217
|
+
fs.writeFileSync(destFile, sanitizeContent(content, dirs));
|
|
218
|
+
} else {
|
|
219
|
+
fs.copyFileSync(srcFile, destFile);
|
|
220
|
+
}
|
|
193
221
|
fileCount++;
|
|
194
222
|
totalSize += fs.statSync(srcFile).size;
|
|
195
223
|
}
|
|
@@ -285,13 +313,38 @@ async function doImport(opts) {
|
|
|
285
313
|
const relPath = path.relative(stagingDir, srcFile);
|
|
286
314
|
const destFile = path.join(stateDir, relPath);
|
|
287
315
|
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
288
|
-
|
|
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
|
+
}
|
|
323
|
+
restoredCount++;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const configsStaging = path.join(stagingDir, "configs");
|
|
327
|
+
if (fs.existsSync(configsStaging)) {
|
|
328
|
+
const cfgFiles = collectAllFiles(configsStaging);
|
|
329
|
+
for (const srcFile of cfgFiles) {
|
|
330
|
+
const relPath = path.relative(stagingDir, srcFile);
|
|
331
|
+
const destFile = path.join(stateDir, relPath);
|
|
332
|
+
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
333
|
+
if (isTextFile(srcFile)) {
|
|
334
|
+
const content = fs.readFileSync(srcFile, "utf-8");
|
|
335
|
+
fs.writeFileSync(destFile, restoreContent(content, dirs));
|
|
336
|
+
} else {
|
|
337
|
+
fs.copyFileSync(srcFile, destFile);
|
|
338
|
+
}
|
|
289
339
|
restoredCount++;
|
|
290
340
|
}
|
|
291
341
|
}
|
|
292
342
|
console.log(`\u2705 \u6062\u590D\u5B8C\u6210: ${restoredCount} \u6587\u4EF6 \u2192 ${stateDir}`);
|
|
343
|
+
const platformConfigName = process.platform === "darwin" ? "xiaoke-mac.json" : "xiaoke-win.json";
|
|
344
|
+
const restoredConfigPath = path.join(stateDir, "configs", platformConfigName);
|
|
345
|
+
const configToUse = fs.existsSync(restoredConfigPath) ? restoredConfigPath : path.join(stateDir, "configs", "xiaoke.json");
|
|
293
346
|
console.log(`
|
|
294
|
-
\u{1F4A1} \u4E0B\u4E00\u6B65: engine7 start --config
|
|
347
|
+
\u{1F4A1} \u4E0B\u4E00\u6B65: engine7 start --config "${configToUse}"`);
|
|
295
348
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
296
349
|
}
|
|
297
350
|
async function uploadToGitHub(cfg, archiveFile, agentName, version, manifest) {
|