@claude-sessions/core 0.3.6 → 0.4.0

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MessagePayload, a as Message, P as Project, T as TodoItem, F as FileChange, b as MoveSessionResult, S as SearchResult, c as SummaryInfo, A as AgentInfo } from './types-C2fzbmg9.js';
2
- export { i as CleanupPreview, h as ClearSessionsResult, C as ContentItem, D as DeleteSessionResult, k as ProjectTreeData, R as RenameSessionResult, l as ResumeSessionOptions, m as ResumeSessionResult, f as SessionFilesSummary, d as SessionMeta, e as SessionTodos, j as SessionTreeData, g as SplitSessionResult } from './types-C2fzbmg9.js';
1
+ import { M as MessagePayload, a as Message, P as Project, S as SummaryInfo, T as TodoItem, b as MoveSessionResult, A as AgentInfo, c as SessionSortOptions, C as CompressSessionOptions, d as SummarizeSessionOptions, e as ConversationLine, f as SearchResult, F as FileChange, g as SessionsIndex, h as SessionIndexEntry } from './types-BdPaAnP8.js';
2
+ export { o as CleanupPreview, n as ClearSessionsResult, v as CompressSessionResult, i as ContentItem, D as DeleteSessionResult, w as ProjectKnowledge, q as ProjectTreeData, R as RenameSessionResult, r as ResumeSessionOptions, s as ResumeSessionResult, u as SessionAnalysis, l as SessionFilesSummary, j as SessionMeta, y as SessionSortField, z as SessionSortOrder, k as SessionTodos, p as SessionTreeData, m as SplitSessionResult, x as SummarizeSessionResult, t as ToolUsageStats } from './types-BdPaAnP8.js';
3
3
  import * as effect_Cause from 'effect/Cause';
4
4
  import { Effect } from 'effect';
5
5
 
@@ -11,7 +11,9 @@ interface FileSystem {
11
11
  readFileSync: (path: string, encoding: 'utf-8') => string;
12
12
  readdirSync: (path: string) => string[];
13
13
  }
14
- /** Get Claude sessions directory (~/.claude/projects) */
14
+ /** Get Claude sessions directory (~/.claude/projects)
15
+ * Can be overridden with CLAUDE_SESSIONS_DIR environment variable for testing
16
+ */
15
17
  declare const getSessionsDir: () => string;
16
18
  /** Get Claude todos directory (~/.claude/todos) */
17
19
  declare const getTodosDir: () => string;
