@mulmoclaude/collection-plugin 0.5.3 → 0.5.7

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 (36) hide show
  1. package/dist/server/host.d.ts +25 -0
  2. package/dist/server/host.d.ts.map +1 -1
  3. package/dist/server/index.d.ts +1 -1
  4. package/dist/server/index.d.ts.map +1 -1
  5. package/dist/server/io.d.ts +6 -0
  6. package/dist/server/io.d.ts.map +1 -1
  7. package/dist/server.cjs +32 -8
  8. package/dist/server.cjs.map +1 -1
  9. package/dist/server.js +31 -9
  10. package/dist/server.js.map +1 -1
  11. package/dist/style.css +19 -3
  12. package/dist/vue/components/CollectionCustomView.vue.d.ts +19 -1
  13. package/dist/vue/components/CollectionCustomView.vue.d.ts.map +1 -1
  14. package/dist/vue/components/CollectionRecordPanel.vue.d.ts +4 -2
  15. package/dist/vue/components/CollectionRecordPanel.vue.d.ts.map +1 -1
  16. package/dist/vue/components/CollectionView.vue.d.ts.map +1 -1
  17. package/dist/vue/lang/de.d.ts.map +1 -1
  18. package/dist/vue/lang/en.d.ts +2 -0
  19. package/dist/vue/lang/en.d.ts.map +1 -1
  20. package/dist/vue/lang/es.d.ts.map +1 -1
  21. package/dist/vue/lang/fr.d.ts.map +1 -1
  22. package/dist/vue/lang/index.d.ts +2 -0
  23. package/dist/vue/lang/index.d.ts.map +1 -1
  24. package/dist/vue/lang/ja.d.ts.map +1 -1
  25. package/dist/vue/lang/ko.d.ts.map +1 -1
  26. package/dist/vue/lang/ptBR.d.ts.map +1 -1
  27. package/dist/vue/lang/zh.d.ts.map +1 -1
  28. package/dist/vue/uiContext.d.ts +12 -0
  29. package/dist/vue/uiContext.d.ts.map +1 -1
  30. package/dist/vue/useCollectionRendering.d.ts +2 -0
  31. package/dist/vue/useCollectionRendering.d.ts.map +1 -1
  32. package/dist/vue.cjs +240 -19
  33. package/dist/vue.cjs.map +1 -1
  34. package/dist/vue.js +241 -20
  35. package/dist/vue.js.map +1 -1
  36. package/package.json +2 -2
@@ -30,11 +30,35 @@ export interface CollectionHost {
30
30
  /** True for a preset-skill slug (host-owned naming convention). */
31
31
  isPresetSlug: (slug: string) => boolean;
32
32
  }
33
+ /** A collection's records changed on disk. Carries the `slug` so the host can
34
+ * publish on a per-collection channel; `ids` lists the affected record ids
35
+ * when known (a consumer may ignore them and refetch the whole collection),
36
+ * and `op` is advisory. Deliberately carries NO record bodies — this is a
37
+ * "refetch" ping, not a data feed, so it stays cheap and leaks nothing when a
38
+ * host relays it into an opaque-origin custom-view iframe. */
39
+ export interface CollectionChangePayload {
40
+ slug: string;
41
+ ids?: string[];
42
+ op?: "upsert" | "delete";
43
+ }
44
+ type CollectionChangePublisher = (payload: CollectionChangePayload) => void;
33
45
  /** Wire the engine to a host. Call once at server startup, before any
34
46
  * collection storage operation. Re-binding to a *different* host throws —
35
47
  * silently redirecting later filesystem operations to another workspace
36
48
  * would be a bug, not a feature. Re-calling with the same host is a no-op. */
37
49
  export declare function configureCollectionHost(host: CollectionHost): void;
50
+ /** Wire a publisher that broadcasts record-change events; the host bridges it
51
+ * to its pubsub. Kept SEPARATE from `configureCollectionHost` because the
52
+ * host's pubsub instance isn't ready at host-binding time (the binding is set
53
+ * at the top of server startup, the pubsub later). Optional: left unset, every
54
+ * write is silent — the default for tests and for a host that doesn't want
55
+ * live view updates. Pass `null` to detach (test teardown). */
56
+ export declare function setCollectionChangePublisher(publish: CollectionChangePublisher | null): void;
57
+ /** Broadcast a record-change event if a publisher is wired (no-op otherwise).
58
+ * Called from the write path (`writeItem`/`deleteItem`). The wired publisher is
59
+ * expected to be fire-and-forget (it wraps its own pubsub call in try/catch),
60
+ * so this stays a thin pass-through and never throws into the write. */
61
+ export declare function publishCollectionChange(payload: CollectionChangePayload): void;
38
62
  /** The configured workspace root. Throws if the host never configured one. */
