cursor-history 0.5.1 → 0.6.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/README.md +81 -1
- package/dist/cli/commands/export.js +1 -1
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/search.js +1 -1
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/show.js +1 -1
- package/dist/cli/commands/show.js.map +1 -1
- package/dist/cli/errors.d.ts +56 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +90 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/core/storage.js +22 -21
- package/dist/core/storage.js.map +1 -1
- package/dist/core/types.d.ts +28 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/lib/config.d.ts +32 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +80 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +37 -39
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +55 -66
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/index.d.ts +142 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +401 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/types.d.ts +119 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +9 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +17 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +20 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +11 -3
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cursor-history Library API
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: This is a library interface for direct import and use in TypeScript/JavaScript
|
|
5
|
+
* projects, NOT a network/REST API. Functions are imported directly:
|
|
6
|
+
* `import { listSessions, getSession, searchSessions } from 'cursor-history'`
|
|
7
|
+
*/
|
|
8
|
+
// Export error classes (will be created in Phase 2)
|
|
9
|
+
export { DatabaseLockedError, DatabaseNotFoundError, InvalidConfigError, isDatabaseLockedError, isDatabaseNotFoundError, isInvalidConfigError, } from './errors.js';
|
|
10
|
+
// Export utility functions
|
|
11
|
+
export { getDefaultDataPath } from './utils.js';
|
|
12
|
+
import { mergeWithDefaults } from './config.js';
|
|
13
|
+
import { DatabaseLockedError, DatabaseNotFoundError } from './errors.js';
|
|
14
|
+
import * as storage from '../core/storage.js';
|
|
15
|
+
import { exportToJson, exportToMarkdown } from '../core/parser.js';
|
|
16
|
+
/**
|
|
17
|
+
* Convert core ChatSession to library Session
|
|
18
|
+
*/
|
|
19
|
+
function convertToLibrarySession(coreSession) {
|
|
20
|
+
return {
|
|
21
|
+
id: coreSession.id,
|
|
22
|
+
workspace: coreSession.workspacePath ?? 'unknown',
|
|
23
|
+
timestamp: coreSession.createdAt.toISOString(),
|
|
24
|
+
messages: coreSession.messages.map((msg) => ({
|
|
25
|
+
role: msg.role === 'user' ? 'user' : 'assistant',
|
|
26
|
+
content: msg.content,
|
|
27
|
+
timestamp: msg.timestamp.toISOString(),
|
|
28
|
+
toolCalls: msg.toolCalls,
|
|
29
|
+
thinking: msg.thinking,
|
|
30
|
+
metadata: msg.metadata,
|
|
31
|
+
})),
|
|
32
|
+
messageCount: coreSession.messageCount,
|
|
33
|
+
metadata: {
|
|
34
|
+
lastModified: coreSession.lastUpdatedAt.toISOString(),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List all chat sessions, optionally filtered and paginated.
|
|
40
|
+
*
|
|
41
|
+
* @param config - Optional configuration (dataPath, workspace filter, pagination)
|
|
42
|
+
* @returns Paginated result with sessions and metadata
|
|
43
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
44
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
45
|
+
* @throws {InvalidConfigError} If config parameters are invalid
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // List all sessions
|
|
49
|
+
* const result = listSessions();
|
|
50
|
+
* console.log(result.data); // Session[]
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // List sessions with pagination
|
|
54
|
+
* const page1 = listSessions({ limit: 10, offset: 0 });
|
|
55
|
+
* const page2 = listSessions({ limit: 10, offset: 10 });
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // List sessions for specific workspace
|
|
59
|
+
* const result = listSessions({ workspace: '/path/to/project' });
|
|
60
|
+
*/
|
|
61
|
+
export function listSessions(config) {
|
|
62
|
+
try {
|
|
63
|
+
const resolved = mergeWithDefaults(config);
|
|
64
|
+
// Get all sessions using core storage layer
|
|
65
|
+
const coreSessions = storage.listSessions({
|
|
66
|
+
limit: -1, // Get all, we'll paginate ourselves
|
|
67
|
+
all: true,
|
|
68
|
+
workspacePath: resolved.workspace,
|
|
69
|
+
}, resolved.dataPath);
|
|
70
|
+
// Total count before pagination
|
|
71
|
+
const total = coreSessions.length;
|
|
72
|
+
// Apply offset and limit
|
|
73
|
+
const start = resolved.offset;
|
|
74
|
+
const end = Math.min(start + resolved.limit, total);
|
|
75
|
+
const paginatedSessions = coreSessions.slice(start, end);
|
|
76
|
+
// Convert to library Session format
|
|
77
|
+
// We need full sessions, not summaries, so we'll fetch each one
|
|
78
|
+
const sessions = paginatedSessions.map((summary) => {
|
|
79
|
+
const fullSession = storage.getSession(summary.index, resolved.dataPath);
|
|
80
|
+
if (!fullSession) {
|
|
81
|
+
throw new DatabaseNotFoundError(`Session ${summary.index} not found`);
|
|
82
|
+
}
|
|
83
|
+
return convertToLibrarySession(fullSession);
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
data: sessions,
|
|
87
|
+
pagination: {
|
|
88
|
+
total,
|
|
89
|
+
limit: resolved.limit,
|
|
90
|
+
offset: resolved.offset,
|
|
91
|
+
hasMore: end < total,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
// Check for SQLite BUSY error (database locked)
|
|
97
|
+
if (err instanceof Error && err.message.includes('SQLITE_BUSY')) {
|
|
98
|
+
throw new DatabaseLockedError(config?.dataPath ?? 'default path');
|
|
99
|
+
}
|
|
100
|
+
// Check for file not found errors
|
|
101
|
+
if (err instanceof Error && (err.message.includes('ENOENT') || err.message.includes('no such file'))) {
|
|
102
|
+
throw new DatabaseNotFoundError(config?.dataPath ?? 'default path');
|
|
103
|
+
}
|
|
104
|
+
// Re-throw library errors as-is
|
|
105
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
// Wrap other errors
|
|
109
|
+
throw new Error(`Failed to list sessions: ${err instanceof Error ? err.message : String(err)}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get a specific session by index.
|
|
114
|
+
*
|
|
115
|
+
* @param index - Zero-based session index (from listSessions result)
|
|
116
|
+
* @param config - Optional configuration (dataPath)
|
|
117
|
+
* @returns Complete session with all messages
|
|
118
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
119
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
120
|
+
* @throws {InvalidConfigError} If index is out of bounds
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const session = getSession(0);
|
|
124
|
+
* console.log(session.messages); // Message[]
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // Get session from custom data path
|
|
128
|
+
* const session = getSession(5, { dataPath: '/custom/cursor/data' });
|
|
129
|
+
*/
|
|
130
|
+
export function getSession(index, config) {
|
|
131
|
+
try {
|
|
132
|
+
const resolved = mergeWithDefaults(config);
|
|
133
|
+
// Core storage uses 1-based indexing, so we add 1
|
|
134
|
+
const coreIndex = index + 1;
|
|
135
|
+
const coreSession = storage.getSession(coreIndex, resolved.dataPath);
|
|
136
|
+
if (!coreSession) {
|
|
137
|
+
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
138
|
+
}
|
|
139
|
+
return convertToLibrarySession(coreSession);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
// Check for SQLite BUSY error (database locked)
|
|
143
|
+
if (err instanceof Error && err.message.includes('SQLITE_BUSY')) {
|
|
144
|
+
throw new DatabaseLockedError(config?.dataPath ?? 'default path');
|
|
145
|
+
}
|
|
146
|
+
// Check for file not found errors
|
|
147
|
+
if (err instanceof Error && (err.message.includes('ENOENT') || err.message.includes('no such file'))) {
|
|
148
|
+
throw new DatabaseNotFoundError(config?.dataPath ?? 'default path');
|
|
149
|
+
}
|
|
150
|
+
// Re-throw library errors as-is
|
|
151
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
// Wrap other errors
|
|
155
|
+
throw new Error(`Failed to get session: ${err instanceof Error ? err.message : String(err)}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Search across all sessions for matching content.
|
|
160
|
+
*
|
|
161
|
+
* @param query - Search query string (case-insensitive substring match)
|
|
162
|
+
* @param config - Optional configuration (dataPath, workspace filter, context lines)
|
|
163
|
+
* @returns Array of search results with context
|
|
164
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
165
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Basic search
|
|
169
|
+
* const results = searchSessions('authentication');
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* // Search with context lines
|
|
173
|
+
* const results = searchSessions('error', { context: 2 });
|
|
174
|
+
* results.forEach(r => {
|
|
175
|
+
* console.log(r.contextBefore); // 2 lines before match
|
|
176
|
+
* console.log(r.match); // matched line
|
|
177
|
+
* console.log(r.contextAfter); // 2 lines after match
|
|
178
|
+
* });
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* // Search within specific workspace
|
|
182
|
+
* const results = searchSessions('bug', { workspace: '/path/to/project' });
|
|
183
|
+
*/
|
|
184
|
+
export function searchSessions(query, config) {
|
|
185
|
+
try {
|
|
186
|
+
const resolved = mergeWithDefaults(config);
|
|
187
|
+
// Search using core storage layer
|
|
188
|
+
const coreResults = storage.searchSessions(query, {
|
|
189
|
+
limit: resolved.limit === Number.MAX_SAFE_INTEGER ? 0 : resolved.limit,
|
|
190
|
+
contextChars: resolved.context * 80, // Rough estimate: 1 line = 80 chars
|
|
191
|
+
workspacePath: resolved.workspace,
|
|
192
|
+
}, resolved.dataPath);
|
|
193
|
+
// Convert core results to library format
|
|
194
|
+
return coreResults.map((coreResult) => {
|
|
195
|
+
// Get full session for reference
|
|
196
|
+
const fullSession = storage.getSession(coreResult.index, resolved.dataPath);
|
|
197
|
+
if (!fullSession) {
|
|
198
|
+
throw new DatabaseNotFoundError(`Session ${coreResult.index} not found`);
|
|
199
|
+
}
|
|
200
|
+
// Find the first match to get offset and context
|
|
201
|
+
const firstSnippet = coreResult.snippets[0];
|
|
202
|
+
const match = firstSnippet?.text ?? '';
|
|
203
|
+
const offset = firstSnippet?.matchPositions[0]?.[0] ?? 0;
|
|
204
|
+
// Extract context lines (split by newlines)
|
|
205
|
+
const lines = match.split('\n');
|
|
206
|
+
const contextBefore = [];
|
|
207
|
+
const contextAfter = [];
|
|
208
|
+
// Find the line containing the match
|
|
209
|
+
let matchLineIndex = 0;
|
|
210
|
+
for (let i = 0; i < lines.length; i++) {
|
|
211
|
+
const line = lines[i];
|
|
212
|
+
if (line && line.includes(query)) {
|
|
213
|
+
matchLineIndex = i;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Get context lines before and after
|
|
218
|
+
if (resolved.context > 0) {
|
|
219
|
+
const start = Math.max(0, matchLineIndex - resolved.context);
|
|
220
|
+
const end = Math.min(lines.length, matchLineIndex + resolved.context + 1);
|
|
221
|
+
for (let i = start; i < matchLineIndex; i++) {
|
|
222
|
+
const line = lines[i];
|
|
223
|
+
if (line)
|
|
224
|
+
contextBefore.push(line);
|
|
225
|
+
}
|
|
226
|
+
for (let i = matchLineIndex + 1; i < end; i++) {
|
|
227
|
+
const line = lines[i];
|
|
228
|
+
if (line)
|
|
229
|
+
contextAfter.push(line);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
session: convertToLibrarySession(fullSession),
|
|
234
|
+
match: lines[matchLineIndex] ?? match,
|
|
235
|
+
messageIndex: 0, // Would need to track which message contains the match
|
|
236
|
+
offset,
|
|
237
|
+
contextBefore: contextBefore.length > 0 ? contextBefore : undefined,
|
|
238
|
+
contextAfter: contextAfter.length > 0 ? contextAfter : undefined,
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
// Check for SQLite BUSY error (database locked)
|
|
244
|
+
if (err instanceof Error && err.message.includes('SQLITE_BUSY')) {
|
|
245
|
+
throw new DatabaseLockedError(config?.dataPath ?? 'default path');
|
|
246
|
+
}
|
|
247
|
+
// Check for file not found errors
|
|
248
|
+
if (err instanceof Error && (err.message.includes('ENOENT') || err.message.includes('no such file'))) {
|
|
249
|
+
throw new DatabaseNotFoundError(config?.dataPath ?? 'default path');
|
|
250
|
+
}
|
|
251
|
+
// Re-throw library errors as-is
|
|
252
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
// Wrap other errors
|
|
256
|
+
throw new Error(`Failed to search sessions: ${err instanceof Error ? err.message : String(err)}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Export a session to JSON format.
|
|
261
|
+
*
|
|
262
|
+
* @param index - Zero-based session index (from listSessions result)
|
|
263
|
+
* @param config - Optional configuration (dataPath)
|
|
264
|
+
* @returns JSON string representation of session
|
|
265
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
266
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
267
|
+
* @throws {InvalidConfigError} If index is out of bounds
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* const json = exportSessionToJson(0);
|
|
271
|
+
* fs.writeFileSync('session.json', json);
|
|
272
|
+
*/
|
|
273
|
+
export function exportSessionToJson(index, config) {
|
|
274
|
+
try {
|
|
275
|
+
const resolved = mergeWithDefaults(config);
|
|
276
|
+
const coreIndex = index + 1; // Convert to 1-based indexing
|
|
277
|
+
const coreSession = storage.getSession(coreIndex, resolved.dataPath);
|
|
278
|
+
if (!coreSession) {
|
|
279
|
+
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
280
|
+
}
|
|
281
|
+
return exportToJson(coreSession, coreSession.workspacePath);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
285
|
+
throw err;
|
|
286
|
+
}
|
|
287
|
+
throw new Error(`Failed to export session to JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Export a session to Markdown format.
|
|
292
|
+
*
|
|
293
|
+
* @param index - Zero-based session index (from listSessions result)
|
|
294
|
+
* @param config - Optional configuration (dataPath)
|
|
295
|
+
* @returns Markdown formatted string
|
|
296
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
297
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
298
|
+
* @throws {InvalidConfigError} If index is out of bounds
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* const markdown = exportSessionToMarkdown(0);
|
|
302
|
+
* fs.writeFileSync('session.md', markdown);
|
|
303
|
+
*/
|
|
304
|
+
export function exportSessionToMarkdown(index, config) {
|
|
305
|
+
try {
|
|
306
|
+
const resolved = mergeWithDefaults(config);
|
|
307
|
+
const coreIndex = index + 1; // Convert to 1-based indexing
|
|
308
|
+
const coreSession = storage.getSession(coreIndex, resolved.dataPath);
|
|
309
|
+
if (!coreSession) {
|
|
310
|
+
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
311
|
+
}
|
|
312
|
+
return exportToMarkdown(coreSession, coreSession.workspacePath);
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
316
|
+
throw err;
|
|
317
|
+
}
|
|
318
|
+
throw new Error(`Failed to export session to Markdown: ${err instanceof Error ? err.message : String(err)}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Export all sessions to JSON format.
|
|
323
|
+
*
|
|
324
|
+
* @param config - Optional configuration (dataPath, workspace filter)
|
|
325
|
+
* @returns JSON string with array of all sessions
|
|
326
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
327
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* const json = exportAllSessionsToJson();
|
|
331
|
+
* fs.writeFileSync('all-sessions.json', json);
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* // Export sessions from specific workspace
|
|
335
|
+
* const json = exportAllSessionsToJson({ workspace: '/path/to/project' });
|
|
336
|
+
*/
|
|
337
|
+
export function exportAllSessionsToJson(config) {
|
|
338
|
+
try {
|
|
339
|
+
const resolved = mergeWithDefaults(config);
|
|
340
|
+
// Get all sessions
|
|
341
|
+
const coreSessions = storage.listSessions({
|
|
342
|
+
limit: -1,
|
|
343
|
+
all: true,
|
|
344
|
+
workspacePath: resolved.workspace,
|
|
345
|
+
}, resolved.dataPath);
|
|
346
|
+
// Export each session
|
|
347
|
+
const exportedSessions = coreSessions.map((summary) => {
|
|
348
|
+
const session = storage.getSession(summary.index, resolved.dataPath);
|
|
349
|
+
if (!session)
|
|
350
|
+
return null;
|
|
351
|
+
return JSON.parse(exportToJson(session, session.workspacePath));
|
|
352
|
+
}).filter((s) => s !== null);
|
|
353
|
+
return JSON.stringify(exportedSessions, null, 2);
|
|
354
|
+
}
|
|
355
|
+
catch (err) {
|
|
356
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
357
|
+
throw err;
|
|
358
|
+
}
|
|
359
|
+
throw new Error(`Failed to export all sessions to JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Export all sessions to Markdown format.
|
|
364
|
+
*
|
|
365
|
+
* @param config - Optional configuration (dataPath, workspace filter)
|
|
366
|
+
* @returns Markdown formatted string with all sessions
|
|
367
|
+
* @throws {DatabaseLockedError} If database is locked by Cursor
|
|
368
|
+
* @throws {DatabaseNotFoundError} If database path does not exist
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* const markdown = exportAllSessionsToMarkdown();
|
|
372
|
+
* fs.writeFileSync('all-sessions.md', markdown);
|
|
373
|
+
*/
|
|
374
|
+
export function exportAllSessionsToMarkdown(config) {
|
|
375
|
+
try {
|
|
376
|
+
const resolved = mergeWithDefaults(config);
|
|
377
|
+
// Get all sessions
|
|
378
|
+
const coreSessions = storage.listSessions({
|
|
379
|
+
limit: -1,
|
|
380
|
+
all: true,
|
|
381
|
+
workspacePath: resolved.workspace,
|
|
382
|
+
}, resolved.dataPath);
|
|
383
|
+
// Export each session
|
|
384
|
+
const parts = [];
|
|
385
|
+
for (const summary of coreSessions) {
|
|
386
|
+
const session = storage.getSession(summary.index, resolved.dataPath);
|
|
387
|
+
if (!session)
|
|
388
|
+
continue;
|
|
389
|
+
parts.push(exportToMarkdown(session, session.workspacePath));
|
|
390
|
+
parts.push('\n\n---\n\n'); // Separator between sessions
|
|
391
|
+
}
|
|
392
|
+
return parts.join('');
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
if (err instanceof DatabaseLockedError || err instanceof DatabaseNotFoundError) {
|
|
396
|
+
throw err;
|
|
397
|
+
}
|
|
398
|
+
throw new Error(`Failed to export all sessions to Markdown: ${err instanceof Error ? err.message : String(err)}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,oDAAoD;AACpD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,2BAA2B;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnE;;GAEG;AACH,SAAS,uBAAuB,CAAC,WAAwB;IACvD,OAAO;QACL,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,SAAS,EAAE,WAAW,CAAC,aAAa,IAAI,SAAS;QACjD,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE;QAC9C,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC3C,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW;YAChD,OAAO,EAAE,GAAG,CAAC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CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public TypeScript type definitions for cursor-history library
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: This is a library interface for direct import and use in TypeScript/JavaScript
|
|
5
|
+
* projects, NOT a network/REST API. Functions are imported directly:
|
|
6
|
+
* `import { Session, Message } from 'cursor-history'`
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Represents a complete chat conversation with metadata and messages.
|
|
10
|
+
*/
|
|
11
|
+
export interface Session {
|
|
12
|
+
/** Unique identifier (database row ID or composite key) */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Absolute path to workspace directory */
|
|
15
|
+
workspace: string;
|
|
16
|
+
/** ISO 8601 timestamp of session creation */
|
|
17
|
+
timestamp: string;
|
|
18
|
+
/** Array of messages in chronological order */
|
|
19
|
+
messages: Message[];
|
|
20
|
+
/** Total number of messages in session */
|
|
21
|
+
messageCount: number;
|
|
22
|
+
/** Metadata about session origin (optional) */
|
|
23
|
+
metadata?: {
|
|
24
|
+
/** Cursor version that created this session */
|
|
25
|
+
cursorVersion?: string;
|
|
26
|
+
/** Last modified timestamp */
|
|
27
|
+
lastModified?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Represents a single message within a session (user or assistant).
|
|
32
|
+
*/
|
|
33
|
+
export interface Message {
|
|
34
|
+
/** Message role: 'user' or 'assistant' */
|
|
35
|
+
role: 'user' | 'assistant';
|
|
36
|
+
/** Message content (text, code blocks, or structured data) */
|
|
37
|
+
content: string;
|
|
38
|
+
/** ISO 8601 timestamp when message was created */
|
|
39
|
+
timestamp: string;
|
|
40
|
+
/** Tool calls executed by assistant (optional, assistant-only) */
|
|
41
|
+
toolCalls?: ToolCall[];
|
|
42
|
+
/** AI reasoning/thinking text (optional, assistant-only) */
|
|
43
|
+
thinking?: string;
|
|
44
|
+
/** Metadata about message processing (optional) */
|
|
45
|
+
metadata?: {
|
|
46
|
+
/** Whether message data was partially corrupted */
|
|
47
|
+
corrupted?: boolean;
|
|
48
|
+
/** Original bubble type from database (for debugging) */
|
|
49
|
+
bubbleType?: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Represents a tool/function call executed by the assistant.
|
|
54
|
+
*/
|
|
55
|
+
export interface ToolCall {
|
|
56
|
+
/** Tool/function name (e.g., 'read_file', 'write', 'grep') */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Tool execution status */
|
|
59
|
+
status: 'completed' | 'cancelled' | 'error';
|
|
60
|
+
/** Tool parameters as JSON object */
|
|
61
|
+
params?: Record<string, unknown>;
|
|
62
|
+
/** Tool execution result (optional, present if status === 'completed') */
|
|
63
|
+
result?: string;
|
|
64
|
+
/** Error message (optional, present if status === 'error') */
|
|
65
|
+
error?: string;
|
|
66
|
+
/** File paths involved in this tool call (optional) */
|
|
67
|
+
files?: string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Represents a search match with context.
|
|
71
|
+
*/
|
|
72
|
+
export interface SearchResult {
|
|
73
|
+
/** Reference to the session containing this match */
|
|
74
|
+
session: Session;
|
|
75
|
+
/** Matched content snippet */
|
|
76
|
+
match: string;
|
|
77
|
+
/** Message index within session where match was found */
|
|
78
|
+
messageIndex: number;
|
|
79
|
+
/** Context lines before match (optional, based on config) */
|
|
80
|
+
contextBefore?: string[];
|
|
81
|
+
/** Context lines after match (optional, based on config) */
|
|
82
|
+
contextAfter?: string[];
|
|
83
|
+
/** Character offset of match within message content */
|
|
84
|
+
offset?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Configuration options for library functions.
|
|
88
|
+
*/
|
|
89
|
+
export interface LibraryConfig {
|
|
90
|
+
/** Custom Cursor data path (optional, defaults to platform path) */
|
|
91
|
+
dataPath?: string;
|
|
92
|
+
/** Filter sessions by workspace path (optional) */
|
|
93
|
+
workspace?: string;
|
|
94
|
+
/** Pagination limit (optional, defaults to no limit) */
|
|
95
|
+
limit?: number;
|
|
96
|
+
/** Pagination offset (optional, defaults to 0) */
|
|
97
|
+
offset?: number;
|
|
98
|
+
/** Search context lines (optional, defaults to 0) */
|
|
99
|
+
context?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Wrapper for paginated API responses.
|
|
103
|
+
*/
|
|
104
|
+
export interface PaginatedResult<T> {
|
|
105
|
+
/** Array of data items for current page */
|
|
106
|
+
data: T[];
|
|
107
|
+
/** Pagination metadata */
|
|
108
|
+
pagination: {
|
|
109
|
+
/** Total number of items across all pages */
|
|
110
|
+
total: number;
|
|
111
|
+
/** Maximum items per page (from config.limit) */
|
|
112
|
+
limit: number;
|
|
113
|
+
/** Offset of first item in current page (from config.offset) */
|
|
114
|
+
offset: number;
|
|
115
|
+
/** Whether more pages exist after this one */
|
|
116
|
+
hasMore: boolean;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IAEX,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAElB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IAErB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE;QACT,+CAA+C;QAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;QAEvB,8BAA8B;QAC9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,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,2CAA2C;IAC3C,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV,0BAA0B;IAC1B,UAAU,EAAE;QACV,6CAA6C;QAC7C,KAAK,EAAE,MAAM,CAAC;QAEd,iDAAiD;QACjD,KAAK,EAAE,MAAM,CAAC;QAEd,gEAAgE;QAChE,MAAM,EAAE,MAAM,CAAC;QAEf,8CAA8C;QAC9C,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public TypeScript type definitions for cursor-history library
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: This is a library interface for direct import and use in TypeScript/JavaScript
|
|
5
|
+
* projects, NOT a network/REST API. Functions are imported directly:
|
|
6
|
+
* `import { Session, Message } from 'cursor-history'`
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for library API
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get the platform-specific default Cursor data path.
|
|
6
|
+
*
|
|
7
|
+
* @returns Absolute path to Cursor data directory
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const defaultPath = getDefaultDataPath();
|
|
11
|
+
* console.log(defaultPath);
|
|
12
|
+
* // macOS: ~/Library/Application Support/Cursor/User/workspaceStorage
|
|
13
|
+
* // Linux: ~/.config/Cursor/User/workspaceStorage
|
|
14
|
+
* // Windows: %APPDATA%\Cursor\User\workspaceStorage
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDefaultDataPath(): string;
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for library API
|
|
3
|
+
*/
|
|
4
|
+
import { getCursorDataPath } from '../lib/platform.js';
|
|
5
|
+
/**
|
|
6
|
+
* Get the platform-specific default Cursor data path.
|
|
7
|
+
*
|
|
8
|
+
* @returns Absolute path to Cursor data directory
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const defaultPath = getDefaultDataPath();
|
|
12
|
+
* console.log(defaultPath);
|
|
13
|
+
* // macOS: ~/Library/Application Support/Cursor/User/workspaceStorage
|
|
14
|
+
* // Linux: ~/.config/Cursor/User/workspaceStorage
|
|
15
|
+
* // Windows: %APPDATA%\Cursor\User\workspaceStorage
|
|
16
|
+
*/
|
|
17
|
+
export function getDefaultDataPath() {
|
|
18
|
+
return getCursorDataPath();
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-history",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "CLI tool to browse and export Cursor AI chat history",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "CLI tool and library to browse and export Cursor AI chat history",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/
|
|
6
|
+
"main": "dist/lib/index.js",
|
|
7
|
+
"types": "dist/lib/index.d.ts",
|
|
7
8
|
"bin": {
|
|
8
9
|
"cursor-history": "dist/cli/index.js"
|
|
9
10
|
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/lib/index.js",
|
|
14
|
+
"require": "./dist/lib/index.cjs",
|
|
15
|
+
"types": "./dist/lib/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
10
18
|
"scripts": {
|
|
11
19
|
"build": "tsc",
|
|
12
20
|
"dev": "tsc --watch",
|