cursor-history 0.5.1 → 0.8.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.
Files changed (83) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +385 -2
  3. package/dist/cli/commands/backup.d.ts +9 -0
  4. package/dist/cli/commands/backup.d.ts.map +1 -0
  5. package/dist/cli/commands/backup.js +168 -0
  6. package/dist/cli/commands/backup.js.map +1 -0
  7. package/dist/cli/commands/export.d.ts.map +1 -1
  8. package/dist/cli/commands/export.js +39 -7
  9. package/dist/cli/commands/export.js.map +1 -1
  10. package/dist/cli/commands/list-backups.d.ts +9 -0
  11. package/dist/cli/commands/list-backups.d.ts.map +1 -0
  12. package/dist/cli/commands/list-backups.js +166 -0
  13. package/dist/cli/commands/list-backups.js.map +1 -0
  14. package/dist/cli/commands/list.d.ts.map +1 -1
  15. package/dist/cli/commands/list.js +44 -9
  16. package/dist/cli/commands/list.js.map +1 -1
  17. package/dist/cli/commands/migrate-session.d.ts +12 -0
  18. package/dist/cli/commands/migrate-session.d.ts.map +1 -0
  19. package/dist/cli/commands/migrate-session.js +125 -0
  20. package/dist/cli/commands/migrate-session.js.map +1 -0
  21. package/dist/cli/commands/migrate.d.ts +13 -0
  22. package/dist/cli/commands/migrate.d.ts.map +1 -0
  23. package/dist/cli/commands/migrate.js +122 -0
  24. package/dist/cli/commands/migrate.js.map +1 -0
  25. package/dist/cli/commands/restore.d.ts +9 -0
  26. package/dist/cli/commands/restore.d.ts.map +1 -0
  27. package/dist/cli/commands/restore.js +192 -0
  28. package/dist/cli/commands/restore.js.map +1 -0
  29. package/dist/cli/commands/search.d.ts.map +1 -1
  30. package/dist/cli/commands/search.js +31 -3
  31. package/dist/cli/commands/search.js.map +1 -1
  32. package/dist/cli/commands/show.d.ts.map +1 -1
  33. package/dist/cli/commands/show.js +32 -4
  34. package/dist/cli/commands/show.js.map +1 -1
  35. package/dist/cli/errors.d.ts +56 -0
  36. package/dist/cli/errors.d.ts.map +1 -0
  37. package/dist/cli/errors.js +90 -0
  38. package/dist/cli/errors.js.map +1 -0
  39. package/dist/cli/index.js +11 -1
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/core/backup.d.ts +89 -0
  42. package/dist/core/backup.d.ts.map +1 -0
  43. package/dist/core/backup.js +709 -0
  44. package/dist/core/backup.js.map +1 -0
  45. package/dist/core/migrate.d.ts +40 -0
  46. package/dist/core/migrate.d.ts.map +1 -0
  47. package/dist/core/migrate.js +586 -0
  48. package/dist/core/migrate.js.map +1 -0
  49. package/dist/core/storage.d.ts +78 -6
  50. package/dist/core/storage.d.ts.map +1 -1
  51. package/dist/core/storage.js +327 -45
  52. package/dist/core/storage.js.map +1 -1
  53. package/dist/core/types.d.ts +280 -0
  54. package/dist/core/types.d.ts.map +1 -1
  55. package/dist/lib/backup.d.ts +98 -0
  56. package/dist/lib/backup.d.ts.map +1 -0
  57. package/dist/lib/backup.js +108 -0
  58. package/dist/lib/backup.js.map +1 -0
  59. package/dist/lib/config.d.ts +33 -0
  60. package/dist/lib/config.d.ts.map +1 -0
  61. package/dist/lib/config.js +81 -0
  62. package/dist/lib/config.js.map +1 -0
  63. package/dist/lib/errors.d.ts +257 -30
  64. package/dist/lib/errors.d.ts.map +1 -1
  65. package/dist/lib/errors.js +404 -54
  66. package/dist/lib/errors.js.map +1 -1
  67. package/dist/lib/index.d.ts +219 -0
  68. package/dist/lib/index.d.ts.map +1 -0
  69. package/dist/lib/index.js +520 -0
  70. package/dist/lib/index.js.map +1 -0
  71. package/dist/lib/platform.d.ts +11 -0
  72. package/dist/lib/platform.d.ts.map +1 -1
  73. package/dist/lib/platform.js +32 -0
  74. package/dist/lib/platform.js.map +1 -1
  75. package/dist/lib/types.d.ts +374 -0
  76. package/dist/lib/types.d.ts.map +1 -0
  77. package/dist/lib/types.js +9 -0
  78. package/dist/lib/types.js.map +1 -0
  79. package/dist/lib/utils.d.ts +17 -0
  80. package/dist/lib/utils.d.ts.map +1 -0
  81. package/dist/lib/utils.js +20 -0
  82. package/dist/lib/utils.js.map +1 -0
  83. package/package.json +32 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/core/backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3H,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,MAAM,MAAM,SAAS,CAAC;AAa7B,+BAA+B;AAC/B,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC,+EAA+E;AAC/E,qCAAqC;AACrC,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,wBAAwB,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CA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,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Core migration logic for Cursor chat history
