mdmeld 0.1.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.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/chunk-UF532LMZ.js +426 -0
- package/dist/chunk-UF532LMZ.js.map +1 -0
- package/dist/chunk-UJZ43GZC.js +128 -0
- package/dist/chunk-UJZ43GZC.js.map +1 -0
- package/dist/cli/index.js +90 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.cjs +609 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +71 -0
- package/dist/core/index.d.ts +71 -0
- package/dist/core/index.js +570 -0
- package/dist/core/index.js.map +1 -0
- package/dist/finalize-NGDCBCTD.js +84 -0
- package/dist/finalize-NGDCBCTD.js.map +1 -0
- package/dist/pack-ODWNG5OH.js +84 -0
- package/dist/pack-ODWNG5OH.js.map +1 -0
- package/dist/release/SHA256SUMS +1 -0
- package/dist/release/SHA256SUMS.asc +16 -0
- package/dist/release/SHA256SUMS.minisig +4 -0
- package/dist/release/SHA512SUMS +1 -0
- package/dist/release/SHA512SUMS.asc +16 -0
- package/dist/release/SHA512SUMS.minisig +4 -0
- package/dist/release/mdmeld-0.1.0.tgz +0 -0
- package/dist/release/mdmeld-minisign.pub +2 -0
- package/dist/release/mdmeld-release-signing-key.asc +64 -0
- package/dist/release/release-notes-v0.1.0.md +29 -0
- package/dist/unpack-2BBZMGLH.js +25 -0
- package/dist/unpack-2BBZMGLH.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/constants.ts
|
|
4
|
+
var FORMAT_VERSION = "1.0.0";
|
|
5
|
+
var MIN_BACKTICK_COUNT = 4;
|
|
6
|
+
var MAX_BACKTICK_COUNT = 8;
|
|
7
|
+
var HASH_PLACEHOLDER = "HASH_PLACEHOLDER";
|
|
8
|
+
var ARCHIVE_HEADER = `<!-- MDMeld v1.0 archive \u2014 a directory tree encoded as markdown.
|
|
9
|
+
Read the manifest below for file listing and positions.
|
|
10
|
+
Spec: https://github.com/3leaps/mdmeld -->`;
|
|
11
|
+
|
|
12
|
+
// src/core/base64.ts
|
|
13
|
+
var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
14
|
+
function encodeBase64(data) {
|
|
15
|
+
let result = "";
|
|
16
|
+
const len = data.length;
|
|
17
|
+
const remainder = len % 3;
|
|
18
|
+
const mainLen = len - remainder;
|
|
19
|
+
for (let i = 0; i < mainLen; i += 3) {
|
|
20
|
+
const a = data[i];
|
|
21
|
+
const b = data[i + 1];
|
|
22
|
+
const c = data[i + 2];
|
|
23
|
+
result += CHARS[a >> 2];
|
|
24
|
+
result += CHARS[(a & 3) << 4 | b >> 4];
|
|
25
|
+
result += CHARS[(b & 15) << 2 | c >> 6];
|
|
26
|
+
result += CHARS[c & 63];
|
|
27
|
+
}
|
|
28
|
+
if (remainder === 1) {
|
|
29
|
+
const a = data[mainLen];
|
|
30
|
+
result += `${CHARS[a >> 2]}${CHARS[(a & 3) << 4]}==`;
|
|
31
|
+
} else if (remainder === 2) {
|
|
32
|
+
const a = data[mainLen];
|
|
33
|
+
const b = data[mainLen + 1];
|
|
34
|
+
result += `${CHARS[a >> 2]}${CHARS[(a & 3) << 4 | b >> 4]}${CHARS[(b & 15) << 2]}=`;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
var DECODE_TABLE = new Uint8Array(128);
|
|
39
|
+
for (let i = 0; i < CHARS.length; i++) {
|
|
40
|
+
DECODE_TABLE[CHARS.charCodeAt(i)] = i;
|
|
41
|
+
}
|
|
42
|
+
function decodeBase64(base64) {
|
|
43
|
+
const str = base64.replace(/\s/g, "");
|
|
44
|
+
const len = str.length;
|
|
45
|
+
let padding = 0;
|
|
46
|
+
if (str[len - 1] === "=") padding++;
|
|
47
|
+
if (str[len - 2] === "=") padding++;
|
|
48
|
+
const byteLen = len * 3 / 4 - padding;
|
|
49
|
+
const result = new Uint8Array(byteLen);
|
|
50
|
+
let j = 0;
|
|
51
|
+
for (let i = 0; i < len; i += 4) {
|
|
52
|
+
const a = DECODE_TABLE[str.charCodeAt(i)];
|
|
53
|
+
const b = DECODE_TABLE[str.charCodeAt(i + 1)];
|
|
54
|
+
const c = DECODE_TABLE[str.charCodeAt(i + 2)];
|
|
55
|
+
const d = DECODE_TABLE[str.charCodeAt(i + 3)];
|
|
56
|
+
result[j++] = a << 2 | b >> 4;
|
|
57
|
+
if (j < byteLen) result[j++] = (b & 15) << 4 | c >> 2;
|
|
58
|
+
if (j < byteLen) result[j++] = (c & 3) << 6 | d;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/core/hash.ts
|
|
64
|
+
import xxhashInit from "xxhash-wasm";
|
|
65
|
+
async function sha256(data) {
|
|
66
|
+
if (typeof globalThis.crypto?.subtle !== "undefined") {
|
|
67
|
+
return globalThis.crypto.subtle.digest("SHA-256", data);
|
|
68
|
+
}
|
|
69
|
+
const { webcrypto } = await import("crypto");
|
|
70
|
+
return webcrypto.subtle.digest("SHA-256", data);
|
|
71
|
+
}
|
|
72
|
+
var xxhashInstance = null;
|
|
73
|
+
async function getXxhash() {
|
|
74
|
+
if (!xxhashInstance) {
|
|
75
|
+
xxhashInstance = await xxhashInit();
|
|
76
|
+
}
|
|
77
|
+
return xxhashInstance;
|
|
78
|
+
}
|
|
79
|
+
async function computeHash(content, algorithm) {
|
|
80
|
+
if (algorithm === "xxh64") {
|
|
81
|
+
const xxhash = await getXxhash();
|
|
82
|
+
return xxhash.h64ToString(content);
|
|
83
|
+
}
|
|
84
|
+
const encoder = new TextEncoder();
|
|
85
|
+
const data = encoder.encode(content);
|
|
86
|
+
const hashBuffer = await sha256(data);
|
|
87
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
88
|
+
return Array.from(hashArray).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
89
|
+
}
|
|
90
|
+
async function computeHashBytes(data, algorithm) {
|
|
91
|
+
if (algorithm === "xxh64") {
|
|
92
|
+
const xxhash = await getXxhash();
|
|
93
|
+
const raw = xxhash.h64Raw(data);
|
|
94
|
+
return raw.toString(16).padStart(16, "0");
|
|
95
|
+
}
|
|
96
|
+
const hashBuffer = await sha256(data);
|
|
97
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
98
|
+
return Array.from(hashArray).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/core/yaml.ts
|
|
102
|
+
import jsYaml from "js-yaml";
|
|
103
|
+
function dump(value) {
|
|
104
|
+
return jsYaml.dump(value, {
|
|
105
|
+
lineWidth: -1,
|
|
106
|
+
noRefs: true,
|
|
107
|
+
quotingType: '"',
|
|
108
|
+
forceQuotes: false
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function load(text) {
|
|
112
|
+
return jsYaml.load(text);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
FORMAT_VERSION,
|
|
117
|
+
MIN_BACKTICK_COUNT,
|
|
118
|
+
MAX_BACKTICK_COUNT,
|
|
119
|
+
HASH_PLACEHOLDER,
|
|
120
|
+
ARCHIVE_HEADER,
|
|
121
|
+
encodeBase64,
|
|
122
|
+
decodeBase64,
|
|
123
|
+
computeHash,
|
|
124
|
+
computeHashBytes,
|
|
125
|
+
dump,
|
|
126
|
+
load
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-UJZ43GZC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/constants.ts","../src/core/base64.ts","../src/core/hash.ts","../src/core/yaml.ts"],"sourcesContent":["export const FORMAT_VERSION = \"1.0.0\";\n\n/** Minimum backtick count for code fences */\nexport const MIN_BACKTICK_COUNT = 4;\n\n/** Maximum backtick count allowed */\nexport const MAX_BACKTICK_COUNT = 8;\n\n/** Placeholder value for hashes that haven't been computed yet */\nexport const HASH_PLACEHOLDER = \"HASH_PLACEHOLDER\";\n\n/** Self-describing header comment prepended to every archive */\nexport const ARCHIVE_HEADER = `<!-- MDMeld v1.0 archive — a directory tree encoded as markdown.\n Read the manifest below for file listing and positions.\n Spec: https://github.com/3leaps/mdmeld -->`;\n","const CHARS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/** Encode a Uint8Array to a base64 string. Pure JS, no Buffer. */\nexport function encodeBase64(data: Uint8Array): string {\n\tlet result = \"\";\n\tconst len = data.length;\n\tconst remainder = len % 3;\n\tconst mainLen = len - remainder;\n\n\tfor (let i = 0; i < mainLen; i += 3) {\n\t\tconst a = data[i] as number;\n\t\tconst b = data[i + 1] as number;\n\t\tconst c = data[i + 2] as number;\n\t\tresult += CHARS[a >> 2];\n\t\tresult += CHARS[((a & 3) << 4) | (b >> 4)];\n\t\tresult += CHARS[((b & 15) << 2) | (c >> 6)];\n\t\tresult += CHARS[c & 63];\n\t}\n\n\tif (remainder === 1) {\n\t\tconst a = data[mainLen] as number;\n\t\tresult += `${CHARS[a >> 2]}${CHARS[(a & 3) << 4]}==`;\n\t} else if (remainder === 2) {\n\t\tconst a = data[mainLen] as number;\n\t\tconst b = data[mainLen + 1] as number;\n\t\tresult += `${CHARS[a >> 2]}${CHARS[((a & 3) << 4) | (b >> 4)]}${CHARS[(b & 15) << 2]}=`;\n\t}\n\n\treturn result;\n}\n\n/** Build a reverse lookup table for decoding */\nconst DECODE_TABLE = new Uint8Array(128);\nfor (let i = 0; i < CHARS.length; i++) {\n\tDECODE_TABLE[CHARS.charCodeAt(i)] = i;\n}\n\n/** Decode a base64 string to a Uint8Array. Pure JS, no Buffer. */\nexport function decodeBase64(base64: string): Uint8Array {\n\t// Strip whitespace\n\tconst str = base64.replace(/\\s/g, \"\");\n\tconst len = str.length;\n\n\t// Count padding\n\tlet padding = 0;\n\tif (str[len - 1] === \"=\") padding++;\n\tif (str[len - 2] === \"=\") padding++;\n\n\tconst byteLen = (len * 3) / 4 - padding;\n\tconst result = new Uint8Array(byteLen);\n\n\tlet j = 0;\n\tfor (let i = 0; i < len; i += 4) {\n\t\tconst a = DECODE_TABLE[str.charCodeAt(i)] as number;\n\t\tconst b = DECODE_TABLE[str.charCodeAt(i + 1)] as number;\n\t\tconst c = DECODE_TABLE[str.charCodeAt(i + 2)] as number;\n\t\tconst d = DECODE_TABLE[str.charCodeAt(i + 3)] as number;\n\n\t\tresult[j++] = (a << 2) | (b >> 4);\n\t\tif (j < byteLen) result[j++] = ((b & 15) << 4) | (c >> 2);\n\t\tif (j < byteLen) result[j++] = ((c & 3) << 6) | d;\n\t}\n\n\treturn result;\n}\n","import xxhashInit from \"xxhash-wasm\";\nimport type { HashAlgorithm } from \"./types.js\";\n\n/**\n * SHA-256 digest via Web Crypto.\n * Node 19+ exposes globalThis.crypto; Node 18 requires explicit import.\n * In browsers, globalThis.crypto is always available.\n */\nasync function sha256(data: Uint8Array): Promise<ArrayBuffer> {\n\tif (typeof globalThis.crypto?.subtle !== \"undefined\") {\n\t\treturn globalThis.crypto.subtle.digest(\"SHA-256\", data);\n\t}\n\t// Node 18 fallback\n\tconst { webcrypto } = await import(\"node:crypto\");\n\treturn (webcrypto as typeof globalThis.crypto).subtle.digest(\"SHA-256\", data);\n}\n\nlet xxhashInstance: Awaited<ReturnType<typeof xxhashInit>> | null = null;\n\nasync function getXxhash() {\n\tif (!xxhashInstance) {\n\t\txxhashInstance = await xxhashInit();\n\t}\n\treturn xxhashInstance;\n}\n\n/** Compute a hash of the given string using the specified algorithm. */\nexport async function computeHash(content: string, algorithm: HashAlgorithm): Promise<string> {\n\tif (algorithm === \"xxh64\") {\n\t\tconst xxhash = await getXxhash();\n\t\treturn xxhash.h64ToString(content);\n\t}\n\n\t// sha256 via Web Crypto (works in browser + Node 18+)\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(content);\n\tconst hashBuffer = await sha256(data);\n\tconst hashArray = new Uint8Array(hashBuffer);\n\treturn Array.from(hashArray)\n\t\t.map((b) => b.toString(16).padStart(2, \"0\"))\n\t\t.join(\"\");\n}\n\n/** Compute a hash of raw bytes. */\nexport async function computeHashBytes(\n\tdata: Uint8Array,\n\talgorithm: HashAlgorithm,\n): Promise<string> {\n\tif (algorithm === \"xxh64\") {\n\t\tconst xxhash = await getXxhash();\n\t\tconst raw = xxhash.h64Raw(data);\n\t\treturn raw.toString(16).padStart(16, \"0\");\n\t}\n\n\tconst hashBuffer = await sha256(data);\n\tconst hashArray = new Uint8Array(hashBuffer);\n\treturn Array.from(hashArray)\n\t\t.map((b) => b.toString(16).padStart(2, \"0\"))\n\t\t.join(\"\");\n}\n","import jsYaml from \"js-yaml\";\n\n/** Serialize a value to YAML string. */\nexport function dump(value: unknown): string {\n\treturn jsYaml.dump(value, {\n\t\tlineWidth: -1,\n\t\tnoRefs: true,\n\t\tquotingType: '\"',\n\t\tforceQuotes: false,\n\t});\n}\n\n/** Parse a YAML string. */\nexport function load(text: string): unknown {\n\treturn jsYaml.load(text);\n}\n"],"mappings":";;;AAAO,IAAM,iBAAiB;AAGvB,IAAM,qBAAqB;AAG3B,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AAGzB,IAAM,iBAAiB;AAAA;AAAA;;;ACZ9B,IAAM,QAAQ;AAGP,SAAS,aAAa,MAA0B;AACtD,MAAI,SAAS;AACb,QAAM,MAAM,KAAK;AACjB,QAAM,YAAY,MAAM;AACxB,QAAM,UAAU,MAAM;AAEtB,WAAS,IAAI,GAAG,IAAI,SAAS,KAAK,GAAG;AACpC,UAAM,IAAI,KAAK,CAAC;AAChB,UAAM,IAAI,KAAK,IAAI,CAAC;AACpB,UAAM,IAAI,KAAK,IAAI,CAAC;AACpB,cAAU,MAAM,KAAK,CAAC;AACtB,cAAU,OAAQ,IAAI,MAAM,IAAM,KAAK,CAA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SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AACV;;;AC3DA,OAAO,YAAY;AAGZ,SAAS,KAAK,OAAwB;AAC5C,SAAO,OAAO,KAAK,OAAO;AAAA,IACzB,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,aAAa;AAAA,EACd,CAAC;AACF;AAGO,SAAS,KAAK,MAAuB;AAC3C,SAAO,OAAO,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { parseArgs } from "util";
|
|
5
|
+
var USAGE = `mdmeld \u2014 pack directory trees into markdown archives
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
mdmeld pack <dir> [-o <file>] [--hash xxh64|sha256]
|
|
9
|
+
mdmeld unpack <file> [-o <dir>]
|
|
10
|
+
mdmeld finalize <file>
|
|
11
|
+
mdmeld --help
|
|
12
|
+
|
|
13
|
+
Commands:
|
|
14
|
+
pack Pack a directory into an .mdmeld archive
|
|
15
|
+
unpack Unpack an .mdmeld archive to a directory
|
|
16
|
+
finalize Compute real hashes for HASH_PLACEHOLDER values
|
|
17
|
+
`;
|
|
18
|
+
async function main() {
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
const command = args[0];
|
|
21
|
+
if (!command || command === "--help" || command === "-h") {
|
|
22
|
+
console.log(USAGE);
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
const rest = args.slice(1);
|
|
26
|
+
switch (command) {
|
|
27
|
+
case "pack": {
|
|
28
|
+
const { values, positionals } = parseArgs({
|
|
29
|
+
args: rest,
|
|
30
|
+
options: {
|
|
31
|
+
output: { type: "string", short: "o" },
|
|
32
|
+
hash: { type: "string" }
|
|
33
|
+
},
|
|
34
|
+
allowPositionals: true
|
|
35
|
+
});
|
|
36
|
+
const dir = positionals[0];
|
|
37
|
+
if (!dir) {
|
|
38
|
+
console.error("Usage: mdmeld pack <dir> [-o <file>]");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
const { runPack } = await import("../pack-ODWNG5OH.js");
|
|
42
|
+
await runPack({
|
|
43
|
+
dir,
|
|
44
|
+
output: values.output,
|
|
45
|
+
hash: values.hash
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "unpack": {
|
|
50
|
+
const { values, positionals } = parseArgs({
|
|
51
|
+
args: rest,
|
|
52
|
+
options: {
|
|
53
|
+
output: { type: "string", short: "o" }
|
|
54
|
+
},
|
|
55
|
+
allowPositionals: true
|
|
56
|
+
});
|
|
57
|
+
const file = positionals[0];
|
|
58
|
+
if (!file) {
|
|
59
|
+
console.error("Usage: mdmeld unpack <file> [-o <dir>]");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const { runUnpack } = await import("../unpack-2BBZMGLH.js");
|
|
63
|
+
await runUnpack({ file, output: values.output });
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "finalize": {
|
|
67
|
+
const { positionals } = parseArgs({
|
|
68
|
+
args: rest,
|
|
69
|
+
allowPositionals: true
|
|
70
|
+
});
|
|
71
|
+
const file = positionals[0];
|
|
72
|
+
if (!file) {
|
|
73
|
+
console.error("Usage: mdmeld finalize <file>");
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
const { runFinalize } = await import("../finalize-NGDCBCTD.js");
|
|
77
|
+
await runFinalize({ file });
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
default:
|
|
81
|
+
console.error(`Unknown command: ${command}`);
|
|
82
|
+
console.log(USAGE);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
main().catch((err) => {
|
|
87
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["import { parseArgs } from \"node:util\";\n\nconst USAGE = `mdmeld — pack directory trees into markdown archives\n\nUsage:\n mdmeld pack <dir> [-o <file>] [--hash xxh64|sha256]\n mdmeld unpack <file> [-o <dir>]\n mdmeld finalize <file>\n mdmeld --help\n\nCommands:\n pack Pack a directory into an .mdmeld archive\n unpack Unpack an .mdmeld archive to a directory\n finalize Compute real hashes for HASH_PLACEHOLDER values\n`;\n\nasync function main() {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\n\tif (!command || command === \"--help\" || command === \"-h\") {\n\t\tconsole.log(USAGE);\n\t\tprocess.exit(0);\n\t}\n\n\tconst rest = args.slice(1);\n\n\tswitch (command) {\n\t\tcase \"pack\": {\n\t\t\tconst { values, positionals } = parseArgs({\n\t\t\t\targs: rest,\n\t\t\t\toptions: {\n\t\t\t\t\toutput: { type: \"string\", short: \"o\" },\n\t\t\t\t\thash: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\tallowPositionals: true,\n\t\t\t});\n\n\t\t\tconst dir = positionals[0];\n\t\t\tif (!dir) {\n\t\t\t\tconsole.error(\"Usage: mdmeld pack <dir> [-o <file>]\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconst { runPack } = await import(\"./commands/pack.js\");\n\t\t\tawait runPack({\n\t\t\t\tdir,\n\t\t\t\toutput: values.output,\n\t\t\t\thash: values.hash as \"xxh64\" | \"sha256\" | undefined,\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"unpack\": {\n\t\t\tconst { values, positionals } = parseArgs({\n\t\t\t\targs: rest,\n\t\t\t\toptions: {\n\t\t\t\t\toutput: { type: \"string\", short: \"o\" },\n\t\t\t\t},\n\t\t\t\tallowPositionals: true,\n\t\t\t});\n\n\t\t\tconst file = positionals[0];\n\t\t\tif (!file) {\n\t\t\t\tconsole.error(\"Usage: mdmeld unpack <file> [-o <dir>]\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconst { runUnpack } = await import(\"./commands/unpack.js\");\n\t\t\tawait runUnpack({ file, output: values.output });\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"finalize\": {\n\t\t\tconst { positionals } = parseArgs({\n\t\t\t\targs: rest,\n\t\t\t\tallowPositionals: true,\n\t\t\t});\n\n\t\t\tconst file = positionals[0];\n\t\t\tif (!file) {\n\t\t\t\tconsole.error(\"Usage: mdmeld finalize <file>\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconst { runFinalize } = await import(\"./commands/finalize.js\");\n\t\t\tawait runFinalize({ file });\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\tconsole.log(USAGE);\n\t\t\tprocess.exit(1);\n\t}\n}\n\nmain().catch((err) => {\n\tconsole.error(err instanceof Error ? err.message : String(err));\n\tprocess.exit(1);\n});\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAE1B,IAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcd,eAAe,OAAO;AACrB,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,UAAU,KAAK,CAAC;AAEtB,MAAI,CAAC,WAAW,YAAY,YAAY,YAAY,MAAM;AACzD,YAAQ,IAAI,KAAK;AACjB,YAAQ,KAAK,CAAC;AAAA,EACf;AAEA,QAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,UAAQ,SAAS;AAAA,IAChB,KAAK,QAAQ;AACZ,YAAM,EAAE,QAAQ,YAAY,IAAI,UAAU;AAAA,QACzC,MAAM;AAAA,QACN,SAAS;AAAA,UACR,QAAQ,EAAE,MAAM,UAAU,OAAO,IAAI;AAAA,UACrC,MAAM,EAAE,MAAM,SAAS;AAAA,Q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