@mulmoclaude/core 7.6.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/assets/helps/bug-report-faq.md +7 -7
  2. package/dist/collection/index.cjs +3 -3
  3. package/dist/collection/index.js +3 -3
  4. package/dist/collection/registry/server/index.cjs +3 -3
  5. package/dist/collection/registry/server/index.js +3 -3
  6. package/dist/collection/server/index.cjs +2 -2
  7. package/dist/collection/server/index.js +2 -2
  8. package/dist/collection-watchers/index.cjs +4 -4
  9. package/dist/collection-watchers/index.js +4 -4
  10. package/dist/{discovery-BSvWBOGB.cjs → discovery-D1cjgQRo.cjs} +4 -4
  11. package/dist/discovery-D1cjgQRo.cjs.map +1 -0
  12. package/dist/{discovery-DEhLlDVW.js → discovery-c5OKO0dI.js} +4 -4
  13. package/dist/discovery-c5OKO0dI.js.map +1 -0
  14. package/dist/{dist-CdSEjlVx.cjs → dist--k7dcIzm.cjs} +2 -2
  15. package/dist/dist--k7dcIzm.cjs.map +1 -0
  16. package/dist/{dist--searOB5.js → dist-Cb-KNFRA.js} +2 -2
  17. package/dist/dist-Cb-KNFRA.js.map +1 -0
  18. package/dist/errorMessage-BDEhi5qf.cjs +1 -0
  19. package/dist/errorMessage-BFkRmkyh.js +1 -0
  20. package/dist/{errors-BbH5CeKm.js → errors-D-LZwNSI.js} +2 -2
  21. package/dist/{errors-BbH5CeKm.js.map → errors-D-LZwNSI.js.map} +1 -1
  22. package/dist/{errors-B7ShVbIB.cjs → errors-DVKixTWx.cjs} +2 -2
  23. package/dist/{errors-B7ShVbIB.cjs.map → errors-DVKixTWx.cjs.map} +1 -1
  24. package/dist/feeds/server/index.cjs +5 -5
  25. package/dist/feeds/server/index.cjs.map +1 -1
  26. package/dist/feeds/server/index.js +5 -5
  27. package/dist/feeds/server/index.js.map +1 -1
  28. package/dist/google/index.cjs +3 -3
  29. package/dist/google/index.js +3 -3
  30. package/dist/{listen-OGOFPIdk.cjs → listen-Bu1QX69l.cjs} +2 -2
  31. package/dist/{listen-OGOFPIdk.cjs.map → listen-Bu1QX69l.cjs.map} +1 -1
  32. package/dist/{listen-Bm8N0g9o.js → listen-CPZX9gpR.js} +2 -2
  33. package/dist/{listen-Bm8N0g9o.js.map → listen-CPZX9gpR.js.map} +1 -1
  34. package/dist/notifier/index.cjs +1 -1
  35. package/dist/notifier/index.js +1 -1
  36. package/dist/{notifier-D7TmVus0.js → notifier-B3cqvwts.js} +2 -2
  37. package/dist/{notifier-D7TmVus0.js.map → notifier-B3cqvwts.js.map} +1 -1
  38. package/dist/{notifier-8R05SHLj.cjs → notifier-Cq2UbCTW.cjs} +2 -2
  39. package/dist/{notifier-8R05SHLj.cjs.map → notifier-Cq2UbCTW.cjs.map} +1 -1
  40. package/dist/plugin-vue/index.cjs +1 -1
  41. package/dist/plugin-vue/index.cjs.map +1 -1
  42. package/dist/plugin-vue/index.js +1 -1
  43. package/dist/plugin-vue/index.js.map +1 -1
  44. package/dist/prompt-files/index.cjs +1 -1
  45. package/dist/prompt-files/index.js +1 -1
  46. package/dist/{promptSafety-CYU_kLUL.js → promptSafety-B_Jbtlcb.js} +2 -2
  47. package/dist/{promptSafety-CYU_kLUL.js.map → promptSafety-B_Jbtlcb.js.map} +1 -1
  48. package/dist/{promptSafety-CF6OCtor.cjs → promptSafety-Ctl7rOvA.cjs} +2 -2
  49. package/dist/{promptSafety-CF6OCtor.cjs.map → promptSafety-Ctl7rOvA.cjs.map} +1 -1
  50. package/dist/remote-host/index.cjs +1 -1
  51. package/dist/remote-host/index.js +1 -1
  52. package/dist/remote-host/server/index.cjs +4 -4
  53. package/dist/remote-host/server/index.js +4 -4
  54. package/dist/{remote-host-BiCg_ioB.js → remote-host-DyAlq52o.js} +2 -2
  55. package/dist/{remote-host-BiCg_ioB.js.map → remote-host-DyAlq52o.js.map} +1 -1
  56. package/dist/{remote-host-neXWDACl.cjs → remote-host-gvsvPRli.cjs} +2 -2
  57. package/dist/{remote-host-neXWDACl.cjs.map → remote-host-gvsvPRli.cjs.map} +1 -1
  58. package/dist/remote-view/index.cjs +1 -1
  59. package/dist/remote-view/index.js +1 -1
  60. package/dist/runtime-plugins/extract.d.ts +6 -0
  61. package/dist/runtime-plugins/index.cjs +95 -15
  62. package/dist/runtime-plugins/index.cjs.map +1 -1
  63. package/dist/runtime-plugins/index.js +96 -16
  64. package/dist/runtime-plugins/index.js.map +1 -1
  65. package/dist/runtime-plugins/install.d.ts +2 -1
  66. package/dist/runtime-plugins/load.d.ts +2 -5
  67. package/dist/scheduler/index.cjs +2 -2
  68. package/dist/scheduler/index.js +2 -2
  69. package/dist/{server-BxwOUg_l.cjs → server-B6usmOfY.cjs} +5 -5
  70. package/dist/{server-BxwOUg_l.cjs.map → server-B6usmOfY.cjs.map} +1 -1
  71. package/dist/{server-C3HNV-PG.js → server-CtghuxhH.js} +5 -5
  72. package/dist/{server-C3HNV-PG.js.map → server-CtghuxhH.js.map} +1 -1
  73. package/dist/utils/index.cjs +2 -2
  74. package/dist/utils/index.js +2 -2
  75. package/dist/whisper/index.cjs +2 -2
  76. package/dist/whisper/index.js +2 -2
  77. package/dist/wiki/index.cjs +1 -1
  78. package/dist/wiki/index.js +1 -1
  79. package/dist/workspace-setup/index.js +1 -1
  80. package/dist/workspace-setup/index.js.map +1 -1
  81. package/package.json +1 -1
  82. package/dist/discovery-BSvWBOGB.cjs.map +0 -1
  83. package/dist/discovery-DEhLlDVW.js.map +0 -1
  84. package/dist/dist--searOB5.js.map +0 -1
  85. package/dist/dist-CdSEjlVx.cjs.map +0 -1
  86. package/dist/errorMessage-B-iVKe5R.cjs +0 -1
  87. package/dist/errorMessage-D-HWCI2W.js +0 -1
