@@ -56,12 +56,56 @@ export function getAgentsSourceDir(packageRoot: string): string
5656 */
5757export declare const AGENTS_TARGET_DIR : string
5858
59+ /**
60+ * Node.js filesystem error codes handled by `getErrorMessage`.
61+ *
62+ * These are the specific error codes that have custom user-friendly messages:
63+ * - `EACCES` - Permission denied
64+ * - `EPERM` - Operation not permitted (file may be in use or locked)
65+ * - `ENOSPC` - No space left on device
66+ * - `ENOENT` - No such file or directory
67+ * - `EROFS` - Read-only file system
68+ * - `EMFILE` - Too many open files (per-process limit)
69+ * - `ENFILE` - Too many open files (system-wide limit)
70+ * - `EEXIST` - File already exists
71+ * - `EISDIR` - Is a directory (expected a file)
72+ * - `EAGAIN` - Resource temporarily unavailable (transient)
73+ * - `EBUSY` - Resource busy or locked (transient)
74+ *
75+ * Any other error code falls back to the error's message property.
76+ */
77+ export type HandledErrorCode =
78+ | "EACCES"
79+ | "EPERM"
80+ | "ENOSPC"
81+ | "ENOENT"
82+ | "EROFS"
83+ | "EMFILE"
84+ | "ENFILE"
85+ | "EEXIST"
86+ | "EISDIR"
87+ | "EAGAIN"
88+ | "EBUSY"
89+
5990/**
6091 * Returns a user-friendly error message based on the error code.
6192 *
6293 * Translates Node.js filesystem error codes into human-readable messages
6394 * that help users understand and resolve installation issues.
6495 *
96+ * Handled error codes (see {@link HandledErrorCode}):
97+ * - `EACCES` - "Permission denied. Check write permissions for {directory}"
98+ * - `EPERM` - "Operation not permitted. The file may be in use or locked"
99+ * - `ENOSPC` - "Disk full. Free up space and try again"
100+ * - `ENOENT` - "Source file not found: {file}"
101+ * - `EROFS` - "Read-only file system. Cannot write to target directory"
102+ * - `EMFILE`/`ENFILE` - "Too many open files. Close some applications and try again"
103+ * - `EEXIST` - "Target already exists: {targetPath}"
104+ * - `EISDIR` - "Expected a file but found a directory: {targetPath}"
105+ * - `EAGAIN` - "Resource temporarily unavailable. Try again"
106+ * - `EBUSY` - "File is busy or locked. Try again later"
107+ * - (other) - Falls back to error.message or "Unknown error"
108+ *
65109 * @param error - The error object from a failed fs operation
66110 * @param file - The filename being processed
67111 * @param targetPath - The target path for the file
@@ -80,7 +124,7 @@ export declare const AGENTS_TARGET_DIR: string
80124 * // Returns: "Source file not found: missing.md"
81125 */
82126export function getErrorMessage (
83- error : Error & { code ?: string } ,
127+ error : Error & { code ?: HandledErrorCode | string } ,
84128 file : string ,
85129 targetPath : string ,
86130) : string
0 commit comments