dir-archiver 3.0.0 → 3.0.2

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,100 @@
1
+ # Changes to Dir Archiver
2
+
3
+ ### Unreleased
4
+
5
+ * No entries yet.
6
+
7
+ ### 3.0.2 (June 19, 2026)
8
+
9
+ * Fix JSR documentation checks for current and pinned Deno doc output.
10
+ * Update `argv-flags` to 1.0.5.
11
+ * Bump GitHub Actions dependencies in CI and release workflows.
12
+
13
+ ### 3.0.1 (March 3, 2026)
14
+
15
+ * Rework README/docs information architecture for fast first-use onboarding.
16
+ * Expand `docs/reference/cli.md` as the canonical CLI command/flag/output reference.
17
+ * Add runnable offline examples and wire `npm run examples:run` into check flows.
18
+ * Add example doc blocks (Goal/Prereqs/Run/Expected output/Safety notes) for each example file.
19
+ * Keep archive runtime behavior and CLI semantics unchanged.
20
+
21
+ ### 3.0.0 (February 28, 2026)
22
+
23
+ * Rewrite dir-archiver as a bytefold-backed orchestration layer over `open`, `detect`, `list`, `audit`, `extract`, `normalize`, and `write`.
24
+ * Expand format support to the full bytefold `ArchiveFormat` surface (zip/tar/layered codecs).
25
+ * Add runtime adapters for Node.js, Deno, and Bun with unified API behavior.
26
+ * Add strict/agent extraction security enforcement and stable `DirArchiverError.code` contracts.
27
+ * Add CLI v3 contract with schema-driven parsing via `argv-flags`, machine JSON mode, and explicit exit code semantics.
28
+ * Add capability-derived runtime matrix tests, determinism fingerprints, and adversarial security fixtures.
29
+ * Add downstream compatibility gates against released dependencies and `main` branches.
30
+ * Enforce ESM-only, workflow-policy, docs-policy, and runtime-policy gates via `npm run check`.
31
+ * Align dependency source to released `@ismail-elkorchi/bytefold@^0.7.2` (remove local/git-sha dependency path).
32
+ * Bump runtime floor to Node.js >=24 and keep Deno/Bun support through dedicated runtime checks.
33
+
34
+ ### 2.2.0 (January 28, 2026)
35
+
36
+ * Migrate source to TypeScript with strict compiler options.
37
+ * Build compiled output into `dist/` with declaration files.
38
+ * Add strict ESLint configuration alongside TypeScript typechecking.
39
+ * Require Node.js >=18.
40
+ * CLI exits with a non-zero status when required arguments are missing.
41
+ * Add a CLI smoke test.
42
+ * Skip symlinks by default and add an option to follow them.
43
+ * Exclude entries by name anywhere unless a relative path is specified.
44
+ * Normalize exclude path separators so Windows-style paths work cross-platform.
45
+ * Accept absolute exclude paths when they resolve inside the source tree.
46
+ * Make exclude matching case-insensitive on Windows.
47
+ * Normalize archive entry paths to forward slashes for cross-platform zip compatibility.
48
+ * Traverse entries in deterministic order.
49
+ * Honor explicit true/false values for CLI boolean flags.
50
+ * Improve error handling for archive creation failures.
51
+ * Bump argv-flags to 0.2.1 (inline flag values).
52
+
53
+ ### 2.1.2 (January 28, 2026)
54
+
55
+ * Add a smoke test suite and npm test script.
56
+ * Add CI to run linting and tests.
57
+ * Declare Node.js >=14 in package metadata.
58
+
59
+ ### 2.1.1 (January 28, 2026)
60
+
61
+ * Avoid archiving the destination zip when it lives inside the source directory ([#5](https://github.com/Ismail-elkorchi/dir-archiver/issues/5)).
62
+ * `createZip()` now returns a Promise that resolves when the archive is closed ([#13](https://github.com/Ismail-elkorchi/dir-archiver/issues/13)).
63
+ * Bump archiver to 7.0.1 to address dependency deprecation warnings ([#14](https://github.com/Ismail-elkorchi/dir-archiver/issues/14)).
64
+
65
+ ### 2.1.0 (October 25, 2022)
66
+
67
+ * Add ESLint ([#12](https://github.com/Ismail-elkorchi/dir-archiver/pull/12)).
68
+ * Several enhancements to better support Microsoft Windows ([Diff](https://github.com/Ismail-elkorchi/dir-archiver/compare/2.0.0...v2.1.0)).
69
+
70
+ ### 2.0.0 (September 20, 2022)
71
+
72
+ * Bump archiver from 5.2.0 to 5.3.1 ([42c30b7](https://github.com/Ismail-elkorchi/dir-archiver/commit/42c30b7a3b7fa0b3101e21559f1774f45d2f06ce)).
73
+ * Add an option to include the base directory in the archive root ([#11](https://github.com/Ismail-elkorchi/dir-archiver/pull/11)).
74
+
75
+ ### 1.2.0 (February 28, 2021)
76
+
77
+ * Bump archiver from 4.0.2 to 5.2.0 ([b84c347](https://github.com/Ismail-elkorchi/dir-archiver/commit/b84c34731617c57b7c439f15910fcc8fa00747b2)).
78
+ * Make exclude paths relative to run directory ([#4](https://github.com/Ismail-elkorchi/dir-archiver/pull/4)).
79
+ * Remove the destination zip if it exists already ([#7](https://github.com/Ismail-elkorchi/dir-archiver/pull/7)).
80
+
81
+ ### 1.1.2 (July 21, 2020)
82
+
83
+ * Bump lodash from 4.17.15 to 4.17.19.
84
+ * Bump archiver from 4.0.1 to 4.0.2.
85
+
86
+ ### 1.1.1 (May 14, 2020)
87
+
88
+ * CLI : prevent execution if the required arguments are missing.
89
+
90
+ ### 1.1.0 (May 13, 2020)
91
+
92
+ * Add cli script.
93
+
94
+ ### 1.0.1 (May 12, 2020)
95
+
96
+ * Fix the installation instructions.
97
+
98
+ ### 1.0.0 (May 12, 2020)
99
+
100
+ * initial release.
package/CONTRACT.md ADDED
@@ -0,0 +1,94 @@
1
+ # dir-archiver contract
2
+
3
+ This document defines the current public behavior contract for `dir-archiver`.
4
+
5
+ ## Runtime support
6
+
7
+ - Node.js LTS (minimum aligned with bytefold `engines.node`).
8
+ - Latest stable Deno.
9
+ - Latest stable Bun.
10
+
11
+ ## Public operations
12
+
13
+ - `open(input, options)`
14
+ - `detect(input, options)`
15
+ - `list(input, options)`
16
+ - `audit(input, options)`
17
+ - `extract(input, destination, options)`
18
+ - `normalize(input, destination, options)`
19
+ - `write(source, destination, options)`
20
+
21
+ Profiles are passed through to bytefold for read/audit/extract/normalize flows (`compat | strict | agent`).
22
+ `WriteOptions.profile` and `WriteOptions.limits` are currently reserved and not forwarded by `write()`.
23
+
24
+ Detailed option fields and examples are maintained in
25
+ `docs/reference/options.md`.
26
+
27
+ ## Format surface
28
+
29
+ The package accepts the full bytefold `ArchiveFormat` union:
30
+
31
+ `zip`, `tar`, `tgz`, `tar.gz`, `gz`, `bz2`, `tar.bz2`, `zst`, `tar.zst`, `br`, `tar.br`, `xz`, `tar.xz`.
32
+
33
+ ### Directory input with single-file codec
34
+
35
+ When `write()` receives a directory source and the requested format is a single-file codec:
36
+
37
+ - `gz` -> `tar.gz`
38
+ - `bz2` -> `tar.bz2`
39
+ - `xz` -> `tar.xz`
40
+ - `zst` -> `tar.zst`
41
+ - `br` -> `tar.br`
42
+
43
+ This conversion is deterministic and reported via `WriteResult.wrappedDirectoryCodec`.
44
+
45
+ ## Determinism rules
46
+
47
+ - Directory traversal order is lexicographic and stable.
48
+ - Archive entry paths are normalized to `/`.
49
+ - `normalize()` defaults to deterministic mode (`isDeterministic: true`).
50
+
51
+ ## Resource limits
52
+
53
+ Extraction limits are explicit options:
54
+
55
+ - `maxEntryBytes`
56
+ - `maxTotalExtractedBytes`
57
+
58
+ Budget overruns fail with stable code `DIRARCHIVER_RESOURCE_LIMIT`.
59
+
60
+ ## Security model
61
+
62
+ - Extraction treats archive entries as untrusted.
63
+ - Absolute paths, drive-prefixed paths, and traversal (`..`) are rejected with `DIRARCHIVER_PATH_TRAVERSAL`.
64
+ - Strict/agent extraction runs an audit gate before writing files.
65
+ - Hard links are rejected with `DIRARCHIVER_UNSUPPORTED_ENTRY`.
66
+ - Symlinks are skipped unless explicitly enabled.
67
+
68
+ ## Error code stability
69
+
70
+ Consumers rely on `DirArchiverError.code`, not message text.
71
+ Current stable codes:
72
+
73
+ - `DIRARCHIVER_INVALID_SOURCE`
74
+ - `DIRARCHIVER_INVALID_DESTINATION`
75
+ - `DIRARCHIVER_PATH_TRAVERSAL`
76
+ - `DIRARCHIVER_UNSUPPORTED_ENTRY`
77
+ - `DIRARCHIVER_RESOURCE_LIMIT`
78
+ - `DIRARCHIVER_RUNTIME_UNSUPPORTED`
79
+ - `DIRARCHIVER_NORMALIZE_UNSUPPORTED`
80
+ - `DIRARCHIVER_USAGE`
81
+
82
+ ## CLI exit codes
83
+
84
+ - `0`: success
85
+ - `1`: operational failure
86
+ - `2`: usage/validation failure
87
+
88
+ Canonical command/flag documentation lives in `docs/reference/cli.md`.
89
+
90
+ ## API surface snapshot oracle
91
+
92
+ `test/api-snapshot.test.mjs` compares module exports with
93
+ `test/fixtures/api-surface.v3.json`.
94
+ Any intentional API change updates both this contract and the snapshot.
@@ -0,0 +1,33 @@
1
+ # Contributing
2
+
3
+ ## Development setup
4
+
5
+ ```sh
6
+ npm ci
7
+ npm run check:fast
8
+ npm run check
9
+ ```
10
+
11
+ ## Verification commands
12
+
13
+ - `npm run check:fast`: lint + Node test suite (no runtime matrix).
14
+ - `npm run check`: full repository gate (policy checks, lint, tests, security tests, runtime matrix).
15
+
16
+ ## Change requirements
17
+
18
+ - Keep ESM-only packaging.
19
+ - Preserve Node + Deno + Bun compatibility.
20
+ - Add/update tests for behavior changes.
21
+ - Update `CONTRACT.md` for API or guarantee changes.
22
+
23
+ ## Runtime dependency freshness policy
24
+
25
+ - Keep direct runtime dependencies in `package.json` and `package-lock.json` on the latest published stable versions before every release.
26
+ - Validate with `npm run deps:fresh` (this gate runs in the release workflow).
27
+ - If a dependency is stale, update it in a dedicated PR and run `npm run check`.
28
+
29
+ ## Pull request checklist
30
+
31
+ - [ ] `npm run check` passes locally
32
+ - [ ] docs updated for user-facing changes
33
+ - [ ] changelog entry added for release-relevant updates
package/README.md CHANGED
@@ -1,88 +1,64 @@
1
- ---
2
- role: overview
3
- audience: users
4
- source_of_truth: README.md
5
- update_triggers:
6
- - public API changes
7
- - CLI contract changes
8
- - runtime support changes
9
- ---
10
-
11
1
  # dir-archiver
12
2
 
13
- `dir-archiver` v3 is a bytefold-backed archive orchestration layer for Node.js, Deno, and Bun.
14
- ESM-only. Safety profiles: `compat | strict | agent`.
3
+ Deterministic directory archiving and extraction over zip, tar, and layered compression.
15
4
 
16
- ## Install
5
+ Supports Node.js, Deno, and Bun.
17
6
 
18
- ### npm
7
+ ## What it is
19
8
 
20
- ```sh
21
- npm install dir-archiver
22
- ```
9
+ `dir-archiver` provides one API surface for archive operations with explicit safety profiles and stable error codes.
23
10
 
24
- ### JSR
11
+ ## Install
25
12
 
26
13
  ```sh
14
+ npm install dir-archiver
27
15
  deno add jsr:@ismail-elkorchi/dir-archiver
28
16
  ```
29
17
 
30
- ## Quickstart (API)
18
+ ## Quickstart
31
19
 
32
20
  ```ts
33
- import { write, detect, list, extract } from 'dir-archiver';
21
+ import { write, detect, extract } from "dir-archiver";
34
22
 
35
- await write('./project', './project.zip', {
36
- format: 'zip',
23
+ await write("./project", "./project.zip", {
24
+ format: "zip",
37
25
  includeBaseDirectory: true,
38
- profile: 'strict'
39
26
  });
40
27
 
41
- const detected = await detect('./project.zip');
42
- const listed = await list('./project.zip');
43
- await extract('./project.zip', './out', { profile: 'strict' });
28
+ const detected = await detect("./project.zip");
29
+ await extract("./project.zip", "./out", { profile: "strict" });
44
30
 
45
- console.log(detected.format, listed.entries.length);
31
+ console.log(detected.format);
46
32
  ```
47
33
 
48
- ## Public operations
49
-
50
- - `open(input, options)`
51
- - `detect(input, options)`
52
- - `list(input, options)`
53
- - `audit(input, options)`
54
- - `extract(input, destination, options)`
55
- - `normalize(input, destination, options)`
56
- - `write(source, destination, options)`
34
+ ## When not to use
57
35
 
58
- Format surface matches bytefold `ArchiveFormat` support.
59
- Directory + single-file codec requests are normalized to `tar.<codec>` (`gz`, `bz2`, `xz`, `zst`, `br`).
36
+ - You only need a low-level parser for a single format.
37
+ - You target CommonJS-only environments or Node < 24.
38
+ - You need interactive archive browsing UI features.
60
39
 
61
- ## CLI
40
+ ## When to use
62
41
 
63
- ```sh
64
- dir-archiver write --source ./project --output ./project.zip --format zip --json
65
- dir-archiver detect --input ./project.zip --json
66
- dir-archiver list --input ./project.zip --json
67
- dir-archiver audit --input ./project.zip --profile agent --json
68
- dir-archiver extract --input ./project.zip --output ./out --profile strict --json
69
- dir-archiver normalize --input ./project.zip --output ./normalized.zip --json
70
- ```
42
+ - You need one API for detect, list, audit, extract, normalize, and write.
43
+ - You want deterministic normalization for CI pipelines.
44
+ - You need safety profiles for untrusted inputs.
71
45
 
72
- Exit codes:
46
+ ## Compatibility
73
47
 
74
- - `0` success
75
- - `1` operational failure
76
- - `2` usage/validation failure
48
+ - Module system: ESM-only.
49
+ - Runtimes: Node `>=24`, current Deno, current Bun.
50
+ - CLI and API contracts are documented in [Contract](https://github.com/Ismail-elkorchi/dir-archiver/blob/main/CONTRACT.md).
77
51
 
78
- ## Security model
52
+ ## Documentation
79
53
 
80
- - Archive extraction treats input as untrusted by default.
81
- - Traversal/absolute paths are blocked in strict/agent profiles.
82
- - See `SECURITY.md` and `docs/security-triage.md`.
54
+ - [Docs index](https://github.com/Ismail-elkorchi/dir-archiver/blob/main/docs/index.md)
55
+ - [Tutorial: bundle a plugin directory](https://github.com/Ismail-elkorchi/dir-archiver/blob/main/docs/tutorial/bundle-a-plugin.md)
56
+ - [Reference: CLI](https://github.com/Ismail-elkorchi/dir-archiver/blob/main/docs/reference/cli.md)
83
57
 
84
- ## Docs
58
+ ## Verification
85
59
 
86
- - `docs/V3_CONTRACT.md`
87
- - `CHANGELOG.md`
88
- - `SECURITY.md`
60
+ ```sh
61
+ npm run examples:run
62
+ npm run check:fast
63
+ npm run check
64
+ ```
package/SECURITY.md ADDED
@@ -0,0 +1,23 @@
1
+ # Security policy
2
+
3
+ ## Threat model
4
+
5
+ - Archive inputs are untrusted by default.
6
+ - Common risks include path traversal, symlink abuse, hard-link abuse, and resource exhaustion.
7
+ - Runtime/feature mismatches are treated as explicit typed failures.
8
+
9
+ ## Safe usage guidance
10
+
11
+ - Prefer `strict` or `agent` profiles for extraction and audit.
12
+ - Audit untrusted archives before extraction (`audit` + `assertSafe` paths).
13
+ - Set resource limits (`maxEntryBytes`, `maxTotalExtractedBytes`) for hostile inputs.
14
+
15
+ ## Reporting vulnerabilities
16
+
17
+ Report security issues through GitHub Security Advisories for this repository.
18
+
19
+ ## Disclosure workflow
20
+
21
+ 1. Reproduce and classify impact.
22
+ 2. Patch with tests.
23
+ 3. Publish release notes and remediation guidance.
package/SUPPORT.md ADDED
@@ -0,0 +1,16 @@
1
+ # Support
2
+
3
+ ## Usage questions
4
+
5
+ Open a GitHub issue and include:
6
+ - runtime (`node`, `deno`, `bun`)
7
+ - package version
8
+ - minimal reproducible example
9
+
10
+ ## Bug reports
11
+
12
+ Use GitHub issues with expected vs actual behavior and sample command/input.
13
+
14
+ ## Security reports
15
+
16
+ Follow `SECURITY.md` for private disclosure.
package/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import { DirArchiverError } from './errors.js';
4
4
  import { parseCliArgs } from './cli-args.js';
5
5
  const usage = `Usage:
6
6
  dir-archiver write --source <path> --output <archive> [--format <format>] [--include-base-directory] [--exclude <path>...]
7
+ dir-archiver open --input <archive> [--profile compat|strict|agent]
7
8
  dir-archiver detect --input <archive>
8
9
  dir-archiver list --input <archive>
9
10
  dir-archiver audit --input <archive> [--profile compat|strict|agent]
package/dist/core.d.ts CHANGED
@@ -1,31 +1,100 @@
1
1
  import type { ArchiveAuditReport, ArchiveReader } from '@ismail-elkorchi/bytefold';
2
2
  import type { DetectResult, DirArchiverInput, ExtractOptions, ExtractResult, ListResult, NormalizeOptions, NormalizeResult, OpenOptions, WriteOptions, WriteResult } from './types.js';
3
3
  /**
4
- * Opens an archive input with bytefold runtime bindings.
4
+ * Opens an archive and returns the live bytefold reader.
5
+ *
6
+ * Use this when you need direct access to low-level reader capabilities such
7
+ * as `entries()`, `audit()`, or normalization support checks. The returned
8
+ * reader is not auto-disposed, so callers should close or dispose it when the
9
+ * active runtime exposes a cleanup hook.
10
+ *
11
+ * @param input Archive bytes, path, URL, stream, or blob to open.
12
+ * @param options Format hints, safety profile, limits, and cancellation
13
+ * signal forwarded to bytefold.
14
+ * @returns A live `ArchiveReader` for advanced inspection flows.
5
15
  */
6
16
  export declare const open: (input: DirArchiverInput, options?: OpenOptions) => Promise<ArchiveReader>;
7
17
  /**
8
- * Detects archive format and exposes bytefold detection metadata.
18
+ * Detects an archive format without extracting or listing its contents.
19
+ *
20
+ * This is the lightest-weight way to confirm the container and compression
21
+ * layers before choosing a follow-up operation.
22
+ *
23
+ * @param input Archive bytes, path, URL, stream, or blob to inspect.
24
+ * @param options Format hints and parse controls applied during detection.
25
+ * @returns The resolved archive format and any bytefold detection metadata.
9
26
  */
10
27
  export declare const detect: (input: DirArchiverInput, options?: OpenOptions) => Promise<DetectResult>;
11
28
  /**
12
- * Lists archive entries without extracting to disk.
29
+ * Lists archive entries without extracting anything to disk.
30
+ *
31
+ * Each entry is projected into a JSON-safe summary so CLI and API callers can
32
+ * inspect paths, sizes, and link metadata before deciding to extract.
33
+ *
34
+ * @param input Archive bytes, path, URL, stream, or blob to inspect.
35
+ * @param options Format hints and parse controls applied while reading the
36
+ * archive directory.
37
+ * @returns Archive metadata plus the entry summaries visible to callers.
13
38
  */
14
39
  export declare const list: (input: DirArchiverInput, options?: OpenOptions) => Promise<ListResult>;
15
40
  /**
16
- * Runs bytefold audit checks for the selected safety profile.
41
+ * Audits an archive against the selected bytefold safety profile.
42
+ *
43
+ * Use this before extraction when you need a report of unsafe paths, link
44
+ * entries, or format-specific concerns without writing files to disk.
45
+ *
46
+ * @param input Archive bytes, path, URL, stream, or blob to audit.
47
+ * @param options Safety profile, limits, and format hints used during the
48
+ * audit pass.
49
+ * @returns The bytefold audit report for the requested profile.
17
50
  */
18
51
  export declare const audit: (input: DirArchiverInput, options?: OpenOptions) => Promise<ArchiveAuditReport>;
19
52
  /**
20
- * Writes a normalized deterministic archive when supported by the format.
53
+ * Rewrites an archive into its normalized deterministic representation.
54
+ *
55
+ * Normalization is available only when the opened archive reader exposes
56
+ * bytefold normalization support. Unsupported formats throw
57
+ * `DIRARCHIVER_NORMALIZE_UNSUPPORTED`.
58
+ *
59
+ * @param input Archive bytes, path, URL, stream, or blob to normalize.
60
+ * @param destination Output archive path that will receive the normalized
61
+ * bytes.
62
+ * @param options Format hints and normalization controls applied during the
63
+ * read and write pass.
64
+ * @returns The source format and bytefold normalization report.
65
+ * @throws {DirArchiverError} When the selected archive format cannot be
66
+ * normalized by the active runtime.
21
67
  */
22
68
  export declare const normalize: (input: DirArchiverInput, destination: string, options?: NormalizeOptions) => Promise<NormalizeResult>;
23
69
  /**
24
- * Extracts entries to a destination directory with safety enforcement.
70
+ * Extracts an archive into a destination directory with safety enforcement.
71
+ *
72
+ * `extract()` defaults to `profile: 'strict'`. Under `strict` or `agent`, the
73
+ * archive is audited before bytes are written to disk and unsafe entries raise
74
+ * a `DirArchiverError` instead of being silently materialized.
75
+ *
76
+ * @param input Archive bytes, path, URL, stream, or blob to extract.
77
+ * @param destination Directory that will receive extracted files.
78
+ * @param options Extraction policy, safety profile, and resource limits.
79
+ * @returns A summary of what was extracted, skipped, and flagged.
80
+ * @throws {DirArchiverError} When audit checks fail, resource limits are
81
+ * exceeded, or unsupported entry types are encountered.
25
82
  */
26
83
  export declare const extract: (input: DirArchiverInput, destination: string, options?: ExtractOptions) => Promise<ExtractResult>;
27
84
  /**
28
- * Writes an archive from a file or directory source.
85
+ * Writes an archive from a file or directory source path.
86
+ *
87
+ * Directory sources are traversed deterministically. When callers request a
88
+ * single-file compression codec such as `gz` for a directory source,
89
+ * `dir-archiver` wraps the directory in the corresponding tar-based container
90
+ * (`tar.gz`, `tar.zst`, and so on).
91
+ *
92
+ * @param source File or directory path to archive.
93
+ * @param destination Output archive path.
94
+ * @param options Format selection, traversal rules, and exclusion controls.
95
+ * @returns A summary of the emitted archive format and entry count.
96
+ * @throws {DirArchiverError} When the requested output format is unsupported by
97
+ * the active bytefold writer.
29
98
  */
30
99
  export declare const write: (source: string, destination: string, options?: WriteOptions) => Promise<WriteResult>;
31
100
  export declare const copyStreamToFile: (source: string, destination: string) => Promise<void>;
package/dist/core.js CHANGED
@@ -12,14 +12,31 @@ const DIRECTORY_TO_SINGLE_FILE_CODEC = {
12
12
  };
13
13
  const writeUnsupportedFormats = new Set(['tar.bz2', 'bz2', 'tar.xz', 'xz']);
14
14
  /**
15
- * Opens an archive input with bytefold runtime bindings.
15
+ * Opens an archive and returns the live bytefold reader.
16
+ *
17
+ * Use this when you need direct access to low-level reader capabilities such
18
+ * as `entries()`, `audit()`, or normalization support checks. The returned
19
+ * reader is not auto-disposed, so callers should close or dispose it when the
20
+ * active runtime exposes a cleanup hook.
21
+ *
22
+ * @param input Archive bytes, path, URL, stream, or blob to open.
23
+ * @param options Format hints, safety profile, limits, and cancellation
24
+ * signal forwarded to bytefold.
25
+ * @returns A live `ArchiveReader` for advanced inspection flows.
16
26
  */
17
27
  export const open = async (input, options = {}) => {
18
28
  const runtime = await loadRuntimeBindings();
19
29
  return runtime.openArchive(input, toArchiveOpenOptions(options));
20
30
  };
21
31
  /**
22
- * Detects archive format and exposes bytefold detection metadata.
32
+ * Detects an archive format without extracting or listing its contents.
33
+ *
34
+ * This is the lightest-weight way to confirm the container and compression
35
+ * layers before choosing a follow-up operation.
36
+ *
37
+ * @param input Archive bytes, path, URL, stream, or blob to inspect.
38
+ * @param options Format hints and parse controls applied during detection.
39
+ * @returns The resolved archive format and any bytefold detection metadata.
23
40
  */
24
41
  export const detect = async (input, options = {}) => {
25
42
  const reader = await open(input, options);
@@ -34,7 +51,15 @@ export const detect = async (input, options = {}) => {
34
51
  }
35
52
  };
36
53
  /**
37
- * Lists archive entries without extracting to disk.
54
+ * Lists archive entries without extracting anything to disk.
55
+ *
56
+ * Each entry is projected into a JSON-safe summary so CLI and API callers can
57
+ * inspect paths, sizes, and link metadata before deciding to extract.
58
+ *
59
+ * @param input Archive bytes, path, URL, stream, or blob to inspect.
60
+ * @param options Format hints and parse controls applied while reading the
61
+ * archive directory.
62
+ * @returns Archive metadata plus the entry summaries visible to callers.
38
63
  */
39
64
  export const list = async (input, options = {}) => {
40
65
  const reader = await open(input, options);
@@ -61,7 +86,15 @@ export const list = async (input, options = {}) => {
61
86
  }
62
87
  };
63
88
  /**
64
- * Runs bytefold audit checks for the selected safety profile.
89
+ * Audits an archive against the selected bytefold safety profile.
90
+ *
91
+ * Use this before extraction when you need a report of unsafe paths, link
92
+ * entries, or format-specific concerns without writing files to disk.
93
+ *
94
+ * @param input Archive bytes, path, URL, stream, or blob to audit.
95
+ * @param options Safety profile, limits, and format hints used during the
96
+ * audit pass.
97
+ * @returns The bytefold audit report for the requested profile.
65
98
  */
66
99
  export const audit = async (input, options = {}) => {
67
100
  const reader = await open(input, options);
@@ -73,7 +106,20 @@ export const audit = async (input, options = {}) => {
73
106
  }
74
107
  };
75
108
  /**
76
- * Writes a normalized deterministic archive when supported by the format.
109
+ * Rewrites an archive into its normalized deterministic representation.
110
+ *
111
+ * Normalization is available only when the opened archive reader exposes
112
+ * bytefold normalization support. Unsupported formats throw
113
+ * `DIRARCHIVER_NORMALIZE_UNSUPPORTED`.
114
+ *
115
+ * @param input Archive bytes, path, URL, stream, or blob to normalize.
116
+ * @param destination Output archive path that will receive the normalized
117
+ * bytes.
118
+ * @param options Format hints and normalization controls applied during the
119
+ * read and write pass.
120
+ * @returns The source format and bytefold normalization report.
121
+ * @throws {DirArchiverError} When the selected archive format cannot be
122
+ * normalized by the active runtime.
77
123
  */
78
124
  export const normalize = async (input, destination, options = {}) => {
79
125
  const reader = await open(input, options);
@@ -95,7 +141,18 @@ export const normalize = async (input, destination, options = {}) => {
95
141
  }
96
142
  };
97
143
  /**
98
- * Extracts entries to a destination directory with safety enforcement.
144
+ * Extracts an archive into a destination directory with safety enforcement.
145
+ *
146
+ * `extract()` defaults to `profile: 'strict'`. Under `strict` or `agent`, the
147
+ * archive is audited before bytes are written to disk and unsafe entries raise
148
+ * a `DirArchiverError` instead of being silently materialized.
149
+ *
150
+ * @param input Archive bytes, path, URL, stream, or blob to extract.
151
+ * @param destination Directory that will receive extracted files.
152
+ * @param options Extraction policy, safety profile, and resource limits.
153
+ * @returns A summary of what was extracted, skipped, and flagged.
154
+ * @throws {DirArchiverError} When audit checks fail, resource limits are
155
+ * exceeded, or unsupported entry types are encountered.
99
156
  */
100
157
  export const extract = async (input, destination, options = {}) => {
101
158
  var _a;
@@ -180,7 +237,19 @@ export const extract = async (input, destination, options = {}) => {
180
237
  }
181
238
  };
182
239
  /**
183
- * Writes an archive from a file or directory source.
240
+ * Writes an archive from a file or directory source path.
241
+ *
242
+ * Directory sources are traversed deterministically. When callers request a
243
+ * single-file compression codec such as `gz` for a directory source,
244
+ * `dir-archiver` wraps the directory in the corresponding tar-based container
245
+ * (`tar.gz`, `tar.zst`, and so on).
246
+ *
247
+ * @param source File or directory path to archive.
248
+ * @param destination Output archive path.
249
+ * @param options Format selection, traversal rules, and exclusion controls.
250
+ * @returns A summary of the emitted archive format and entry count.
251
+ * @throws {DirArchiverError} When the requested output format is unsupported by
252
+ * the active bytefold writer.
184
253
  */
185
254
  export const write = async (source, destination, options = {}) => {
186
255
  var _a, _b;