@@ -1,9 +1,9 @@
1
- import { c as isRecord, i as hasStringProp } from "../dist--searOB5.js";
1
+ import { c as isRecord, i as hasStringProp } from "../dist-Cb-KNFRA.js";
2
2
  import { n as isWithinRoot, r as realpathSyncOrNull, t as isInsideRoot } from "../containment-D_vAa6eT.js";
3
3
  import { t as writeJsonAtomic } from "../json-BizOSThv.js";
4
4
  import { n as writeFileAtomic } from "../atomic-C3NMg6-j.js";
5
5
  import { isPluginFactory } from "gui-chat-protocol";
6
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
6
+ import { closeSync, constants, existsSync, fstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
7
7
  import path from "node:path";
8
8
  import { createHash } from "node:crypto";
9
9
  import { constants as constants$1, mkdir, mkdtemp, open, readFile, rm, writeFile } from "node:fs/promises";
@@ -139,6 +139,53 @@ function extractTgz(tgzAbs, destDir) {
139
139
  throw err;
140
140
  }
141
141
  }
142
+ var removeQuietly = (dir) => {
143
+ try {
144
+ rmSync(dir, {
145
+ recursive: true,
146
+ force: true
147
+ });
148
+ } catch {}
149
+ };
150
+ function publishStaged(staging, destDir) {
151
+ try {
152
+ renameSync(staging, destDir);
153
+ } catch (err) {
154
+ removeQuietly(staging);
155
+ if (!isCacheValid(destDir)) throw err;
156
+ }
157
+ }
158
+ /** Unpack `bytes` (a gzipped npm tarball) to `destDir` so that no reader ever sees a partial tree, even
159
+ * with two processes (MulmoClaude and MulmoTerminal on one workspace) unpacking the same folder at once:
160
+ * into a unique sibling folder, completed with the marker, then renamed into place. The bytes are the
161
+ * ones the caller already read and keyed the folder by, so what is unpacked is what the key names. */
162
+ function extractBytesAtomically(bytes, destDir) {
163
+ if (isCacheValid(destDir)) return;
164
+ const parent = path.dirname(destDir);
165
+ mkdirSync(parent, { recursive: true });
166
+ const staging = mkdtempSync(path.join(parent, `.${path.basename(destDir)}-`));
167
+ try {
168
+ execFileSync("tar", [
169
+ "-xzf",
170
+ "-",
171
+ "-C",
172
+ staging,
173
+ "--strip-components=1"
174
+ ], {
175
+ input: bytes,
176
+ stdio: [
177
+ "pipe",
178
+ "pipe",
179
+ "pipe"
180
+ ]
181
+ });
182
+ writeMarker(path.join(staging, EXTRACT_MARKER));
183
+ publishStaged(staging, destDir);
184
+ } catch (err) {
185
+ removeQuietly(staging);
186
+ throw err;
187
+ }
188
+ }
142
189
  // src/runtime-plugins/containment.ts