@@ -74,6 +76,21 @@ declare const getDisplayTitle: (customTitle: string | undefined, currentSummary:
74
76
  * Only masks the specified homeDir, not other users' paths
75
77
  */
76
78
  declare const maskHomePath: (text: string, homeDir: string) => string;
79
+ /**
80
+ * Get session sort timestamp based on official Claude Code extension behavior
81
+ *
82
+ * CRITICAL ARCHITECTURE:
83
+ * - Summary records have `leafUuid` but NO timestamp in the summary record itself
84
+ * - `leafUuid` points to a message in ANOTHER session (cross-session reference)
85
+ * - The timestamp for sorting must come from the TARGET message's timestamp
86
+ * - Official extension uses leafUuid's target message timestamp for sorting/display
87
+ *
88
+ * Priority: summaries[0].timestamp (leafUuid-based) > createdAt
89
+ */
90
+ declare const getSessionSortTimestamp: (session: {
91
+ summaries?: SummaryInfo[];
92
+ createdAt?: string;
93
+ }) => string | undefined;
77
94
  /**
78
95
  * Sort projects with priority:
79
96
  * 1. Current project (if specified)
@@ -94,6 +111,11 @@ declare const findOrphanAgents: (projectName: string) => Effect.Effect<{
94
111
  declare const deleteOrphanAgents: (projectName: string) => Effect.Effect<{
95
112
  success: boolean;
96
113
  deletedAgents: string[];
114
+ backedUpAgents: string[];
115
+ cleanedFolders: string[];
116
+ deletedCount: number;
117
+ backedUpCount: number;
118
+ cleanedFolderCount: number;
97
119
  count: number;
98
120
  }, effect_Cause.UnknownException, never>;
99
121
  declare const loadAgentMessages: (projectName: string, _sessionId: string, // Reserved for future validation
@@ -119,10 +141,16 @@ declare const deleteOrphanTodos: () => Effect.Effect<{
119
141
  }, effect_Cause.UnknownException, never>;
120
142
 
121
143
  declare const listProjects: Effect.Effect<Project[], effect_Cause.UnknownException, never>;
144
+
145
+ declare const updateSessionSummary: (projectName: string, sessionId: string, newSummary: string) => Effect.Effect<{
146
+ success: boolean;
147
+ }, effect_Cause.UnknownException, never>;
122
148
  declare const listSessions: (projectName: string) => Effect.Effect<{
123
149
  id: string;
124
150
  projectName: string;
125
151
  title: string;
152
+ customTitle: string | undefined;
153
+ currentSummary: string | undefined;
126
154
  messageCount: number;
127
155
  createdAt: string | undefined;
128
156
  updatedAt: string | undefined;
@@ -162,12 +190,6 @@ declare const renameSession: (projectName: string, sessionId: string, newTitle:
162
190
  success: true;
163
191
  error?: undefined;
164
192
  }, effect_Cause.UnknownException, never>;
165
- declare const getSessionFiles: (projectName: string, sessionId: string) => Effect.Effect<{
166
- sessionId: string;
167
- projectName: string;
168
- files: FileChange[];
169
- totalChanges: number;
170
- }, effect_Cause.UnknownException, never>;
171
193
  declare const moveSession: (sourceProject: string, sessionId: string, targetProject: string) => Effect.Effect<MoveSessionResult, Error>;
172
194
  declare const splitSession: (projectName: string, sessionId: string, splitAtMessageUuid: string) => Effect.Effect<{
173
195
  success: false;
@@ -184,46 +206,7 @@ declare const splitSession: (projectName: string, sessionId: string, splitAtMess
184
206
  duplicatedSummary: boolean;
185
207
  error?: undefined;
186
208
  }, effect_Cause.UnknownException, never>;
187
- declare const previewCleanup: (projectName?: string) => Effect.Effect<{
188
- project: string;
189
- emptySessions: {
190
- id: string;
191
- projectName: string;
192
- title: string;
193
- messageCount: number;
194
- createdAt: string | undefined;
195
- updatedAt: string | undefined;
196
- }[];
197
- invalidSessions: {
198
- id: string;
199
- projectName: string;
200
- title: string;
201
- messageCount: number;
202
- createdAt: string | undefined;
203
- updatedAt: string | undefined;
204
- }[];
205
- emptyWithTodosCount: number;
206
- orphanAgentCount: number;
207
- orphanTodoCount: number;
208
- }[], effect_Cause.UnknownException, never>;
209
- declare const clearSessions: (options: {
210
- projectName?: string;
211
- clearEmpty?: boolean;
212
- clearInvalid?: boolean;
213
- skipWithTodos?: boolean;
214
- clearOrphanAgents?: boolean;
215
- clearOrphanTodos?: boolean;
216
- }) => Effect.Effect<{
217
- success: true;
218
- deletedCount: number;
219
- removedMessageCount: number;
220
- deletedOrphanAgentCount: number;
221
- deletedOrphanTodoCount: number;
222
- }, effect_Cause.UnknownException, never>;
223
- declare const searchSessions: (query: string, options?: {
224
- projectName?: string;
225
- searchContent?: boolean;
226
- }) => Effect.Effect<SearchResult[], effect_Cause.UnknownException, never>;
209
+
227
210
  declare const loadSessionTreeData: (projectName: string, sessionId: string) => Effect.Effect<{
228
211
  id: string;
229
212
  projectName: string;
@@ -233,6 +216,7 @@ declare const loadSessionTreeData: (projectName: string, sessionId: string) => E
233
216
  messageCount: number;
234
217
  createdAt: string;
235
218
  updatedAt: string;
219
+ fileMtime: number | undefined;
236
220
  summaries: SummaryInfo[];
237
221
  agents: AgentInfo[];
238
222
  todos: {
@@ -246,7 +230,7 @@ declare const loadSessionTreeData: (projectName: string, sessionId: string) => E
246
230
  };
247
231
  lastCompactBoundaryUuid: string | undefined;
248
232
  }, effect_Cause.UnknownException, never>;
249
- declare const loadProjectTreeData: (projectName: string) => Effect.Effect<{
233
+ declare const loadProjectTreeData: (projectName: string, sortOptions?: SessionSortOptions) => Effect.Effect<{
250
234
  name: string;
251
235
  displayName: string;
252
236
  path: string;
@@ -260,6 +244,7 @@ declare const loadProjectTreeData: (projectName: string) => Effect.Effect<{
260
244
  messageCount: number;
261
245
  createdAt: string;
262
246
  updatedAt: string;
247
+ fileMtime: number | undefined;
263
248
  summaries: SummaryInfo[];
264
249
  agents: AgentInfo[];
265
250
  todos: {
@@ -274,9 +259,138 @@ declare const loadProjectTreeData: (projectName: string) => Effect.Effect<{
274
259
  lastCompactBoundaryUuid: string | undefined;
275
260
  }[];
276
261
  } | null, effect_Cause.UnknownException, never>;
277
- declare const updateSessionSummary: (projectName: string, sessionId: string, newSummary: string) => Effect.Effect<{
278
- success: boolean;
262
+
263
+ declare const analyzeSession: (projectName: string, sessionId: string) => Effect.Effect<{
264
+ sessionId: string;
265
+ projectName: string;
266
+ durationMinutes: number;
267
+ stats: {
268
+ totalMessages: number;
269
+ userMessages: number;
270
+ assistantMessages: number;
271
+ summaryCount: number;
272
+ snapshotCount: number;
273
+ };
274
+ toolUsage: {
275
+ name: string;
276
+ count: number;
277
+ errorCount: number;
278
+ }[];
279
+ filesChanged: string[];
280
+ patterns: {
281
+ type: string;
282
+ description: string;
283
+ count: number;
284
+ }[];
285
+ milestones: {
286
+ timestamp?: string;
287
+ description: string;
288
+ messageUuid?: string;
289
+ }[];
290
+ }, effect_Cause.UnknownException, never>;
291
+ declare const compressSession: (projectName: string, sessionId: string, options?: CompressSessionOptions) => Effect.Effect<{
292
+ success: true;
293
+ originalSize: number;
294
+ compressedSize: number;
295
+ removedSnapshots: number;
296
+ truncatedOutputs: number;
279
297
  }, effect_Cause.UnknownException, never>;
298
+ declare const extractProjectKnowledge: (projectName: string, sessionIds?: string[]) => Effect.Effect<{
299
+ projectName: string;
300
+ patterns: never[];
301
+ hotFiles: {
302
+ path: string;
303
+ modifyCount: number;
304
+ lastModified: string | undefined;
305
+ }[];
306
+ workflows: {
307
+ sequence: string[];
308
+ count: number;
309
+ }[];
310
+ decisions: {
311
+ context: string;
312
+ decision: string;
313
+ sessionId: string;
314
+ }[];
315
+ }, effect_Cause.UnknownException, never>;
316
+ declare const summarizeSession: (projectName: string, sessionId: string, options?: SummarizeSessionOptions) => Effect.Effect<{
317
+ sessionId: string;
318
+ projectName: string;
319
+ lines: ConversationLine[];
320
+ formatted: string;
321
+ }, effect_Cause.UnknownException, never>;
322
+
323
+ declare const previewCleanup: (projectName?: string) => Effect.Effect<{
324
+ project: string;
325
+ emptySessions: {
326
+ id: string;
327
+ projectName: string;
328
+ title: string;
329
+ customTitle: string | undefined;
330
+ currentSummary: string | undefined;
331
+ messageCount: number;
332
+ createdAt: string | undefined;
333
+ updatedAt: string | undefined;
334
+ }[];
335
+ invalidSessions: {
336
+ id: string;
337
+ projectName: string;
338
+ title: string;
339
+ customTitle: string | undefined;
340
+ currentSummary: string | undefined;
341
+ messageCount: number;
342
+ createdAt: string | undefined;
343
+ updatedAt: string | undefined;
344
+ }[];
345
+ emptyWithTodosCount: number;
346
+ orphanAgentCount: number;
347
+ orphanTodoCount: number;
348
+ }[], effect_Cause.UnknownException, never>;
349
+ declare const clearSessions: (options: {
350
+ projectName?: string;
351
+ clearEmpty?: boolean;
352
+ clearInvalid?: boolean;
353
+ skipWithTodos?: boolean;
354
+ clearOrphanAgents?: boolean;
355
+ clearOrphanTodos?: boolean;
356
+ }) => Effect.Effect<{
357
+ success: true;
358
+ deletedCount: number;
359
+ removedMessageCount: number;
360
+ deletedOrphanAgentCount: number;
361
+ deletedOrphanTodoCount: number;
362
+ }, effect_Cause.UnknownException, never>;
363
+
364
+ declare const searchSessions: (query: string, options?: {
365
+ projectName?: string;
366
+ searchContent?: boolean;
367
+ }) => Effect.Effect<SearchResult[], effect_Cause.UnknownException, never>;
368
+
369
+ declare const getSessionFiles: (projectName: string, sessionId: string) => Effect.Effect<{
370
+ sessionId: string;
371
+ projectName: string;
372
+ files: FileChange[];
373
+ totalChanges: number;
374
+ }, effect_Cause.UnknownException, never>;
375
+
376
+ /**
377
+ * Load sessions-index.json for a project
378
+ * Returns null if the file doesn't exist
379
+ */
380
+ declare const loadSessionsIndex: (projectName: string) => Effect.Effect<SessionsIndex | null, effect_Cause.UnknownException, never>;
381
+ /**
382
+ * Get display title from index entry
383
+ * Priority: customTitle > summary > firstPrompt (cleaned)
384
+ */
385
+ declare const getIndexEntryDisplayTitle: (entry: SessionIndexEntry) => string;
386
+ /**
387
+ * Sort index entries by modified time (newest first)
388
+ */
389
+ declare const sortIndexEntriesByModified: (entries: SessionIndexEntry[]) => SessionIndexEntry[];
390
+ /**
391
+ * Check if sessions-index.json exists for a project
392
+ */
393
+ declare const hasSessionsIndex: (projectName: string) => Effect.Effect<boolean, effect_Cause.UnknownException, never>;
280
394
 
281
395
  /**
282
396
  * Simple logger abstraction for Claude Sessions
@@ -312,4 +426,4 @@ declare const getLogger: () => Logger;
312
426
  */
313
427
  declare const createLogger: (namespace: string) => Logger;
314
428
 
315
- export { AgentInfo, FileChange, type Logger, Message, MessagePayload, MoveSessionResult, Project, SearchResult, SummaryInfo, TodoItem, clearSessions, createLogger, deleteLinkedTodos, deleteMessage, deleteOrphanAgents, deleteOrphanTodos, deleteSession, displayPathToFolderName, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, getDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionsDir, getTodosDir, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, maskHomePath, moveSession, pathToFolderName, previewCleanup, readSession, renameSession, restoreMessage, searchSessions, sessionHasTodos, setLogger, sortProjects, splitSession, updateSessionSummary };
429
+ export { AgentInfo, CompressSessionOptions, ConversationLine, FileChange, type Logger, Message, MessagePayload, MoveSessionResult, Project, SearchResult, SessionIndexEntry, SessionSortOptions, SessionsIndex, SummarizeSessionOptions, SummaryInfo, TodoItem, analyzeSession, clearSessions, compressSession, createLogger, deleteLinkedTodos, deleteMessage, deleteOrphanAgents, deleteOrphanTodos, deleteSession, displayPathToFolderName, extractProjectKnowledge, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, getDisplayTitle, getIndexEntryDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionSortTimestamp, getSessionsDir, getTodosDir, hasSessionsIndex, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, loadSessionsIndex, maskHomePath, moveSession, pathToFolderName, previewCleanup, readSession, renameSession, restoreMessage, searchSessions, sessionHasTodos, setLogger, sortIndexEntriesByModified, sortProjects, splitSession, summarizeSession, updateSessionSummary };