39
63
  export declare function getWorkspaceRoot(): string;
40
64
  export declare function userSkillsDir(): string;
@@ -50,4 +74,5 @@ export declare function isPresetSlug(slug: string): boolean;
50
74
  * `getWorkspaceRoot()`, which fails loudly because the engine cannot operate
51
75
  * without a workspace root. */
52
76
  export declare const log: CollectionLogger;
77
+ export {};
53
78
  //# sourceMappingURL=host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/server/host.ts"],"names":[],"mappings":"AAUA;mDACmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACjF,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAChF,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAChF,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAClF;AAED,MAAM,WAAW,cAAc;IAC7B;;6BAEyB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,GAAG,EAAE,gBAAgB,CAAC;IACtB;6EACyE;IACzE,KAAK,EAAE;QACL,+EAA+E;QAC/E,aAAa,EAAE,MAAM,CAAC;QACtB,mFAAmF;QACnF,gBAAgB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,MAAM,CAAC;QACpD,0EAA0E;QAC1E,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,MAAM,CAAC;QAC7C,oFAAoF;QACpF,gBAAgB,EAAE,CAAC,aAAa,EAAE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AASD,8EAA8E;AAC9E,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAKD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AACD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE9D;AACD,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEvD;AACD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE9D;AACD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;gCAKgC;AAChC,eAAO,MAAM,GAAG,EAAE,gBAKjB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { configureCollectionHost, getWorkspaceRoot, log, type CollectionHost, type CollectionLogger } from "./host";
1
+ export { configureCollectionHost, getWorkspaceRoot, log, setCollectionChangePublisher, publishCollectionChange, type CollectionHost, type CollectionLogger, type CollectionChangePayload, } from "./host";
2
2
  export type { LoadedCollection } from "./discoveredCollection";
3
3
  export * from "./paths";
4
4
  export * from "./templatePath";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,GAAG,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACpH,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,GAAG,EACH,4BAA4B,EAC5B,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -7,6 +7,12 @@ export interface IoOptions {
7
7
  * without touching `~/mulmoclaude/`. Same pattern as
8
8
  * `server/workspace/skills/catalog.ts#CatalogOptions`. */
9
9
  workspaceRoot?: string;
10
+ /** Collection slug this write/delete belongs to. When provided, a
11
+ * successful write/delete publishes a record-change event (see
12
+ * `publishCollectionChange`) so live views refetch. `writeItem` has no
13
+ * slug of its own (it's keyed by `dataDir`), so callers thread it through;
14
+ * omitting it just means no event is published (internal / test writes). */
15
+ slug?: string;
10
16
  }
