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,108 @@
1
+ /**
2
+ * Library API for backup and restore operations
3
+ *
4
+ * IMPORTANT: This is a library interface for direct import and use in TypeScript/JavaScript
5
+ * projects, NOT a network/REST API.
6
+ */
7
+ import { createBackup as coreCreateBackup, restoreBackup as coreRestoreBackup, validateBackup as coreValidateBackup, listBackups as coreListBackups, getDefaultBackupDir as coreGetDefaultBackupDir, } from '../core/backup.js';
8
+ /**
9
+ * Create a full backup of Cursor chat history.
10
+ *
11
+ * @param config - Optional backup configuration
12
+ * @returns Promise resolving to backup result
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { createBackup } from 'cursor-history';
17
+ *
18
+ * // Basic usage
19
+ * const result = await createBackup();
20
+ * console.log(`Backup created: ${result.backupPath}`);
21
+ *
22
+ * // With options
23
+ * const result = await createBackup({
24
+ * outputPath: '/path/to/backup.zip',
25
+ * force: true,
26
+ * onProgress: (progress) => {
27
+ * console.log(`${progress.phase}: ${progress.filesCompleted}/${progress.totalFiles}`);
28
+ * }
29
+ * });
30
+ * ```
31
+ */
32
+ export async function createBackup(config) {
33
+ return coreCreateBackup(config);
34
+ }
35
+ /**
36
+ * Restore Cursor chat history from a backup file.
37
+ *
38
+ * @param config - Restore configuration (backupPath required)
39
+ * @returns Restore result
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { restoreBackup } from 'cursor-history';
44
+ *
45
+ * const result = restoreBackup({
46
+ * backupPath: '/path/to/backup.zip',
47
+ * force: true
48
+ * });
49
+ * ```
50
+ */
51
+ export function restoreBackup(config) {
52
+ return coreRestoreBackup(config);
53
+ }
54
+ /**
55
+ * Validate a backup file's integrity without restoring.
56
+ *
57
+ * @param backupPath - Path to backup zip file
58
+ * @returns Validation result with status and details
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { validateBackup } from 'cursor-history';
63
+ *
64
+ * const validation = validateBackup('/path/to/backup.zip');
65
+ * if (validation.status === 'valid') {
66
+ * console.log('Backup is valid');
67
+ * }
68
+ * ```
69
+ */
70
+ export function validateBackup(backupPath) {
71
+ return coreValidateBackup(backupPath);
72
+ }
73
+ /**
74
+ * List available backup files in a directory.
75
+ *
76
+ * @param directory - Directory to scan (default: ~/cursor-history-backups)
77
+ * @returns Array of backup info objects
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * import { listBackups } from 'cursor-history';
82
+ *
83
+ * const backups = listBackups();
84
+ * for (const backup of backups) {
85
+ * console.log(`${backup.filename}: ${backup.manifest?.stats.sessionCount} sessions`);
86
+ * }
87
+ * ```
88
+ */
89
+ export function listBackups(directory) {
90
+ return coreListBackups(directory);
91
+ }
92
+ /**
93
+ * Get the default backup directory path.
94
+ *
95
+ * @returns Default backup directory path (~/cursor-history-backups)
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import { getDefaultBackupDir } from 'cursor-history';
100
+ *
101
+ * const dir = getDefaultBackupDir();
102
+ * // Returns: /home/user/cursor-history-backups (Linux)
103
+ * ```
104
+ */
105
+ export function getDefaultBackupDir() {
106
+ return coreGetDefaultBackupDir();
107
+ }
108
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/lib/backup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,WAAW,IAAI,eAAe,EAC9B,mBAAmB,IAAI,uBAAuB,GAC/C,MAAM,mBAAmB,CAAC;AAW3B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAqB;IACtD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,SAAkB;IAC5C,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,uBAAuB,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Configuration handling and validation for 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.
6
+ */
7
+ import type { LibraryConfig } from './types.js';
8
+ /**
9
+ * Merged configuration with all defaults applied
10
+ */
11
+ export interface ResolvedConfig {
12
+ dataPath: string;
13
+ workspace?: string;
14
+ limit: number;
15
+ offset: number;
16
+ context: number;
17
+ backupPath?: string;
18
+ }
19
+ /**
20
+ * Validate configuration parameters
21
+ * @throws {InvalidConfigError} If any parameter is invalid
22
+ */
23
+ export declare function validateConfig(config?: LibraryConfig): void;
24
+ /**
25
+ * Merge user configuration with defaults
26
+ */
27
+ export declare function mergeWithDefaults(config?: LibraryConfig): ResolvedConfig;
28
+ /**
29
+ * Resolve database path with symlink handling
30
+ * @throws {DatabaseNotFoundError} If path does not exist
31
+ */
32
+ export declare function resolveDatabasePath(configPath?: string): string;
33
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAsC3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAaxE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAW/D"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Configuration handling and validation for 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.
6
+ */
7
+ import { realpathSync } from 'node:fs';
8
+ import { resolve, normalize, isAbsolute } from 'node:path';
9
+ import { InvalidConfigError, DatabaseNotFoundError } from './errors.js';
10
+ import { getCursorDataPath } from '../lib/platform.js';
11
+ /**
12
+ * Validate configuration parameters
13
+ * @throws {InvalidConfigError} If any parameter is invalid
14
+ */
15
+ export function validateConfig(config) {
16
+ if (!config)
17
+ return;
18
+ // Validate limit
19
+ if (config.limit !== undefined) {
20
+ if (typeof config.limit !== 'number' || config.limit < 1 || !Number.isInteger(config.limit)) {
21
+ throw new InvalidConfigError('limit', config.limit, 'must be a positive integer greater than 0');
22
+ }
23
+ }
24
+ // Validate offset
25
+ if (config.offset !== undefined) {
26
+ if (typeof config.offset !== 'number' || config.offset < 0 || !Number.isInteger(config.offset)) {
27
+ throw new InvalidConfigError('offset', config.offset, 'must be a non-negative integer');
28
+ }
29
+ }
30
+ // Validate context
31
+ if (config.context !== undefined) {
32
+ if (typeof config.context !== 'number' || config.context < 0 || !Number.isInteger(config.context)) {
33
+ throw new InvalidConfigError('context', config.context, 'must be a non-negative integer');
34
+ }
35
+ }
36
+ // Validate workspace path
37
+ if (config.workspace !== undefined) {
38
+ if (typeof config.workspace !== 'string') {
39
+ throw new InvalidConfigError('workspace', config.workspace, 'must be a string');
40
+ }
41
+ if (!isAbsolute(config.workspace)) {
42
+ throw new InvalidConfigError('workspace', config.workspace, 'must be an absolute path');
43
+ }
44
+ }
45
+ // Validate dataPath
46
+ if (config.dataPath !== undefined && typeof config.dataPath !== 'string') {
47
+ throw new InvalidConfigError('dataPath', config.dataPath, 'must be a string');
48
+ }
49
+ }
50
+ /**
51
+ * Merge user configuration with defaults
52
+ */
53
+ export function mergeWithDefaults(config) {
54
+ validateConfig(config);
55
+ const dataPath = config?.dataPath ?? getCursorDataPath();
56
+ return {
57
+ dataPath,
58
+ workspace: config?.workspace,
59
+ limit: config?.limit ?? Number.MAX_SAFE_INTEGER,
60
+ offset: config?.offset ?? 0,
61
+ context: config?.context ?? 0,
62
+ backupPath: config?.backupPath,
63
+ };
64
+ }
65
+ /**
66
+ * Resolve database path with symlink handling
67
+ * @throws {DatabaseNotFoundError} If path does not exist
68
+ */
69
+ export function resolveDatabasePath(configPath) {
70
+ const basePath = configPath ?? getCursorDataPath();
71
+ const normalized = normalize(basePath);
72
+ const resolved = resolve(normalized);
73
+ try {
74
+ // Resolve symlinks and verify path exists
75
+ return realpathSync(resolved);
76
+ }
77
+ catch {
78
+ throw new DatabaseNotFoundError(resolved);
79
+ }
80
+ }
81
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB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,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
@@ -1,56 +1,283 @@
1
1
  /**
2
- * Error handling utilities and exit codes
2
+ * Custom error classes for 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.
3
6
  */
