@wairon/sdk 5.1.1-dev.7 → 5.1.1-dev.9

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/dist/index.d.ts CHANGED
@@ -143,6 +143,82 @@ interface PackExtractionPlan {
143
143
  /** Sum of approved entries' inflated sizes. */
144
144
  totalUncompressedBytes: number;
145
145
  }
146
+ /**
147
+ * The `.waitree` envelope, serialized as `wairon-tree.yaml` at the archive root
148
+ * — the portable, versioned identity + integrity header wrapping one project's
149
+ * spec tree (its `.wai/` plus the `.wai/` of every chained subproject).
150
+ */
151
+ interface TreeArchiveManifest {
152
+ /** Tree-archive format version (currently 1); a newer major is rejected, not silently mis-read. */
153
+ formatVersion: number;
154
+ /** The exporting project's name. */
155
+ projectName: string;
156
+ /** Project-relative directory of every packed root, in packing order ('.' first). */
157
+ roots: string[];
158
+ /** The exporting tree's content state at export time — provenance, never an import gate. */
159
+ stateId?: string;
160
+ /** The wairon version that produced the archive. */
161
+ waironVersion?: string;
162
+ /** Minimum compatible wairon version (semver range). */
163
+ minWaironVersion?: string;
164
+ /** Whether regenerable artifacts (generated/, docs/) were packed too. */
165
+ includesDerived?: boolean;
166
+ /** Optional integrity digest over the manifest. */
167
+ digest?: string;
168
+ /** Optional per-entry integrity map: archive path -> sha256. */
169
+ entryDigests?: Record<string, string>;
170
+ /** Producer stamp, e.g. "@wairon/sdk@X.Y.Z". */
171
+ generatedBy?: string;
172
+ /** ISO-8601 export timestamp. */
173
+ generatedAt?: string;
174
+ }
175
+ /**
176
+ * One spec-tree root to pack: where it sits relative to the project root, and
177
+ * the absolute directory holding its `.wai/`. The caller (which knows how to
178
+ * walk chained subprojects) resolves these — the SDK never walks a spec tree,
179
+ * it only archives the roots it is handed.
180
+ */
181
+ interface TreeRootSource {
182
+ /** Project-relative directory: '.' for the top project, e.g. 'packages/foo'. */
183
+ relativePath: string;
184
+ /** Absolute path of this root's .wai/ directory. */
185
+ waiDir: string;
186
+ }
187
+ /** What a `.waitree` declares about itself, read WITHOUT extracting anything. */
188
+ interface TreeArchiveInfo {
189
+ manifest: TreeArchiveManifest;
190
+ /** Number of regular file entries in the archive. */
191
+ entryCount: number;
192
+ totalUncompressedBytes: number;
193
+ /** Whether formatVersion + minWaironVersion are compatible with the running wairon. */
194
+ compatible: boolean;
195
+ }
196
+ /** The output of packing a spec tree: bytes, sealed envelope, suggested name. */
197
+ interface TreeBuildResult {
198
+ /** The assembled .waitree (ZIP) bytes. */
199
+ archive: Uint8Array;
200
+ /** The sealed envelope written into the archive. */
201
+ manifest: TreeArchiveManifest;
202
+ /** e.g. "waffle-airon.waitree". */
203
+ suggestedFileName: string;
204
+ /** How many spec-tree files were packed. */
205
+ fileCount: number;
206
+ }
207
+ /**
208
+ * Where an extracted spec tree landed and what it contained. Purely the archive
209
+ * layer's account — what to do about a pre-existing tree (refuse, back up,
210
+ * replace) is the importing caller's policy, not the codec's.
211
+ */
212
+ interface TreeExtractionResult {
213
+ /** Absolute path the tree was written under. */
214
+ destDir: string;
215
+ /** The archive's parsed envelope. */
216
+ manifest: TreeArchiveManifest;
217
+ /** Project-relative roots recreated under destDir. */
218
+ roots: string[];
219
+ /** Archive-relative paths written. */
220
+ writtenPaths: string[];
221
+ }
146
222
 
147
223
  /** Severity of a finding a pack rule emits. */
148
224
  type RuleSeverity = 'error' | 'warning';
@@ -215,5 +291,11 @@ declare function buildPack(sourceDir: string): PackBuildResult;
215
291
  declare function inspectArchive(archive: Uint8Array): PackArchiveInfo;
216
292
  /** Safely extract a .wpack archive into a destination directory under enforced limits. */
217
293
  declare function extractPack(archive: Uint8Array, destDir: string, limits?: PackExtractionLimits): PackExtractionResult;
294
+ /** Pack a project's spec tree — the supplied roots' .wai directories — into a .waitree archive. */
295
+ declare function buildTreeArchive(roots: TreeRootSource[], projectName: string, stateId?: string, includeDerived?: boolean): TreeBuildResult;
296
+ /** Inspect a .waitree archive without extracting it. */
297
+ declare function inspectTreeArchive(archive: Uint8Array): TreeArchiveInfo;
298
+ /** Safely extract a .waitree archive into a destination project root under enforced limits. */
299
+ declare function extractTreeArchive(archive: Uint8Array, destDir: string, limits?: PackExtractionLimits, refuseExecutableEntries?: boolean): TreeExtractionResult;
218
300
 
219
- export { type ArchiveEntryMeta, type Finding, type PackArchiveInfo, type PackArchiveManifest, type PackBuildResult, type PackExtractionLimits, type PackExtractionPlan, type PackExtractionResult, type PackFile, type PackScaffoldRequest, type RuleContext, type RuleSeverity, type RuleSpecNode, type SddRule, buildPack, defineRule, extractPack, inspectArchive, scaffoldPack };
301
+ export { type ArchiveEntryMeta, type Finding, type PackArchiveInfo, type PackArchiveManifest, type PackBuildResult, type PackExtractionLimits, type PackExtractionPlan, type PackExtractionResult, type PackFile, type PackScaffoldRequest, type RuleContext, type RuleSeverity, type RuleSpecNode, type SddRule, type TreeArchiveInfo, type TreeArchiveManifest, type TreeBuildResult, type TreeExtractionResult, type TreeRootSource, buildPack, buildTreeArchive, defineRule, extractPack, extractTreeArchive, inspectArchive, inspectTreeArchive, scaffoldPack };
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@wairon/sdk",
38
- version: "5.1.1-dev.7",
38
+ version: "5.1.1-dev.9",
39
39
  description: "Wairon pack-archive (.wpack) format authority and authoring toolkit \u2014 scaffold, build, inspect, and safely extract wairon extension packs.",
