osborn 0.9.3 → 0.9.4
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/index.js +7 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -308,41 +308,23 @@ function startApiServer(workingDir, port) {
|
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
const
|
|
311
|
+
const claudeDir = join(homedir(), '.claude');
|
|
312
|
+
const projectsDir = join(claudeDir, 'projects');
|
|
312
313
|
const workDir = url.searchParams.get('workDir');
|
|
313
|
-
if (workDir) {
|
|
314
|
-
const slug = workDir.replace(/\//g, '-');
|
|
315
|
-
const slugDir = join(projectsDir, slug);
|
|
316
|
-
if (!existsSync(slugDir)) {
|
|
317
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
318
|
-
res.end(JSON.stringify({ error: 'Project not found', slug }));
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
res.writeHead(200, {
|
|
322
|
-
'Content-Type': 'application/gzip',
|
|
323
|
-
'Content-Disposition': `attachment; filename="claude-sessions-${slug}.tar.gz"`,
|
|
324
|
-
'Access-Control-Allow-Origin': '*',
|
|
325
|
-
});
|
|
326
|
-
// Use '--' to prevent tar from interpreting the leading-hyphen slug as flags
|
|
327
|
-
const tar = spawn('tar', ['-czf', '-', '-C', projectsDir, '--', slug]);
|
|
328
|
-
tar.stdout.pipe(res);
|
|
329
|
-
tar.stderr.on('data', (d) => console.error('[export]', d.toString()));
|
|
330
|
-
tar.on('close', (code) => { if (code !== 0)
|
|
331
|
-
res.destroy(); });
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
314
|
if (!existsSync(projectsDir)) {
|
|
335
315
|
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
336
316
|
res.end(JSON.stringify({ error: 'No sessions found' }));
|
|
337
317
|
return;
|
|
338
318
|
}
|
|
319
|
+
const tarArgs = ['-czf', '-', '-C', claudeDir, 'projects'];
|
|
320
|
+
void workDir; // workDir param accepted but full projects/ export is returned
|
|
339
321
|
res.writeHead(200, {
|
|
340
322
|
'Content-Type': 'application/gzip',
|
|
341
323
|
'Content-Disposition': 'attachment; filename="claude-sessions.tar.gz"',
|
|
342
324
|
'Access-Control-Allow-Origin': '*',
|
|
343
325
|
});
|
|
344
326
|
// Stream tar output directly to response
|
|
345
|
-
const tar = spawn('tar',
|
|
327
|
+
const tar = spawn('tar', tarArgs);
|
|
346
328
|
tar.stdout.pipe(res);
|
|
347
329
|
tar.stderr.on('data', (d) => console.error('[export]', d.toString()));
|
|
348
330
|
tar.on('close', (code) => { if (code !== 0)
|
|
@@ -378,7 +360,8 @@ function startApiServer(workingDir, port) {
|
|
|
378
360
|
return;
|
|
379
361
|
}
|
|
380
362
|
try {
|
|
381
|
-
const
|
|
363
|
+
const claudeDir = join(homedir(), '.claude');
|
|
364
|
+
const projectsDir = join(claudeDir, 'projects');
|
|
382
365
|
mkdirSync(projectsDir, { recursive: true });
|
|
383
366
|
// The archive should contain a 'projects' subdirectory
|
|
384
367
|
const extractedProjects = join(tmpDir, 'projects');
|