4
7
  /**
5
- * CLI exit codes following Unix conventions
8
+ * Thrown when database is locked by Cursor or another process.
9
+ *
10
+ * Recovery: Close Cursor IDE and retry, or implement custom retry logic.
6
11
  */
7
- export declare const ExitCode: {
8
- readonly SUCCESS: 0;
9
- readonly GENERAL_ERROR: 1;
10
- readonly USAGE_ERROR: 2;
11
- readonly NOT_FOUND: 3;
12
- readonly IO_ERROR: 4;
13
- };
14
- export type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];
12
+ export declare class DatabaseLockedError extends Error {
13
+ name: "DatabaseLockedError";
14
+ /** Path to locked database file */
15
+ path: string;
16
+ constructor(path: string);
17
+ }
18
+ /**
19
+ * Thrown when database file or directory does not exist.
20
+ *
21
+ * Recovery: Verify Cursor is installed, check dataPath configuration.
22
+ */
23
+ export declare class DatabaseNotFoundError extends Error {
24
+ name: "DatabaseNotFoundError";
25
+ /** Path that was not found */
26
+ path: string;
27
+ constructor(path: string);
28
+ }
29
+ /**
30
+ * Thrown when configuration parameters are invalid.
31
+ *
32
+ * Recovery: Fix configuration values per LibraryConfig validation rules.
33
+ */
34
+ export declare class InvalidConfigError extends Error {
35
+ name: "InvalidConfigError";
36
+ /** Name of invalid config field */
37
+ field: string;
38
+ /** Invalid value provided */
39
+ value: unknown;
40
+ constructor(field: string, value: unknown, reason: string);
41
+ }
42
+ /**
43
+ * Type guard to check if an error is a DatabaseLockedError.
44
+ */
45
+ export declare function isDatabaseLockedError(error: unknown): error is DatabaseLockedError;
46
+ /**
47
+ * Type guard to check if an error is a DatabaseNotFoundError.
48
+ */
49
+ export declare function isDatabaseNotFoundError(error: unknown): error is DatabaseNotFoundError;
50
+ /**
51
+ * Type guard to check if an error is an InvalidConfigError.
52
+ */
53
+ export declare function isInvalidConfigError(error: unknown): error is InvalidConfigError;
54
+ /**
55
+ * Thrown when a session ID or index cannot be resolved.
56
+ *
57
+ * Recovery: Check session exists with `listSessions()`, use valid ID or index.
58
+ */
59
+ export declare class SessionNotFoundError extends Error {
60
+ name: "SessionNotFoundError";
61
+ /** The identifier that was not found (index or UUID) */
62
+ identifier: string | number;
63
+ constructor(identifier: string | number);
64
+ }
65
+ /**
66
+ * Thrown when destination workspace path has no workspace directory.
67
+ *
68
+ * Recovery: Open the project in Cursor first to create the workspace directory.
69
+ */
70
+ export declare class WorkspaceNotFoundError extends Error {
71
+ name: "WorkspaceNotFoundError";
72
+ /** The workspace path that was not found */
73
+ path: string;
74
+ constructor(path: string);
75
+ }
76
+ /**
77
+ * Thrown when source and destination paths are the same.
78
+ *
79
+ * Recovery: Specify different source and destination paths.
80
+ */
81
+ export declare class SameWorkspaceError extends Error {
82
+ name: "SameWorkspaceError";
83
+ /** The path that was specified for both source and destination */
84
+ path: string;
85
+ constructor(path: string);
86
+ }
87
+ /**
88
+ * Thrown when no sessions are found for the specified source workspace.
89
+ *
90
+ * Recovery: Check the source path is correct, verify sessions exist with `list --workspace`.
91
+ */
92
+ export declare class NoSessionsFoundError extends Error {
93
+ name: "NoSessionsFoundError";
94
+ /** The source workspace path */
95
+ path: string;
96
+ constructor(path: string);
97
+ }
98
+ /**
99
+ * Thrown when destination has existing sessions and --force not specified.
100
+ *
101
+ * Recovery: Use --force flag to proceed with additive merge.
102
+ */
103
+ export declare class DestinationHasSessionsError extends Error {
104
+ name: "DestinationHasSessionsError";
105
+ /** The destination workspace path */
106
+ path: string;
107
+ /** Number of existing sessions at destination */
108
+ sessionCount: number;
109
+ constructor(path: string, sessionCount: number);
110
+ }
111
+ /**
112
+ * Type guard to check if an error is a SessionNotFoundError.
113
+ */
114
+ export declare function isSessionNotFoundError(error: unknown): error is SessionNotFoundError;
115
+ /**
116
+ * Type guard to check if an error is a WorkspaceNotFoundError.
117
+ */
118
+ export declare function isWorkspaceNotFoundError(error: unknown): error is WorkspaceNotFoundError;
119
+ /**
120
+ * Type guard to check if an error is a SameWorkspaceError.
121
+ */
122
+ export declare function isSameWorkspaceError(error: unknown): error is SameWorkspaceError;
123
+ /**
124
+ * Type guard to check if an error is a NoSessionsFoundError.
125
+ */
126
+ export declare function isNoSessionsFoundError(error: unknown): error is NoSessionsFoundError;
127
+ /**
128
+ * Type guard to check if an error is a DestinationHasSessionsError.
129
+ */
130
+ export declare function isDestinationHasSessionsError(error: unknown): error is DestinationHasSessionsError;
131
+ /**
132
+ * Thrown when destination workspace path is nested within source workspace.
133
+ *
134
+ * Recovery: Choose a destination that is not a subdirectory of the source.
135
+ */
136
+ export declare class NestedPathError extends Error {
137
+ name: "NestedPathError";
138
+ /** The source workspace path */
139
+ source: string;
140
+ /** The destination workspace path (nested in source) */
141
+ destination: string;
142
+ constructor(source: string, destination: string);
143
+ }
144
+ /**
145
+ * Type guard to check if an error is a NestedPathError.
146
+ */
147
+ export declare function isNestedPathError(error: unknown): error is NestedPathError;
148
+ /**
149
+ * Base error for backup operations.
150
+ *
151
+ * Recovery: Check specific subclass for targeted recovery actions.
152
+ */
153
+ export declare class BackupError extends Error {
154
+ name: string;
155
+ constructor(message: string);
156
+ }
157
+ /**
158
+ * Thrown when there is no Cursor data to backup.
159
+ *
160
+ * Recovery: Verify Cursor is installed and has been used.
161
+ */
162
+ export declare class NoDataError extends BackupError {
163
+ name: string;
164
+ /** Path that was checked for data */
165
+ path: string;
166
+ constructor(path: string);
167
+ }
168
+ /**
169
+ * Thrown when output file already exists.
170
+ *
171
+ * Recovery: Use force: true to overwrite, or specify different output path.
172
+ */
173
+ export declare class FileExistsError extends BackupError {
174
+ name: string;
175
+ /** Path to existing file */
176
+ path: string;
177
+ constructor(path: string);
178
+ }
15
179
  /**
16
- * Custom error class for CLI errors with exit codes
180
+ * Thrown when there is insufficient disk space for backup.
181
+ *
182
+ * Recovery: Free up disk space or specify different output location.
17
183
  */
