@socketsecurity/lib 5.14.0 → 5.16.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 (85) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -2
  3. package/dist/abort.d.ts +13 -0
  4. package/dist/agent.d.ts +81 -0
  5. package/dist/ansi.d.ts +13 -0
  6. package/dist/archives.d.ts +31 -0
  7. package/dist/argv/flags.d.ts +91 -0
  8. package/dist/argv/parse.d.ts +31 -0
  9. package/dist/bin.d.ts +54 -0
  10. package/dist/cacache.d.ts +38 -0
  11. package/dist/cache-with-ttl.d.ts +7 -0
  12. package/dist/colors.d.ts +12 -0
  13. package/dist/cover/formatters.d.ts +18 -0
  14. package/dist/debug.d.ts +6 -0
  15. package/dist/dlx/binary.d.ts +84 -0
  16. package/dist/dlx/cache.d.ts +6 -0
  17. package/dist/dlx/detect.d.ts +33 -0
  18. package/dist/dlx/dir.d.ts +34 -0
  19. package/dist/dlx/manifest.d.ts +16 -0
  20. package/dist/dlx/package.d.ts +43 -0
  21. package/dist/dlx/packages.d.ts +36 -0
  22. package/dist/dlx/paths.d.ts +20 -0
  23. package/dist/dlx/paths.js +1 -1
  24. package/dist/effects/pulse-frames.d.ts +6 -0
  25. package/dist/effects/text-shimmer.d.ts +9 -0
  26. package/dist/effects/ultra.d.ts +6 -0
  27. package/dist/env/ci.d.ts +14 -0
  28. package/dist/env/debug.d.ts +13 -0
  29. package/dist/env/github.d.ts +80 -0
  30. package/dist/env/helpers.d.ts +45 -0
  31. package/dist/env/home.d.ts +13 -0
  32. package/dist/env/locale.d.ts +30 -0
  33. package/dist/env/node-auth-token.d.ts +13 -0
  34. package/dist/env/node-env.d.ts +13 -0
  35. package/dist/env/npm.d.ts +50 -0
  36. package/dist/env/path.d.ts +13 -0
  37. package/dist/env/pre-commit.d.ts +14 -0
  38. package/dist/env/rewire.d.ts +38 -0
  39. package/dist/env/shell.d.ts +13 -0
  40. package/dist/env/socket-cli-shadow.d.ts +43 -0
  41. package/dist/env/socket-cli.d.ts +116 -0
  42. package/dist/env/socket.d.ts +153 -0
  43. package/dist/env/temp-dir.d.ts +30 -0
  44. package/dist/env/term.d.ts +13 -0
  45. package/dist/env/test.d.ts +32 -0
  46. package/dist/env/windows.d.ts +40 -0
  47. package/dist/env/xdg.d.ts +30 -0
  48. package/dist/env.d.ts +40 -0
  49. package/dist/external/npm-pack.js +202 -291
  50. package/dist/external/tar-fs.js +27 -7
  51. package/dist/fs.d.ts +13 -0
  52. package/dist/functions.d.ts +30 -0
  53. package/dist/globs.d.ts +27 -0
  54. package/dist/http-request.d.ts +40 -18
  55. package/dist/http-request.js +84 -129
  56. package/dist/json/format.d.ts +18 -0
  57. package/dist/memoization.d.ts +5 -0
  58. package/dist/packages/edit.d.ts +28 -0
  59. package/dist/packages/exports.d.ts +40 -0
  60. package/dist/packages/licenses.d.ts +59 -0
  61. package/dist/packages/manifest.d.ts +18 -0
  62. package/dist/packages/normalize.d.ts +22 -0
  63. package/dist/packages/operations.d.ts +51 -0
  64. package/dist/packages/provenance.d.ts +11 -0
  65. package/dist/packages/specs.d.ts +30 -0
  66. package/dist/packages/validation.d.ts +18 -0
  67. package/dist/paths/normalize.d.ts +49 -5
  68. package/dist/paths/normalize.js +13 -0
  69. package/dist/paths/rewire.js +12 -3
  70. package/dist/regexps.d.ts +7 -0
  71. package/dist/releases/github.d.ts +63 -0
  72. package/dist/releases/socket-btm.d.ts +31 -0
  73. package/dist/sea.d.ts +15 -0
  74. package/dist/shadow.d.ts +7 -0
  75. package/dist/signal-exit.d.ts +27 -0
  76. package/dist/sorts.d.ts +33 -0
  77. package/dist/spawn.d.ts +9 -0
  78. package/dist/stdio/mask.d.ts +26 -0
  79. package/dist/streams.d.ts +28 -0
  80. package/dist/suppress-warnings.d.ts +7 -0
  81. package/dist/temporary-executor.d.ts +7 -0
  82. package/dist/url.d.ts +59 -0
  83. package/dist/versions.d.ts +119 -0
  84. package/dist/words.d.ts +20 -0
  85. package/package.json +8 -58
