@bitcobblers/wod-wiki-engine 0.63.2275 → 0.63.2276

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/agent.cjs CHANGED
@@ -850,12 +850,22 @@ async function ensureUserNotebookLanding(tx, notebookId, now) {
850
850
  seedOrigin: "user"
851
851
  });
852
852
  }
853
- async function createUserNotebookLanding(storage, rawName) {
853
+ var RESERVED_NOTEBOOK_SLUGS = new Set(
854
+ wodWikiCore.BUILTIN_NOTEBOOKS.map((b) => b.slug)
855
+ );
856
+ function resolveUserNotebookSlug(rawName, takenSlugs) {
854
857
  const trimmed = rawName.trim();
855
- let slug = trimmed.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "notebook";
856
- if (wodWikiCore.isNonPublishableNotebook(slug) || slug === "journal" || slug === "playground" || slug === "custom") {
857
- slug = `${slug}-user`;
858
+ let baseSlug = trimmed.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "notebook";
859
+ if (RESERVED_NOTEBOOK_SLUGS.has(baseSlug) || wodWikiCore.isNonPublishableNotebook(baseSlug)) {
860
+ baseSlug = `${baseSlug}-user`;
861
+ }
862
+ {
863
+ return baseSlug;
858
864
  }
865
+ }
866
+ async function createUserNotebookLanding(storage, rawName) {
867
+ const trimmed = rawName.trim();
868
+ const slug = resolveUserNotebookSlug(trimmed);
859
869
  const nbId = wodWikiCore.toNotebookId(slug);
860
870
  await storage.transaction(["notes"], "readwrite", async (tx) => {
861
871
  const existing = await tx.readonly("notes").get(nbId);
@@ -2125,13 +2135,14 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
2125
2135
  const res = options.isNotebookSubscribed(feedId, chunkId);
2126
2136
  subscribed = typeof res === "boolean" ? res : Boolean(await res);
2127
2137
  }
2138
+ const builtin = wodWikiCore.BUILTIN_NOTEBOOKS.find((b) => b.slug === slug);
2128
2139
  rows.push({
2129
2140
  id: notebookId,
2130
2141
  feedId,
2131
2142
  feedLabel: feedSourceId ?? "Yours (Local)",
2132
2143
  chunkId,
2133
2144
  slug,
2134
- label: landing?.title ?? slug,
2145
+ label: builtin ? builtin.name : landing?.title ?? slug,
2135
2146
  count,
2136
2147
  subscribed,
2137
2148
  installed: true,
@@ -4114,11 +4125,32 @@ async function setNotebookPublic(storage, notebookIdOrSlug, isPublic) {
4114
4125
  if (existing && (existing.feedOrigin === "feed" || existing.seedOrigin === "seed")) {
4115
4126
  throw new Error(`Subscribed feed notebooks cannot be published directly (${notebookId}). Clone into a user notebook first.`);
4116
4127
  }
4117
- const base = existing ?? {
4128
+ const slug = wodWikiCore.notebookSlugFromId(notebookId);
4129
+ const builtin = wodWikiCore.BUILTIN_NOTEBOOKS.find((b) => b.slug === slug);
4130
+ const canonicalTitle = builtin?.name ?? slug;
4131
+ const canonicalRawContent = builtin ? `---
4132
+ description: ${JSON.stringify(builtin.description)}
4133
+ icon: ${JSON.stringify(builtin.icon)}
4134
+ ---
4135
+
4136
+ # ${builtin.name}
4137
+ ` : `# ${slug}
4138
+ `;
4139
+ const needsTitleHeal = Boolean(builtin && (!existing?.title || existing.title === builtin.slug));
4140
+ const needsRawHeal = Boolean(
4141
+ existing && needsTitleHeal && existing.rawContent.trim() === `# ${builtin.slug}`
4142
+ );
4143
+ const base = existing ? {
4144
+ ...existing,
4145
+ ...needsTitleHeal ? { title: builtin.name } : {},
4146
+ ...needsRawHeal ? {
4147
+ rawContent: canonicalRawContent,
4148
+ sourceRevision: (existing.sourceRevision ?? 0) + 1
4149
+ } : {}
4150
+ } : {
4118
4151
  id: notebookId,
4119
- title: notebookId.slice("notebook/".length),
4120
- rawContent: `# ${notebookId.slice("notebook/".length)}
4121
- `,
4152
+ title: canonicalTitle,
4153
+ rawContent: canonicalRawContent,
4122
4154
  sourceRevision: 1,
4123
4155
  blocks: {},
4124
4156
  createdAt: Date.now(),
@@ -4423,7 +4455,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
4423
4455
  }
4424
4456
 
4425
4457
  // src/version.ts
4426
- var VERSION = "0.63.2275";
4458
+ var VERSION = "0.63.2276";
4427
4459
 
4428
4460
  // src/feed/qr.ts
4429
4461
  var APP_ORIGIN = "https://wod.wiki";
@@ -6375,12 +6407,13 @@ var wodNotebookListTool = defineAgentTool({
6375
6407
  const icon = typeof fm["icon"] === "string" ? fm["icon"].replace(/^"|"$/g, "") : "\u{1F4D3}";
6376
6408
  const isFeed = n.feedOrigin === "feed" || n.seedOrigin === "seed";
6377
6409
  const existing = byId.get(n.id);
6410
+ const isBuiltinDefault = existing?.origin === "default";
6378
6411
  byId.set(n.id, {
6379
6412
  notebookId: n.id,
6380
6413
  slug,
6381
- name: n.title || existing?.name || slug,
6414
+ name: isBuiltinDefault ? existing.name : n.title || existing?.name || slug,
6382
6415
  description: description || existing?.description || "",
6383
- icon: icon || existing?.icon || "\u{1F4D3}",
6416
+ icon: (icon !== "\u{1F4D3}" ? icon : existing?.icon) || icon,
6384
6417
  origin: existing?.origin ?? (isFeed ? "feed" : "user"),
6385
6418
  writable: !wodWikiCore.isSystemReadOnlyNotebook(n.id) && !isFeed,
6386
6419
  public: n.public === true,