@shepai/cli 1.148.0 → 1.149.0-pr463.3fd9e4e
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/packages/core/src/application/use-cases/features/get-branch-sync-status.use-case.d.ts.map +1 -1
- package/dist/packages/core/src/application/use-cases/features/get-branch-sync-status.use-case.js +4 -0
- package/dist/src/presentation/web/app/api/agent-events/route.js +1 -1
- package/dist/src/presentation/web/app/api/sessions/route.d.ts.map +1 -1
- package/dist/src/presentation/web/app/api/sessions/route.js +2 -268
- package/dist/src/presentation/web/app/api/sessions-batch/route.d.ts +17 -0
- package/dist/src/presentation/web/app/api/sessions-batch/route.d.ts.map +1 -0
- package/dist/src/presentation/web/app/api/sessions-batch/route.js +61 -0
- package/dist/src/presentation/web/components/common/control-center-drawer/feature-drawer-client.d.ts.map +1 -1
- package/dist/src/presentation/web/components/common/control-center-drawer/feature-drawer-client.js +6 -3
- package/dist/src/presentation/web/components/common/feature-node/feature-sessions-dropdown.d.ts +1 -1
- package/dist/src/presentation/web/components/common/feature-node/feature-sessions-dropdown.d.ts.map +1 -1
- package/dist/src/presentation/web/components/common/feature-node/feature-sessions-dropdown.js +15 -73
- package/dist/src/presentation/web/components/common/feature-node/feature-sessions-dropdown.stories.d.ts.map +1 -1
- package/dist/src/presentation/web/components/common/feature-node/feature-sessions-dropdown.stories.js +18 -17
- package/dist/src/presentation/web/components/features/control-center/control-center.d.ts.map +1 -1
- package/dist/src/presentation/web/components/features/control-center/control-center.js +2 -1
- package/dist/src/presentation/web/components/features/control-center/use-control-center-state.d.ts.map +1 -1
- package/dist/src/presentation/web/components/features/control-center/use-control-center-state.js +4 -1
- package/dist/src/presentation/web/components/layouts/app-sidebar/app-sidebar.d.ts.map +1 -1
- package/dist/src/presentation/web/components/layouts/app-sidebar/app-sidebar.js +32 -33
- package/dist/src/presentation/web/hooks/sessions-provider.d.ts +12 -0
- package/dist/src/presentation/web/hooks/sessions-provider.d.ts.map +1 -0
- package/dist/src/presentation/web/hooks/sessions-provider.js +57 -0
- package/dist/src/presentation/web/hooks/use-deploy-action.d.ts.map +1 -1
- package/dist/src/presentation/web/hooks/use-deploy-action.js +8 -54
- package/dist/src/presentation/web/lib/session-scanner.d.ts +27 -0
- package/dist/src/presentation/web/lib/session-scanner.d.ts.map +1 -0
- package/dist/src/presentation/web/lib/session-scanner.js +255 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/app-path-routes-manifest.json +1 -0
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/fallback-build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +3 -3
- package/web/.next/required-server-files.js +3 -3
- package/web/.next/required-server-files.json +3 -3
- package/web/.next/routes-manifest.json +6 -0
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +28 -28
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +28 -28
- package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +36 -36
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +36 -36
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +26 -26
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +28 -28
- package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +36 -36
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +36 -36
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +26 -26
- package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +26 -26
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/_not-found/page/server-reference-manifest.json +3 -3
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/api/attachments/preview/route.js.nft.json +1 -1
- package/web/.next/server/app/api/evidence/route.js.nft.json +1 -1
- package/web/.next/server/app/api/graph-data/route.js.nft.json +1 -1
- package/web/.next/server/app/api/sessions/route.js +2 -3
- package/web/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/web/.next/server/app/api/sessions-batch/route/app-paths-manifest.json +3 -0
- package/web/.next/server/app/api/sessions-batch/route/build-manifest.json +11 -0
- package/web/.next/server/app/api/sessions-batch/route/server-reference-manifest.json +4 -0
- package/web/.next/server/app/api/sessions-batch/route.js +7 -0
- package/web/.next/server/app/api/sessions-batch/route.js.map +5 -0
- package/web/.next/server/app/api/sessions-batch/route.js.nft.json +1 -0
- package/web/.next/server/app/api/sessions-batch/route_client-reference-manifest.js +2 -0
- package/web/.next/server/app/settings/page/server-reference-manifest.json +8 -8
- package/web/.next/server/app/settings/page.js.nft.json +1 -1
- package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/skills/page/server-reference-manifest.json +8 -8
- package/web/.next/server/app/skills/page.js.nft.json +1 -1
- package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/tools/page/server-reference-manifest.json +8 -8
- package/web/.next/server/app/tools/page.js.nft.json +1 -1
- package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/version/page/server-reference-manifest.json +3 -3
- package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app-paths-manifest.json +1 -0
- package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_4d623b8e.js +1 -1
- package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_4d623b8e.js.map +1 -1
- package/web/.next/server/chunks/744ca_web__next-internal_server_app_api_sessions-batch_route_actions_4859f283.js +3 -0
- package/web/.next/server/chunks/[root-of-the-server]__0d33c29e._.js +3 -0
- package/web/.next/server/chunks/[root-of-the-server]__0d33c29e._.js.map +1 -0
- package/web/.next/server/chunks/[root-of-the-server]__2f61738a._.js +3 -0
- package/web/.next/server/chunks/[root-of-the-server]__2f61738a._.js.map +1 -0
- package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__2138fa7e._.js +2 -2
- package/web/.next/server/chunks/ssr/[root-of-the-server]__29580090._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__29580090._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__357d99f9._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__3ef34e4c._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__43f51aa6._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__43f51aa6._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__684a868c._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__815546bd._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__815546bd._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js +3 -3
- package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__c094882b._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__c094882b._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__c16bf5de._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__d48c5b11._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__d48c5b11._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dac5dbf1._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dac5dbf1._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__fae8b355._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__fae8b355._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_05c23ad9._.js +1 -1
- package/web/.next/server/chunks/ssr/_05c23ad9._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_0c5f56e3._.js +2 -2
- package/web/.next/server/chunks/ssr/_0c5f56e3._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_16eb4fec._.js +1 -1
- package/web/.next/server/chunks/ssr/_16eb4fec._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_1b719e7f._.js +1 -1
- package/web/.next/server/chunks/ssr/_1b719e7f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_37e8548b._.js +1 -1
- package/web/.next/server/chunks/ssr/_37e8548b._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_55d763e2._.js +1 -1
- package/web/.next/server/chunks/ssr/_55d763e2._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_6256a985._.js +1 -1
- package/web/.next/server/chunks/ssr/_6256a985._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_64bdfc6f._.js +2 -2
- package/web/.next/server/chunks/ssr/_64bdfc6f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_8fcc39d4._.js +1 -1
- package/web/.next/server/chunks/ssr/_b71645b4._.js +1 -1
- package/web/.next/server/chunks/ssr/_b71645b4._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_cd7fb17f._.js +4 -0
- package/web/.next/server/chunks/ssr/_cd7fb17f._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_d8575088._.js +1 -1
- package/web/.next/server/chunks/ssr/_d8575088._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{_fe63a7f9._.js → _fff03050._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_fe63a7f9._.js.map → _fff03050._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1b176e3c.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1b176e3c.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_bd9f0dda.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_bd9f0dda.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js +1 -1
- package/web/.next/server/chunks/ssr/{src_presentation_web_7b2fda40._.js → src_presentation_web_bc27a88f._.js} +2 -2
- package/web/.next/server/chunks/ssr/{src_presentation_web_7b2fda40._.js.map → src_presentation_web_bc27a88f._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
- package/web/.next/server/pages/500.html +2 -2
- package/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/server/server-reference-manifest.json +44 -44
- package/web/.next/static/chunks/{6f76e63ead3fac2e.js → 121c2afa739794c8.js} +1 -1
- package/web/.next/static/chunks/3fc3c48d5fc1d34b.js +1 -0
- package/web/.next/static/chunks/6fb988bb7502376a.js +1 -0
- package/web/.next/static/chunks/7510c0f6c2e3f7ed.js +1 -0
- package/web/.next/static/chunks/{c731682077fbac4f.js → 768af4e247048769.js} +1 -1
- package/web/.next/static/chunks/834e374897ece7a3.js +1 -0
- package/web/.next/static/chunks/{7c5131e33516a325.js → 9d71dd508eeb2a7b.js} +1 -1
- package/web/.next/static/chunks/{48850e202dd814ac.js → ab62defde8095aaf.js} +1 -1
- package/web/.next/static/chunks/{9dad6769d10a32df.js → b2e8d1bb057a5233.js} +1 -1
- package/web/.next/static/chunks/{04869f1d3f5d9071.js → b9170990200dc7f7.js} +1 -1
- package/web/.next/static/chunks/{0137d4850cab3c45.js → ca75d824df20fe75.js} +3 -3
- package/web/.next/static/chunks/fdebfc97662845ff.js +2 -0
- package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_ff60e4a5.js +0 -3
- package/web/.next/server/chunks/403f9_next_dist_esm_build_templates_app-route_ff60e4a5.js.map +0 -1
- package/web/.next/server/chunks/[externals]__448264a3._.js +0 -3
- package/web/.next/server/chunks/ssr/_4533d6f8._.js +0 -4
- package/web/.next/server/chunks/ssr/_4533d6f8._.js.map +0 -1
- package/web/.next/static/chunks/063a24b49d9818a0.js +0 -1
- package/web/.next/static/chunks/21e82fee1a7e1668.js +0 -1
- package/web/.next/static/chunks/682563e4503cbd58.js +0 -1
- package/web/.next/static/chunks/683b1d85e789c2eb.js +0 -2
- package/web/.next/static/chunks/d62ae5e449d87057.js +0 -1
- /package/web/.next/server/chunks/{[externals]__448264a3._.js.map → 744ca_web__next-internal_server_app_api_sessions-batch_route_actions_4859f283.js.map} +0 -0
- /package/web/.next/static/{zYKuE1zbe1UWwAJv5EVwg → uf467r-P2iBzLS8YsN7j2}/_buildManifest.js +0 -0
- /package/web/.next/static/{zYKuE1zbe1UWwAJv5EVwg → uf467r-P2iBzLS8YsN7j2}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{zYKuE1zbe1UWwAJv5EVwg → uf467r-P2iBzLS8YsN7j2}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared session scanning logic used by both /api/sessions and /api/sessions-batch.
|
|
3
|
+
*
|
|
4
|
+
* Scans Claude Code and Cursor session directories for JSONL session files,
|
|
5
|
+
* parsing headers to extract preview, message count, and timestamps.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
11
|
+
// ── Path encoding helpers ─────────────────────────────────────────────
|
|
12
|
+
/**
|
|
13
|
+
* Claude Code encodes paths by replacing '/', '\', '.' with '-'.
|
|
14
|
+
* e.g. /home/user/.shep/repos/abc → -home-user--shep-repos-abc
|
|
15
|
+
*/
|
|
16
|
+
function claudeEncodePath(p) {
|
|
17
|
+
return p.replace(/[/\\.]/g, '-');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Cursor encodes paths by stripping the leading '/', removing dots,
|
|
21
|
+
* and replacing '/' and '\' with '-'.
|
|
22
|
+
* e.g. /home/user/.shep/repos/abc → home-user-shep-repos-abc
|
|
23
|
+
*/
|
|
24
|
+
function cursorEncodePath(p) {
|
|
25
|
+
return p.replace(/^\//, '').replace(/\./g, '').replace(/[/\\]/g, '-');
|
|
26
|
+
}
|
|
27
|
+
// ── Shared helpers ────────────────────────────────────────────────────
|
|
28
|
+
function extractText(content) {
|
|
29
|
+
if (typeof content === 'string')
|
|
30
|
+
return content;
|
|
31
|
+
if (Array.isArray(content)) {
|
|
32
|
+
for (const block of content) {
|
|
33
|
+
if (typeof block === 'object' && block !== null) {
|
|
34
|
+
const b = block;
|
|
35
|
+
if (b.type === 'text' && typeof b.text === 'string')
|
|
36
|
+
return b.text;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const PREVIEW_READ_BYTES = 8_192; // 8KB is enough for first few messages
|
|
43
|
+
// ── Claude Code session scanner ───────────────────────────────────────
|
|
44
|
+
async function collectJsonlFiles(projectDir) {
|
|
45
|
+
let entries;
|
|
46
|
+
try {
|
|
47
|
+
entries = await readdir(projectDir);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const jsonlFiles = entries.filter((e) => e.endsWith('.jsonl'));
|
|
53
|
+
const fileInfos = await Promise.allSettled(jsonlFiles.map(async (name) => {
|
|
54
|
+
const filePath = join(projectDir, name);
|
|
55
|
+
const s = await stat(filePath);
|
|
56
|
+
return { name, filePath, mtime: s.mtime.getTime() };
|
|
57
|
+
}));
|
|
58
|
+
return fileInfos
|
|
59
|
+
.filter((r) => r.status === 'fulfilled')
|
|
60
|
+
.map((r) => r.value);
|
|
61
|
+
}
|
|
62
|
+
async function parseClaudeSession(filePath, fileName, mtime, repositoryPath) {
|
|
63
|
+
const { createReadStream } = await import('node:fs');
|
|
64
|
+
const id = fileName.replace('.jsonl', '');
|
|
65
|
+
let preview = null;
|
|
66
|
+
let firstTimestamp = null;
|
|
67
|
+
let messageCount = 0;
|
|
68
|
+
const head = await new Promise((resolve) => {
|
|
69
|
+
const chunks = [];
|
|
70
|
+
let size = 0;
|
|
71
|
+
const stream = createReadStream(filePath, { end: PREVIEW_READ_BYTES - 1 });
|
|
72
|
+
stream.on('data', (chunk) => {
|
|
73
|
+
chunks.push(chunk);
|
|
74
|
+
size += chunk.length;
|
|
75
|
+
});
|
|
76
|
+
stream.on('end', () => resolve(Buffer.concat(chunks, size).toString('utf-8')));
|
|
77
|
+
stream.on('error', () => resolve(''));
|
|
78
|
+
});
|
|
79
|
+
if (!head)
|
|
80
|
+
return null;
|
|
81
|
+
const lines = head.split('\n').filter((l) => l.trim());
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
try {
|
|
84
|
+
const entry = JSON.parse(line);
|
|
85
|
+
if (entry.type === 'user' || entry.type === 'assistant') {
|
|
86
|
+
const role = entry.message?.role;
|
|
87
|
+
if (role === 'user' || role === 'assistant') {
|
|
88
|
+
messageCount++;
|
|
89
|
+
if (entry.timestamp) {
|
|
90
|
+
firstTimestamp ??= entry.timestamp;
|
|
91
|
+
}
|
|
92
|
+
if (role === 'user' && preview === null) {
|
|
93
|
+
preview = extractText(entry.message?.content);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (messageCount === 0)
|
|
103
|
+
return null;
|
|
104
|
+
const mtimeIso = new Date(mtime).toISOString();
|
|
105
|
+
return {
|
|
106
|
+
id,
|
|
107
|
+
agentType: 'claude-code',
|
|
108
|
+
preview,
|
|
109
|
+
messageCount,
|
|
110
|
+
firstMessageAt: firstTimestamp,
|
|
111
|
+
lastMessageAt: mtimeIso,
|
|
112
|
+
createdAt: firstTimestamp ?? mtimeIso,
|
|
113
|
+
projectPath: repositoryPath,
|
|
114
|
+
filePath,
|
|
115
|
+
_mtime: mtime,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export async function scanClaudeSessions(repositoryPath, limit, includeWorktrees = false) {
|
|
119
|
+
const dirName = claudeEncodePath(repositoryPath);
|
|
120
|
+
const projectsRoot = join(homedir(), '.claude', 'projects');
|
|
121
|
+
const primaryDir = join(projectsRoot, dirName);
|
|
122
|
+
let allFiles = await collectJsonlFiles(primaryDir);
|
|
123
|
+
if (includeWorktrees) {
|
|
124
|
+
try {
|
|
125
|
+
const allDirs = await readdir(projectsRoot);
|
|
126
|
+
const prefixMatches = allDirs.filter((d) => d !== dirName && d.startsWith(dirName));
|
|
127
|
+
const normalizedRepoPath = repositoryPath.replace(/\\/g, '/');
|
|
128
|
+
const repoHash = createHash('sha256').update(normalizedRepoPath).digest('hex').slice(0, 16);
|
|
129
|
+
const shepHome = join(homedir(), '.shep').replace(/\\/g, '/');
|
|
130
|
+
const shepWorktreePrefix = claudeEncodePath(join(shepHome, 'repos', repoHash));
|
|
131
|
+
const shepMatches = allDirs.filter((d) => d.startsWith(shepWorktreePrefix) && !prefixMatches.includes(d) && d !== dirName);
|
|
132
|
+
const worktreeDirs = [...prefixMatches, ...shepMatches];
|
|
133
|
+
const worktreeResults = await Promise.all(worktreeDirs.map((d) => collectJsonlFiles(join(projectsRoot, d))));
|
|
134
|
+
for (const files of worktreeResults) {
|
|
135
|
+
allFiles = allFiles.concat(files);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// projectsRoot doesn't exist — no sessions at all
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const valid = allFiles.sort((a, b) => b.mtime - a.mtime).slice(0, limit);
|
|
143
|
+
const results = await Promise.allSettled(valid.map(async (fi) => parseClaudeSession(fi.filePath, fi.name, fi.mtime, repositoryPath)));
|
|
144
|
+
return results
|
|
145
|
+
.filter((r) => r.status === 'fulfilled')
|
|
146
|
+
.map((r) => r.value)
|
|
147
|
+
.filter((s) => s !== null);
|
|
148
|
+
}
|
|
149
|
+
// ── Cursor session scanner ────────────────────────────────────────────
|
|
150
|
+
async function parseCursorSession(filePath, fileName, mtime, repositoryPath) {
|
|
151
|
+
const { createReadStream } = await import('node:fs');
|
|
152
|
+
const id = fileName.replace('.jsonl', '');
|
|
153
|
+
const head = await new Promise((resolve) => {
|
|
154
|
+
const chunks = [];
|
|
155
|
+
let size = 0;
|
|
156
|
+
const stream = createReadStream(filePath, { end: PREVIEW_READ_BYTES - 1 });
|
|
157
|
+
stream.on('data', (chunk) => {
|
|
158
|
+
chunks.push(chunk);
|
|
159
|
+
size += chunk.length;
|
|
160
|
+
});
|
|
161
|
+
stream.on('end', () => resolve(Buffer.concat(chunks, size).toString('utf-8')));
|
|
162
|
+
stream.on('error', () => resolve(''));
|
|
163
|
+
});
|
|
164
|
+
if (!head)
|
|
165
|
+
return null;
|
|
166
|
+
let preview = null;
|
|
167
|
+
let messageCount = 0;
|
|
168
|
+
const lines = head.split('\n').filter((l) => l.trim());
|
|
169
|
+
for (const line of lines) {
|
|
170
|
+
try {
|
|
171
|
+
const entry = JSON.parse(line);
|
|
172
|
+
if (entry.role === 'user' || entry.role === 'assistant') {
|
|
173
|
+
messageCount++;
|
|
174
|
+
if (entry.role === 'user' && preview === null) {
|
|
175
|
+
preview = extractText(entry.message?.content);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (messageCount === 0)
|
|
184
|
+
return null;
|
|
185
|
+
const mtimeIso = new Date(mtime).toISOString();
|
|
186
|
+
return {
|
|
187
|
+
id,
|
|
188
|
+
agentType: 'cursor',
|
|
189
|
+
preview,
|
|
190
|
+
messageCount,
|
|
191
|
+
firstMessageAt: mtimeIso,
|
|
192
|
+
lastMessageAt: mtimeIso,
|
|
193
|
+
createdAt: mtimeIso,
|
|
194
|
+
projectPath: repositoryPath,
|
|
195
|
+
filePath,
|
|
196
|
+
_mtime: mtime,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export async function scanCursorSessions(repositoryPath, limit) {
|
|
200
|
+
const dirName = cursorEncodePath(repositoryPath);
|
|
201
|
+
const transcriptsDir = join(homedir(), '.cursor', 'projects', dirName, 'agent-transcripts');
|
|
202
|
+
let entries;
|
|
203
|
+
try {
|
|
204
|
+
entries = await readdir(transcriptsDir);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
const fileInfos = await Promise.allSettled(entries.map(async (entry) => {
|
|
210
|
+
const entryPath = join(transcriptsDir, entry);
|
|
211
|
+
const s = await stat(entryPath);
|
|
212
|
+
if (s.isFile() && entry.endsWith('.jsonl')) {
|
|
213
|
+
return { name: entry, filePath: entryPath, mtime: s.mtime.getTime() };
|
|
214
|
+
}
|
|
215
|
+
if (s.isDirectory()) {
|
|
216
|
+
const jsonlPath = join(entryPath, `${entry}.jsonl`);
|
|
217
|
+
try {
|
|
218
|
+
const jsonlStat = await stat(jsonlPath);
|
|
219
|
+
return {
|
|
220
|
+
name: `${entry}.jsonl`,
|
|
221
|
+
filePath: jsonlPath,
|
|
222
|
+
mtime: jsonlStat.mtime.getTime(),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}));
|
|
231
|
+
const valid = fileInfos
|
|
232
|
+
.filter((r) => r.status === 'fulfilled')
|
|
233
|
+
.map((r) => r.value)
|
|
234
|
+
.filter((v) => v !== null)
|
|
235
|
+
.sort((a, b) => b.mtime - a.mtime)
|
|
236
|
+
.slice(0, limit);
|
|
237
|
+
const results = await Promise.allSettled(valid.map(async (fi) => parseCursorSession(fi.filePath, fi.name, fi.mtime, repositoryPath)));
|
|
238
|
+
return results
|
|
239
|
+
.filter((r) => r.status === 'fulfilled')
|
|
240
|
+
.map((r) => r.value)
|
|
241
|
+
.filter((s) => s !== null);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Scan sessions for a single repository path from all providers.
|
|
245
|
+
* Merges and sorts by recency.
|
|
246
|
+
*/
|
|
247
|
+
export async function scanSessionsForPath(repositoryPath, limit, includeWorktrees = false) {
|
|
248
|
+
const [claudeSessions, cursorSessions] = await Promise.all([
|
|
249
|
+
scanClaudeSessions(repositoryPath, limit, includeWorktrees),
|
|
250
|
+
scanCursorSessions(repositoryPath, limit),
|
|
251
|
+
]);
|
|
252
|
+
return [...claudeSessions, ...cursorSessions]
|
|
253
|
+
.sort((a, b) => b._mtime - a._mtime)
|
|
254
|
+
.slice(0, Math.min(limit, 50));
|
|
255
|
+
}
|