143
190
  /** True when `file` exists and, with every link followed, is inside `root`. */
144
191
  function resolvesInside(file, root) {
@@ -310,9 +357,50 @@ function ensureInsideBase(candidate, base) {
310
357
  /** Make a ledger entry's cache directory ready to load: both of its paths anchored inside their
311
358
  * roots, its tgz present, and the tgz extracted unless a complete extract is already there.
312
359
  * Returns the cache directory, or null (logged) when the entry cannot be loaded. */
360
+ var MAX_PACKAGE_FILE_BYTES = 52428800;
361
+ var READ_CHUNK_BYTES$1 = 65536;
362
+ var READ_FLAGS$1 = constants.O_RDONLY | (constants.O_NONBLOCK ?? 0);
363
+ function readChunks(fileHandle, maxBytes) {
364
+ const chunks = [];
365
+ let received = 0;
366
+ for (;;) {
367
+ const chunk = Buffer.alloc(READ_CHUNK_BYTES$1);
368
+ const bytesRead = readSync(fileHandle, chunk, 0, READ_CHUNK_BYTES$1, null);
369
+ if (bytesRead === 0) return Buffer.concat(chunks, received);
370
+ received += bytesRead;
371
+ if (received > maxBytes) return null;
372
+ chunks.push(chunk.subarray(0, bytesRead));
373
+ }
374
+ }
375
+ /** The package file's bytes, or null when it is not a regular file or grows past the limit while read. */
376
+ function readPackageFile$1(tgzAbs) {
377
+ const fileHandle = openSync(tgzAbs, READ_FLAGS$1);
378
+ try {
379
+ return fstatSync(fileHandle).isFile() ? readChunks(fileHandle, MAX_PACKAGE_FILE_BYTES) : null;
380
+ } finally {
381
+ closeSync(fileHandle);
382
+ }
383
+ }
384
+ function loggedPackageBytes(tgzAbs, entry, log) {
385
+ try {
386
+ const bytes = readPackageFile$1(tgzAbs);
387
+ if (bytes === null) log.warn("tgz is not a package file within the size limit — skipping", {
388
+ name: entry.name,
389
+ tgz: entry.tgz
390
+ });
391
+ return bytes;
392
+ } catch (err) {
393
+ log.error("tgz unreadable — skipping", {
394
+ name: entry.name,
395
+ tgz: entry.tgz,
396
+ error: String(err)
397
+ });
398
+ return null;
399
+ }
400
+ }
313
401
  function prepareLedgerEntry(entry, roots, log) {
314
402
  const tgzAbs = path.join(roots.pluginsDir, entry.tgz);
315
- const cachePath = path.join(roots.cacheDir, entry.name, entry.version);
403
+ const versionDir = path.join(roots.cacheDir, entry.name, entry.version);
316
404
  if (!ensureInsideBase(tgzAbs, roots.pluginsDir)) {
317
405
  log.warn("ledger entry tgz escapes plugins root — skipping", {
318
406
  name: entry.name,
@@ -320,7 +408,7 @@ function prepareLedgerEntry(entry, roots, log) {
320
408
  });
321
409
  return null;
322
410
  }
323
- if (!ensureInsideBase(cachePath, roots.cacheDir)) {
411
+ if (!ensureInsideBase(versionDir, roots.cacheDir)) {
324
412
  log.warn("ledger entry escapes plugin cache root — skipping", {
325
413
  name: entry.name,
326
414
  version: entry.version
@@ -334,8 +422,11 @@ function prepareLedgerEntry(entry, roots, log) {
334
422
  });
335
423
  return null;
336
424
  }
425
+ const bytes = loggedPackageBytes(tgzAbs, entry, log);
426
+ if (bytes === null) return null;
427
+ const cachePath = path.join(versionDir, createHash("sha256").update(bytes).digest("hex"));
337
428
  if (!isCacheValid(cachePath)) try {
338
- extractTgz(tgzAbs, cachePath);
429
+ extractBytesAtomically(bytes, cachePath);
339
430
  log.info("extracted", {
340
431
  name: entry.name,
341
432
  version: entry.version
@@ -998,16 +1089,6 @@ async function preparePlan(source, deps) {
998
1089
  raw: ledger.raw
999
1090
  };
1000
1091
  }
1001
- async function dropStaleCache(plan, raw, paths) {
1002
- const sameVersion = parseLedger(raw).filter((entry) => entry.name === plan.name && entry.version === plan.version);
1003
- if (sameVersion.length > 0 && sameVersion.every((entry) => entry.tgz === plan.tgz)) return;
1004
- const cacheDir = paths.cacheDir ?? path.join(paths.pluginsDir, ".cache");
1005
- const stale = path.join(cacheDir, plan.name, plan.version);
1006
- if (ensureInsideBase(stale, cacheDir)) await rm(stale, {
1007
- recursive: true,
1008
- force: true
1009
- });
1010
- }
1011
1092
  async function writePackageFile(plan, bytes, pluginsDir) {
1012
1093
  const tgzPath = path.join(pluginsDir, plan.tgz);
1013
1094
  const fileWasThere = existsSync(tgzPath);
@@ -1029,7 +1110,6 @@ async function commit(plan, bytes, raw, deps) {
1029
1110
  source: plan.source
1030
1111
  };
1031
1112
  try {
1032
- await dropStaleCache(plan, raw, deps.paths);
1033
1113
  await writeLedger(deps.paths.ledgerPath, withLedgerEntry(raw, entry));
1034
1114
  } catch (err) {
1035
1115
  if (!fileWasThere) await rm(tgzPath, { force: true });