11
17
  /** Read every record under `dataDir`. Returns [] if the dir doesn't
12
18
  * exist yet (legitimate first-use state). Malformed JSON files and
@@ -1 +1 @@
1
- {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/server/io.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,WAAW,SAAS;IACxB;;;;+DAI2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAoCD;;;;;iCAKiC;AACjC,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,G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UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,SAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkBjH;AAED;;2CAE2C;AAC3C,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;mEASmE;AACnE,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,EAClE,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,SAAc,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYxB;AAED;;;;;;gEAMgE;AAChE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAInG;AAED;;+DAE+D;AAC/D,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASzG;AA8BD;;;;+CAI+C;AAC/C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAS1F;AAiBD;;;4EAG4E;AAC5E,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAS/H"}
package/dist/server.cjs CHANGED
@@ -10,6 +10,7 @@ let node_crypto = require("node:crypto");
10
10
  let zod = require("zod");
11
11
  //#region src/server/host.ts
12
12
  var current = null;
13
+ var changePublisher = null;
13
14
  /** Wire the engine to a host. Call once at server startup, before any
14
15
  * collection storage operation. Re-binding to a *different* host throws —
15
16
  * silently redirecting later filesystem operations to another workspace
@@ -18,6 +19,22 @@ function configureCollectionHost(host) {
18
19
  if (current !== null && current !== host) throw new Error("@mulmoclaude/collection-plugin/server: configureCollectionHost() was already called with a different host");
19
20
  current = host;
20
21
  }
22
+ /** Wire a publisher that broadcasts record-change events; the host bridges it
23
+ * to its pubsub. Kept SEPARATE from `configureCollectionHost` because the
24
+ * host's pubsub instance isn't ready at host-binding time (the binding is set
25
+ * at the top of server startup, the pubsub later). Optional: left unset, every
26
+ * write is silent — the default for tests and for a host that doesn't want
27
+ * live view updates. Pass `null` to detach (test teardown). */
28
+ function setCollectionChangePublisher(publish) {
29
+ changePublisher = publish;
30
+ }
31
+ /** Broadcast a record-change event if a publisher is wired (no-op otherwise).
32
+ * Called from the write path (`writeItem`/`deleteItem`). The wired publisher is
33
+ * expected to be fire-and-forget (it wraps its own pubsub call in try/catch),
34
+ * so this stays a thin pass-through and never throws into the write. */
35
+ function publishCollectionChange(payload) {
36
+ changePublisher?.(payload);
37
+ }
21
38
  function requireHost() {
22
39
  if (current === null) throw new Error("@mulmoclaude/collection-plugin/server: configureCollectionHost() was not called by the host");
23
40
  return current;
@@ -394,13 +411,12 @@ async function writeItem(dataDir, itemId, item, opts = {}) {
394
411
  } finally {
395
412
  await handle.close();
396
413
  }
397
- return {
398
- kind: "ok",
399
- itemId: safeId,
400
- item
401
- };
402
- }
403
- await writeFileAtomic(filePath, payload);
414
+ } else await writeFileAtomic(filePath, payload);
415
+ if (opts.slug) publishCollectionChange({
416
+ slug: opts.slug,
417
+ ids: [safeId],
418
+ op: "upsert"
419
+ });
404
420
  return {
405
421
  kind: "ok",
406
422
  itemId: safeId,
@@ -426,6 +442,11 @@ async function deleteItem(dataDir, itemId, opts = {}) {
426
442
  const filePath = itemFilePath(dataDir, safeId);
427
443
  try {
428
444
  await (0, node_fs_promises.unlink)(filePath);
445
+ if (opts.slug) publishCollectionChange({
446
+ slug: opts.slug,
447
+ ids: [safeId],
448
+ op: "delete"
449
+ });
429
450
  return {
430
451
  kind: "ok",
431
452
  itemId: safeId
@@ -1437,7 +1458,8 @@ async function maybeSpawnSuccessor(slug, schema, dataDir, sourceItem, sourceId,
1437
1458
  try {
1438
1459
  const result = await writeItem(dataDir, computed.id, computed.record, {
1439
1460
  ...ioOpts,
1440
- refuseOverwrite: true
1461
+ refuseOverwrite: true,
1462
+ slug
1441
1463
  });
1442
1464
  if (result.kind === "ok") log.info("collections", "spawned successor", {
1443
1465
  slug,
@@ -1716,6 +1738,7 @@ exports.loadCollection = loadCollection;
1716
1738
  exports.log = log;
1717
1739
  exports.maybeSpawnSuccessor = maybeSpawnSuccessor;
1718
1740
  exports.parseCivil = parseCivil;
1741
+ exports.publishCollectionChange = publishCollectionChange;
1719
1742
  exports.readCustomViewHtml = readCustomViewHtml;
1720
1743
  exports.readItem = readItem;
1721
1744
  exports.readSkillTemplate = readSkillTemplate;
@@ -1725,6 +1748,7 @@ exports.resolveEvery = resolveEvery;
1725
1748
  exports.resolveTemplatePath = resolveTemplatePath;
1726
1749
  exports.safeRecordId = safeRecordId;
1727
1750
  exports.safeSlugName = safeSlugName;
1751
+ exports.setCollectionChangePublisher = setCollectionChangePublisher;
1728
1752
  exports.successorId = successorId;
1729
1753
  exports.toDetail = toDetail;
1730
1754
  exports.toSummary = toSummary;