18
- export declare class CliError extends Error {
19
- readonly exitCode: ExitCode;
20
- constructor(message: string, exitCode?: ExitCode);
184
+ export declare class InsufficientSpaceError extends BackupError {
185
+ name: string;
186
+ /** Required space in bytes */
187
+ required: number;
188
+ /** Available space in bytes */
189
+ available: number;
190
+ constructor(required: number, available: number);
21
191
  }
22
192
  /**
23
- * Error for when no Cursor installation is found
193
+ * Base error for restore operations.
194
+ *
195
+ * Recovery: Check specific subclass for targeted recovery actions.
24
196
  */
25
- export declare class CursorNotFoundError extends CliError {
26
- constructor(searchPath: string);
197
+ export declare class RestoreError extends Error {
198
+ name: string;
199
+ constructor(message: string);
27
200
  }
28
201
  /**
29
- * Error for when no chat history exists
202
+ * Thrown when backup file is not found.
203
+ *
204
+ * Recovery: Verify backup file path is correct.
30
205
  */
31
- export declare class NoHistoryError extends CliError {
32
- constructor();
206
+ export declare class BackupNotFoundError extends RestoreError {
207
+ name: string;
208
+ /** Path to backup file that was not found */
209
+ path: string;
210
+ constructor(path: string);
33
211
  }
34
212
  /**
35
- * Error for invalid session index
213
+ * Thrown when backup file is invalid or corrupted.
214
+ *
215
+ * Recovery: Use a different backup file, or attempt to repair with external tools.
36
216
  */
37
- export declare class SessionNotFoundError extends CliError {
38
- constructor(index: number, maxIndex: number);
217
+ export declare class InvalidBackupError extends RestoreError {
218
+ name: string;
219
+ /** Path to invalid backup file */
220
+ path: string;
221
+ /** Reason for invalidity */
222
+ reason: string;
223
+ constructor(path: string, reason: string);
39
224
  }
40
225
  /**
41
- * Error for file already exists
226
+ * Thrown when target directory already has Cursor data.
227
+ *
228
+ * Recovery: Use force: true to overwrite, or specify different target path.
42
229
  */
43
- export declare class FileExistsError extends CliError {
230
+ export declare class TargetExistsError extends RestoreError {
231
+ name: string;
232
+ /** Path to existing target */
233
+ path: string;
44
234
  constructor(path: string);
45
235
  }
46
236
  /**
47
- * Error for search with no results
237
+ * Thrown when backup integrity check fails critically.
238
+ *
239
+ * Recovery: Backup may be corrupted beyond repair; try a different backup.
48
240
  */
49
- export declare class NoSearchResultsError extends CliError {
50
- constructor(query: string);
241
+ export declare class IntegrityError extends RestoreError {
242
+ name: string;
243
+ /** Files that failed integrity check */
244
+ failedFiles: string[];
245
+ constructor(failedFiles: string[]);
51
246
  }
52
247
  /**
53
- * Handle an error and exit with appropriate code
248
+ * Type guard to check if an error is a BackupError or subclass.
249
+ */
250
+ export declare function isBackupError(error: unknown): error is BackupError;
251
+ /**
252
+ * Type guard to check if an error is a RestoreError or subclass.
253
+ */
254
+ export declare function isRestoreError(error: unknown): error is RestoreError;
255
+ /**
256
+ * Type guard to check if an error is an InvalidBackupError.
257
+ */
258
+ export declare function isInvalidBackupError(error: unknown): error is InvalidBackupError;
259
+ /**
260
+ * Type guard to check if an error is a NoDataError.
261
+ */
262
+ export declare function isNoDataError(error: unknown): error is NoDataError;
263
+ /**
264
+ * Type guard to check if an error is a FileExistsError.
265
+ */
266
+ export declare function isFileExistsError(error: unknown): error is FileExistsError;
267
+ /**
268
+ * Type guard to check if an error is an InsufficientSpaceError.
269
+ */
270
+ export declare function isInsufficientSpaceError(error: unknown): error is InsufficientSpaceError;
271
+ /**
272
+ * Type guard to check if an error is a BackupNotFoundError.
273
+ */
274
+ export declare function isBackupNotFoundError(error: unknown): error is BackupNotFoundError;
275
+ /**
276
+ * Type guard to check if an error is a TargetExistsError.
277
+ */
278
+ export declare function isTargetExistsError(error: unknown): error is TargetExistsError;
279
+ /**
280
+ * Type guard to check if an error is an IntegrityError.
54
281
  */
55
- export declare function handleError(error: unknown): never;
282
+ export declare function isIntegrityError(error: unknown): error is IntegrityError;
56
283
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG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