package/dist/cacache.d.ts CHANGED
@@ -32,6 +32,12 @@ export interface RemoveOptions {
32
32
  }
33
33
  /**
34
34
  * Get the cacache module for cache operations.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const cacache = getCacache()
39
+ * const entries = await cacache.ls(cacheDir)
40
+ * ```
35
41
  */
36
42
  export declare function getCacache(): import("./external/cacache").CacacheInstance;
37
43
  /**
@@ -64,12 +70,23 @@ export declare function clear(options?: RemoveOptions | undefined): Promise<numb
64
70
  * Get data from the Socket shared cache by key.
65
71
  * @throws {Error} When cache entry is not found.
66
72
  * @throws {TypeError} If key contains wildcards (*)
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const entry = await get('socket-sdk:scans:abc123')
77
+ * console.log(entry.data.toString('utf8'))
78
+ * ```
67
79
  */
68
80
  export declare function get(key: string, options?: GetOptions | undefined): Promise<CacheEntry>;
69
81
  /**
70
82
  * Put data into the Socket shared cache with a key.
71
83
  *
72
84
  * @throws {TypeError} If key contains wildcards (*)
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * await put('socket-sdk:scans:abc123', Buffer.from('result data'))
89
+ * ```
73
90
  */
74
91
  export declare function put(key: string, data: string | Buffer, options?: PutOptions | undefined): Promise<{
75
92
  integrity: string;
@@ -79,13 +96,34 @@ export declare function put(key: string, data: string | Buffer, options?: PutOpt
79
96
  * Remove an entry from the Socket shared cache by key.
80
97
  *
81
98
  * @throws {TypeError} If key contains wildcards (*)
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * await remove('socket-sdk:scans:abc123')
103
+ * ```
82
104
  */
83
105
  export declare function remove(key: string): Promise<unknown>;
84
106
  /**
85
107
  * Get data from the Socket shared cache by key without throwing.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const entry = await safeGet('socket-sdk:scans:abc123')
112
+ * if (entry) {
113
+ * console.log(entry.data.toString('utf8'))
114
+ * }
115
+ * ```
86
116
  */
87
117
  export declare function safeGet(key: string, options?: GetOptions | undefined): Promise<CacheEntry | undefined>;
88
118
  /**
89
119
  * Execute a callback with a temporary directory for cache operations.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const result = await withTmp(async (tmpDir) => {
124
+ * // Use tmpDir for temporary cache work
125
+ * return 'done'
126
+ * })
127
+ * ```
90
128
  */
91
129
  export declare function withTmp<T>(callback: (tmpDirPath: string) => Promise<T>): Promise<T>;
@@ -129,5 +129,12 @@ export interface TtlCache {
129
129
  }
130
130
  /**
131
131
  * Create a TTL-based cache instance.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const cache = createTtlCache({ ttl: 60_000, prefix: 'my-app' })
136
+ * await cache.set('key', { value: 42 })
137
+ * const data = await cache.get('key') // { value: 42 }
138
+ * ```
132
139
  */
133
140
  export declare function createTtlCache(options?: TtlCacheOptions): TtlCache;
package/dist/colors.d.ts CHANGED
@@ -26,6 +26,12 @@ export type ColorValue = ColorName | ColorRgb;
26
26
  * Type guard to check if a color value is an RGB tuple.
27
27
  * @param value - Color value to check
28
28
  * @returns `true` if value is an RGB tuple, `false` if it's a color name
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * isRgbTuple([255, 0, 0]) // true
33
+ * isRgbTuple('red') // false
34
+ * ```
29
35
  */
30
36
  export declare function isRgbTuple(value: ColorValue): value is ColorRgb;
31
37
  /**
@@ -33,5 +39,11 @@ export declare function isRgbTuple(value: ColorValue): value is ColorRgb;
33
39
  * Named colors are looked up in the `colorToRgb` map, RGB tuples are returned as-is.
34
40
  * @param color - Color name or RGB tuple
35
41
  * @returns RGB tuple with values 0-255
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * toRgb('red') // [255, 0, 0]
46
+ * toRgb([0, 128, 0]) // [0, 128, 0]
47
+ * ```
36
48
  */
37
49
  export declare function toRgb(color: ColorValue): ColorRgb;
@@ -1,9 +1,27 @@
1
1
  import type { FormatCoverageOptions } from './types';
2
2
  /**
3
3
  * Get emoji for coverage percentage.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * getCoverageEmoji(95) // ' \u{1F3AF}'
8
+ * getCoverageEmoji(50) // ' \u{1F528}'
9
+ * ```
4
10
  */
5
11
  export declare function getCoverageEmoji(percent: number): string;
6
12
  /**
7
13
  * Format coverage data for console output.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const output = formatCoverage({
18
+ * code: {
19
+ * statements: { percent: '85.00' },
20
+ * branches: { percent: '80.00' },
21
+ * functions: { percent: '90.00' },
22
+ * lines: { percent: '88.00' },
23
+ * },
24
+ * })
25
+ * ```
8
26
  */
9
27
  export declare function formatCoverage(options: FormatCoverageOptions): string;
package/dist/debug.d.ts CHANGED
@@ -36,6 +36,12 @@ declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unkn
36
36
  declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation: string, key: string, meta?: unknown | undefined): void;
37
37
  /**
38
38
  * Cache debug function with caller info.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * debugCache('hit', 'socket-sdk:scans:abc123')
43
+ * debugCache('miss', 'socket-sdk:scans:xyz', { ttl: 60000 })
44
+ * ```
39
45
  */
40
46
  /*@__NO_SIDE_EFFECTS__*/
41
47
  export declare function debugCache(operation: string, key: string, meta?: unknown | undefined): void;
@@ -113,10 +113,28 @@ export interface DlxMetadata {
113
113
  }
114
114
  /**
115
115
  * Clean expired entries from the DLX cache.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * // Remove cache entries older than the default TTL
120
+ * const removed = await cleanDlxCache()
121
+ *
122
+ * // Remove entries older than 1 hour
123
+ * const removed2 = await cleanDlxCache(60 * 60 * 1000)
124
+ * ```
116
125
  */
117
126
  export declare function cleanDlxCache(maxAge?: number): Promise<number>;
118
127
  /**
119
128
  * Download and execute a binary from a URL with caching.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const result = await dlxBinary(['--version'], {
133
+ * url: 'https://example.com/tool-linux-x64',
134
+ * name: 'tool',
135
+ * })
136
+ * await result.spawnPromise
137
+ * ```
120
138
  */
121
139
  export declare function dlxBinary(args: readonly string[] | string[], options?: DlxBinaryOptions | undefined, spawnExtra?: SpawnExtra | undefined): Promise<DlxBinaryResult>;
122
140
  /**
@@ -124,6 +142,15 @@ export declare function dlxBinary(args: readonly string[] | string[], options?:
124
142
  * Similar to downloadPackage from dlx-package.
125
143
  *
126
144
  * @returns Object containing the path to the cached binary and whether it was downloaded
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const { binaryPath, downloaded } = await downloadBinary({
149
+ * url: 'https://example.com/tool-linux-x64',
150
+ * name: 'tool',
151
+ * })
152
+ * console.log(`Binary at: ${binaryPath}, fresh: ${downloaded}`)
153
+ * ```
127
154
  */
128
155
  export declare function downloadBinary(options: Omit<DlxBinaryOptions, 'spawnOptions'>): Promise<{
129
156
  binaryPath: string;
@@ -139,6 +166,15 @@ export declare function downloadBinary(options: Omit<DlxBinaryOptions, 'spawnOpt
139
166
  * - integrity: SRI format sha512-<base64> (verified post-download)
140
167
  *
141
168
  * The sha256 option is preferred as it fails early during download if the checksum doesn't match.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const integrity = await downloadBinaryFile(
173
+ * 'https://example.com/tool-linux-x64',
174
+ * '/tmp/dlx-cache/tool'
175
+ * )
176
+ * console.log(`Integrity: ${integrity}`)
177
+ * ```
142
178
  */
143
179
  export declare function downloadBinaryFile(url: string, destPath: string, integrity?: string | undefined, sha256?: string | undefined): Promise<string>;
144
180
  /**
@@ -151,24 +187,61 @@ export declare function downloadBinaryFile(url: string, destPath: string, integr
151
187
  * @param spawnOptions Spawn options for execution
152
188
  * @param spawnExtra Extra spawn configuration
153
189
  * @returns The spawn promise for the running process
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const { binaryPath } = await downloadBinary({
194
+ * url: 'https://example.com/tool-linux-x64',
195
+ * name: 'tool',
196
+ * })
197
+ * const result = executeBinary(binaryPath, ['--help'])
198
+ * ```
154
199
  */
155
200
  export declare function executeBinary(binaryPath: string, args: readonly string[] | string[], spawnOptions?: SpawnOptions | undefined, spawnExtra?: SpawnExtra | undefined): ReturnType<typeof spawn>;
156
201
  /**
157
202
  * Get the DLX binary cache directory path.
158
203
  * Returns normalized path for cross-platform compatibility.
159
204
  * Uses same directory as dlx-package for unified DLX storage.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const cachePath = getDlxCachePath()
209
+ * ```
160
210
  */
161
211
  export declare function getDlxCachePath(): string;
162
212
  /**
163
213
  * Get metadata file path for a cached binary.
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const metaPath = getBinaryCacheMetadataPath('/tmp/dlx-cache/a1b2c3d4')
218
+ * // '/tmp/dlx-cache/a1b2c3d4/.dlx-metadata.json'
219
+ * ```
164
220
  */
165
221
  export declare function getBinaryCacheMetadataPath(cacheEntryPath: string): string;
166
222
  /**
167
223
  * Check if a cached binary is still valid.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const ttl = 7 * 24 * 60 * 60 * 1000
228
+ * const valid = await isBinaryCacheValid('/tmp/dlx-cache/a1b2c3d4', ttl)
229
+ * if (!valid) {
230
+ * // Re-download the binary
231
+ * }
232
+ * ```
168
233
  */
169
234
  export declare function isBinaryCacheValid(cacheEntryPath: string, cacheTtl: number): Promise<boolean>;
170
235
  /**
171
236
  * Get information about cached binaries.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const entries = await listDlxCache()
241
+ * for (const entry of entries) {
242
+ * console.log(`${entry.name}: ${entry.size} bytes`)
243
+ * }
244
+ * ```
172
245
  */
173
246
  export declare function listDlxCache(): Promise<Array<{
174
247
  age: number;
@@ -181,5 +254,16 @@ export declare function listDlxCache(): Promise<Array<{
181
254
  * Write metadata for a cached binary.
182
255
  * Uses unified schema shared with C++ decompressor and CLI dlxBinary.
183
256
  * Schema documentation: See DlxMetadata interface in this file (exported).
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * await writeBinaryCacheMetadata(
261
+ * '/tmp/dlx-cache/a1b2c3d4',
262
+ * 'a1b2c3d4',
263
+ * 'https://example.com/tool',
264
+ * 'sha512-abc123...',
265
+ * 15000000
266
+ * )
267
+ * ```
184
268
  */
185
269
  export declare function writeBinaryCacheMetadata(cacheEntryPath: string, cacheKey: string, url: string, integrity: string, size: number): Promise<void>;
@@ -21,5 +21,11 @@
21
21
  * https://github.com/npm/cli/blob/v11.6.2/workspaces/libnpmexec/lib/index.js#L233-L244
22
22
  * Implementation: packages.map().sort().join('\n') → SHA-512 → slice(0,16)
23
23
  * npx hashes the package spec (name@version), not just name
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const key = generateCacheKey('prettier@3.0.0')
28
+ * // e.g. 'a1b2c3d4e5f67890'
29
+ * ```
24
30
  */
25
31
  export declare function generateCacheKey(spec: string): string;
@@ -11,6 +11,12 @@ export interface ExecutableDetectionResult {
11
11
  *
12
12
  * @param filePath - Path within DLX cache (~/.socket/_dlx/)
13
13
  * @returns Detection result
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const result = detectDlxExecutableType('/tmp/.socket/_dlx/a1b2c3d4/tool')
18
+ * console.log(result.type) // 'package' or 'binary'
19
+ * ```
14
20
  */
15
21
  export declare function detectDlxExecutableType(filePath: string): ExecutableDetectionResult;
16
22
  /**
@@ -41,6 +47,14 @@ export declare function detectExecutableType(filePath: string): ExecutableDetect
41
47
  *
42
48
  * @param filePath - Local filesystem path (not in DLX cache)
43
49
  * @returns Detection result
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const result = detectLocalExecutableType('/usr/local/bin/tool')
54
+ * if (result.type === 'package') {
55
+ * console.log('Node.js package at:', result.packageJsonPath)
56
+ * }
57
+ * ```
44
58
  */
45
59
  export declare function detectLocalExecutableType(filePath: string): ExecutableDetectionResult;
46
60
  /**
@@ -48,6 +62,13 @@ export declare function detectLocalExecutableType(filePath: string): ExecutableD
48
62
  *
49
63
  * @param filePath - Path to check
50
64
  * @returns True if file has .js, .mjs, or .cjs extension
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * isJsFilePath('index.js') // true
69
+ * isJsFilePath('lib.mjs') // true
70
+ * isJsFilePath('tool.exe') // false
71
+ * ```
51
72
  */
52
73
  export declare function isJsFilePath(filePath: string): boolean;
53
74
  /**
@@ -55,6 +76,12 @@ export declare function isJsFilePath(filePath: string): boolean;
55
76
  *
56
77
  * @param filePath - Path to check
57
78
  * @returns True if detected as native binary (not Node.js package)
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * isNativeBinary('/usr/local/bin/tool') // true
83
+ * isNativeBinary('/tmp/project/index.js') // false
84
+ * ```
58
85
  */
59
86
  export declare function isNativeBinary(filePath: string): boolean;
60
87
  /**
@@ -62,5 +89,11 @@ export declare function isNativeBinary(filePath: string): boolean;
62
89
  *
63
90
  * @param filePath - Path to check
64
91
  * @returns True if detected as Node.js package
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * isNodePackage('/tmp/project/index.js') // true
96
+ * isNodePackage('/usr/local/bin/tool') // false
97
+ * ```
65
98
  */
66
99
  export declare function isNodePackage(filePath: string): boolean;
package/dist/dlx/dir.d.ts CHANGED
@@ -1,24 +1,58 @@
1
1
  /**
2
2
  * Clear all DLX package installations.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * await clearDlx()
7
+ * ```
3
8
  */
4
9
  export declare function clearDlx(): Promise<void>;
5
10
  /**
6
11
  * Clear all DLX package installations synchronously.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * clearDlxSync()
16
+ * ```
7
17
  */
8
18
  export declare function clearDlxSync(): void;
9
19
  /**
10
20
  * Check if the DLX directory exists.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * if (dlxDirExists()) {
25
+ * console.log('DLX directory is present')
26
+ * }
27
+ * ```
11
28
  */
12
29
  export declare function dlxDirExists(): boolean;
13
30
  /**
14
31
  * Check if the DLX directory exists asynchronously.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * if (await dlxDirExistsAsync()) {
36
+ * console.log('DLX directory is present')
37
+ * }
38
+ * ```
15
39
  */
16
40
  export declare function dlxDirExistsAsync(): Promise<boolean>;
17
41
  /**
18
42
  * Ensure the DLX directory exists, creating it if necessary.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * await ensureDlxDir()
47
+ * ```
19
48
  */
20
49
  export declare function ensureDlxDir(): Promise<void>;
21
50
  /**
22
51
  * Ensure the DLX directory exists synchronously, creating it if necessary.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * ensureDlxDirSync()
56
+ * ```
23
57
  */
24
58
  export declare function ensureDlxDirSync(): void;
@@ -57,12 +57,28 @@ export interface DlxManifestOptions {
57
57
  }
58
58
  /**
59
59
  * Type guard for binary entries.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const entry = manifest.getManifestEntry('https://example.com/tool')
64
+ * if (entry && isBinaryEntry(entry)) {
65
+ * console.log(entry.details.integrity)
66
+ * }
67
+ * ```
60
68
  */
61
69
  export declare function isBinaryEntry(entry: ManifestEntry): entry is ManifestEntry & {
62
70
  details: BinaryDetails;
63
71
  };
64
72
  /**
65
73
  * Type guard for package entries.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const entry = manifest.getManifestEntry('@socketsecurity/cli@^2.0.0')
78
+ * if (entry && isPackageEntry(entry)) {
79
+ * console.log(entry.details.installed_version)
80
+ * }
81
+ * ```
66
82
  */
67
83
  export declare function isPackageEntry(entry: ManifestEntry): entry is ManifestEntry & {
68
84
  details: PackageDetails;
@@ -103,6 +103,16 @@ export declare function downloadPackage(options: DlxPackageOptions): Promise<Dow
103
103
  * Install package to ~/.socket/_dlx/<hash>/ if not already installed.
104
104
  * Uses pacote for installation (no npm CLI required).
105
105
  * Protected by process lock to prevent concurrent installation corruption.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const { installed, packageDir } = await ensurePackageInstalled(
110
+ * 'prettier',
111
+ * 'prettier@3.0.0',
112
+ * false
113
+ * )
114
+ * console.log(`Installed: ${installed}, dir: ${packageDir}`)
115
+ * ```
106
116
  */
107
117
  export declare function ensurePackageInstalled(packageName: string, packageSpec: string, force: boolean): Promise<{
108
118
  installed: boolean;
@@ -137,6 +147,15 @@ export declare function executePackage(binaryPath: string, args: readonly string
137
147
  * 2. Fall back to user-provided binaryName if npm's strategy fails
138
148
  * 3. Try last segment of package name as final fallback
139
149
  * 4. Use first binary as last resort
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const binPath = findBinaryPath(
154
+ * '/tmp/.socket/_dlx/a1b2c3d4',
155
+ * 'prettier'
156
+ * )
157
+ * console.log(`Binary: ${binPath}`)
158
+ * ```
140
159
  */
141
160
  export declare function findBinaryPath(packageDir: string, packageName: string, binaryName?: string): string;
142
161
  /**
@@ -152,6 +171,14 @@ export declare function findBinaryPath(packageDir: string, packageName: string,
152
171
  * References:
153
172
  * - npm cmd-shim: https://github.com/npm/cmd-shim/blob/main/lib/index.js
154
173
  * - npm getBinFromManifest: https://github.com/npm/libnpmexec/blob/main/lib/get-bin-from-manifest.js
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * makePackageBinsExecutable(
178
+ * '/tmp/.socket/_dlx/a1b2c3d4',
179
+ * 'prettier'
180
+ * )
181
+ * ```
155
182
  */
156
183
  export declare function makePackageBinsExecutable(packageDir: string, packageName: string): void;
157
184
  /**
@@ -160,6 +187,15 @@ export declare function makePackageBinsExecutable(packageDir: string, packageNam
160
187
  * - 'lodash@4.17.21' → { name: 'lodash', version: '4.17.21' }
161
188
  * - '@scope/pkg@1.0.0' → { name: '@scope/pkg', version: '1.0.0' }
162
189
  * - 'lodash' → { name: 'lodash', version: undefined }
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * parsePackageSpec('lodash@4.17.21')
194
+ * // { name: 'lodash', version: '4.17.21' }
195
+ *
196
+ * parsePackageSpec('@scope/pkg')
197
+ * // { name: '@scope/pkg', version: undefined }
198
+ * ```
163
199
  */
164
200
  export declare function parsePackageSpec(spec: string): {
165
201
  name: string;
@@ -171,5 +207,12 @@ export declare function parsePackageSpec(spec: string): {
171
207
  * On Unix, uses path directly.
172
208
  *
173
209
  * Aligns with npm/npx binary resolution strategy.
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const resolved = resolveBinaryPath('/tmp/.socket/_dlx/a1b2c3d4/prettier')
214
+ * // On Windows: may resolve to '.cmd' or '.ps1' wrapper
215
+ * // On Unix: returns the path unchanged
216
+ * ```
174
217
  */
175
218
  export declare function resolveBinaryPath(basePath: string): string;
@@ -1,24 +1,60 @@
1
1
  /**
2
2
  * Check if a package is installed in DLX.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * if (isDlxPackageInstalled('prettier')) {
7
+ * console.log('prettier is installed')
8
+ * }
9
+ * ```
3
10
  */
4
11
  export declare function isDlxPackageInstalled(packageName: string): boolean;
5
12
  /**
6
13
  * Check if a package is installed in DLX asynchronously.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * if (await isDlxPackageInstalledAsync('prettier')) {
18
+ * console.log('prettier is installed')
19
+ * }
20
+ * ```
7
21
  */
8
22
  export declare function isDlxPackageInstalledAsync(packageName: string): Promise<boolean>;
9
23
  /**
10
24
  * List all packages installed in DLX.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const packages = listDlxPackages()
29
+ * console.log('Installed:', packages.join(', '))
30
+ * ```
11
31
  */
12
32
  export declare function listDlxPackages(): string[];
13
33
  /**
14
34
  * List all packages installed in DLX asynchronously.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const packages = await listDlxPackagesAsync()
39
+ * console.log('Installed:', packages.join(', '))
40
+ * ```
15
41
  */
16
42
  export declare function listDlxPackagesAsync(): Promise<string[]>;
17
43
  /**
18
44
  * Remove a DLX package installation.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * await removeDlxPackage('prettier')
49
+ * ```
19
50
  */
20
51
  export declare function removeDlxPackage(packageName: string): Promise<void>;
21
52
  /**
22
53
  * Remove a DLX package installation synchronously.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * removeDlxPackageSync('prettier')
58
+ * ```
23
59
  */
24
60
  export declare function removeDlxPackageSync(packageName: string): void;
@@ -1,17 +1,37 @@
1
1
  /**
2
2
  * Get the installed package directory within DLX node_modules.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const dir = getDlxInstalledPackageDir('prettier')
7
+ * ```
3
8
  */
4
9
  export declare function getDlxInstalledPackageDir(packageName: string): string;
5
10
  /**
6
11
  * Get the DLX installation directory for a specific package.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const dir = getDlxPackageDir('a1b2c3d4')
16
+ * ```
7
17
  */
8
18
  export declare function getDlxPackageDir(packageName: string): string;
9
19
  /**
10
20
  * Get the package.json path for a DLX installed package.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const jsonPath = getDlxPackageJsonPath('prettier')
25
+ * ```
11
26
  */
12
27
  export declare function getDlxPackageJsonPath(packageName: string): string;
13
28
  /**
14
29
  * Get the node_modules directory for a DLX package installation.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const nmDir = getDlxPackageNodeModulesDir('a1b2c3d4')
34
+ * ```
15
35
  */
16
36
  export declare function getDlxPackageNodeModulesDir(packageName: string): string;
17
37
  /**
package/dist/dlx/paths.js CHANGED
@@ -61,7 +61,7 @@ function isInSocketDlx(filePath) {
61
61
  return false;
62
62
  }
63
63
  const path = /* @__PURE__ */ getPath();
64
- const dlxDir = (0, import_socket.getSocketDlxDir)();
64
+ const dlxDir = (0, import_normalize.normalizePath)((0, import_socket.getSocketDlxDir)());
65
65
  const absolutePath = (0, import_normalize.normalizePath)(path.resolve(filePath));
66
66
  return absolutePath.startsWith(`${dlxDir}/`);
67
67
  }
@@ -23,6 +23,12 @@ export type SocketFramesOptions = {
23
23
  * Returns a spinner definition compatible with cli-spinners format.
24
24
  *
25
25
  * @see https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const { frames, interval } = generateSocketSpinnerFrames()
30
+ * console.log(frames.length, interval) // 18 50
31
+ * ```
26
32
  */
27
33
  export declare function generateSocketSpinnerFrames(options?: SocketFramesOptions | undefined): {
28
34
  frames: string[];
@@ -34,5 +34,14 @@ export declare const MODE_BI = "bi";
34
34
  * 4. Renders each character with appropriate brightness based on distance from wave
35
35
  * 5. Updates the animation state for the next frame
36
36
  * 6. Handles direction changes for bidirectional and random modes
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const state = { step: 0, speed: 0.33, currentDir: 'ltr', mode: 'ltr' }
41
+ * const result = applyShimmer('Loading...', state, {
42
+ * color: [140, 82, 255],
43
+ * direction: 'ltr',
44
+ * })
45
+ * ```
37
46
  */
38
47
  export declare function applyShimmer(text: string, state: ShimmerState, options?: ShimmerOptions | undefined): string;
@@ -12,5 +12,11 @@ export declare const RAINBOW_GRADIENT: ShimmerColorGradient;
12
12
  /**
13
13
  * Generate rainbow gradient colors for any text length.
14
14
  * Colors are distributed evenly across the text by cycling through the gradient.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const colors = generateRainbowGradient('Hello'.length)
19
+ * console.log(colors.length) // 5
20
+ * ```
15
21
  */
16
22
  export declare function generateRainbowGradient(textLength: number): ShimmerColorGradient;