40
40
  keywords: [
41
41
  "wairon",
@@ -89,16 +89,19 @@ var require_package = __commonJS({
89
89
  var src_exports = {};
90
90
  __export(src_exports, {
91
91
  buildPack: () => buildPack2,
92
+ buildTreeArchive: () => buildTreeArchive2,
92
93
  defineRule: () => defineRule,
93
94
  extractPack: () => extractPack2,
95
+ extractTreeArchive: () => extractTreeArchive2,
94
96
  inspectArchive: () => inspectArchive2,
97
+ inspectTreeArchive: () => inspectTreeArchive2,
95
98
  scaffoldPack: () => scaffoldPack2
96
99
  });
97
100
  module.exports = __toCommonJS(src_exports);
98
101
 
99
102
  // src/orchestrator.ts
100
103
  var path2 = __toESM(require("path"));
101
- var import_js_yaml2 = require("js-yaml");
104
+ var import_js_yaml3 = require("js-yaml");
102
105
 
103
106
  // src/codec.ts
104
107
  var import_js_yaml = require("js-yaml");
@@ -278,6 +281,210 @@ function parseSemverCore(v) {
278
281
  return [parts[0] || 0, parts[1] || 0, parts[2] || 0];
279
282
  }
280
283
 
284
+ // src/treecodec.ts
285
+ var import_js_yaml2 = require("js-yaml");
286
+ var import_crypto2 = require("crypto");
287
+ var TREE_ENVELOPE_FILENAME = "wairon-tree.yaml";
288
+ var SUPPORTED_FORMAT_VERSION2 = 1;
289
+ var TREE_DEFAULTS = {
290
+ maxEntries: 2e4,
291
+ maxTotalUncompressedBytes: 64 * 1024 * 1024,
292
+ maxEntryBytes: 8 * 1024 * 1024,
293
+ maxCompressionRatio: 100,
294
+ maxDepth: 24
295
+ };
296
+ var DERIVED_ROOTS = ["generated", "docs"];
297
+ var EXECUTABLE_EXT_RE = /\.(c|m)?js$/i;
298
+ var WAI_SEGMENT = ".wai";
299
+ function parseTreeManifest(text) {
300
+ const raw = (0, import_js_yaml2.load)(text);
301
+ const manifest = validateEnvelope2(raw);
302
+ if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION2) {
303
+ throw new Error("unsupported tree-archive formatVersion (newer than this wairon understands)");
304
+ }
305
+ return manifest;
306
+ }
307
+ function serializeTreeManifest(manifest) {
308
+ const clean = {
309
+ formatVersion: manifest.formatVersion,
310
+ projectName: manifest.projectName,
311
+ roots: manifest.roots
312
+ };
313
+ if (manifest.stateId !== void 0) clean.stateId = manifest.stateId;
314
+ if (manifest.waironVersion !== void 0) clean.waironVersion = manifest.waironVersion;
315
+ if (manifest.minWaironVersion !== void 0) clean.minWaironVersion = manifest.minWaironVersion;
316
+ if (manifest.includesDerived !== void 0) clean.includesDerived = manifest.includesDerived;
317
+ if (manifest.digest !== void 0) clean.digest = manifest.digest;
318
+ if (manifest.entryDigests !== void 0) clean.entryDigests = manifest.entryDigests;
319
+ if (manifest.generatedBy !== void 0) clean.generatedBy = manifest.generatedBy;
320
+ if (manifest.generatedAt !== void 0) clean.generatedAt = manifest.generatedAt;
321
+ return (0, import_js_yaml2.dump)(clean, { sortKeys: false });
322
+ }
323
+ function defaultTreeLimits() {
324
+ return { ...TREE_DEFAULTS };
325
+ }
326
+ function selectTreeFiles(files, includeDerived) {
327
+ if (includeDerived) {
328
+ return files;
329
+ }
330
+ const kept = files.filter((file) => !isDerivedPath(file.path));
331
+ return kept;
332
+ }
333
+ function planTreeExtraction(entries, limits) {
334
+ const caps = {
335
+ maxEntries: limits.maxEntries ?? TREE_DEFAULTS.maxEntries,
336
+ maxTotalUncompressedBytes: limits.maxTotalUncompressedBytes ?? TREE_DEFAULTS.maxTotalUncompressedBytes,
337
+ maxEntryBytes: limits.maxEntryBytes ?? TREE_DEFAULTS.maxEntryBytes,
338
+ maxCompressionRatio: limits.maxCompressionRatio ?? TREE_DEFAULTS.maxCompressionRatio,
339
+ maxDepth: limits.maxDepth ?? TREE_DEFAULTS.maxDepth
340
+ };
341
+ const approved = [];
342
+ let total = 0;
343
+ for (const entry of entries) {
344
+ if (isSymlinkOrNonRegular2(entry.kind) || isStructurallyUnsafePath2(entry.path)) {
345
+ rejectUnsafe2();
346
+ }
347
+ if (entry.kind === "dir") continue;
348
+ const normalized = normalizeRelPath2(entry.path);
349
+ if (escapesDestination2(normalized) || pathDepth2(normalized) > caps.maxDepth) {
350
+ rejectUnsafe2();
351
+ }
352
+ if (entry.uncompressedSize > caps.maxEntryBytes || compressionRatio2(entry) > caps.maxCompressionRatio) {
353
+ rejectUnsafe2();
354
+ }
355
+ approved.push(normalized);
356
+ total += entry.uncompressedSize;
357
+ }
358
+ if (approved.length > caps.maxEntries || total > caps.maxTotalUncompressedBytes) {
359
+ rejectUnsafe2();
360
+ }
361
+ return { paths: approved, totalUncompressedBytes: total };
362
+ }
363
+ function assertPortableTreePaths(paths) {
364
+ for (const entryPath of paths) {
365
+ if (EXECUTABLE_EXT_RE.test(entryPath)) {
366
+ throw new Error(
367
+ "refused: the archive carries executable content. Only declarative spec state transfers over this surface; rule/code packs are executable and install via the trusted filesystem (mount into WAIRON_PACKS_DIR, or run `wairon packs add`)."
368
+ );
369
+ }
370
+ if (entryPath !== TREE_ENVELOPE_FILENAME && !isUnderWaiRoot(entryPath)) {
371
+ throw new Error(`refused: the archive carries an entry outside any spec-tree root ("${entryPath}")`);
372
+ }
373
+ }
374
+ }
375
+ function verifyTreeIntegrity(manifest, files) {
376
+ if (!manifest.entryDigests) {
377
+ return false;
378
+ }
379
+ const digests = manifest.entryDigests;
380
+ for (const file of files) {
381
+ if (file.path === TREE_ENVELOPE_FILENAME) continue;
382
+ if (sha2562(file.contents) !== digests[file.path]) {
383
+ throw new Error("tree integrity digest mismatch");
384
+ }
385
+ }
386
+ return true;
387
+ }
388
+ function sealTreeIntegrity(manifest, files, generatedBy, generatedAt) {
389
+ const entryDigests = {};
390
+ for (const file of files) {
391
+ if (file.path === TREE_ENVELOPE_FILENAME) continue;
392
+ entryDigests[file.path] = sha2562(file.contents);
393
+ }
394
+ const digest = sha2562(canonicalDigestBytes2(entryDigests));
395
+ return { ...manifest, entryDigests, digest, generatedBy, generatedAt };
396
+ }
397
+ function checkTreeCompatibility(manifest, waironVersion) {
398
+ if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION2) {
399
+ return false;
400
+ }
401
+ if (manifest.minWaironVersion && isBelow2(waironVersion, manifest.minWaironVersion)) {
402
+ return false;
403
+ }
404
+ return true;
405
+ }
406
+ function rejectUnsafe2() {
407
+ throw new Error("reject: unsafe or oversized tree-archive entry (zip-slip / size / ratio / depth guard)");
408
+ }
409
+ function validateEnvelope2(raw) {
410
+ if (!raw || typeof raw !== "object") {
411
+ throw new Error("malformed tree envelope (not a YAML mapping)");
412
+ }
413
+ const o = raw;
414
+ if (typeof o.formatVersion !== "number") throw new Error("tree envelope: formatVersion must be a number");
415
+ if (typeof o.projectName !== "string" || !o.projectName) throw new Error("tree envelope: projectName is required");
416
+ if (!Array.isArray(o.roots) || o.roots.length === 0 || o.roots.some((r) => typeof r !== "string" || !r)) {
417
+ throw new Error("tree envelope: roots must be a non-empty list of project-relative directories");
418
+ }
419
+ const manifest = {
420
+ formatVersion: o.formatVersion,
421
+ projectName: o.projectName,
422
+ roots: o.roots
423
+ };
424
+ if (typeof o.stateId === "string") manifest.stateId = o.stateId;
425
+ if (typeof o.waironVersion === "string") manifest.waironVersion = o.waironVersion;
426
+ if (typeof o.minWaironVersion === "string") manifest.minWaironVersion = o.minWaironVersion;
427
+ if (typeof o.includesDerived === "boolean") manifest.includesDerived = o.includesDerived;
428
+ if (typeof o.digest === "string") manifest.digest = o.digest;
429
+ if (o.entryDigests && typeof o.entryDigests === "object") {
430
+ manifest.entryDigests = o.entryDigests;
431
+ }
432
+ if (typeof o.generatedBy === "string") manifest.generatedBy = o.generatedBy;
433
+ if (typeof o.generatedAt === "string") manifest.generatedAt = o.generatedAt;
434
+ return manifest;
435
+ }
436
+ function isDerivedPath(relPath) {
437
+ const first = relPath.split("/")[0];
438
+ return DERIVED_ROOTS.includes(first);
439
+ }
440
+ function isUnderWaiRoot(archivePath) {
441
+ const segments = archivePath.split("/");
442
+ const at = segments.indexOf(WAI_SEGMENT);
443
+ return at >= 0 && at < segments.length - 1;
444
+ }
445
+ function isSymlinkOrNonRegular2(kind) {
446
+ return kind !== "file" && kind !== "dir";
447
+ }
448
+ function isStructurallyUnsafePath2(p) {
449
+ if (p.includes("\\")) return true;
450
+ if (/^[A-Za-z]:/.test(p)) return true;
451
+ if (p.startsWith("/")) return true;
452
+ return p.split("/").some((seg) => seg === "..");
453
+ }
454
+ function normalizeRelPath2(p) {
455
+ return p.split("/").filter((seg) => seg !== "" && seg !== ".").join("/");
456
+ }
457
+ function escapesDestination2(normalized) {
458
+ return normalized.startsWith("/") || normalized.split("/").some((seg) => seg === "..");
459
+ }
460
+ function pathDepth2(normalized) {
461
+ return normalized.split("/").filter((seg) => seg !== "").length;
462
+ }
463
+ function compressionRatio2(entry) {
464
+ if (entry.compressedSize > 0) return entry.uncompressedSize / entry.compressedSize;
465
+ return entry.uncompressedSize > 0 ? Infinity : 0;
466
+ }
467
+ function canonicalDigestBytes2(entryDigests) {
468
+ const lines = Object.keys(entryDigests).sort().map((key) => `${key}:${entryDigests[key]}`).join("\n");
469
+ return new TextEncoder().encode(lines);
470
+ }
471
+ function sha2562(data) {
472
+ return (0, import_crypto2.createHash)("sha256").update(data).digest("hex");
473
+ }
474
+ function isBelow2(running, minimum) {
475
+ const [rMaj, rMin, rPat] = parseSemverCore2(running);
476
+ const [mMaj, mMin, mPat] = parseSemverCore2(minimum);
477
+ if (rMaj !== mMaj) return rMaj < mMaj;
478
+ if (rMin !== mMin) return rMin < mMin;
479
+ return rPat < mPat;
480
+ }
481
+ function parseSemverCore2(v) {
482
+ const cleaned = v.trim().replace(/^[^0-9]*/, "");
483
+ const core = cleaned.split(/[-+]/)[0];
484
+ const parts = core.split(".").map((n) => parseInt(n, 10));
485
+ return [parts[0] || 0, parts[1] || 0, parts[2] || 0];
486
+ }
487
+
281
488
  // src/version.ts
282
489
  var SDK_VERSION = loadVersion();
283
490
  function loadVersion() {
@@ -644,11 +851,99 @@ function extractPack(archiveBytes, destDir, limits) {
644
851
  };
645
852
  return result;
646
853
  }
854
+ function buildTreeArchive(roots, projectName, stateId, includeDerived) {
855
+ const files = [];
856
+ const packedRoots = [];
857
+ for (const root of roots) {
858
+ const rootFiles = readPackDir(root.waiDir);
859
+ const portable = selectTreeFiles(rootFiles, includeDerived === true);
860
+ const prefix = treeRootPrefix(root.relativePath);
861
+ for (const file of portable) files.push({ path: `${prefix}${file.path}`, contents: file.contents });
862
+ packedRoots.push(normalizeRootPath(root.relativePath));
863
+ }
864
+ if (files.length === 0) {
865
+ throw new Error("tree export found no spec-tree files under the supplied roots");
866
+ }
867
+ const manifest = {
868
+ formatVersion: 1,
869
+ projectName,
870
+ roots: packedRoots,
871
+ waironVersion: SDK_VERSION,
872
+ includesDerived: includeDerived === true
873
+ };
874
+ if (stateId !== void 0) manifest.stateId = stateId;
875
+ const sealed = sealTreeIntegrity(
876
+ manifest,
877
+ files,
878
+ `@wairon/sdk@${SDK_VERSION}`,
879
+ (/* @__PURE__ */ new Date()).toISOString()
880
+ );
881
+ const sealedText = serializeTreeManifest(sealed);
882
+ const finalFiles = [
883
+ ...files.filter((file) => file.path !== TREE_ENVELOPE_FILENAME),
884
+ { path: TREE_ENVELOPE_FILENAME, contents: encode(sealedText) }
885
+ ];
886
+ const archiveBytes = assembleArchive(finalFiles);
887
+ const suggestedFileName = `${slugify(projectName)}.waitree`;
888
+ return { archive: archiveBytes, manifest: sealed, suggestedFileName, fileCount: files.length };
889
+ }
890
+ function inspectTreeArchive(archiveBytes) {
891
+ const entries = listEntries(archiveBytes);
892
+ if (!entries.some((entry) => entry.path === TREE_ENVELOPE_FILENAME)) {
893
+ throw new Error("not a .waitree archive (missing wairon-tree.yaml envelope)");
894
+ }
895
+ const envelopeBytes = inflateEntry(archiveBytes, TREE_ENVELOPE_FILENAME);
896
+ const manifest = parseTreeManifest(decode(envelopeBytes));
897
+ const compatible = checkTreeCompatibility(manifest, SDK_VERSION);
898
+ const fileEntries = entries.filter((entry) => entry.kind === "file");
899
+ const totalUncompressedBytes = entries.reduce((sum, entry) => sum + entry.uncompressedSize, 0);
900
+ return { manifest, entryCount: fileEntries.length, totalUncompressedBytes, compatible };
901
+ }
902
+ function extractTreeArchive(archiveBytes, destDir, limits, refuseExecutableEntries) {
903
+ const effectiveLimits = limits === void 0 ? defaultTreeLimits() : limits;
904
+ const entries = listEntries(archiveBytes);
905
+ const plan = planTreeExtraction(entries, effectiveLimits);
906
+ if (refuseExecutableEntries === true) {
907
+ assertPortableTreePaths(plan.paths);
908
+ }
909
+ const files = [];
910
+ for (const approvedPath of plan.paths) {
911
+ const contents = inflateEntry(archiveBytes, approvedPath);
912
+ files.push({ path: approvedPath, contents });
913
+ }
914
+ const envelope = files.find((file) => file.path === TREE_ENVELOPE_FILENAME);
915
+ if (!envelope) {
916
+ throw new Error("not a .waitree archive (missing wairon-tree.yaml envelope)");
917
+ }
918
+ const manifest = parseTreeManifest(decode(envelope.contents));
919
+ verifyTreeIntegrity(manifest, files);
920
+ const directory = path2.resolve(destDir);
921
+ writeTree(directory, files);
922
+ const result = {
923
+ destDir: directory,
924
+ manifest,
925
+ roots: manifest.roots,
926
+ writtenPaths: files.map((file) => file.path)
927
+ };
928
+ return result;
929
+ }
930
+ function treeRootPrefix(relativePath) {
931
+ const normalized = normalizeRootPath(relativePath);
932
+ return normalized === "." ? ".wai/" : `${normalized}/.wai/`;
933
+ }
934
+ function normalizeRootPath(relativePath) {
935
+ const posix = relativePath.split(path2.sep).join("/").replace(/^\.\//, "").replace(/\/+$/, "");
936
+ return posix === "" || posix === "." ? "." : posix;
937
+ }
938
+ function slugify(projectName) {
939
+ const slug2 = projectName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
940
+ return slug2 || "spec-tree";
941
+ }
647
942
  function readInnerIdentity(files, manifest) {
648
943
  const innerPath = manifest.kind === "code" ? "package.json" : manifest.entry;
649
944
  const inner = files.find((file) => file.path === innerPath);
650
945
  if (!inner) throw new Error(`pack build: inner pack manifest "${innerPath}" is missing`);
651
- const parsed = manifest.kind === "code" ? JSON.parse(decode(inner.contents)) : (0, import_js_yaml2.load)(decode(inner.contents));
946
+ const parsed = manifest.kind === "code" ? JSON.parse(decode(inner.contents)) : (0, import_js_yaml3.load)(decode(inner.contents));
652
947
  const name = parsed?.name;
653
948
  const version = parsed?.version;
654
949
  if (typeof name !== "string" || typeof version !== "string") {
@@ -694,12 +989,24 @@ function inspectArchive2(archive) {
694
989
  function extractPack2(archive, destDir, limits) {
695
990
  return extractPack(archive, destDir, limits);
696
991
  }
992
+ function buildTreeArchive2(roots, projectName, stateId, includeDerived) {
993
+ return buildTreeArchive(roots, projectName, stateId, includeDerived);
994
+ }
995
+ function inspectTreeArchive2(archive) {
996
+ return inspectTreeArchive(archive);
997
+ }
998
+ function extractTreeArchive2(archive, destDir, limits, refuseExecutableEntries) {
999
+ return extractTreeArchive(archive, destDir, limits, refuseExecutableEntries);
1000
+ }
697
1001
  // Annotate the CommonJS export names for ESM import in node:
698
1002
  0 && (module.exports = {
699
1003
  buildPack,
1004
+ buildTreeArchive,
700
1005
  defineRule,
701
1006
  extractPack,
1007
+ extractTreeArchive,
702
1008
  inspectArchive,
1009
+ inspectTreeArchive,
703
1010
  scaffoldPack
704
1011
  });
705
1012
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/index.ts","../src/orchestrator.ts","../src/codec.ts","../src/version.ts","../src/scaffold.ts","../src/archive.ts","../src/authoring.ts"],"sourcesContent":["{\n \"name\": \"@wairon/sdk\",\n \"version\": \"5.1.1-dev.7\",\n \"description\": \"Wairon pack-archive (.wpack) format authority and authoring toolkit — scaffold, build, inspect, and safely extract wairon extension packs.\",\n \"keywords\": [\n \"wairon\",\n \"sdd\",\n \"pack\",\n \"wpack\",\n \"archive\",\n \"developer-tools\"\n ],\n \"author\": \"SYW\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/SYW-Apps/Waffle-AIron\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/SYW-Apps/Waffle-AIron.git\"\n },\n \"type\": \"commonjs\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"clean\": \"rimraf dist\"\n },\n \"dependencies\": {\n \"fflate\": \"^0.8.2\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^20.14.0\",\n \"rimraf\": \"^5.0.7\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.2\",\n \"vitest\": \"^4.1.9\"\n }\n}\n","import * as orchestrator from './orchestrator.js';\nimport type {\n PackArchiveInfo,\n PackBuildResult,\n PackExtractionLimits,\n PackExtractionResult,\n PackScaffoldRequest,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// SDK Portal (sdk_portal_impl) — the @wairon/sdk package entry. Each capability\n// is a 1:1 forward to the SDK orchestrator with no logic of its own; the module\n// also re-exports the pure pack-authoring value objects and the rule-authoring\n// contract (compile-time types + the defineRule helper).\n// ---------------------------------------------------------------------------\n\n/** Scaffold a new pack project (declarative or code) into a directory; returns the created file paths. */\nexport function scaffoldPack(request: PackScaffoldRequest): string[] {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.scaffoldPack(request);\n}\n\n/** Build an installable .wpack archive from a pack directory. */\nexport function buildPack(sourceDir: string): PackBuildResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.buildPack(sourceDir);\n}\n\n/** Inspect + verify a .wpack archive without extracting it. */\nexport function inspectArchive(archive: Uint8Array): PackArchiveInfo {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.inspectArchive(archive);\n}\n\n/** Safely extract a .wpack archive into a destination directory under enforced limits. */\nexport function extractPack(\n archive: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n): PackExtractionResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.extractPack(archive, destDir, limits);\n}\n\n// Re-export the pure pack-archive value objects...\nexport * from './types.js';\n// ...and the rule-authoring contract (SddRule + stable RuleContext/Finding facade + defineRule).\nexport * from './authoring.js';\n","import * as path from 'path';\nimport { load as yamlLoad } from 'js-yaml';\nimport * as codec from './codec.js';\nimport * as scaffold from './scaffold.js';\nimport * as archive from './archive.js';\nimport { SDK_VERSION } from './version.js';\nimport type {\n PackArchiveInfo,\n PackArchiveManifest,\n PackBuildResult,\n PackExtractionLimits,\n PackExtractionResult,\n PackFile,\n PackScaffoldRequest,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// SDK Orchestrator (sdk_orchestrator_impl) — the four pack workflows. Delegates\n// format/safety decisions to the codec, template rendering to the scaffold\n// specialist, and all zip+fs I/O to the archive adapter. Holds no state.\n// ---------------------------------------------------------------------------\n\nconst decode = (b: Uint8Array): string => new TextDecoder().decode(b);\nconst encode = (s: string): Uint8Array => new TextEncoder().encode(s);\n\n/** Render the scaffold file map and write it under the target directory. */\nexport function scaffoldPack(request: PackScaffoldRequest): string[] {\n // Step 1: render the scaffold file map for the requested pack.\n const files = scaffold.render(request);\n // Step 2: write the rendered files as a directory tree under targetDir.\n archive.writeTree(request.targetDir, files);\n // Step 3: return the created file paths (targetDir-joined).\n return files.map((file) => path.join(request.targetDir, file.path));\n}\n\n/** Build an installable .wpack archive from a pack directory. */\nexport function buildPack(sourceDir: string): PackBuildResult {\n // Step 1: read the source pack directory into a file map.\n const files = archive.readPackDir(sourceDir);\n // Step 2: require an envelope.\n const envelope = files.find((file) => file.path === codec.ENVELOPE_FILENAME);\n if (!envelope) {\n // Step 3: reject a pack directory with no envelope.\n throw new Error('pack build requires a wairon-pack.yaml envelope (run `wairon pack init` to scaffold one)');\n }\n // Step 4 (parse): parse + validate the envelope (also version-gates the format).\n const manifest = codec.parseManifest(decode(envelope.contents));\n // Step 5: read the inner pack identity (pack.yaml, or package.json for code).\n const identity = readInnerIdentity(files, manifest);\n // Step 6: assert the envelope's name/version match the inner pack manifest.\n codec.verifyIdentity(manifest, identity.name, identity.version);\n // Step 7: seal integrity (entryDigests + digest + generatedBy/generatedAt).\n const sealed = codec.sealIntegrity(manifest, files, `@wairon/sdk@${SDK_VERSION}`, new Date().toISOString());\n // Step 8: serialize the sealed manifest back to canonical envelope text.\n const sealedText = codec.serializeManifest(sealed);\n // Step 9: upsert wairon-pack.yaml (sealed envelope text) into the file map.\n const finalFiles = upsertEnvelope(files, sealedText);\n // Step 10: deflate the files + envelope into .wpack archive bytes.\n const archiveBytes = archive.assembleArchive(finalFiles);\n // Step 11: assemble PackArchiveInfo + suggestedFileName.\n const info = buildInfo(sealed, finalFiles);\n const suggestedFileName = `${sealed.name}-${sealed.version}.wpack`;\n // Step 12: return the build result.\n return { archive: archiveBytes, info, suggestedFileName };\n}\n\n/** Inspect + verify a .wpack archive without extracting it. */\nexport function inspectArchive(archiveBytes: Uint8Array): PackArchiveInfo {\n // Step 1: enumerate archive entries without inflating.\n const entries = archive.listEntries(archiveBytes);\n // Step 2: is there no wairon-pack.yaml entry?\n if (!entries.some((entry) => entry.path === codec.ENVELOPE_FILENAME)) {\n // Step 3: reject a non-.wpack archive.\n throw new Error('not a .wpack archive (missing wairon-pack.yaml envelope)');\n }\n // Step 4 (readEnv): inflate just the envelope entry.\n const envelopeBytes = archive.inflateEntry(archiveBytes, codec.ENVELOPE_FILENAME);\n // Step 5: parse + version-check the envelope text.\n const manifest = codec.parseManifest(decode(envelopeBytes));\n // Step 6: compute compatibility against the running wairon version.\n const compatible = codec.checkCompatibility(manifest, SDK_VERSION);\n // Step 7: assemble PackArchiveInfo from the manifest + archive stats.\n const fileEntries = entries.filter((entry) => entry.kind === 'file');\n const totalUncompressedBytes = entries.reduce((sum, entry) => sum + entry.uncompressedSize, 0);\n const info: PackArchiveInfo = {\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n formatVersion: manifest.formatVersion,\n entryCount: fileEntries.length,\n totalUncompressedBytes,\n compatible,\n };\n if (manifest.minWaironVersion !== undefined) info.minWaironVersion = manifest.minWaironVersion;\n // Step 8: return the PackArchiveInfo (no extraction performed).\n return info;\n}\n\n/** Safely extract a .wpack archive into a destination directory under enforced limits. */\nexport function extractPack(\n archiveBytes: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n): PackExtractionResult {\n // Step 1: did the caller omit limits?\n const effectiveLimits = limits === undefined\n // Step 2: fall back to the codec's default limit profile.\n ? codec.defaultLimits()\n : limits;\n // Step 3 (list): enumerate archive entries without inflating (caps run pre-decompress).\n const entries = archive.listEntries(archiveBytes);\n // Step 4: compute the safe extraction plan (throws on any unsafe/oversized entry).\n const plan = codec.planExtraction(entries, effectiveLimits);\n // Step 5: initialize an empty file list.\n const files: PackFile[] = [];\n // Step 6: inflate each approved path from the plan.\n for (const approvedPath of plan.paths) {\n // Step 7: inflate one approved entry.\n const contents = archive.inflateEntry(archiveBytes, approvedPath);\n // Step 8 (inflateEnd): append { path, contents } to the file list.\n files.push({ path: approvedPath, contents });\n }\n // Step 9: read the wairon-pack.yaml text from the inflated files.\n const envelope = files.find((file) => file.path === codec.ENVELOPE_FILENAME);\n if (!envelope) {\n throw new Error('not a .wpack archive (missing wairon-pack.yaml envelope)');\n }\n // Step 10: parse the envelope into the result manifest.\n const manifest = codec.parseManifest(decode(envelope.contents));\n // Step 11: enforce integrity BEFORE writing (throws on mismatch; no-op when none carried).\n codec.verifyIntegrity(manifest, files);\n // Step 12: write the approved, integrity-checked files as a directory tree.\n const directory = path.resolve(destDir);\n archive.writeTree(directory, files);\n // Step 13: assemble PackExtractionResult.\n const result: PackExtractionResult = {\n directory,\n entryPath: manifest.entry,\n manifest,\n name: manifest.name,\n kind: manifest.kind,\n entryCount: files.length,\n };\n // Step 14: return where the pack landed + its parsed manifest.\n return result;\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction readInnerIdentity(files: PackFile[], manifest: PackArchiveManifest): { name: string; version: string } {\n const innerPath = manifest.kind === 'code' ? 'package.json' : manifest.entry;\n const inner = files.find((file) => file.path === innerPath);\n if (!inner) throw new Error(`pack build: inner pack manifest \"${innerPath}\" is missing`);\n const parsed = (manifest.kind === 'code'\n ? JSON.parse(decode(inner.contents))\n : yamlLoad(decode(inner.contents))) as Record<string, unknown> | null;\n const name = parsed?.name;\n const version = parsed?.version;\n if (typeof name !== 'string' || typeof version !== 'string') {\n throw new Error(`pack build: inner pack manifest \"${innerPath}\" lacks a name/version`);\n }\n return { name, version };\n}\n\nfunction upsertEnvelope(files: PackFile[], envelopeText: string): PackFile[] {\n const others = files.filter((file) => file.path !== codec.ENVELOPE_FILENAME);\n return [...others, { path: codec.ENVELOPE_FILENAME, contents: encode(envelopeText) }];\n}\n\nfunction buildInfo(manifest: PackArchiveManifest, files: PackFile[]): PackArchiveInfo {\n const totalUncompressedBytes = files.reduce((sum, file) => sum + file.contents.length, 0);\n const info: PackArchiveInfo = {\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n formatVersion: manifest.formatVersion,\n entryCount: files.length,\n totalUncompressedBytes,\n compatible: true,\n };\n if (manifest.minWaironVersion !== undefined) info.minWaironVersion = manifest.minWaironVersion;\n return info;\n}\n","import { load as yamlLoad, dump as yamlDump } from 'js-yaml';\nimport { createHash } from 'crypto';\nimport type {\n ArchiveEntryMeta,\n PackArchiveManifest,\n PackExtractionLimits,\n PackExtractionPlan,\n PackFile,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// Pack Codec (pack_codec_impl) — PURE format + safety logic, no I/O.\n//\n// planExtraction is the single safety chokepoint (zip-slip / size / ratio /\n// depth / symlink guards, all pre-decompress). sealIntegrity/verifyIntegrity\n// are the produce/verify integrity pair. The codec stays pure: build time is\n// passed in, never read here.\n// ---------------------------------------------------------------------------\n\n/** The archive-root envelope filename. */\nexport const ENVELOPE_FILENAME = 'wairon-pack.yaml';\n\n/** The highest pack-archive format major this SDK understands. */\nconst SUPPORTED_FORMAT_VERSION = 1;\n\n/** The default extraction-safety profile: 4096 / 32 MiB / 8 MiB / 100:1 / depth 16. */\nconst DEFAULTS = {\n maxEntries: 4096,\n maxTotalUncompressedBytes: 32 * 1024 * 1024,\n maxEntryBytes: 8 * 1024 * 1024,\n maxCompressionRatio: 100,\n maxDepth: 16,\n} as const;\n\n/** Parse + validate the envelope text into a PackArchiveManifest; throws on malformed/newer-major. */\nexport function parseManifest(text: string): PackArchiveManifest {\n // Step 1: parse the envelope YAML text (throws on malformed YAML).\n const raw = yamlLoad(text);\n // Step 2: validate the required fields are present and well-typed.\n const manifest = validateEnvelope(raw);\n // Step 3: is the format major newer than this wairon supports?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: fail loudly rather than silently mis-read a newer format.\n throw new Error('unsupported pack-archive formatVersion (newer than this wairon understands)');\n }\n // Step 5: return the parsed manifest.\n return manifest;\n}\n\n/** Serialize a manifest to canonical wairon-pack.yaml text (build path). */\nexport function serializeManifest(manifest: PackArchiveManifest): string {\n // Step 1: drop undefined optional fields for a clean, canonical envelope.\n const clean: Record<string, unknown> = {\n formatVersion: manifest.formatVersion,\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n };\n if (manifest.minWaironVersion !== undefined) clean.minWaironVersion = manifest.minWaironVersion;\n if (manifest.digest !== undefined) clean.digest = manifest.digest;\n if (manifest.entryDigests !== undefined) clean.entryDigests = manifest.entryDigests;\n if (manifest.generatedBy !== undefined) clean.generatedBy = manifest.generatedBy;\n if (manifest.generatedAt !== undefined) clean.generatedAt = manifest.generatedAt;\n // Step 2: return the wairon-pack.yaml text.\n return yamlDump(clean, { sortKeys: false });\n}\n\n/** The default extraction-safety profile; callers override individual caps. */\nexport function defaultLimits(): PackExtractionLimits {\n // Step 1: return the default caps profile.\n return { ...DEFAULTS };\n}\n\n/** Compute the safe extraction plan from enumerated entries under `limits`, or throw. */\nexport function planExtraction(entries: ArchiveEntryMeta[], limits: PackExtractionLimits): PackExtractionPlan {\n // Step 1: resolve effective caps — each field of `limits` over the defaults.\n const caps = {\n maxEntries: limits.maxEntries ?? DEFAULTS.maxEntries,\n maxTotalUncompressedBytes: limits.maxTotalUncompressedBytes ?? DEFAULTS.maxTotalUncompressedBytes,\n maxEntryBytes: limits.maxEntryBytes ?? DEFAULTS.maxEntryBytes,\n maxCompressionRatio: limits.maxCompressionRatio ?? DEFAULTS.maxCompressionRatio,\n maxDepth: limits.maxDepth ?? DEFAULTS.maxDepth,\n };\n // Step 2: initialize an empty approved-path list and a running total of 0.\n const approved: string[] = [];\n let total = 0;\n // Step 3: vet each enumerated entry.\n for (const entry of entries) {\n // Step 4: reject symlinks/non-regular entries and structurally unsafe paths.\n if (isSymlinkOrNonRegular(entry.kind) || isStructurallyUnsafePath(entry.path)) {\n rejectUnsafe();\n }\n // Directory entries are structural (writeTree recreates them from file\n // paths) — skip without approving, never inflate a 0-byte dir marker.\n if (entry.kind === 'dir') continue;\n // Step 5: normalize the entry path to a destination-relative POSIX path.\n const normalized = normalizeRelPath(entry.path);\n // Step 6: reject zip-slip and over-deep paths.\n if (escapesDestination(normalized) || pathDepth(normalized) > caps.maxDepth) {\n rejectUnsafe();\n }\n // Step 7: reject oversized entries and zip bombs.\n if (entry.uncompressedSize > caps.maxEntryBytes || compressionRatio(entry) > caps.maxCompressionRatio) {\n rejectUnsafe();\n }\n // Step 8 (vetEnd): accept — append the path and add its inflated size.\n approved.push(normalized);\n total += entry.uncompressedSize;\n }\n // Step 9: reject archives exceeding the aggregate caps.\n if (approved.length > caps.maxEntries || total > caps.maxTotalUncompressedBytes) {\n rejectUnsafe();\n }\n // Step 11: return the approved plan.\n return { paths: approved, totalUncompressedBytes: total };\n}\n\n/** Assert the envelope's name/version match the inner pack manifest; throw on mismatch. */\nexport function verifyIdentity(manifest: PackArchiveManifest, packName: string, packVersion: string): void {\n // Step 1: do envelope name/version differ from the inner pack manifest?\n if (manifest.name !== packName || manifest.version !== packVersion) {\n // Step 2: reject a tampered/mis-assembled archive.\n throw new Error('envelope identity mismatch (envelope name/version differ from the inner pack manifest)');\n }\n // Step 3: identity verified.\n}\n\n/** Verify every entry's sha256 against entryDigests; false when none carried, throws on mismatch. */\nexport function verifyIntegrity(manifest: PackArchiveManifest, files: PackFile[]): boolean {\n // Step 1: did the envelope carry no integrity data?\n if (!manifest.entryDigests) {\n // Step 2: no integrity data present — return false.\n return false;\n }\n const digests = manifest.entryDigests;\n // Step 3: check each file's digest.\n for (const file of files) {\n // The envelope carries these digests and cannot digest itself — skip it.\n if (file.path === ENVELOPE_FILENAME) continue;\n // Step 4: does the recomputed sha256 differ from the recorded digest?\n if (sha256(file.contents) !== digests[file.path]) {\n // Step 7: a digest mismatch means tampering.\n throw new Error('integrity digest mismatch');\n }\n // Step 5 (checkEnd): this file's digest matches.\n }\n // Step 6: all digests matched — return true.\n return true;\n}\n\n/** Produce-side partner of verifyIntegrity: fill entryDigests + digest + stamps. */\nexport function sealIntegrity(\n manifest: PackArchiveManifest,\n files: PackFile[],\n generatedBy: string,\n generatedAt: string,\n): PackArchiveManifest {\n // Step 1: initialize an empty entryDigests map.\n const entryDigests: Record<string, string> = {};\n // Step 2: hash each file.\n for (const file of files) {\n // The envelope is the carrier of these digests — never hash it into itself.\n if (file.path === ENVELOPE_FILENAME) continue;\n // Step 3 (hashEnd): compute sha256(file.contents) and record it under file.path.\n entryDigests[file.path] = sha256(file.contents);\n }\n // Step 4: compute an overall manifest digest over the sorted entryDigests.\n const digest = sha256(canonicalDigestBytes(entryDigests));\n // Step 5: set entryDigests, digest, generatedBy, generatedAt.\n // Step 6: return the sealed manifest.\n return { ...manifest, entryDigests, digest, generatedBy, generatedAt };\n}\n\n/** Whether the archive's formatVersion + minWaironVersion are compatible with `waironVersion`. */\nexport function checkCompatibility(manifest: PackArchiveManifest, waironVersion: string): boolean {\n // Step 1: is the archive format unsupported?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: incompatible.\n return false;\n }\n // Step 2: is the running wairon below the pack's minimum?\n if (manifest.minWaironVersion && isBelow(waironVersion, manifest.minWaironVersion)) {\n // Step 4: incompatible.\n return false;\n }\n // Step 3: compatible.\n return true;\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction rejectUnsafe(): never {\n throw new Error('reject: unsafe or oversized archive entry (zip-slip / size / ratio / depth guard)');\n}\n\nfunction validateEnvelope(raw: unknown): PackArchiveManifest {\n if (!raw || typeof raw !== 'object') {\n throw new Error('malformed pack envelope (not a YAML mapping)');\n }\n const o = raw as Record<string, unknown>;\n if (typeof o.formatVersion !== 'number') throw new Error('pack envelope: formatVersion must be a number');\n if (typeof o.name !== 'string' || !o.name) throw new Error('pack envelope: name is required');\n if (typeof o.version !== 'string' || !o.version) throw new Error('pack envelope: version is required');\n if (typeof o.kind !== 'string' || (o.kind !== 'declarative' && o.kind !== 'code')) {\n throw new Error('pack envelope: kind must be \"declarative\" or \"code\"');\n }\n if (typeof o.entry !== 'string' || !o.entry) throw new Error('pack envelope: entry is required');\n const manifest: PackArchiveManifest = {\n formatVersion: o.formatVersion,\n name: o.name,\n version: o.version,\n kind: o.kind,\n entry: o.entry,\n };\n if (typeof o.minWaironVersion === 'string') manifest.minWaironVersion = o.minWaironVersion;\n if (typeof o.digest === 'string') manifest.digest = o.digest;\n if (o.entryDigests && typeof o.entryDigests === 'object') {\n manifest.entryDigests = o.entryDigests as Record<string, string>;\n }\n if (typeof o.generatedBy === 'string') manifest.generatedBy = o.generatedBy;\n if (typeof o.generatedAt === 'string') manifest.generatedAt = o.generatedAt;\n return manifest;\n}\n\nfunction isSymlinkOrNonRegular(kind: string): boolean {\n return kind !== 'file' && kind !== 'dir';\n}\n\nfunction isStructurallyUnsafePath(p: string): boolean {\n if (p.includes('\\\\')) return true; // backslash\n if (/^[A-Za-z]:/.test(p)) return true; // drive letter\n if (p.startsWith('/')) return true; // absolute POSIX\n return p.split('/').some((seg) => seg === '..'); // parent traversal\n}\n\nfunction normalizeRelPath(p: string): string {\n return p\n .split('/')\n .filter((seg) => seg !== '' && seg !== '.')\n .join('/');\n}\n\nfunction escapesDestination(normalized: string): boolean {\n return normalized.startsWith('/') || normalized.split('/').some((seg) => seg === '..');\n}\n\nfunction pathDepth(normalized: string): number {\n return normalized.split('/').filter((seg) => seg !== '').length;\n}\n\nfunction compressionRatio(entry: ArchiveEntryMeta): number {\n if (entry.compressedSize > 0) return entry.uncompressedSize / entry.compressedSize;\n return entry.uncompressedSize > 0 ? Infinity : 0;\n}\n\nfunction canonicalDigestBytes(entryDigests: Record<string, string>): Uint8Array {\n const lines = Object.keys(entryDigests)\n .sort()\n .map((key) => `${key}:${entryDigests[key]}`)\n .join('\\n');\n return new TextEncoder().encode(lines);\n}\n\nfunction sha256(data: Uint8Array): string {\n return createHash('sha256').update(data).digest('hex');\n}\n\nfunction isBelow(running: string, minimum: string): boolean {\n const [rMaj, rMin, rPat] = parseSemverCore(running);\n const [mMaj, mMin, mPat] = parseSemverCore(minimum);\n if (rMaj !== mMaj) return rMaj < mMaj;\n if (rMin !== mMin) return rMin < mMin;\n return rPat < mPat;\n}\n\nfunction parseSemverCore(v: string): [number, number, number] {\n const cleaned = v.trim().replace(/^[^0-9]*/, ''); // strip leading ^, ~, >=, v, etc.\n const core = cleaned.split(/[-+]/)[0]; // drop prerelease/build metadata\n const parts = core.split('.').map((n) => parseInt(n, 10));\n return [parts[0] || 0, parts[1] || 0, parts[2] || 0];\n}\n","// The running @wairon/sdk version — stamped into built archives (generatedBy)\n// and used as the \"running wairon version\" for pack version-compatibility\n// checks. tsup inlines package.json at build time; at runtime the require\n// resolves against the shipped package (../package.json from dist/).\n\nexport const SDK_VERSION: string = loadVersion();\n\nfunction loadVersion(): string {\n try {\n const pkg = require('../package.json') as { version?: string };\n return pkg.version ?? '0.0.0';\n } catch {\n return '0.0.0';\n }\n}\n","import type { PackFile, PackScaffoldRequest } from './types.js';\nimport { SDK_VERSION } from './version.js';\n\n// ---------------------------------------------------------------------------\n// Pack Scaffold Specialist (pack_scaffold_specialist_impl) — PURE template\n// rendering for `wairon pack init`. Produces an in-memory file map; writes\n// nothing. Code packs pin @wairon/sdk to the running SDK version.\n// ---------------------------------------------------------------------------\n\nconst enc = (s: string): Uint8Array => new TextEncoder().encode(s);\n\n/** Render the scaffold file map for the requested pack (declarative or code). */\nexport function render(request: PackScaffoldRequest): PackFile[] {\n const version = request.version ?? '0.1.0';\n let files: PackFile[];\n // Step 1: which variant?\n if (request.kind === 'code') {\n // Step 2: render the code-pack file map.\n files = renderCodePack(request.name, version);\n // Step 3: skip the declarative variant (fall through to the skill gate).\n } else {\n // Step 4 (declVariant): render the declarative-pack file map.\n files = renderDeclarativePack(request.name, version);\n }\n // Step 5 (skillGate): include a skill stub?\n if (request.withSkill) {\n // Step 6: append a skills/<id>/SKILL.md stub to the file map.\n files.push(renderSkillStub(request.name, version));\n }\n // Step 7 (done): return the rendered file map.\n return files;\n}\n\n// --- variant renderers -----------------------------------------------------\n\nfunction renderDeclarativePack(name: string, version: string): PackFile[] {\n return [\n { path: 'wairon-pack.yaml', contents: enc(declarativeEnvelope(name, version)) },\n { path: 'pack.yaml', contents: enc(declarativeManifest(name, version)) },\n { path: 'README.md', contents: enc(readme(name, 'declarative', 'pack.yaml')) },\n ];\n}\n\nfunction renderCodePack(name: string, version: string): PackFile[] {\n return [\n { path: 'wairon-pack.yaml', contents: enc(codeEnvelope(name, version)) },\n { path: 'package.json', contents: enc(codePackageJson(name, version)) },\n { path: 'tsconfig.json', contents: enc(codeTsconfig()) },\n { path: 'pack.ts', contents: enc(codeEntry(name, version)) },\n { path: 'README.md', contents: enc(readme(name, 'code', 'pack.cjs')) },\n ];\n}\n\nfunction renderSkillStub(name: string, _version: string): PackFile {\n const id = slug(name);\n return { path: `skills/${id}/SKILL.md`, contents: enc(skillStub(name)) };\n}\n\n// --- templates -------------------------------------------------------------\n\nfunction declarativeEnvelope(name: string, version: string): string {\n return [\n 'formatVersion: 1',\n `name: ${name}`,\n `version: ${version}`,\n 'kind: declarative',\n 'entry: pack.yaml',\n '',\n ].join('\\n');\n}\n\nfunction codeEnvelope(name: string, version: string): string {\n return [\n 'formatVersion: 1',\n `name: ${name}`,\n `version: ${version}`,\n 'kind: code',\n 'entry: pack.cjs',\n `minWaironVersion: ${SDK_VERSION}`,\n '',\n ].join('\\n');\n}\n\nfunction declarativeManifest(name: string, version: string): string {\n return [\n `name: ${name}`,\n `version: ${version}`,\n '',\n '# Custom architectural profiles this pack contributes (example, commented):',\n '# profiles:',\n '# my-profile:',\n '# family: backend-like',\n '# forbiddenStereotypes:',\n '# - types: [Adapter]',\n '# reason: \"Domain components must not touch adapters directly.\"',\n 'profiles: {}',\n '',\n '# Target language / platform tables (example, commented):',\n '# languages:',\n '# rust:',\n '# unsupportedFlow: {}',\n '# foreignBuiltins: []',\n 'languages: {}',\n '',\n '# Reusable, versioned architecture patterns:',\n 'patterns: []',\n '',\n ].join('\\n');\n}\n\nfunction codePackageJson(name: string, version: string): string {\n const pkg = {\n name,\n version,\n private: true,\n scripts: {\n build: 'esbuild pack.ts --bundle --platform=node --packages=external --format=cjs --outfile=pack.cjs',\n },\n dependencies: {\n '@wairon/sdk': SDK_VERSION,\n },\n devDependencies: {\n esbuild: '^0.21.0',\n typescript: '^5.0.0',\n },\n };\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nfunction codeTsconfig(): string {\n const tsconfig = {\n compilerOptions: {\n target: 'ES2020',\n module: 'CommonJS',\n moduleResolution: 'node',\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n declaration: false,\n noEmit: true,\n },\n include: ['pack.ts'],\n };\n return `${JSON.stringify(tsconfig, null, 2)}\\n`;\n}\n\nfunction codeEntry(name: string, version: string): string {\n const code = slug(name).toUpperCase().replace(/-/g, '_');\n return [\n \"import { defineRule } from '@wairon/sdk';\",\n \"import type { RuleContext, Finding } from '@wairon/sdk';\",\n '',\n 'const exampleRule = defineRule({',\n ` name: '${slug(name)}-example',`,\n \" description: 'Example architectural rule. Replace with your own doctrine.',\",\n ` codes: ['${code}_EXAMPLE'],`,\n ' check(ctx: RuleContext): Finding[] {',\n ' const findings: Finding[] = [];',\n ' for (const component of ctx.components) {',\n ' // Inspect the spec tree and push findings as needed.',\n ' void component;',\n ' }',\n ' return findings;',\n ' },',\n '});',\n '',\n 'export default {',\n ` name: '${name}',`,\n ` version: '${version}',`,\n ' rules: [exampleRule],',\n '};',\n '',\n ].join('\\n');\n}\n\nfunction readme(name: string, kind: string, entry: string): string {\n return [\n `# ${name}`,\n '',\n `A wairon ${kind} pack.`,\n '',\n `- Envelope: \\`wairon-pack.yaml\\``,\n `- Entry: \\`${entry}\\``,\n '',\n 'Build an installable `.wpack` archive with `wairon pack build`.',\n '',\n ].join('\\n');\n}\n\nfunction skillStub(name: string): string {\n return [\n '---',\n `name: ${name}`,\n `description: ${name} authoring skill (stub).`,\n '---',\n '',\n `# ${name}`,\n '',\n 'Describe when this skill applies and what it guides.',\n '',\n ].join('\\n');\n}\n\nfunction slug(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\nimport { zipSync, unzipSync, type Zippable } from 'fflate';\nimport type { ArchiveEntryMeta, PackFile } from './types.js';\n\n// ---------------------------------------------------------------------------\n// Pack Archive Adapter (pack_archive_adapter_impl) — the ONLY zip-library + fs\n// I/O boundary of the SDK. Technology: fflate (pure-JS ZIP, no native deps).\n//\n// Acts only on already-validated inputs: it makes no path-safety or format\n// decisions (that is the codec's job). Enumeration reads sizes WITHOUT\n// inflating so the codec can enforce zip-bomb / size caps before any bytes are\n// decompressed.\n// ---------------------------------------------------------------------------\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', '.hg', '.svn']);\n\n/**\n * Enumerate every entry's metadata (path, compressed + uncompressed size, kind)\n * WITHOUT decompressing any bytes, so the codec can enforce caps before\n * inflation.\n */\nexport function listEntries(archive: Uint8Array): ArchiveEntryMeta[] {\n // Step 1: read the central directory via the zip library, mapping each record\n // to ArchiveEntryMeta without inflating any data. fflate's filter reports\n // {name, size (compressed), originalSize (uncompressed)} for every entry;\n // returning false skips decompression. Symlink detection reads the central\n // directory's external attributes (fflate's metadata omits the unix mode).\n const symlinks = detectSymlinkNames(archive);\n const metas: ArchiveEntryMeta[] = [];\n unzipSync(archive, {\n filter: (info): boolean => {\n metas.push({\n path: info.name,\n uncompressedSize: info.originalSize,\n compressedSize: info.size,\n kind: classifyKind(info.name, symlinks),\n });\n return false;\n },\n });\n // Step 2: return the entry metadata list.\n return metas;\n}\n\n/** Decompress and return the bytes of a single named entry. */\nexport function inflateEntry(archive: Uint8Array, entryPath: string): Uint8Array {\n // Step 1: locate the named entry and inflate only it.\n const inflated = unzipSync(archive, { filter: (info): boolean => info.name === entryPath });\n const bytes = inflated[entryPath];\n if (!bytes) throw new Error(`archive entry not found: ${entryPath}`);\n // Step 2: return the entry's decompressed bytes.\n return bytes;\n}\n\n/** Deflate a set of files (the envelope + pack contents) into a single ZIP buffer. */\nexport function assembleArchive(files: PackFile[]): Uint8Array {\n // Step 1: add each file to a zip container (deflating) and finalize.\n const zippable: Zippable = {};\n for (const file of files) zippable[file.path] = file.contents;\n const bytes = zipSync(zippable);\n // Step 2: return the archive bytes.\n return bytes;\n}\n\n/** Read a source pack directory recursively into a file map (POSIX paths + bytes). */\nexport function readPackDir(dir: string): PackFile[] {\n // Step 1: walk the directory recursively, reading each file into\n // { path: POSIX-relative, contents } (skipping node_modules and VCS dirs).\n const files: PackFile[] = [];\n walkPackDir(dir, dir, files);\n // Step 2: return the file map.\n return files;\n}\n\n/** Write a file map as a directory tree under destDir, creating parent directories. */\nexport function writeTree(destDir: string, files: PackFile[]): void {\n // Step 1: write each approved file.\n for (const file of files) {\n // Step 2 (writeEnd): create parent directories and write the file's bytes.\n const absolute = path.join(destDir, file.path);\n fs.mkdirSync(path.dirname(absolute), { recursive: true });\n fs.writeFileSync(absolute, file.contents);\n }\n // Step 3: done.\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction classifyKind(name: string, symlinks: Set<string>): string {\n if (symlinks.has(name)) return 'symlink';\n if (name.endsWith('/')) return 'dir';\n return 'file';\n}\n\nfunction walkPackDir(root: string, current: string, out: PackFile[]): void {\n for (const entry of fs.readdirSync(current, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name)) continue;\n walkPackDir(root, path.join(current, entry.name), out);\n } else if (entry.isFile()) {\n const absolute = path.join(current, entry.name);\n const relative = path.relative(root, absolute).split(path.sep).join('/');\n out.push({ path: relative, contents: fs.readFileSync(absolute) });\n }\n }\n}\n\n// Best-effort central-directory scan for symlink entries (unix S_IFLNK in the\n// external file attributes). fflate's high-level metadata omits the unix mode,\n// so the codec's symlink rejection needs this. Any parse trouble yields an\n// empty set — no worse than fflate alone, and confinement/size caps still apply.\nfunction detectSymlinkNames(archive: Uint8Array): Set<string> {\n const names = new Set<string>();\n try {\n const eocd = findEocd(archive);\n if (eocd < 0) return names;\n let p = readU32(archive, eocd + 16); // central directory offset\n const count = readU16(archive, eocd + 10);\n const decoder = new TextDecoder();\n for (let i = 0; i < count; i++) {\n if (readU32(archive, p) !== 0x02014b50) break; // central file header sig\n const versionMadeBy = readU16(archive, p + 4);\n const nameLen = readU16(archive, p + 28);\n const extraLen = readU16(archive, p + 30);\n const commentLen = readU16(archive, p + 32);\n const externalAttrs = readU32(archive, p + 38);\n const name = decoder.decode(archive.subarray(p + 46, p + 46 + nameLen));\n if ((versionMadeBy >> 8) === 3) { // unix host\n const unixMode = (externalAttrs >>> 16) & 0xffff;\n if ((unixMode & 0o170000) === 0o120000) names.add(name);\n }\n p += 46 + nameLen + extraLen + commentLen;\n }\n } catch {\n return names;\n }\n return names;\n}\n\nfunction findEocd(buf: Uint8Array): number {\n const minRecord = 22;\n const lowerBound = Math.max(0, buf.length - (minRecord + 0xffff));\n for (let i = buf.length - minRecord; i >= lowerBound; i--) {\n if (readU32(buf, i) === 0x06054b50) return i;\n }\n return -1;\n}\n\nfunction readU16(buf: Uint8Array, off: number): number {\n return buf[off] | (buf[off + 1] << 8);\n}\n\nfunction readU32(buf: Uint8Array, off: number): number {\n return (buf[off] | (buf[off + 1] << 8) | (buf[off + 2] << 16) | (buf[off + 3] << 24)) >>> 0;\n}\n","// ---------------------------------------------------------------------------\n// Rule-authoring contract (the code-pack compile target).\n//\n// Code packs are written against `@wairon/sdk`, never against wairon core. This\n// is a small, stable, hand-authored facade — deliberately NOT core's fat\n// RuleContext. `defineRule` returns the rule unchanged (identity + type\n// inference); the runtime shape `{ name, description?, codes: string[], check }`\n// is exactly what the core extension loader duck-types.\n// ---------------------------------------------------------------------------\n\n/** Severity of a finding a pack rule emits. */\nexport type RuleSeverity = 'error' | 'warning';\n\n/** A single issue a pack rule reports about the spec tree. */\nexport interface Finding {\n /** Pack-local issue code (surfaced namespaced by wairon, e.g. `<PACK>_<CODE>`). */\n code: string;\n /** 'error' | 'warning'. */\n severity: RuleSeverity;\n /** Human-readable explanation of the violation. */\n message: string;\n /** The spec id the finding is anchored to (optional). */\n specId?: string;\n}\n\n/**\n * A read-only spec node as seen by a pack rule: its id/name plus arbitrary\n * further fields (kept open so the facade stays stable as the spec model grows).\n */\nexport interface RuleSpecNode {\n id: string;\n name?: string;\n [key: string]: unknown;\n}\n\n/**\n * The minimal, stable view of the spec tree a code-pack rule inspects. A rule\n * reads these collections and returns findings — it never mutates state and\n * never reaches into wairon core internals.\n */\nexport interface RuleContext {\n /** The L0 system spec. */\n system: RuleSpecNode;\n /** All L1 subsystem specs. */\n subsystems: RuleSpecNode[];\n /** All L2 component specs. */\n components: RuleSpecNode[];\n /** All L3 interface specs. */\n interfaces: RuleSpecNode[];\n /** All L4 implementation specs. */\n implementations: RuleSpecNode[];\n /** All shared type/value-object specs. */\n types: RuleSpecNode[];\n}\n\n/**\n * A programmatic conformance rule shipped by a code pack. Its runtime shape —\n * `{ name, description?, codes: string[], check }` — is what wairon's extension\n * loader duck-types when it loads a `pack.cjs`.\n */\nexport interface SddRule {\n /** Stable rule id (kebab-case), e.g. \"my-portal-transport\". */\n name: string;\n /** One-line description of what the rule enforces and why. */\n description?: string;\n /** The issue codes this rule can emit. */\n codes: string[];\n /** Inspect the spec tree and return findings (empty when clean). */\n check(ctx: RuleContext): Finding[];\n}\n\n/**\n * Author an SddRule with full type inference. Returns the rule unchanged — it\n * exists purely so code packs get typed authoring without importing anything\n * from wairon core.\n */\nexport function defineRule(rule: SddRule): SddRule {\n return rule;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAU;AAAA,MACV,SAAW;AAAA,MACX,UAAY;AAAA,MACZ,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,OAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAW;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,WAAa;AAAA,QACb,MAAQ;AAAA,QACR,cAAc;AAAA,QACd,OAAS;AAAA,MACX;AAAA,MACA,cAAgB;AAAA,QACd,QAAU;AAAA,QACV,WAAW;AAAA,MACb;AAAA,MACA,iBAAmB;AAAA,QACjB,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,QAAU;AAAA,QACV,MAAQ;AAAA,QACR,YAAc;AAAA,QACd,QAAU;AAAA,MACZ;AAAA,IACF;AAAA;AAAA;;;AChDA;AAAA;AAAA,mBAAAC;AAAA,EAAA;AAAA,qBAAAC;AAAA,EAAA,sBAAAC;AAAA,EAAA,oBAAAC;AAAA;AAAA;;;ACAA,IAAAC,QAAsB;AACtB,IAAAC,kBAAiC;;;ACDjC,qBAAmD;AACnD,oBAA2B;AAmBpB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AAGjC,IAAM,WAAW;AAAA,EACf,YAAY;AAAA,EACZ,2BAA2B,KAAK,OAAO;AAAA,EACvC,eAAe,IAAI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AAe,SAAsC;AAEnE,SAAoB,eAAe,OAAO;AAC5C;AAGO,SAASC,aACd,SACA,SACA,QACsB;AAEtB,SAAoB,YAAY,SAAS,SAAS,MAAM;AAC1D;","names":["exports","module","buildPack","extractPack","inspectArchive","scaffoldPack","path","import_js_yaml","yamlLoad","yamlDump","relative","yamlLoad","scaffoldPack","buildPack","inspectArchive","extractPack"]}
1
+ {"version":3,"sources":["../package.json","../src/index.ts","../src/orchestrator.ts","../src/codec.ts","../src/treecodec.ts","../src/version.ts","../src/scaffold.ts","../src/archive.ts","../src/authoring.ts"],"sourcesContent":["{\n \"name\": \"@wairon/sdk\",\n \"version\": \"5.1.1-dev.9\",\n \"description\": \"Wairon pack-archive (.wpack) format authority and authoring toolkit — scaffold, build, inspect, and safely extract wairon extension packs.\",\n \"keywords\": [\n \"wairon\",\n \"sdd\",\n \"pack\",\n \"wpack\",\n \"archive\",\n \"developer-tools\"\n ],\n \"author\": \"SYW\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/SYW-Apps/Waffle-AIron\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/SYW-Apps/Waffle-AIron.git\"\n },\n \"type\": \"commonjs\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"clean\": \"rimraf dist\"\n },\n \"dependencies\": {\n \"fflate\": \"^0.8.2\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^20.14.0\",\n \"rimraf\": \"^5.0.7\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.2\",\n \"vitest\": \"^4.1.9\"\n }\n}\n","import * as orchestrator from './orchestrator.js';\nimport type {\n PackArchiveInfo,\n PackBuildResult,\n PackExtractionLimits,\n PackExtractionResult,\n PackScaffoldRequest,\n TreeArchiveInfo,\n TreeBuildResult,\n TreeExtractionResult,\n TreeRootSource,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// SDK Portal (sdk_portal_impl) — the @wairon/sdk package entry. Each capability\n// is a 1:1 forward to the SDK orchestrator with no logic of its own; the module\n// also re-exports the pure pack-authoring value objects and the rule-authoring\n// contract (compile-time types + the defineRule helper).\n// ---------------------------------------------------------------------------\n\n/** Scaffold a new pack project (declarative or code) into a directory; returns the created file paths. */\nexport function scaffoldPack(request: PackScaffoldRequest): string[] {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.scaffoldPack(request);\n}\n\n/** Build an installable .wpack archive from a pack directory. */\nexport function buildPack(sourceDir: string): PackBuildResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.buildPack(sourceDir);\n}\n\n/** Inspect + verify a .wpack archive without extracting it. */\nexport function inspectArchive(archive: Uint8Array): PackArchiveInfo {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.inspectArchive(archive);\n}\n\n/** Safely extract a .wpack archive into a destination directory under enforced limits. */\nexport function extractPack(\n archive: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n): PackExtractionResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.extractPack(archive, destDir, limits);\n}\n\n/** Pack a project's spec tree — the supplied roots' .wai directories — into a .waitree archive. */\nexport function buildTreeArchive(\n roots: TreeRootSource[],\n projectName: string,\n stateId?: string,\n includeDerived?: boolean,\n): TreeBuildResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.buildTreeArchive(roots, projectName, stateId, includeDerived);\n}\n\n/** Inspect a .waitree archive without extracting it. */\nexport function inspectTreeArchive(archive: Uint8Array): TreeArchiveInfo {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.inspectTreeArchive(archive);\n}\n\n/** Safely extract a .waitree archive into a destination project root under enforced limits. */\nexport function extractTreeArchive(\n archive: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n refuseExecutableEntries?: boolean,\n): TreeExtractionResult {\n // Step 1: forward to the SDK orchestrator.\n return orchestrator.extractTreeArchive(archive, destDir, limits, refuseExecutableEntries);\n}\n\n// Re-export the pure pack-archive value objects...\nexport * from './types.js';\n// ...and the rule-authoring contract (SddRule + stable RuleContext/Finding facade + defineRule).\nexport * from './authoring.js';\n","import * as path from 'path';\nimport { load as yamlLoad } from 'js-yaml';\nimport * as codec from './codec.js';\nimport * as treecodec from './treecodec.js';\nimport * as scaffold from './scaffold.js';\nimport * as archive from './archive.js';\nimport { SDK_VERSION } from './version.js';\nimport type {\n PackArchiveInfo,\n PackArchiveManifest,\n PackBuildResult,\n PackExtractionLimits,\n PackExtractionResult,\n PackFile,\n PackScaffoldRequest,\n TreeArchiveInfo,\n TreeArchiveManifest,\n TreeBuildResult,\n TreeExtractionResult,\n TreeRootSource,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// SDK Orchestrator (sdk_orchestrator_impl) — the four pack workflows and the\n// three spec-tree archive workflows. Delegates format/safety decisions to the\n// codecs, template rendering to the scaffold specialist, and all zip+fs I/O to\n// the archive adapter. Holds no state.\n//\n// Root DISCOVERY stays with the caller: the SDK never walks a spec tree, it\n// only archives the roots it is handed.\n// ---------------------------------------------------------------------------\n\nconst decode = (b: Uint8Array): string => new TextDecoder().decode(b);\nconst encode = (s: string): Uint8Array => new TextEncoder().encode(s);\n\n/** Render the scaffold file map and write it under the target directory. */\nexport function scaffoldPack(request: PackScaffoldRequest): string[] {\n // Step 1: render the scaffold file map for the requested pack.\n const files = scaffold.render(request);\n // Step 2: write the rendered files as a directory tree under targetDir.\n archive.writeTree(request.targetDir, files);\n // Step 3: return the created file paths (targetDir-joined).\n return files.map((file) => path.join(request.targetDir, file.path));\n}\n\n/** Build an installable .wpack archive from a pack directory. */\nexport function buildPack(sourceDir: string): PackBuildResult {\n // Step 1: read the source pack directory into a file map.\n const files = archive.readPackDir(sourceDir);\n // Step 2: require an envelope.\n const envelope = files.find((file) => file.path === codec.ENVELOPE_FILENAME);\n if (!envelope) {\n // Step 3: reject a pack directory with no envelope.\n throw new Error('pack build requires a wairon-pack.yaml envelope (run `wairon pack init` to scaffold one)');\n }\n // Step 4 (parse): parse + validate the envelope (also version-gates the format).\n const manifest = codec.parseManifest(decode(envelope.contents));\n // Step 5: read the inner pack identity (pack.yaml, or package.json for code).\n const identity = readInnerIdentity(files, manifest);\n // Step 6: assert the envelope's name/version match the inner pack manifest.\n codec.verifyIdentity(manifest, identity.name, identity.version);\n // Step 7: seal integrity (entryDigests + digest + generatedBy/generatedAt).\n const sealed = codec.sealIntegrity(manifest, files, `@wairon/sdk@${SDK_VERSION}`, new Date().toISOString());\n // Step 8: serialize the sealed manifest back to canonical envelope text.\n const sealedText = codec.serializeManifest(sealed);\n // Step 9: upsert wairon-pack.yaml (sealed envelope text) into the file map.\n const finalFiles = upsertEnvelope(files, sealedText);\n // Step 10: deflate the files + envelope into .wpack archive bytes.\n const archiveBytes = archive.assembleArchive(finalFiles);\n // Step 11: assemble PackArchiveInfo + suggestedFileName.\n const info = buildInfo(sealed, finalFiles);\n const suggestedFileName = `${sealed.name}-${sealed.version}.wpack`;\n // Step 12: return the build result.\n return { archive: archiveBytes, info, suggestedFileName };\n}\n\n/** Inspect + verify a .wpack archive without extracting it. */\nexport function inspectArchive(archiveBytes: Uint8Array): PackArchiveInfo {\n // Step 1: enumerate archive entries without inflating.\n const entries = archive.listEntries(archiveBytes);\n // Step 2: is there no wairon-pack.yaml entry?\n if (!entries.some((entry) => entry.path === codec.ENVELOPE_FILENAME)) {\n // Step 3: reject a non-.wpack archive.\n throw new Error('not a .wpack archive (missing wairon-pack.yaml envelope)');\n }\n // Step 4 (readEnv): inflate just the envelope entry.\n const envelopeBytes = archive.inflateEntry(archiveBytes, codec.ENVELOPE_FILENAME);\n // Step 5: parse + version-check the envelope text.\n const manifest = codec.parseManifest(decode(envelopeBytes));\n // Step 6: compute compatibility against the running wairon version.\n const compatible = codec.checkCompatibility(manifest, SDK_VERSION);\n // Step 7: assemble PackArchiveInfo from the manifest + archive stats.\n const fileEntries = entries.filter((entry) => entry.kind === 'file');\n const totalUncompressedBytes = entries.reduce((sum, entry) => sum + entry.uncompressedSize, 0);\n const info: PackArchiveInfo = {\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n formatVersion: manifest.formatVersion,\n entryCount: fileEntries.length,\n totalUncompressedBytes,\n compatible,\n };\n if (manifest.minWaironVersion !== undefined) info.minWaironVersion = manifest.minWaironVersion;\n // Step 8: return the PackArchiveInfo (no extraction performed).\n return info;\n}\n\n/** Safely extract a .wpack archive into a destination directory under enforced limits. */\nexport function extractPack(\n archiveBytes: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n): PackExtractionResult {\n // Step 1: did the caller omit limits?\n const effectiveLimits = limits === undefined\n // Step 2: fall back to the codec's default limit profile.\n ? codec.defaultLimits()\n : limits;\n // Step 3 (list): enumerate archive entries without inflating (caps run pre-decompress).\n const entries = archive.listEntries(archiveBytes);\n // Step 4: compute the safe extraction plan (throws on any unsafe/oversized entry).\n const plan = codec.planExtraction(entries, effectiveLimits);\n // Step 5: initialize an empty file list.\n const files: PackFile[] = [];\n // Step 6: inflate each approved path from the plan.\n for (const approvedPath of plan.paths) {\n // Step 7: inflate one approved entry.\n const contents = archive.inflateEntry(archiveBytes, approvedPath);\n // Step 8 (inflateEnd): append { path, contents } to the file list.\n files.push({ path: approvedPath, contents });\n }\n // Step 9: read the wairon-pack.yaml text from the inflated files.\n const envelope = files.find((file) => file.path === codec.ENVELOPE_FILENAME);\n if (!envelope) {\n throw new Error('not a .wpack archive (missing wairon-pack.yaml envelope)');\n }\n // Step 10: parse the envelope into the result manifest.\n const manifest = codec.parseManifest(decode(envelope.contents));\n // Step 11: enforce integrity BEFORE writing (throws on mismatch; no-op when none carried).\n codec.verifyIntegrity(manifest, files);\n // Step 12: write the approved, integrity-checked files as a directory tree.\n const directory = path.resolve(destDir);\n archive.writeTree(directory, files);\n // Step 13: assemble PackExtractionResult.\n const result: PackExtractionResult = {\n directory,\n entryPath: manifest.entry,\n manifest,\n name: manifest.name,\n kind: manifest.kind,\n entryCount: files.length,\n };\n // Step 14: return where the pack landed + its parsed manifest.\n return result;\n}\n\n// ── Spec-tree archive workflows (.waitree) ──────────────────────────────────\n\n/** Pack a project's spec tree — the supplied roots' .wai directories — into a .waitree. */\nexport function buildTreeArchive(\n roots: TreeRootSource[],\n projectName: string,\n stateId?: string,\n includeDerived?: boolean,\n): TreeBuildResult {\n // Step 1: initialize an empty archive file map and an empty packed-roots list.\n const files: PackFile[] = [];\n const packedRoots: string[] = [];\n // Step 2: pack each supplied root.\n for (const root of roots) {\n // Step 3: read this root's .wai directory recursively into a file map.\n const rootFiles = archive.readPackDir(root.waiDir);\n // Step 4: keep only portable design state.\n const portable = treecodec.selectTreeFiles(rootFiles, includeDerived === true);\n // Step 5 (packEnd): prefix with this root's project-relative path + '.wai/'.\n const prefix = treeRootPrefix(root.relativePath);\n for (const file of portable) files.push({ path: `${prefix}${file.path}`, contents: file.contents });\n packedRoots.push(normalizeRootPath(root.relativePath));\n }\n // Step 6: did the roots yield no files at all?\n if (files.length === 0) {\n // Step 7: an export that silently carries nothing is worse than a failure.\n throw new Error('tree export found no spec-tree files under the supplied roots');\n }\n // Step 8: build the unsealed envelope.\n const manifest: TreeArchiveManifest = {\n formatVersion: 1,\n projectName,\n roots: packedRoots,\n waironVersion: SDK_VERSION,\n includesDerived: includeDerived === true,\n };\n if (stateId !== undefined) manifest.stateId = stateId;\n // Step 9: seal integrity (entryDigests + digest + generatedBy/generatedAt).\n const sealed = treecodec.sealTreeIntegrity(\n manifest,\n files,\n `@wairon/sdk@${SDK_VERSION}`,\n new Date().toISOString(),\n );\n // Step 10: serialize the sealed manifest to canonical envelope text.\n const sealedText = treecodec.serializeTreeManifest(sealed);\n // Step 11: upsert wairon-tree.yaml (sealed envelope text) into the file map.\n const finalFiles: PackFile[] = [\n ...files.filter((file) => file.path !== treecodec.TREE_ENVELOPE_FILENAME),\n { path: treecodec.TREE_ENVELOPE_FILENAME, contents: encode(sealedText) },\n ];\n // Step 12: deflate the files + envelope into .waitree archive bytes.\n const archiveBytes = archive.assembleArchive(finalFiles);\n // Step 13: derive the suggested file name from the project name.\n const suggestedFileName = `${slugify(projectName)}.waitree`;\n // Step 14: return the build result.\n return { archive: archiveBytes, manifest: sealed, suggestedFileName, fileCount: files.length };\n}\n\n/** Inspect a .waitree archive without extracting it. */\nexport function inspectTreeArchive(archiveBytes: Uint8Array): TreeArchiveInfo {\n // Step 1: enumerate archive entries without inflating.\n const entries = archive.listEntries(archiveBytes);\n // Step 2: is there no wairon-tree.yaml entry?\n if (!entries.some((entry) => entry.path === treecodec.TREE_ENVELOPE_FILENAME)) {\n // Step 3: reject a non-.waitree archive.\n throw new Error('not a .waitree archive (missing wairon-tree.yaml envelope)');\n }\n // Step 4 (readEnv): inflate just the envelope entry.\n const envelopeBytes = archive.inflateEntry(archiveBytes, treecodec.TREE_ENVELOPE_FILENAME);\n // Step 5: parse + version-check the envelope text.\n const manifest = treecodec.parseTreeManifest(decode(envelopeBytes));\n // Step 6: compute compatibility against the running wairon version.\n const compatible = treecodec.checkTreeCompatibility(manifest, SDK_VERSION);\n // Step 7: assemble TreeArchiveInfo from the manifest + archive stats.\n const fileEntries = entries.filter((entry) => entry.kind === 'file');\n const totalUncompressedBytes = entries.reduce((sum, entry) => sum + entry.uncompressedSize, 0);\n // Step 8: return the TreeArchiveInfo (no extraction performed).\n return { manifest, entryCount: fileEntries.length, totalUncompressedBytes, compatible };\n}\n\n/** Safely extract a .waitree archive into a destination project root under enforced limits. */\nexport function extractTreeArchive(\n archiveBytes: Uint8Array,\n destDir: string,\n limits?: PackExtractionLimits,\n refuseExecutableEntries?: boolean,\n): TreeExtractionResult {\n // Step 1: did the caller omit limits?\n const effectiveLimits = limits === undefined\n // Step 2: fall back to the codec's tree limit profile.\n ? treecodec.defaultTreeLimits()\n : limits;\n // Step 3 (list): enumerate archive entries without inflating (caps run pre-decompress).\n const entries = archive.listEntries(archiveBytes);\n // Step 4: compute the safe extraction plan (throws on any unsafe/oversized entry).\n const plan = treecodec.planTreeExtraction(entries, effectiveLimits);\n // Step 5: did the caller ask for the over-the-wire portability guard?\n if (refuseExecutableEntries === true) {\n // Step 6: refuse executable or non-spec-tree entries before anything is inflated.\n treecodec.assertPortableTreePaths(plan.paths);\n }\n // Step 7 (inflate): initialize an empty file list.\n const files: PackFile[] = [];\n // Step 8: inflate each approved path from the plan.\n for (const approvedPath of plan.paths) {\n // Step 9: inflate one approved entry.\n const contents = archive.inflateEntry(archiveBytes, approvedPath);\n // Step 10 (inflateEnd): append { path, contents } to the file list.\n files.push({ path: approvedPath, contents });\n }\n // Step 11: is the wairon-tree.yaml envelope missing from the inflated files?\n const envelope = files.find((file) => file.path === treecodec.TREE_ENVELOPE_FILENAME);\n if (!envelope) {\n // Step 12: reject a non-.waitree archive.\n throw new Error('not a .waitree archive (missing wairon-tree.yaml envelope)');\n }\n // Step 13 (parse): parse the envelope into the result manifest.\n const manifest = treecodec.parseTreeManifest(decode(envelope.contents));\n // Step 14: enforce integrity BEFORE writing (throws on mismatch; no-op when none carried).\n treecodec.verifyTreeIntegrity(manifest, files);\n // Step 15: write the approved, integrity-checked files as a directory tree.\n const directory = path.resolve(destDir);\n archive.writeTree(directory, files);\n // Step 16: assemble TreeExtractionResult.\n const result: TreeExtractionResult = {\n destDir: directory,\n manifest,\n roots: manifest.roots,\n writtenPaths: files.map((file) => file.path),\n };\n // Step 17: return where the tree landed + its parsed manifest.\n return result;\n}\n\n// --- helpers ---------------------------------------------------------------\n\n/** The archive-path prefix for one packed root: '.wai/' at the top, else '<dir>/.wai/'. */\nfunction treeRootPrefix(relativePath: string): string {\n const normalized = normalizeRootPath(relativePath);\n return normalized === '.' ? '.wai/' : `${normalized}/.wai/`;\n}\n\n/** A packed root's canonical project-relative form: POSIX separators, '.' for the top root. */\nfunction normalizeRootPath(relativePath: string): string {\n const posix = relativePath.split(path.sep).join('/').replace(/^\\.\\//, '').replace(/\\/+$/, '');\n return posix === '' || posix === '.' ? '.' : posix;\n}\n\n/** A file-name-safe stem for a project name. */\nfunction slugify(projectName: string): string {\n const slug = projectName\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return slug || 'spec-tree';\n}\n\nfunction readInnerIdentity(files: PackFile[], manifest: PackArchiveManifest): { name: string; version: string } {\n const innerPath = manifest.kind === 'code' ? 'package.json' : manifest.entry;\n const inner = files.find((file) => file.path === innerPath);\n if (!inner) throw new Error(`pack build: inner pack manifest \"${innerPath}\" is missing`);\n const parsed = (manifest.kind === 'code'\n ? JSON.parse(decode(inner.contents))\n : yamlLoad(decode(inner.contents))) as Record<string, unknown> | null;\n const name = parsed?.name;\n const version = parsed?.version;\n if (typeof name !== 'string' || typeof version !== 'string') {\n throw new Error(`pack build: inner pack manifest \"${innerPath}\" lacks a name/version`);\n }\n return { name, version };\n}\n\nfunction upsertEnvelope(files: PackFile[], envelopeText: string): PackFile[] {\n const others = files.filter((file) => file.path !== codec.ENVELOPE_FILENAME);\n return [...others, { path: codec.ENVELOPE_FILENAME, contents: encode(envelopeText) }];\n}\n\nfunction buildInfo(manifest: PackArchiveManifest, files: PackFile[]): PackArchiveInfo {\n const totalUncompressedBytes = files.reduce((sum, file) => sum + file.contents.length, 0);\n const info: PackArchiveInfo = {\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n formatVersion: manifest.formatVersion,\n entryCount: files.length,\n totalUncompressedBytes,\n compatible: true,\n };\n if (manifest.minWaironVersion !== undefined) info.minWaironVersion = manifest.minWaironVersion;\n return info;\n}\n","import { load as yamlLoad, dump as yamlDump } from 'js-yaml';\nimport { createHash } from 'crypto';\nimport type {\n ArchiveEntryMeta,\n PackArchiveManifest,\n PackExtractionLimits,\n PackExtractionPlan,\n PackFile,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// Pack Codec (pack_codec_impl) — PURE format + safety logic, no I/O.\n//\n// planExtraction is the single safety chokepoint (zip-slip / size / ratio /\n// depth / symlink guards, all pre-decompress). sealIntegrity/verifyIntegrity\n// are the produce/verify integrity pair. The codec stays pure: build time is\n// passed in, never read here.\n// ---------------------------------------------------------------------------\n\n/** The archive-root envelope filename. */\nexport const ENVELOPE_FILENAME = 'wairon-pack.yaml';\n\n/** The highest pack-archive format major this SDK understands. */\nconst SUPPORTED_FORMAT_VERSION = 1;\n\n/** The default extraction-safety profile: 4096 / 32 MiB / 8 MiB / 100:1 / depth 16. */\nconst DEFAULTS = {\n maxEntries: 4096,\n maxTotalUncompressedBytes: 32 * 1024 * 1024,\n maxEntryBytes: 8 * 1024 * 1024,\n maxCompressionRatio: 100,\n maxDepth: 16,\n} as const;\n\n/** Parse + validate the envelope text into a PackArchiveManifest; throws on malformed/newer-major. */\nexport function parseManifest(text: string): PackArchiveManifest {\n // Step 1: parse the envelope YAML text (throws on malformed YAML).\n const raw = yamlLoad(text);\n // Step 2: validate the required fields are present and well-typed.\n const manifest = validateEnvelope(raw);\n // Step 3: is the format major newer than this wairon supports?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: fail loudly rather than silently mis-read a newer format.\n throw new Error('unsupported pack-archive formatVersion (newer than this wairon understands)');\n }\n // Step 5: return the parsed manifest.\n return manifest;\n}\n\n/** Serialize a manifest to canonical wairon-pack.yaml text (build path). */\nexport function serializeManifest(manifest: PackArchiveManifest): string {\n // Step 1: drop undefined optional fields for a clean, canonical envelope.\n const clean: Record<string, unknown> = {\n formatVersion: manifest.formatVersion,\n name: manifest.name,\n version: manifest.version,\n kind: manifest.kind,\n entry: manifest.entry,\n };\n if (manifest.minWaironVersion !== undefined) clean.minWaironVersion = manifest.minWaironVersion;\n if (manifest.digest !== undefined) clean.digest = manifest.digest;\n if (manifest.entryDigests !== undefined) clean.entryDigests = manifest.entryDigests;\n if (manifest.generatedBy !== undefined) clean.generatedBy = manifest.generatedBy;\n if (manifest.generatedAt !== undefined) clean.generatedAt = manifest.generatedAt;\n // Step 2: return the wairon-pack.yaml text.\n return yamlDump(clean, { sortKeys: false });\n}\n\n/** The default extraction-safety profile; callers override individual caps. */\nexport function defaultLimits(): PackExtractionLimits {\n // Step 1: return the default caps profile.\n return { ...DEFAULTS };\n}\n\n/** Compute the safe extraction plan from enumerated entries under `limits`, or throw. */\nexport function planExtraction(entries: ArchiveEntryMeta[], limits: PackExtractionLimits): PackExtractionPlan {\n // Step 1: resolve effective caps — each field of `limits` over the defaults.\n const caps = {\n maxEntries: limits.maxEntries ?? DEFAULTS.maxEntries,\n maxTotalUncompressedBytes: limits.maxTotalUncompressedBytes ?? DEFAULTS.maxTotalUncompressedBytes,\n maxEntryBytes: limits.maxEntryBytes ?? DEFAULTS.maxEntryBytes,\n maxCompressionRatio: limits.maxCompressionRatio ?? DEFAULTS.maxCompressionRatio,\n maxDepth: limits.maxDepth ?? DEFAULTS.maxDepth,\n };\n // Step 2: initialize an empty approved-path list and a running total of 0.\n const approved: string[] = [];\n let total = 0;\n // Step 3: vet each enumerated entry.\n for (const entry of entries) {\n // Step 4: reject symlinks/non-regular entries and structurally unsafe paths.\n if (isSymlinkOrNonRegular(entry.kind) || isStructurallyUnsafePath(entry.path)) {\n rejectUnsafe();\n }\n // Directory entries are structural (writeTree recreates them from file\n // paths) — skip without approving, never inflate a 0-byte dir marker.\n if (entry.kind === 'dir') continue;\n // Step 5: normalize the entry path to a destination-relative POSIX path.\n const normalized = normalizeRelPath(entry.path);\n // Step 6: reject zip-slip and over-deep paths.\n if (escapesDestination(normalized) || pathDepth(normalized) > caps.maxDepth) {\n rejectUnsafe();\n }\n // Step 7: reject oversized entries and zip bombs.\n if (entry.uncompressedSize > caps.maxEntryBytes || compressionRatio(entry) > caps.maxCompressionRatio) {\n rejectUnsafe();\n }\n // Step 8 (vetEnd): accept — append the path and add its inflated size.\n approved.push(normalized);\n total += entry.uncompressedSize;\n }\n // Step 9: reject archives exceeding the aggregate caps.\n if (approved.length > caps.maxEntries || total > caps.maxTotalUncompressedBytes) {\n rejectUnsafe();\n }\n // Step 11: return the approved plan.\n return { paths: approved, totalUncompressedBytes: total };\n}\n\n/** Assert the envelope's name/version match the inner pack manifest; throw on mismatch. */\nexport function verifyIdentity(manifest: PackArchiveManifest, packName: string, packVersion: string): void {\n // Step 1: do envelope name/version differ from the inner pack manifest?\n if (manifest.name !== packName || manifest.version !== packVersion) {\n // Step 2: reject a tampered/mis-assembled archive.\n throw new Error('envelope identity mismatch (envelope name/version differ from the inner pack manifest)');\n }\n // Step 3: identity verified.\n}\n\n/** Verify every entry's sha256 against entryDigests; false when none carried, throws on mismatch. */\nexport function verifyIntegrity(manifest: PackArchiveManifest, files: PackFile[]): boolean {\n // Step 1: did the envelope carry no integrity data?\n if (!manifest.entryDigests) {\n // Step 2: no integrity data present — return false.\n return false;\n }\n const digests = manifest.entryDigests;\n // Step 3: check each file's digest.\n for (const file of files) {\n // The envelope carries these digests and cannot digest itself — skip it.\n if (file.path === ENVELOPE_FILENAME) continue;\n // Step 4: does the recomputed sha256 differ from the recorded digest?\n if (sha256(file.contents) !== digests[file.path]) {\n // Step 7: a digest mismatch means tampering.\n throw new Error('integrity digest mismatch');\n }\n // Step 5 (checkEnd): this file's digest matches.\n }\n // Step 6: all digests matched — return true.\n return true;\n}\n\n/** Produce-side partner of verifyIntegrity: fill entryDigests + digest + stamps. */\nexport function sealIntegrity(\n manifest: PackArchiveManifest,\n files: PackFile[],\n generatedBy: string,\n generatedAt: string,\n): PackArchiveManifest {\n // Step 1: initialize an empty entryDigests map.\n const entryDigests: Record<string, string> = {};\n // Step 2: hash each file.\n for (const file of files) {\n // The envelope is the carrier of these digests — never hash it into itself.\n if (file.path === ENVELOPE_FILENAME) continue;\n // Step 3 (hashEnd): compute sha256(file.contents) and record it under file.path.\n entryDigests[file.path] = sha256(file.contents);\n }\n // Step 4: compute an overall manifest digest over the sorted entryDigests.\n const digest = sha256(canonicalDigestBytes(entryDigests));\n // Step 5: set entryDigests, digest, generatedBy, generatedAt.\n // Step 6: return the sealed manifest.\n return { ...manifest, entryDigests, digest, generatedBy, generatedAt };\n}\n\n/** Whether the archive's formatVersion + minWaironVersion are compatible with `waironVersion`. */\nexport function checkCompatibility(manifest: PackArchiveManifest, waironVersion: string): boolean {\n // Step 1: is the archive format unsupported?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: incompatible.\n return false;\n }\n // Step 2: is the running wairon below the pack's minimum?\n if (manifest.minWaironVersion && isBelow(waironVersion, manifest.minWaironVersion)) {\n // Step 4: incompatible.\n return false;\n }\n // Step 3: compatible.\n return true;\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction rejectUnsafe(): never {\n throw new Error('reject: unsafe or oversized archive entry (zip-slip / size / ratio / depth guard)');\n}\n\nfunction validateEnvelope(raw: unknown): PackArchiveManifest {\n if (!raw || typeof raw !== 'object') {\n throw new Error('malformed pack envelope (not a YAML mapping)');\n }\n const o = raw as Record<string, unknown>;\n if (typeof o.formatVersion !== 'number') throw new Error('pack envelope: formatVersion must be a number');\n if (typeof o.name !== 'string' || !o.name) throw new Error('pack envelope: name is required');\n if (typeof o.version !== 'string' || !o.version) throw new Error('pack envelope: version is required');\n if (typeof o.kind !== 'string' || (o.kind !== 'declarative' && o.kind !== 'code')) {\n throw new Error('pack envelope: kind must be \"declarative\" or \"code\"');\n }\n if (typeof o.entry !== 'string' || !o.entry) throw new Error('pack envelope: entry is required');\n const manifest: PackArchiveManifest = {\n formatVersion: o.formatVersion,\n name: o.name,\n version: o.version,\n kind: o.kind,\n entry: o.entry,\n };\n if (typeof o.minWaironVersion === 'string') manifest.minWaironVersion = o.minWaironVersion;\n if (typeof o.digest === 'string') manifest.digest = o.digest;\n if (o.entryDigests && typeof o.entryDigests === 'object') {\n manifest.entryDigests = o.entryDigests as Record<string, string>;\n }\n if (typeof o.generatedBy === 'string') manifest.generatedBy = o.generatedBy;\n if (typeof o.generatedAt === 'string') manifest.generatedAt = o.generatedAt;\n return manifest;\n}\n\nfunction isSymlinkOrNonRegular(kind: string): boolean {\n return kind !== 'file' && kind !== 'dir';\n}\n\nfunction isStructurallyUnsafePath(p: string): boolean {\n if (p.includes('\\\\')) return true; // backslash\n if (/^[A-Za-z]:/.test(p)) return true; // drive letter\n if (p.startsWith('/')) return true; // absolute POSIX\n return p.split('/').some((seg) => seg === '..'); // parent traversal\n}\n\nfunction normalizeRelPath(p: string): string {\n return p\n .split('/')\n .filter((seg) => seg !== '' && seg !== '.')\n .join('/');\n}\n\nfunction escapesDestination(normalized: string): boolean {\n return normalized.startsWith('/') || normalized.split('/').some((seg) => seg === '..');\n}\n\nfunction pathDepth(normalized: string): number {\n return normalized.split('/').filter((seg) => seg !== '').length;\n}\n\nfunction compressionRatio(entry: ArchiveEntryMeta): number {\n if (entry.compressedSize > 0) return entry.uncompressedSize / entry.compressedSize;\n return entry.uncompressedSize > 0 ? Infinity : 0;\n}\n\nfunction canonicalDigestBytes(entryDigests: Record<string, string>): Uint8Array {\n const lines = Object.keys(entryDigests)\n .sort()\n .map((key) => `${key}:${entryDigests[key]}`)\n .join('\\n');\n return new TextEncoder().encode(lines);\n}\n\nfunction sha256(data: Uint8Array): string {\n return createHash('sha256').update(data).digest('hex');\n}\n\nfunction isBelow(running: string, minimum: string): boolean {\n const [rMaj, rMin, rPat] = parseSemverCore(running);\n const [mMaj, mMin, mPat] = parseSemverCore(minimum);\n if (rMaj !== mMaj) return rMaj < mMaj;\n if (rMin !== mMin) return rMin < mMin;\n return rPat < mPat;\n}\n\nfunction parseSemverCore(v: string): [number, number, number] {\n const cleaned = v.trim().replace(/^[^0-9]*/, ''); // strip leading ^, ~, >=, v, etc.\n const core = cleaned.split(/[-+]/)[0]; // drop prerelease/build metadata\n const parts = core.split('.').map((n) => parseInt(n, 10));\n return [parts[0] || 0, parts[1] || 0, parts[2] || 0];\n}\n","import { load as yamlLoad, dump as yamlDump } from 'js-yaml';\nimport { createHash } from 'crypto';\nimport type {\n ArchiveEntryMeta,\n PackExtractionLimits,\n PackExtractionPlan,\n PackFile,\n TreeArchiveManifest,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// Tree Codec (tree_codec_impl) — PURE format + safety logic for the `.waitree`\n// spec-tree archive, no I/O and no clock.\n//\n// selectTreeFiles is the single portability decision (what belongs in a tree\n// archive at all); planTreeExtraction is the single pre-decompress safety\n// chokepoint; assertPortableTreePaths is the over-the-wire executable guard;\n// sealTreeIntegrity/verifyTreeIntegrity are the produce/verify pair.\n//\n// The small pure path/digest helpers below deliberately mirror the pack codec's\n// rather than importing them: tree_codec declares NO dependencies, and reaching\n// into pack_codec for them would make one codec depend on the other for a\n// handful of one-line functions.\n// ---------------------------------------------------------------------------\n\n/** The tree-archive envelope filename. */\nexport const TREE_ENVELOPE_FILENAME = 'wairon-tree.yaml';\n\n/** The highest tree-archive format major this SDK understands. */\nconst SUPPORTED_FORMAT_VERSION = 1;\n\n/**\n * The tree caps profile: looser than the pack profile on entry count and total\n * size (a real spec tree is thousands of small YAML files across several\n * chained roots) and stricter on nothing.\n */\nconst TREE_DEFAULTS = {\n maxEntries: 20000,\n maxTotalUncompressedBytes: 64 * 1024 * 1024,\n maxEntryBytes: 8 * 1024 * 1024,\n maxCompressionRatio: 100,\n maxDepth: 24,\n} as const;\n\n/** Root-relative directories holding REGENERABLE artifacts — never portable design state. */\nconst DERIVED_ROOTS = ['generated', 'docs'];\n\n/** Executable extensions: a bundled code pack's entry can ride inside a tree. */\nconst EXECUTABLE_EXT_RE = /\\.(c|m)?js$/i;\n\n/** The directory every packed root's content lives under, inside the archive. */\nconst WAI_SEGMENT = '.wai';\n\n/** Parse + validate the envelope text into a TreeArchiveManifest; throws on malformed/newer-major. */\nexport function parseTreeManifest(text: string): TreeArchiveManifest {\n // Step 1: parse the envelope YAML text (throws on malformed YAML).\n const raw = yamlLoad(text);\n // Step 2: validate the required fields are present and well-typed.\n const manifest = validateEnvelope(raw);\n // Step 3: is the format major newer than this wairon supports?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: fail loudly rather than silently mis-read a newer format.\n throw new Error('unsupported tree-archive formatVersion (newer than this wairon understands)');\n }\n // Step 5: return the parsed manifest.\n return manifest;\n}\n\n/** Serialize a manifest to canonical wairon-tree.yaml text (export path). */\nexport function serializeTreeManifest(manifest: TreeArchiveManifest): string {\n // Step 1: drop undefined optional fields for a clean, canonical envelope.\n const clean: Record<string, unknown> = {\n formatVersion: manifest.formatVersion,\n projectName: manifest.projectName,\n roots: manifest.roots,\n };\n if (manifest.stateId !== undefined) clean.stateId = manifest.stateId;\n if (manifest.waironVersion !== undefined) clean.waironVersion = manifest.waironVersion;\n if (manifest.minWaironVersion !== undefined) clean.minWaironVersion = manifest.minWaironVersion;\n if (manifest.includesDerived !== undefined) clean.includesDerived = manifest.includesDerived;\n if (manifest.digest !== undefined) clean.digest = manifest.digest;\n if (manifest.entryDigests !== undefined) clean.entryDigests = manifest.entryDigests;\n if (manifest.generatedBy !== undefined) clean.generatedBy = manifest.generatedBy;\n if (manifest.generatedAt !== undefined) clean.generatedAt = manifest.generatedAt;\n // Step 2: return the wairon-tree.yaml text.\n return yamlDump(clean, { sortKeys: false });\n}\n\n/** The tree extraction-safety profile; callers override individual caps. */\nexport function defaultTreeLimits(): PackExtractionLimits {\n // Step 1: return the tree caps profile.\n return { ...TREE_DEFAULTS };\n}\n\n/**\n * Decide which of a root's files are portable design state: keep authored spec\n * state, drop regenerable artifacts unless the caller asked for them. Paths are\n * relative to the root's `.wai/` directory.\n */\nexport function selectTreeFiles(files: PackFile[], includeDerived: boolean): PackFile[] {\n // Step 1: did the caller ask for regenerable artifacts too?\n if (includeDerived) {\n // Step 2: return the file map unchanged — an explicit full-fidelity archive.\n return files;\n }\n // Step 3: drop every file under a regenerable root — a moved tree carries the\n // design, not its rendered output, which the destination regenerates.\n const kept = files.filter((file) => !isDerivedPath(file.path));\n // Step 4: return the portable design state.\n return kept;\n}\n\n/** Compute the safe extraction plan from enumerated entries under `limits`, or throw. */\nexport function planTreeExtraction(entries: ArchiveEntryMeta[], limits: PackExtractionLimits): PackExtractionPlan {\n // Step 1: resolve effective caps — each field of `limits` over the tree defaults.\n const caps = {\n maxEntries: limits.maxEntries ?? TREE_DEFAULTS.maxEntries,\n maxTotalUncompressedBytes: limits.maxTotalUncompressedBytes ?? TREE_DEFAULTS.maxTotalUncompressedBytes,\n maxEntryBytes: limits.maxEntryBytes ?? TREE_DEFAULTS.maxEntryBytes,\n maxCompressionRatio: limits.maxCompressionRatio ?? TREE_DEFAULTS.maxCompressionRatio,\n maxDepth: limits.maxDepth ?? TREE_DEFAULTS.maxDepth,\n };\n // Step 2: initialize an empty approved-path list and a running total of 0.\n const approved: string[] = [];\n let total = 0;\n // Step 3: vet each enumerated entry.\n for (const entry of entries) {\n // Step 4: reject symlinks/non-regular entries and structurally unsafe paths.\n if (isSymlinkOrNonRegular(entry.kind) || isStructurallyUnsafePath(entry.path)) {\n rejectUnsafe();\n }\n // Directory entries are structural (writeTree recreates them from file\n // paths) — skip without approving, never inflate a 0-byte dir marker.\n if (entry.kind === 'dir') continue;\n // Step 5: normalize the entry path to a destination-relative POSIX path.\n const normalized = normalizeRelPath(entry.path);\n // Step 6: reject zip-slip and over-deep paths.\n if (escapesDestination(normalized) || pathDepth(normalized) > caps.maxDepth) {\n rejectUnsafe();\n }\n // Step 7: reject oversized entries and zip bombs.\n if (entry.uncompressedSize > caps.maxEntryBytes || compressionRatio(entry) > caps.maxCompressionRatio) {\n rejectUnsafe();\n }\n // Step 8 (vetEnd): accept — append the path and add its inflated size.\n approved.push(normalized);\n total += entry.uncompressedSize;\n }\n // Step 9: reject archives exceeding the aggregate caps.\n if (approved.length > caps.maxEntries || total > caps.maxTotalUncompressedBytes) {\n rejectUnsafe();\n }\n // Step 11: return the approved plan.\n return { paths: approved, totalUncompressedBytes: total };\n}\n\n/**\n * Assert the planned paths carry no executable content and nothing outside a\n * spec-tree root. Called by any surface accepting an archive over the wire; a\n * local extraction on the developer's own machine may skip it.\n */\nexport function assertPortableTreePaths(paths: string[]): void {\n // Step 1: check each planned path.\n for (const entryPath of paths) {\n // Step 2: is this an executable file (a bundled code pack's entry)?\n if (EXECUTABLE_EXT_RE.test(entryPath)) {\n // Step 6 (rejectExecutable): same guidance the pack surface gives.\n throw new Error(\n 'refused: the archive carries executable content. Only declarative spec state transfers over this ' +\n 'surface; rule/code packs are executable and install via the trusted filesystem (mount into ' +\n 'WAIRON_PACKS_DIR, or run `wairon packs add`).',\n );\n }\n // Step 3: does the path sit outside any recognized spec-tree root?\n if (entryPath !== TREE_ENVELOPE_FILENAME && !isUnderWaiRoot(entryPath)) {\n // Step 7 (rejectForeign): a tree archive carries .wai trees, never arbitrary project files.\n throw new Error(`refused: the archive carries an entry outside any spec-tree root (\"${entryPath}\")`);\n }\n // Step 4 (checkEnd): this path is portable spec-tree content.\n }\n // Step 5: every path is portable.\n}\n\n/** Verify every entry's sha256 against entryDigests; false when none carried, throws on mismatch. */\nexport function verifyTreeIntegrity(manifest: TreeArchiveManifest, files: PackFile[]): boolean {\n // Step 1: did the envelope carry no integrity data?\n if (!manifest.entryDigests) {\n // Step 2: no integrity data present — return false.\n return false;\n }\n const digests = manifest.entryDigests;\n // Step 3: check each file's digest.\n for (const file of files) {\n // The envelope carries these digests and cannot digest itself — skip it.\n if (file.path === TREE_ENVELOPE_FILENAME) continue;\n // Step 4: does the recomputed sha256 differ from the recorded digest?\n if (sha256(file.contents) !== digests[file.path]) {\n // Step 7: a digest mismatch means tampering.\n throw new Error('tree integrity digest mismatch');\n }\n // Step 5 (checkEnd): this file's digest matches.\n }\n // Step 6: all digests matched — return true.\n return true;\n}\n\n/** Produce-side partner of verifyTreeIntegrity: fill entryDigests + digest + stamps. */\nexport function sealTreeIntegrity(\n manifest: TreeArchiveManifest,\n files: PackFile[],\n generatedBy: string,\n generatedAt: string,\n): TreeArchiveManifest {\n // Step 1: initialize an empty entryDigests map.\n const entryDigests: Record<string, string> = {};\n // Step 2: hash each file.\n for (const file of files) {\n // The envelope is the carrier of these digests — never hash it into itself.\n if (file.path === TREE_ENVELOPE_FILENAME) continue;\n // Step 3 (hashEnd): compute sha256(file.contents) and record it under file.path.\n entryDigests[file.path] = sha256(file.contents);\n }\n // Step 4: compute an overall manifest digest over the sorted entryDigests.\n const digest = sha256(canonicalDigestBytes(entryDigests));\n // Step 5: set entryDigests, digest, generatedBy, generatedAt.\n // Step 6: return the sealed manifest.\n return { ...manifest, entryDigests, digest, generatedBy, generatedAt };\n}\n\n/** Whether the archive's formatVersion + minWaironVersion are compatible with `waironVersion`. */\nexport function checkTreeCompatibility(manifest: TreeArchiveManifest, waironVersion: string): boolean {\n // Step 1: is the archive format unsupported?\n if (Math.trunc(manifest.formatVersion) > SUPPORTED_FORMAT_VERSION) {\n // Step 4: incompatible.\n return false;\n }\n // Step 2: is the running wairon below the archive's minimum?\n if (manifest.minWaironVersion && isBelow(waironVersion, manifest.minWaironVersion)) {\n // Step 4: incompatible.\n return false;\n }\n // Step 3: compatible.\n return true;\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction rejectUnsafe(): never {\n throw new Error('reject: unsafe or oversized tree-archive entry (zip-slip / size / ratio / depth guard)');\n}\n\nfunction validateEnvelope(raw: unknown): TreeArchiveManifest {\n if (!raw || typeof raw !== 'object') {\n throw new Error('malformed tree envelope (not a YAML mapping)');\n }\n const o = raw as Record<string, unknown>;\n if (typeof o.formatVersion !== 'number') throw new Error('tree envelope: formatVersion must be a number');\n if (typeof o.projectName !== 'string' || !o.projectName) throw new Error('tree envelope: projectName is required');\n if (!Array.isArray(o.roots) || o.roots.length === 0 || o.roots.some((r) => typeof r !== 'string' || !r)) {\n throw new Error('tree envelope: roots must be a non-empty list of project-relative directories');\n }\n const manifest: TreeArchiveManifest = {\n formatVersion: o.formatVersion,\n projectName: o.projectName,\n roots: o.roots as string[],\n };\n if (typeof o.stateId === 'string') manifest.stateId = o.stateId;\n if (typeof o.waironVersion === 'string') manifest.waironVersion = o.waironVersion;\n if (typeof o.minWaironVersion === 'string') manifest.minWaironVersion = o.minWaironVersion;\n if (typeof o.includesDerived === 'boolean') manifest.includesDerived = o.includesDerived;\n if (typeof o.digest === 'string') manifest.digest = o.digest;\n if (o.entryDigests && typeof o.entryDigests === 'object') {\n manifest.entryDigests = o.entryDigests as Record<string, string>;\n }\n if (typeof o.generatedBy === 'string') manifest.generatedBy = o.generatedBy;\n if (typeof o.generatedAt === 'string') manifest.generatedAt = o.generatedAt;\n return manifest;\n}\n\n/** True for a path under a regenerable root, relative to a root's .wai/ directory. */\nfunction isDerivedPath(relPath: string): boolean {\n const first = relPath.split('/')[0];\n return DERIVED_ROOTS.includes(first);\n}\n\n/** True when an archive path lives under some root's .wai/ directory. */\nfunction isUnderWaiRoot(archivePath: string): boolean {\n const segments = archivePath.split('/');\n // The .wai segment must exist AND carry content beneath it — a bare '.wai'\n // entry names a directory, not spec-tree state.\n const at = segments.indexOf(WAI_SEGMENT);\n return at >= 0 && at < segments.length - 1;\n}\n\nfunction isSymlinkOrNonRegular(kind: string): boolean {\n return kind !== 'file' && kind !== 'dir';\n}\n\nfunction isStructurallyUnsafePath(p: string): boolean {\n if (p.includes('\\\\')) return true; // backslash\n if (/^[A-Za-z]:/.test(p)) return true; // drive letter\n if (p.startsWith('/')) return true; // absolute POSIX\n return p.split('/').some((seg) => seg === '..'); // parent traversal\n}\n\nfunction normalizeRelPath(p: string): string {\n return p\n .split('/')\n .filter((seg) => seg !== '' && seg !== '.')\n .join('/');\n}\n\nfunction escapesDestination(normalized: string): boolean {\n return normalized.startsWith('/') || normalized.split('/').some((seg) => seg === '..');\n}\n\nfunction pathDepth(normalized: string): number {\n return normalized.split('/').filter((seg) => seg !== '').length;\n}\n\nfunction compressionRatio(entry: ArchiveEntryMeta): number {\n if (entry.compressedSize > 0) return entry.uncompressedSize / entry.compressedSize;\n return entry.uncompressedSize > 0 ? Infinity : 0;\n}\n\nfunction canonicalDigestBytes(entryDigests: Record<string, string>): Uint8Array {\n const lines = Object.keys(entryDigests)\n .sort()\n .map((key) => `${key}:${entryDigests[key]}`)\n .join('\\n');\n return new TextEncoder().encode(lines);\n}\n\nfunction sha256(data: Uint8Array): string {\n return createHash('sha256').update(data).digest('hex');\n}\n\nfunction isBelow(running: string, minimum: string): boolean {\n const [rMaj, rMin, rPat] = parseSemverCore(running);\n const [mMaj, mMin, mPat] = parseSemverCore(minimum);\n if (rMaj !== mMaj) return rMaj < mMaj;\n if (rMin !== mMin) return rMin < mMin;\n return rPat < mPat;\n}\n\nfunction parseSemverCore(v: string): [number, number, number] {\n const cleaned = v.trim().replace(/^[^0-9]*/, ''); // strip leading ^, ~, >=, v, etc.\n const core = cleaned.split(/[-+]/)[0]; // drop prerelease/build metadata\n const parts = core.split('.').map((n) => parseInt(n, 10));\n return [parts[0] || 0, parts[1] || 0, parts[2] || 0];\n}\n","// The running @wairon/sdk version — stamped into built archives (generatedBy)\n// and used as the \"running wairon version\" for pack version-compatibility\n// checks. tsup inlines package.json at build time; at runtime the require\n// resolves against the shipped package (../package.json from dist/).\n\nexport const SDK_VERSION: string = loadVersion();\n\nfunction loadVersion(): string {\n try {\n const pkg = require('../package.json') as { version?: string };\n return pkg.version ?? '0.0.0';\n } catch {\n return '0.0.0';\n }\n}\n","import type { PackFile, PackScaffoldRequest } from './types.js';\nimport { SDK_VERSION } from './version.js';\n\n// ---------------------------------------------------------------------------\n// Pack Scaffold Specialist (pack_scaffold_specialist_impl) — PURE template\n// rendering for `wairon pack init`. Produces an in-memory file map; writes\n// nothing. Code packs pin @wairon/sdk to the running SDK version.\n// ---------------------------------------------------------------------------\n\nconst enc = (s: string): Uint8Array => new TextEncoder().encode(s);\n\n/** Render the scaffold file map for the requested pack (declarative or code). */\nexport function render(request: PackScaffoldRequest): PackFile[] {\n const version = request.version ?? '0.1.0';\n let files: PackFile[];\n // Step 1: which variant?\n if (request.kind === 'code') {\n // Step 2: render the code-pack file map.\n files = renderCodePack(request.name, version);\n // Step 3: skip the declarative variant (fall through to the skill gate).\n } else {\n // Step 4 (declVariant): render the declarative-pack file map.\n files = renderDeclarativePack(request.name, version);\n }\n // Step 5 (skillGate): include a skill stub?\n if (request.withSkill) {\n // Step 6: append a skills/<id>/SKILL.md stub to the file map.\n files.push(renderSkillStub(request.name, version));\n }\n // Step 7 (done): return the rendered file map.\n return files;\n}\n\n// --- variant renderers -----------------------------------------------------\n\nfunction renderDeclarativePack(name: string, version: string): PackFile[] {\n return [\n { path: 'wairon-pack.yaml', contents: enc(declarativeEnvelope(name, version)) },\n { path: 'pack.yaml', contents: enc(declarativeManifest(name, version)) },\n { path: 'README.md', contents: enc(readme(name, 'declarative', 'pack.yaml')) },\n ];\n}\n\nfunction renderCodePack(name: string, version: string): PackFile[] {\n return [\n { path: 'wairon-pack.yaml', contents: enc(codeEnvelope(name, version)) },\n { path: 'package.json', contents: enc(codePackageJson(name, version)) },\n { path: 'tsconfig.json', contents: enc(codeTsconfig()) },\n { path: 'pack.ts', contents: enc(codeEntry(name, version)) },\n { path: 'README.md', contents: enc(readme(name, 'code', 'pack.cjs')) },\n ];\n}\n\nfunction renderSkillStub(name: string, _version: string): PackFile {\n const id = slug(name);\n return { path: `skills/${id}/SKILL.md`, contents: enc(skillStub(name)) };\n}\n\n// --- templates -------------------------------------------------------------\n\nfunction declarativeEnvelope(name: string, version: string): string {\n return [\n 'formatVersion: 1',\n `name: ${name}`,\n `version: ${version}`,\n 'kind: declarative',\n 'entry: pack.yaml',\n '',\n ].join('\\n');\n}\n\nfunction codeEnvelope(name: string, version: string): string {\n return [\n 'formatVersion: 1',\n `name: ${name}`,\n `version: ${version}`,\n 'kind: code',\n 'entry: pack.cjs',\n `minWaironVersion: ${SDK_VERSION}`,\n '',\n ].join('\\n');\n}\n\nfunction declarativeManifest(name: string, version: string): string {\n return [\n `name: ${name}`,\n `version: ${version}`,\n '',\n '# Custom architectural profiles this pack contributes (example, commented):',\n '# profiles:',\n '# my-profile:',\n '# family: backend-like',\n '# forbiddenStereotypes:',\n '# - types: [Adapter]',\n '# reason: \"Domain components must not touch adapters directly.\"',\n 'profiles: {}',\n '',\n '# Target language / platform tables (example, commented):',\n '# languages:',\n '# rust:',\n '# unsupportedFlow: {}',\n '# foreignBuiltins: []',\n 'languages: {}',\n '',\n '# Reusable, versioned architecture patterns:',\n 'patterns: []',\n '',\n ].join('\\n');\n}\n\nfunction codePackageJson(name: string, version: string): string {\n const pkg = {\n name,\n version,\n private: true,\n scripts: {\n build: 'esbuild pack.ts --bundle --platform=node --packages=external --format=cjs --outfile=pack.cjs',\n },\n dependencies: {\n '@wairon/sdk': SDK_VERSION,\n },\n devDependencies: {\n esbuild: '^0.21.0',\n typescript: '^5.0.0',\n },\n };\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nfunction codeTsconfig(): string {\n const tsconfig = {\n compilerOptions: {\n target: 'ES2020',\n module: 'CommonJS',\n moduleResolution: 'node',\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n declaration: false,\n noEmit: true,\n },\n include: ['pack.ts'],\n };\n return `${JSON.stringify(tsconfig, null, 2)}\\n`;\n}\n\nfunction codeEntry(name: string, version: string): string {\n const code = slug(name).toUpperCase().replace(/-/g, '_');\n return [\n \"import { defineRule } from '@wairon/sdk';\",\n \"import type { RuleContext, Finding } from '@wairon/sdk';\",\n '',\n 'const exampleRule = defineRule({',\n ` name: '${slug(name)}-example',`,\n \" description: 'Example architectural rule. Replace with your own doctrine.',\",\n ` codes: ['${code}_EXAMPLE'],`,\n ' check(ctx: RuleContext): Finding[] {',\n ' const findings: Finding[] = [];',\n ' for (const component of ctx.components) {',\n ' // Inspect the spec tree and push findings as needed.',\n ' void component;',\n ' }',\n ' return findings;',\n ' },',\n '});',\n '',\n 'export default {',\n ` name: '${name}',`,\n ` version: '${version}',`,\n ' rules: [exampleRule],',\n '};',\n '',\n ].join('\\n');\n}\n\nfunction readme(name: string, kind: string, entry: string): string {\n return [\n `# ${name}`,\n '',\n `A wairon ${kind} pack.`,\n '',\n `- Envelope: \\`wairon-pack.yaml\\``,\n `- Entry: \\`${entry}\\``,\n '',\n 'Build an installable `.wpack` archive with `wairon pack build`.',\n '',\n ].join('\\n');\n}\n\nfunction skillStub(name: string): string {\n return [\n '---',\n `name: ${name}`,\n `description: ${name} authoring skill (stub).`,\n '---',\n '',\n `# ${name}`,\n '',\n 'Describe when this skill applies and what it guides.',\n '',\n ].join('\\n');\n}\n\nfunction slug(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\nimport { zipSync, unzipSync, type Zippable } from 'fflate';\nimport type { ArchiveEntryMeta, PackFile } from './types.js';\n\n// ---------------------------------------------------------------------------\n// Pack Archive Adapter (pack_archive_adapter_impl) — the ONLY zip-library + fs\n// I/O boundary of the SDK. Technology: fflate (pure-JS ZIP, no native deps).\n//\n// Acts only on already-validated inputs: it makes no path-safety or format\n// decisions (that is the codec's job). Enumeration reads sizes WITHOUT\n// inflating so the codec can enforce zip-bomb / size caps before any bytes are\n// decompressed.\n// ---------------------------------------------------------------------------\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', '.hg', '.svn']);\n\n/**\n * Enumerate every entry's metadata (path, compressed + uncompressed size, kind)\n * WITHOUT decompressing any bytes, so the codec can enforce caps before\n * inflation.\n */\nexport function listEntries(archive: Uint8Array): ArchiveEntryMeta[] {\n // Step 1: read the central directory via the zip library, mapping each record\n // to ArchiveEntryMeta without inflating any data. fflate's filter reports\n // {name, size (compressed), originalSize (uncompressed)} for every entry;\n // returning false skips decompression. Symlink detection reads the central\n // directory's external attributes (fflate's metadata omits the unix mode).\n const symlinks = detectSymlinkNames(archive);\n const metas: ArchiveEntryMeta[] = [];\n unzipSync(archive, {\n filter: (info): boolean => {\n metas.push({\n path: info.name,\n uncompressedSize: info.originalSize,\n compressedSize: info.size,\n kind: classifyKind(info.name, symlinks),\n });\n return false;\n },\n });\n // Step 2: return the entry metadata list.\n return metas;\n}\n\n/** Decompress and return the bytes of a single named entry. */\nexport function inflateEntry(archive: Uint8Array, entryPath: string): Uint8Array {\n // Step 1: locate the named entry and inflate only it.\n const inflated = unzipSync(archive, { filter: (info): boolean => info.name === entryPath });\n const bytes = inflated[entryPath];\n if (!bytes) throw new Error(`archive entry not found: ${entryPath}`);\n // Step 2: return the entry's decompressed bytes.\n return bytes;\n}\n\n/** Deflate a set of files (the envelope + pack contents) into a single ZIP buffer. */\nexport function assembleArchive(files: PackFile[]): Uint8Array {\n // Step 1: add each file to a zip container (deflating) and finalize.\n const zippable: Zippable = {};\n for (const file of files) zippable[file.path] = file.contents;\n const bytes = zipSync(zippable);\n // Step 2: return the archive bytes.\n return bytes;\n}\n\n/** Read a source pack directory recursively into a file map (POSIX paths + bytes). */\nexport function readPackDir(dir: string): PackFile[] {\n // Step 1: walk the directory recursively, reading each file into\n // { path: POSIX-relative, contents } (skipping node_modules and VCS dirs).\n const files: PackFile[] = [];\n walkPackDir(dir, dir, files);\n // Step 2: return the file map.\n return files;\n}\n\n/** Write a file map as a directory tree under destDir, creating parent directories. */\nexport function writeTree(destDir: string, files: PackFile[]): void {\n // Step 1: write each approved file.\n for (const file of files) {\n // Step 2 (writeEnd): create parent directories and write the file's bytes.\n const absolute = path.join(destDir, file.path);\n fs.mkdirSync(path.dirname(absolute), { recursive: true });\n fs.writeFileSync(absolute, file.contents);\n }\n // Step 3: done.\n}\n\n// --- helpers ---------------------------------------------------------------\n\nfunction classifyKind(name: string, symlinks: Set<string>): string {\n if (symlinks.has(name)) return 'symlink';\n if (name.endsWith('/')) return 'dir';\n return 'file';\n}\n\nfunction walkPackDir(root: string, current: string, out: PackFile[]): void {\n for (const entry of fs.readdirSync(current, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name)) continue;\n walkPackDir(root, path.join(current, entry.name), out);\n } else if (entry.isFile()) {\n const absolute = path.join(current, entry.name);\n const relative = path.relative(root, absolute).split(path.sep).join('/');\n out.push({ path: relative, contents: fs.readFileSync(absolute) });\n }\n }\n}\n\n// Best-effort central-directory scan for symlink entries (unix S_IFLNK in the\n// external file attributes). fflate's high-level metadata omits the unix mode,\n// so the codec's symlink rejection needs this. Any parse trouble yields an\n// empty set — no worse than fflate alone, and confinement/size caps still apply.\nfunction detectSymlinkNames(archive: Uint8Array): Set<string> {\n const names = new Set<string>();\n try {\n const eocd = findEocd(archive);\n if (eocd < 0) return names;\n let p = readU32(archive, eocd + 16); // central directory offset\n const count = readU16(archive, eocd + 10);\n const decoder = new TextDecoder();\n for (let i = 0; i < count; i++) {\n if (readU32(archive, p) !== 0x02014b50) break; // central file header sig\n const versionMadeBy = readU16(archive, p + 4);\n const nameLen = readU16(archive, p + 28);\n const extraLen = readU16(archive, p + 30);\n const commentLen = readU16(archive, p + 32);\n const externalAttrs = readU32(archive, p + 38);\n const name = decoder.decode(archive.subarray(p + 46, p + 46 + nameLen));\n if ((versionMadeBy >> 8) === 3) { // unix host\n const unixMode = (externalAttrs >>> 16) & 0xffff;\n if ((unixMode & 0o170000) === 0o120000) names.add(name);\n }\n p += 46 + nameLen + extraLen + commentLen;\n }\n } catch {\n return names;\n }\n return names;\n}\n\nfunction findEocd(buf: Uint8Array): number {\n const minRecord = 22;\n const lowerBound = Math.max(0, buf.length - (minRecord + 0xffff));\n for (let i = buf.length - minRecord; i >= lowerBound; i--) {\n if (readU32(buf, i) === 0x06054b50) return i;\n }\n return -1;\n}\n\nfunction readU16(buf: Uint8Array, off: number): number {\n return buf[off] | (buf[off + 1] << 8);\n}\n\nfunction readU32(buf: Uint8Array, off: number): number {\n return (buf[off] | (buf[off + 1] << 8) | (buf[off + 2] << 16) | (buf[off + 3] << 24)) >>> 0;\n}\n","// ---------------------------------------------------------------------------\n// Rule-authoring contract (the code-pack compile target).\n//\n// Code packs are written against `@wairon/sdk`, never against wairon core. This\n// is a small, stable, hand-authored facade — deliberately NOT core's fat\n// RuleContext. `defineRule` returns the rule unchanged (identity + type\n// inference); the runtime shape `{ name, description?, codes: string[], check }`\n// is exactly what the core extension loader duck-types.\n// ---------------------------------------------------------------------------\n\n/** Severity of a finding a pack rule emits. */\nexport type RuleSeverity = 'error' | 'warning';\n\n/** A single issue a pack rule reports about the spec tree. */\nexport interface Finding {\n /** Pack-local issue code (surfaced namespaced by wairon, e.g. `<PACK>_<CODE>`). */\n code: string;\n /** 'error' | 'warning'. */\n severity: RuleSeverity;\n /** Human-readable explanation of the violation. */\n message: string;\n /** The spec id the finding is anchored to (optional). */\n specId?: string;\n}\n\n/**\n * A read-only spec node as seen by a pack rule: its id/name plus arbitrary\n * further fields (kept open so the facade stays stable as the spec model grows).\n */\nexport interface RuleSpecNode {\n id: string;\n name?: string;\n [key: string]: unknown;\n}\n\n/**\n * The minimal, stable view of the spec tree a code-pack rule inspects. A rule\n * reads these collections and returns findings — it never mutates state and\n * never reaches into wairon core internals.\n */\nexport interface RuleContext {\n /** The L0 system spec. */\n system: RuleSpecNode;\n /** All L1 subsystem specs. */\n subsystems: RuleSpecNode[];\n /** All L2 component specs. */\n components: RuleSpecNode[];\n /** All L3 interface specs. */\n interfaces: RuleSpecNode[];\n /** All L4 implementation specs. */\n implementations: RuleSpecNode[];\n /** All shared type/value-object specs. */\n types: RuleSpecNode[];\n}\n\n/**\n * A programmatic conformance rule shipped by a code pack. Its runtime shape —\n * `{ name, description?, codes: string[], check }` — is what wairon's extension\n * loader duck-types when it loads a `pack.cjs`.\n */\nexport interface SddRule {\n /** Stable rule id (kebab-case), e.g. \"my-portal-transport\". */\n name: string;\n /** One-line description of what the rule enforces and why. */\n description?: string;\n /** The issue codes this rule can emit. */\n codes: string[];\n /** Inspect the spec tree and return findings (empty when clean). */\n check(ctx: RuleContext): Finding[];\n}\n\n/**\n * Author an SddRule with full type inference. Returns the rule unchanged — it\n * exists purely so code packs get typed authoring without importing anything\n * from wairon core.\n */\nexport function defineRule(rule: SddRule): SddRule {\n return rule;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAU;AAAA,MACV,SAAW;AAAA,MACX,UAAY;AAAA,MACZ,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,OAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAW;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,WAAa;AAAA,QACb,MAAQ;AAAA,QACR,cAAc;AAAA,QACd,OAAS;AAAA,MACX;AAAA,MACA,cAAgB;AAAA,QACd,QAAU;AAAA,QACV,WAAW;AAAA,MACb;AAAA,MACA,iBAAmB;AAAA,QACjB,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,QAAU;AAAA,QACV,MAAQ;AAAA,QACR,YAAc;AAAA,QACd,QAAU;AAAA,MACZ;AAAA,IACF;AAAA;AAAA;;;AChDA;AAAA;AAAA,mBAAAC;AAAA,EAAA,wBAAAC;AAAA,EAAA;AAAA,qBAAAC;AAAA,EAAA,0BAAAC;AAAA,EAAA,sBAAAC;AAAA,EAAA,0BAAAC;AAAA,EAAA,oBAAAC;AAAA;AAAA;;;ACAA,IAAAC,QAAsB;AACtB,IAAAC,kBAAiC;;;ACDjC,qBAAmD;AACnD,oBAA2B;AAmBpB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B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ACA,SAAO,EAAE,MAAM,QAAQ;AACzB;AAEA,SAAS,eAAe,OAAmB,cAAkC;AAC3E,QAAM,SAAS,MAAM,OAAO,CAAC,SAAS,KAAK,SAAe,iBAAiB;AAC3E,SAAO,CAAC,GAAG,QAAQ,EAAE,MAAY,mBAAmB,UAAU,OAAO,YAAY,EAAE,CAAC;AACtF;AAEA,SAAS,UAAU,UAA+B,OAAoC;AACpF,QAAM,yBAAyB,MAAM,OAAO,CAAC,KAAK,SAAS,MAAM,KAAK,SAAS,QAAQ,CAAC;AACxF,QAAM,OAAwB;AAAA,IAC5B,MAAM,SAAS;AAAA,IACf,SAAS,SAAS;AAAA,IAClB,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB,eAAe,SAAS;AAAA,IACxB,YAAY,MAAM;AAAA,IAClB;AAAA,IACA,YAAY;AAAA,EACd;AACA,MAAI,SAAS,qBAAqB,OAAW,MAAK,mBAAmB,SAAS;AAC9E,SAAO;AACT;;;AMnRO,SAAS,WAAW,MAAwB;AACjD,SAAO;AACT;;;APzDO,SAASC,cAAa,SAAwC;AAEnE,SAAoB,aAAa,OAAO;AAC1C;AAGO,SAASC,WAAU,WAAoC;AAE5D,SAAoB,UAAU,SAAS;AACzC;AAGO,SAASC,gBAAe,SAAsC;AAEnE,SAAoB,eAAe,OAAO;AAC5C;AAGO,SAASC,aACd,SACA,SACA,QACsB;AAEtB,SAAoB,YAAY,SAAS,SAAS,MAAM;AAC1D;AAGO,SAASC,kBACd,OACA,aACA,SACA,gBACiB;AAEjB,SAAoB,iBAAiB,OAAO,aAAa,SAAS,cAAc;AAClF;AAGO,SAASC,oBAAmB,SAAsC;AAEvE,SAAoB,mBAAmB,OAAO;AAChD;AAGO,SAASC,oBACd,SACA,SACA,QACA,yBACsB;AAEtB,SAAoB,mBAAmB,SAAS,SAAS,QAAQ,uBAAuB;AAC1F;","names":["exports","module","buildPack","buildTreeArchive","extractPack","extractTreeArchive","inspectArchive","inspectTreeArchive","scaffoldPack","path","import_js_yaml","yamlLoad","yamlDump","import_js_yaml","import_crypto","SUPPORTED_FORMAT_VERSION","yamlLoad","validateEnvelope","yamlDump","isSymlinkOrNonRegular","isStructurallyUnsafePath","rejectUnsafe","normalizeRelPath","escapesDestination","pathDepth","compressionRatio","sha256","canonicalDigestBytes","isBelow","parseSemverCore","relative","slug","yamlLoad","scaffoldPack","buildPack","inspectArchive","extractPack","buildTreeArchive","inspectTreeArchive","extractTreeArchive"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wairon/sdk",
3
- "version": "5.1.1-dev.7",
3
+ "version": "5.1.1-dev.9",
4
4
  "description": "Wairon pack-archive (.wpack) format authority and authoring toolkit — scaffold, build, inspect, and safely extract wairon extension packs.",
5
5
  "keywords": [
6
6
  "wairon",