3
+ *
4
+ * This module provides session-level migration as the core primitive.
5
+ * Workspace-level migration is built on top of session migration.
6
+ */
7
+ import type { MigrateSessionOptions, MigrateWorkspaceOptions, SessionMigrationResult, WorkspaceMigrationResult } from './types.js';
8
+ /**
9
+ * Migrate a single session from its current workspace to a destination workspace.
10
+ *
11
+ * This is the core primitive for all migration operations.
12
+ * Move mode: removes session from source, adds to destination.
13
+ * Copy mode: duplicates session to destination, keeps source intact.
14
+ *
15
+ * @param sessionId - The session ID to migrate
16
+ * @param options - Migration options
17
+ * @returns Migration result for this session
18
+ */
19
+ export declare function migrateSession(sessionId: string, options: Omit<MigrateSessionOptions, 'sessionIds'>): SessionMigrationResult;
20
+ /**
21
+ * Migrate multiple sessions to a destination workspace.
22
+ *
23
+ * Handles batch migration with partial failure support.
24
+ * Each session is migrated independently - failures don't stop the batch.
25
+ *
26
+ * @param options - Migration options including session IDs
27
+ * @returns Array of results for each session
28
+ */
29
+ export declare function migrateSessions(options: MigrateSessionOptions): SessionMigrationResult[];
30
+ /**
31
+ * Migrate all sessions from one workspace to another.
32
+ *
33
+ * This is a convenience wrapper that finds all sessions in the source workspace
34
+ * and calls migrateSession for each one.
35
+ *
36
+ * @param options - Workspace migration options
37
+ * @returns Aggregate result with per-session details
38
+ */
39
+ export declare function migrateWorkspace(options: MigrateWorkspaceOptions): WorkspaceMigrationResult;
40
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/core/migrate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AA+apB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,YAAY,CAAC,GACjD,sBAAsB,CA+IxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,EAAE,CAuBxF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,wBAAwB,CAoF3F"}
@@ -0,0 +1,586 @@
1
+ /**
2
+ * Core migration logic for Cursor chat history
3
+ *
4
+ * This module provides session-level migration as the core primitive.
5
+ * Workspace-level migration is built on top of session migration.
6
+ */
7
+ import { existsSync } from 'node:fs';
8
+ import { join } from 'node:path';
9
+ import { homedir } from 'node:os';
10
+ import Database from 'better-sqlite3';
11
+ import { findWorkspaceForSession, findWorkspaceByPath, openDatabaseReadWrite, getComposerData, updateComposerData, } from './storage.js';
12
+ import { normalizePath, pathsEqual } from '../lib/platform.js';
13
+ import { SessionNotFoundError, WorkspaceNotFoundError, SameWorkspaceError, NoSessionsFoundError, DestinationHasSessionsError, NestedPathError, } from '../lib/errors.js';
14
+ /**
15
+ * Generate a new unique session ID (UUID v4 format)
16
+ */
17
+ function generateSessionId() {
18
+ // Simple UUID v4 generator
19
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
20
+ const r = (Math.random() * 16) | 0;
21
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
22
+ return v.toString(16);
23
+ });
24
+ }
25
+ /**
26
+ * Get the global Cursor storage path
27
+ */
28
+ function getGlobalStoragePath() {
29
+ const platform = process.platform;
30
+ const home = homedir();
31
+ if (platform === 'win32') {
32
+ return join(process.env['APPDATA'] ?? join(home, 'AppData', 'Roaming'), 'Cursor', 'User', 'globalStorage');
33
+ }
34
+ else if (platform === 'darwin') {
35
+ return join(home, 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage');
36
+ }
37
+ else {
38
+ return join(home, '.config', 'Cursor', 'User', 'globalStorage');
39
+ }
40
+ }
41
+ /**
42
+ * T004: Transform a single path by replacing source prefix with destination prefix.
43
+ * Returns null if path doesn't start with source prefix (external path).
44
+ *
45
+ * @param path - The path to transform
46
+ * @param sourcePrefix - Source workspace path prefix
47
+ * @param destPrefix - Destination workspace path prefix
48
+ * @returns Transformed path or null if path is external
49
+ */
50
+ function transformPath(path, sourcePrefix, destPrefix) {
51
+ // Normalize for comparison (handle trailing slashes)
52
+ const normalizedSource = sourcePrefix.replace(/\/+$/, '');
53
+ const normalizedPath = path;
54
+ // Check if path starts with source prefix
55
+ if (normalizedPath.startsWith(normalizedSource + '/') || normalizedPath === normalizedSource) {
56
+ // Replace the prefix
57
+ return destPrefix + normalizedPath.slice(normalizedSource.length);
58
+ }
59
+ // Path is outside source workspace
60
+ return null;
61
+ }
62
+ /**
63
+ * T005: Transform file paths in toolFormerData.params.
64
+ * Updates: relativeWorkspacePath, targetFile, filePath, path
65
+ *
66
+ * @param params - Parsed params object (will be mutated)
67
+ * @param sourcePrefix - Source workspace path prefix
68
+ * @param destPrefix - Destination workspace path prefix
69
+ * @param debug - Whether to log transformations
70
+ * @returns Count of transformed and skipped paths
71
+ */
72
+ function transformToolFormerParams(params, sourcePrefix, destPrefix, debug) {
73
+ const result = { transformed: 0, skipped: 0 };
74
+ const pathFields = ['relativeWorkspacePath', 'targetFile', 'filePath', 'path'];
75
+ for (const field of pathFields) {
76
+ const value = params[field];
77
+ if (typeof value !== 'string')
78
+ continue;
79
+ const transformed = transformPath(value, sourcePrefix, destPrefix);
80
+ if (transformed !== null) {
81
+ if (debug) {
82
+ console.error(`[DEBUG] toolFormerData.params.${field}: ${value} -> ${transformed}`);
83
+ }
84
+ params[field] = transformed;
85
+ result.transformed++;
86
+ }
87
+ else {
88
+ if (debug) {
89
+ console.error(`[SKIP] toolFormerData.params.${field}: ${value} (outside workspace)`);
90
+ }
91
+ result.skipped++;
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ /**
97
+ * T006: Transform file paths in codeBlocks[].uri.
98
+ * Updates: path, _formatted, _fsPath
99
+ *
100
+ * @param uri - URI object (will be mutated)
101
+ * @param sourcePrefix - Source workspace path prefix
102
+ * @param destPrefix - Destination workspace path prefix
103
+ * @param debug - Whether to log transformations
104
+ * @param blockIndex - Index of code block for logging
105
+ * @returns Count of transformed and skipped paths
106
+ */
107
+ function transformCodeBlockUri(uri, sourcePrefix, destPrefix, debug, blockIndex) {
108
+ const result = { transformed: 0, skipped: 0 };
109
+ // Transform uri.path
110
+ if (typeof uri.path === 'string') {
111
+ const transformed = transformPath(uri.path, sourcePrefix, destPrefix);
112
+ if (transformed !== null) {
113
+ if (debug) {
114
+ console.error(`[DEBUG] codeBlocks[${blockIndex}].uri.path: ${uri.path} -> ${transformed}`);
115
+ }
116
+ uri.path = transformed;
117
+ result.transformed++;
118
+ }
119
+ else {
120
+ if (debug) {
121
+ console.error(`[SKIP] codeBlocks[${blockIndex}].uri.path: ${uri.path} (outside workspace)`);
122
+ }
123
+ result.skipped++;
124
+ }
125
+ }
126
+ // Transform uri._fsPath
127
+ if (typeof uri._fsPath === 'string') {
128
+ const transformed = transformPath(uri._fsPath, sourcePrefix, destPrefix);
129
+ if (transformed !== null) {
130
+ if (debug) {
131
+ console.error(`[DEBUG] codeBlocks[${blockIndex}].uri._fsPath: ${uri._fsPath} -> ${transformed}`);
132
+ }
133
+ uri._fsPath = transformed;
134
+ result.transformed++;
135
+ }
136
+ else {
137
+ if (debug) {
138
+ console.error(`[SKIP] codeBlocks[${blockIndex}].uri._fsPath: ${uri._fsPath} (outside workspace)`);
139
+ }
140
+ result.skipped++;
141
+ }
142
+ }
143
+ // Transform uri._formatted (file:// URL format)
144
+ if (typeof uri._formatted === 'string') {
145
+ // Extract path from file:// URL
146
+ const fileUrlPrefix = 'file://';
147
+ if (uri._formatted.startsWith(fileUrlPrefix)) {
148
+ const urlPath = uri._formatted.slice(fileUrlPrefix.length);
149
+ const transformed = transformPath(urlPath, sourcePrefix, destPrefix);
150
+ if (transformed !== null) {
151
+ const newFormatted = fileUrlPrefix + transformed;
152
+ if (debug) {
153
+ console.error(`[DEBUG] codeBlocks[${blockIndex}].uri._formatted: ${uri._formatted} -> ${newFormatted}`);
154
+ }
155
+ uri._formatted = newFormatted;
156
+ result.transformed++;
157
+ }
158
+ else {
159
+ if (debug) {
160
+ console.error(`[SKIP] codeBlocks[${blockIndex}].uri._formatted: ${uri._formatted} (outside workspace)`);
161
+ }
162
+ result.skipped++;
163
+ }
164
+ }
165
+ }
166
+ return result;
167
+ }
168
+ /**
169
+ * T007: Transform all file paths in a bubble's data.
170
+ * Updates toolFormerData.params and codeBlocks[].uri
171
+ *
172
+ * @param bubbleData - Bubble data object (will be mutated)
173
+ * @param sourcePrefix - Source workspace path prefix
174
+ * @param destPrefix - Destination workspace path prefix
175
+ * @param debug - Whether to log transformations
176
+ * @returns Total count of transformed and skipped paths
177
+ */
178
+ function transformBubblePaths(bubbleData, sourcePrefix, destPrefix, debug) {
179
+ const result = { transformed: 0, skipped: 0 };
180
+ // Transform toolFormerData.params
181
+ const toolFormerData = bubbleData.toolFormerData;
182
+ if (toolFormerData?.params) {
183
+ try {
184
+ // params is stored as JSON string
185
+ const params = JSON.parse(toolFormerData.params);
186
+ const paramsResult = transformToolFormerParams(params, sourcePrefix, destPrefix, debug);
187
+ result.transformed += paramsResult.transformed;
188
+ result.skipped += paramsResult.skipped;
189
+ // Update params back to JSON string if any paths were transformed
190
+ if (paramsResult.transformed > 0) {
191
+ toolFormerData.params = JSON.stringify(params);
192
+ }
193
+ }
194
+ catch {
195
+ // params is not valid JSON, skip
196
+ }
197
+ }
198
+ // Transform codeBlocks[].uri
199
+ const codeBlocks = bubbleData.codeBlocks;
200
+ if (Array.isArray(codeBlocks)) {
201
+ for (let i = 0; i < codeBlocks.length; i++) {
202
+ const block = codeBlocks[i];
203
+ if (block?.uri && typeof block.uri === 'object') {
204
+ const uriResult = transformCodeBlockUri(block.uri, sourcePrefix, destPrefix, debug, i);
205
+ result.transformed += uriResult.transformed;
206
+ result.skipped += uriResult.skipped;
207
+ }
208
+ }
209
+ }
210
+ return result;
211
+ }
212
+ /**
213
+ * T008: Check if destination path is nested within source path.
214
+ * This would cause infinite replacement loops during path transformation.
215
+ *
216
+ * @param source - Source workspace path
217
+ * @param destination - Destination workspace path
218
+ * @returns true if destination is nested within source
219
+ */
220
+ function isNestedPath(source, destination) {
221
+ const normalizedSource = normalizePath(source).replace(/\/+$/, '');
222
+ const normalizedDest = normalizePath(destination).replace(/\/+$/, '');
223
+ // Destination is nested if it starts with source + separator
224
+ return normalizedDest.startsWith(normalizedSource + '/');
225
+ }
226
+ /**
227
+ * Copy all bubble data for a session in global storage with new IDs.
228
+ * This is required for copy mode to create independent session data.
229
+ * Also transforms file paths from source workspace to destination workspace.
230
+ *
231
+ * @param oldComposerId - Original composer ID
232
+ * @param newComposerId - New composer ID for the copy
233
+ * @param sourceWorkspace - Source workspace path (for path transformation)
234
+ * @param destWorkspace - Destination workspace path (for path transformation)
235
+ * @param debug - Whether to log detailed path transformations
236
+ * @returns Map of old bubble IDs to new bubble IDs
237
+ */
238
+ function copyBubbleDataInGlobalStorage(oldComposerId, newComposerId, sourceWorkspace, destWorkspace, debug = false) {
239
+ const globalDbPath = join(getGlobalStoragePath(), 'state.vscdb');
240
+ if (!existsSync(globalDbPath)) {
241
+ return new Map();
242
+ }
243
+ const bubbleIdMap = new Map();
244
+ const db = new Database(globalDbPath, { readonly: false });
245
+ // Normalize workspace paths for transformation
246
+ const sourcePrefix = normalizePath(sourceWorkspace).replace(/\/+$/, '');
247
+ const destPrefix = normalizePath(destWorkspace).replace(/\/+$/, '');
248
+ try {
249
+ // 1. Copy composerData entry with new ID
250
+ const composerDataRow = db.prepare("SELECT value FROM cursorDiskKV WHERE key = ?").get(`composerData:${oldComposerId}`);
251
+ if (composerDataRow) {
252
+ const composerData = JSON.parse(composerDataRow.value);
253
+ // Update composerId in the data
254
+ composerData.composerId = newComposerId;
255
+ // We'll update fullConversationHeadersOnly after generating new bubble IDs
256
+ const oldBubbleHeaders = composerData.fullConversationHeadersOnly || [];
257
+ // Generate new bubble IDs and build the mapping
258
+ const newBubbleHeaders = [];
259
+ for (const header of oldBubbleHeaders) {
260
+ if (header.bubbleId) {
261
+ const newBubbleId = generateSessionId();
262
+ bubbleIdMap.set(header.bubbleId, newBubbleId);
263
+ newBubbleHeaders.push({
264
+ ...header,
265
+ bubbleId: newBubbleId,
266
+ });
267
+ }
268
+ }
269
+ composerData.fullConversationHeadersOnly = newBubbleHeaders;
270
+ // Insert new composerData
271
+ db.prepare("INSERT OR REPLACE INTO cursorDiskKV (key, value) VALUES (?, ?)").run(`composerData:${newComposerId}`, JSON.stringify(composerData));
272
+ }
273
+ // 2. Copy all bubble entries with new IDs and transform paths
274
+ const bubbleRows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ?").all(`bubbleId:${oldComposerId}:%`);
275
+ for (const row of bubbleRows) {
276
+ // Extract old bubble ID from key: bubbleId:<composerId>:<bubbleId>
277
+ const parts = row.key.split(':');
278
+ const oldBubbleId = parts[2];
279
+ if (!oldBubbleId)
280
+ continue;
281
+ // Get or generate new bubble ID
282
+ let newBubbleId = bubbleIdMap.get(oldBubbleId);
283
+ if (!newBubbleId) {
284
+ newBubbleId = generateSessionId();
285
+ bubbleIdMap.set(oldBubbleId, newBubbleId);
286
+ }
287
+ // Parse and update the bubble data
288
+ const bubbleData = JSON.parse(row.value);
289
+ bubbleData.bubbleId = newBubbleId;
290
+ // T010-T011: Transform file paths in the bubble data
291
+ if (debug) {
292
+ console.error(`[DEBUG] Processing bubble: ${oldBubbleId} -> ${newBubbleId}`);
293
+ }
294
+ transformBubblePaths(bubbleData, sourcePrefix, destPrefix, debug);
295
+ // Create new key with new IDs
296
+ const newKey = `bubbleId:${newComposerId}:${newBubbleId}`;
297
+ // Insert the copied bubble with transformed paths
298
+ db.prepare("INSERT OR REPLACE INTO cursorDiskKV (key, value) VALUES (?, ?)").run(newKey, JSON.stringify(bubbleData));
299
+ }
300
+ return bubbleIdMap;
301
+ }
302
+ finally {
303
+ db.close();
304
+ }
305
+ }
306
+ /**
307
+ * Update file paths in existing bubble data for move operations.
308
+ * Unlike copy mode, this modifies bubbles in place (no new IDs needed).
309
+ *
310
+ * @param composerId - Composer ID to update
311
+ * @param sourceWorkspace - Source workspace path
312
+ * @param destWorkspace - Destination workspace path
313
+ * @param debug - Whether to log detailed path transformations
314
+ */
315
+ function updateBubblePathsInGlobalStorage(composerId, sourceWorkspace, destWorkspace, debug = false) {
316
+ const globalDbPath = join(getGlobalStoragePath(), 'state.vscdb');
317
+ if (!existsSync(globalDbPath)) {
318
+ return;
319
+ }
320
+ const db = new Database(globalDbPath, { readonly: false });
321
+ // Normalize workspace paths for transformation
322
+ const sourcePrefix = normalizePath(sourceWorkspace).replace(/\/+$/, '');
323
+ const destPrefix = normalizePath(destWorkspace).replace(/\/+$/, '');
324
+ try {
325
+ // Get all bubble entries for this composer
326
+ const bubbleRows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ?").all(`bubbleId:${composerId}:%`);
327
+ for (const row of bubbleRows) {
328
+ // Parse the bubble data
329
+ const bubbleData = JSON.parse(row.value);
330
+ const bubbleId = bubbleData.bubbleId;
331
+ // Transform file paths in the bubble data
332
+ if (debug && bubbleId) {
333
+ console.error(`[DEBUG] Processing bubble: ${bubbleId}`);
334
+ }
335
+ const result = transformBubblePaths(bubbleData, sourcePrefix, destPrefix, debug);
336
+ // Only update if paths were transformed
337
+ if (result.transformed > 0) {
338
+ db.prepare("UPDATE cursorDiskKV SET value = ? WHERE key = ?").run(JSON.stringify(bubbleData), row.key);
339
+ }
340
+ }
341
+ }
342
+ finally {
343
+ db.close();
344
+ }
345
+ }
346
+ /**
347
+ * Migrate a single session from its current workspace to a destination workspace.
348
+ *
349
+ * This is the core primitive for all migration operations.
350
+ * Move mode: removes session from source, adds to destination.
351
+ * Copy mode: duplicates session to destination, keeps source intact.
352
+ *
353
+ * @param sessionId - The session ID to migrate
354
+ * @param options - Migration options
355
+ * @returns Migration result for this session
356
+ */
357
+ export function migrateSession(sessionId, options) {
358
+ const { destination, mode, dryRun, dataPath, debug = false } = options;
359
+ // Note: force option is used at the CLI layer for validation, not in core migration
360
+ // Normalize destination path
361
+ const normalizedDest = normalizePath(destination);
362
+ // Find source workspace for this session
363
+ const sourceInfo = findWorkspaceForSession(sessionId, dataPath);
364
+ if (!sourceInfo) {
365
+ throw new SessionNotFoundError(sessionId);
366
+ }
367
+ const sourceWorkspace = sourceInfo.workspace.path;
368
+ // Check if source and destination are the same
369
+ if (pathsEqual(sourceWorkspace, normalizedDest)) {
370
+ throw new SameWorkspaceError(normalizedDest);
371
+ }
372
+ // T013: Check for nested paths (would cause infinite replacement loops)
373
+ if (isNestedPath(sourceWorkspace, normalizedDest)) {
374
+ throw new NestedPathError(sourceWorkspace, normalizedDest);
375
+ }
376
+ // Find destination workspace
377
+ const destInfo = findWorkspaceByPath(normalizedDest, dataPath);
378
+ if (!destInfo) {
379
+ throw new WorkspaceNotFoundError(normalizedDest);
380
+ }
381
+ // If dry run, return preview result without making changes
382
+ if (dryRun) {
383
+ return {
384
+ success: true,
385
+ sessionId,
386
+ sourceWorkspace,
387
+ destinationWorkspace: normalizedDest,
388
+ mode,
389
+ dryRun: true,
390
+ pathsWillBeUpdated: true,
391
+ };
392
+ }
393
+ // Perform the actual migration
394
+ try {
395
+ // Open both databases for read-write
396
+ const sourceDb = openDatabaseReadWrite(sourceInfo.dbPath);
397
+ const destDb = openDatabaseReadWrite(destInfo.dbPath);
398
+ try {
399
+ // Get composer data from both workspaces
400
+ const sourceResult = getComposerData(sourceDb);
401
+ const destResult = getComposerData(destDb);
402
+ if (!sourceResult) {
403
+ throw new Error('Source workspace has no composer data');
404
+ }
405
+ // Find the session in source data
406
+ const sessionIndex = sourceResult.composers.findIndex((s) => s.composerId === sessionId);
407
+ if (sessionIndex === -1) {
408
+ throw new SessionNotFoundError(sessionId);
409
+ }
410
+ const sessionToMigrate = sourceResult.composers[sessionIndex];
411
+ if (mode === 'move') {
412
+ // Remove from source
413
+ const newSourceComposers = sourceResult.composers.filter((_, i) => i !== sessionIndex);
414
+ updateComposerData(sourceDb, newSourceComposers, sourceResult.isNewFormat, sourceResult.rawData);
415
+ // Add to destination
416
+ const destComposers = destResult ? destResult.composers : [];
417
+ const newDestComposers = [...destComposers, sessionToMigrate];
418
+ updateComposerData(destDb, newDestComposers, destResult?.isNewFormat ?? sourceResult.isNewFormat, destResult?.rawData);
419
+ // T010-T012: Update file paths in global storage bubble data for move mode
420
+ updateBubblePathsInGlobalStorage(sessionId, sourceWorkspace, normalizedDest, debug);
421
+ return {
422
+ success: true,
423
+ sessionId,
424
+ sourceWorkspace,
425
+ destinationWorkspace: normalizedDest,
426
+ mode: 'move',
427
+ dryRun: false,
428
+ };
429
+ }
430
+ else {
431
+ // Copy mode - duplicate session to destination, keep source intact
432
+ // Generate new session ID for the copy
433
+ const newSessionId = generateSessionId();
434
+ // Copy all bubble data in global storage with new IDs
435
+ // This ensures the copy is fully independent from the original
436
+ // T014: Transform paths during copy (AFTER copying, on new data only)
437
+ copyBubbleDataInGlobalStorage(sessionId, newSessionId, sourceWorkspace, normalizedDest, debug);
438
+ // Deep clone and update the session with new ID
439
+ const copiedSession = JSON.parse(JSON.stringify(sessionToMigrate));
440
+ copiedSession.composerId = newSessionId;
441
+ // Add to destination (don't modify source)
442
+ const destComposers = destResult ? destResult.composers : [];
443
+ const newDestComposers = [...destComposers, copiedSession];
444
+ updateComposerData(destDb, newDestComposers, destResult?.isNewFormat ?? sourceResult.isNewFormat, destResult?.rawData);
445
+ return {
446
+ success: true,
447
+ sessionId,
448
+ sourceWorkspace,
449
+ destinationWorkspace: normalizedDest,
450
+ mode: 'copy',
451
+ newSessionId,
452
+ dryRun: false,
453
+ };
454
+ }
455
+ }
456
+ finally {
457
+ sourceDb.close();
458
+ destDb.close();
459
+ }
460
+ }
461
+ catch (error) {
462
+ // Return failure result instead of throwing for partial failure handling
463
+ return {
464
+ success: false,
465
+ sessionId,
466
+ sourceWorkspace,
467
+ destinationWorkspace: normalizedDest,
468
+ mode,
469
+ error: error instanceof Error ? error.message : String(error),
470
+ dryRun: false,
471
+ };
472
+ }
473
+ }
474
+ /**
475
+ * Migrate multiple sessions to a destination workspace.
476
+ *
477
+ * Handles batch migration with partial failure support.
478
+ * Each session is migrated independently - failures don't stop the batch.
479
+ *
480
+ * @param options - Migration options including session IDs
481
+ * @returns Array of results for each session
482
+ */
483
+ export function migrateSessions(options) {
484
+ const { sessionIds, ...sessionOptions } = options;
485
+ const results = [];
486
+ for (const sessionId of sessionIds) {
487
+ try {
488
+ const result = migrateSession(sessionId, sessionOptions);
489
+ results.push(result);
490
+ }
491
+ catch (error) {
492
+ // Convert thrown errors to result objects for partial failure handling
493
+ results.push({
494
+ success: false,
495
+ sessionId,
496
+ sourceWorkspace: 'unknown',
497
+ destinationWorkspace: options.destination,
498
+ mode: options.mode,
499
+ error: error instanceof Error ? error.message : String(error),
500
+ dryRun: options.dryRun,
501
+ });
502
+ }
503
+ }
504
+ return results;
505
+ }
506
+ /**
507
+ * Migrate all sessions from one workspace to another.
508
+ *
509
+ * This is a convenience wrapper that finds all sessions in the source workspace
510
+ * and calls migrateSession for each one.
511
+ *
512
+ * @param options - Workspace migration options
513
+ * @returns Aggregate result with per-session details
514
+ */
515
+ export function migrateWorkspace(options) {
516
+ const { source, destination, mode, dryRun, force, dataPath, debug = false } = options;
517
+ // Normalize paths
518
+ const normalizedSource = normalizePath(source);
519
+ const normalizedDest = normalizePath(destination);
520
+ // Check if source and destination are the same
521
+ if (pathsEqual(normalizedSource, normalizedDest)) {
522
+ throw new SameWorkspaceError(normalizedSource);
523
+ }
524
+ // T015: Check for nested paths (would cause infinite replacement loops)
525
+ if (isNestedPath(normalizedSource, normalizedDest)) {
526
+ throw new NestedPathError(normalizedSource, normalizedDest);
527
+ }
528
+ // Find source workspace
529
+ const sourceInfo = findWorkspaceByPath(normalizedSource, dataPath);
530
+ if (!sourceInfo) {
531
+ throw new WorkspaceNotFoundError(normalizedSource);
532
+ }
533
+ // Find destination workspace
534
+ const destInfo = findWorkspaceByPath(normalizedDest, dataPath);
535
+ if (!destInfo) {
536
+ throw new WorkspaceNotFoundError(normalizedDest);
537
+ }
538
+ // Get sessions from source workspace
539
+ const sourceDb = openDatabaseReadWrite(sourceInfo.dbPath);
540
+ const sourceResult = getComposerData(sourceDb);
541
+ sourceDb.close();
542
+ if (!sourceResult || sourceResult.composers.length === 0) {
543
+ throw new NoSessionsFoundError(normalizedSource);
544
+ }
545
+ // Check if destination has existing sessions (unless force is set)
546
+ if (!force) {
547
+ const destDb = openDatabaseReadWrite(destInfo.dbPath);
548
+ const destResult = getComposerData(destDb);
549
+ destDb.close();
550
+ if (destResult && destResult.composers.length > 0) {
551
+ throw new DestinationHasSessionsError(normalizedDest, destResult.composers.length);
552
+ }
553
+ }
554
+ // Extract session IDs
555
+ const sessionIds = sourceResult.composers
556
+ .map((s) => s.composerId)
557
+ .filter((id) => typeof id === 'string');
558
+ if (sessionIds.length === 0) {
559
+ throw new NoSessionsFoundError(normalizedSource);
560
+ }
561
+ // Migrate all sessions
562
+ const results = migrateSessions({
563
+ sessionIds,
564
+ destination: normalizedDest,
565
+ mode,
566
+ dryRun,
567
+ force,
568
+ dataPath,
569
+ debug,
570
+ });
571
+ // Aggregate results
572
+ const successCount = results.filter((r) => r.success).length;
573
+ const failureCount = results.filter((r) => !r.success).length;
574
+ return {
575
+ success: failureCount === 0,
576
+ source: normalizedSource,
577
+ destination: normalizedDest,
578
+ mode,
579
+ totalSessions: results.length,
580
+ successCount,
581
+ failureCount,
582
+ results,
583
+ dryRun,
584
+ };
585
+ }
586
+ //# sourceMappingURL=migrate.js.map