@@ -191,6 +191,15 @@ export interface DlxMetadata {
191191
192192/**
193193 * Clean expired entries from the DLX cache.
194+ *
195+ * @example
196+ * ```typescript
197+ * // Remove cache entries older than the default TTL
198+ * const removed = await cleanDlxCache()
199+ *
200+ * // Remove entries older than 1 hour
201+ * const removed2 = await cleanDlxCache(60 * 60 * 1000)
202+ * ```
194203 */
195204export async function cleanDlxCache (
196205 maxAge : number = DLX_BINARY_CACHE_TTL ,
@@ -260,6 +269,15 @@ export async function cleanDlxCache(
260269
261270/**
262271 * Download and execute a binary from a URL with caching.
272+ *
273+ * @example
274+ * ```typescript
275+ * const result = await dlxBinary(['--version'], {
276+ * url: 'https://example.com/tool-linux-x64',
277+ * name: 'tool',
278+ * })
279+ * await result.spawnPromise
280+ * ```
263281 */
264282export async function dlxBinary (
265283 args : readonly string [ ] | string [ ] ,
@@ -417,6 +435,15 @@ export async function dlxBinary(
417435 * Similar to downloadPackage from dlx-package.
418436 *
419437 * @returns Object containing the path to the cached binary and whether it was downloaded
438+ *
439+ * @example
440+ * ```typescript
441+ * const { binaryPath, downloaded } = await downloadBinary({
442+ * url: 'https://example.com/tool-linux-x64',
443+ * name: 'tool',
444+ * })
445+ * console.log(`Binary at: ${binaryPath}, fresh: ${downloaded}`)
446+ * ```
420447 */
421448export async function downloadBinary (
422449 options : Omit < DlxBinaryOptions , 'spawnOptions' > ,
@@ -512,6 +539,15 @@ export async function downloadBinary(
512539 * - integrity: SRI format sha512-<base64> (verified post-download)
513540 *
514541 * The sha256 option is preferred as it fails early during download if the checksum doesn't match.
542+ *
543+ * @example
544+ * ```typescript
545+ * const integrity = await downloadBinaryFile(
546+ * 'https://example.com/tool-linux-x64',
547+ * '/tmp/dlx-cache/tool'
548+ * )
549+ * console.log(`Integrity: ${integrity}`)
550+ * ```
515551 */
516552export async function downloadBinaryFile (
517553 url : string ,
@@ -608,6 +644,15 @@ export async function downloadBinaryFile(
608644 * @param spawnOptions Spawn options for execution
609645 * @param spawnExtra Extra spawn configuration
610646 * @returns The spawn promise for the running process
647+ *
648+ * @example
649+ * ```typescript
650+ * const { binaryPath } = await downloadBinary({
651+ * url: 'https://example.com/tool-linux-x64',
652+ * name: 'tool',
653+ * })
654+ * const result = executeBinary(binaryPath, ['--help'])
655+ * ```
611656 */
612657export function executeBinary (
613658 binaryPath : string ,
@@ -647,20 +692,40 @@ export function executeBinary(
647692 * Get the DLX binary cache directory path.
648693 * Returns normalized path for cross-platform compatibility.
649694 * Uses same directory as dlx-package for unified DLX storage.
695+ *
696+ * @example
697+ * ```typescript
698+ * const cachePath = getDlxCachePath()
699+ * ```
650700 */
651701export function getDlxCachePath ( ) : string {
652702 return getSocketDlxDir ( )
653703}
654704
655705/**
656706 * Get metadata file path for a cached binary.
707+ *
708+ * @example
709+ * ```typescript
710+ * const metaPath = getBinaryCacheMetadataPath('/tmp/dlx-cache/a1b2c3d4')
711+ * // '/tmp/dlx-cache/a1b2c3d4/.dlx-metadata.json'
712+ * ```
657713 */
658714export function getBinaryCacheMetadataPath ( cacheEntryPath : string ) : string {
659715 return getPath ( ) . join ( cacheEntryPath , '.dlx-metadata.json' )
660716}
661717
662718/**
663719 * Check if a cached binary is still valid.
720+ *
721+ * @example
722+ * ```typescript
723+ * const ttl = 7 * 24 * 60 * 60 * 1000
724+ * const valid = await isBinaryCacheValid('/tmp/dlx-cache/a1b2c3d4', ttl)
725+ * if (!valid) {
726+ * // Re-download the binary
727+ * }
728+ * ```
664729 */
665730export async function isBinaryCacheValid (
666731 cacheEntryPath : string ,
@@ -696,6 +761,14 @@ export async function isBinaryCacheValid(
696761
697762/**
698763 * Get information about cached binaries.
764+ *
765+ * @example
766+ * ```typescript
767+ * const entries = await listDlxCache()
768+ * for (const entry of entries) {
769+ * console.log(`${entry.name}: ${entry.size} bytes`)
770+ * }
771+ * ```
699772 */
700773export async function listDlxCache ( ) : Promise <
701774 Array < {
@@ -773,6 +846,17 @@ export async function listDlxCache(): Promise<
773846 * Write metadata for a cached binary.
774847 * Uses unified schema shared with C++ decompressor and CLI dlxBinary.
775848 * Schema documentation: See DlxMetadata interface in this file (exported).
849+ *
850+ * @example
851+ * ```typescript
852+ * await writeBinaryCacheMetadata(
853+ * '/tmp/dlx-cache/a1b2c3d4',
854+ * 'a1b2c3d4',
855+ * 'https://example.com/tool',
856+ * 'sha512-abc123...',
857+ * 15000000
858+ * )
859+ * ```
776860 */
777861export async function writeBinaryCacheMetadata (
778862 cacheEntryPath : string ,
0 commit comments