@bitcobblers/wod-wiki-engine 0.63.2274 → 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,10 +850,22 @@ async function ensureUserNotebookLanding(tx, notebookId, now) {
850
850
  seedOrigin: "user"
851
851
  });
852
852
  }
853
+ var RESERVED_NOTEBOOK_SLUGS = new Set(
854
+ wodWikiCore.BUILTIN_NOTEBOOKS.map((b) => b.slug)
855
+ );
856
+ function resolveUserNotebookSlug(rawName, takenSlugs) {
857
+ const trimmed = rawName.trim();
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;
864
+ }
865
+ }
853
866
  async function createUserNotebookLanding(storage, rawName) {
854
867
  const trimmed = rawName.trim();
855
- let slug = trimmed.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "notebook";
856
- if (wodWikiCore.isNonPublishableNotebook(slug)) slug = `${slug}-user`;
868
+ const slug = resolveUserNotebookSlug(trimmed);
857
869
  const nbId = wodWikiCore.toNotebookId(slug);
858
870
  await storage.transaction(["notes"], "readwrite", async (tx) => {
859
871
  const existing = await tx.readonly("notes").get(nbId);
@@ -2123,13 +2135,14 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
2123
2135
  const res = options.isNotebookSubscribed(feedId, chunkId);
2124
2136
  subscribed = typeof res === "boolean" ? res : Boolean(await res);
2125
2137
  }
2138
+ const builtin = wodWikiCore.BUILTIN_NOTEBOOKS.find((b) => b.slug === slug);
2126
2139
  rows.push({
2127
2140
  id: notebookId,
2128
2141
  feedId,
2129
2142
  feedLabel: feedSourceId ?? "Yours (Local)",
2130
2143
  chunkId,
2131
2144
  slug,
2132
- label: landing?.title ?? slug,
2145
+ label: builtin ? builtin.name : landing?.title ?? slug,
2133
2146
  count,
2134
2147
  subscribed,
2135
2148
  installed: true,
@@ -4112,11 +4125,32 @@ async function setNotebookPublic(storage, notebookIdOrSlug, isPublic) {
4112
4125
  if (existing && (existing.feedOrigin === "feed" || existing.seedOrigin === "seed")) {
4113
4126
  throw new Error(`Subscribed feed notebooks cannot be published directly (${notebookId}). Clone into a user notebook first.`);
4114
4127
  }
4115
- 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
+ } : {
4116
4151
  id: notebookId,
4117
- title: notebookId.slice("notebook/".length),
4118
- rawContent: `# ${notebookId.slice("notebook/".length)}
4119
- `,
4152
+ title: canonicalTitle,
4153
+ rawContent: canonicalRawContent,
4120
4154
  sourceRevision: 1,
4121
4155
  blocks: {},
4122
4156
  createdAt: Date.now(),
@@ -4421,7 +4455,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
4421
4455
  }
4422
4456
 
4423
4457
  // src/version.ts
4424
- var VERSION = "0.63.2274";
4458
+ var VERSION = "0.63.2276";
4425
4459
 
4426
4460
  // src/feed/qr.ts
4427
4461
  var APP_ORIGIN = "https://wod.wiki";
@@ -6373,12 +6407,13 @@ var wodNotebookListTool = defineAgentTool({
6373
6407
  const icon = typeof fm["icon"] === "string" ? fm["icon"].replace(/^"|"$/g, "") : "\u{1F4D3}";
6374
6408
  const isFeed = n.feedOrigin === "feed" || n.seedOrigin === "seed";
6375
6409
  const existing = byId.get(n.id);
6410
+ const isBuiltinDefault = existing?.origin === "default";
6376
6411
  byId.set(n.id, {
6377
6412
  notebookId: n.id,
6378
6413
  slug,
6379
- name: n.title || existing?.name || slug,
6414
+ name: isBuiltinDefault ? existing.name : n.title || existing?.name || slug,
6380
6415
  description: description || existing?.description || "",
6381
- icon: icon || existing?.icon || "\u{1F4D3}",
6416
+ icon: (icon !== "\u{1F4D3}" ? icon : existing?.icon) || icon,
6382
6417
  origin: existing?.origin ?? (isFeed ? "feed" : "user"),
6383
6418
  writable: !wodWikiCore.isSystemReadOnlyNotebook(n.id) && !isFeed,
6384
6419
  public: n.public === true,
@@ -6581,6 +6616,7 @@ var noteListInputSchema = zod.z.strictObject({
6581
6616
  tag: zod.z.string().optional().describe("Filter to Notes carrying this tag label."),
6582
6617
  origin: zod.z.enum(["all", "user", "feed", "seed"]).optional().describe('Filter by Note origin ("user", "feed", "seed", or "all"; defaults to "all").'),
6583
6618
  includeSeed: zod.z.boolean().optional().describe("Include read-only Seed/Feed notes (default true; pass false for user-authored notes only)."),
6619
+ includeCatalog: zod.z.boolean().optional().describe("Include built-in entity catalog records (efforts, equipment, guides, dashboards). Defaults to false to match :note{}."),
6584
6620
  orphanedOnly: zod.z.boolean().optional().describe("When true, return only user Notes not belonging to any Notebook (equivalent to `:note{!notebook:*}`)."),
6585
6621
  limit: zod.z.number().int().min(1).max(200).optional().describe("Max notes to return (default 50).")
6586
6622
  });
@@ -6602,6 +6638,7 @@ var wodNoteListTool = defineAgentTool({
6602
6638
  async execute(args, ctx) {
6603
6639
  const targetNb = args.notebookId ? wodWikiCore.toNotebookId(args.notebookId) : void 0;
6604
6640
  const includeSeed = args.includeSeed ?? true;
6641
+ const includeCatalog = args.includeCatalog === true || Boolean(targetNb);
6605
6642
  const origin = args.origin ?? "all";
6606
6643
  const orphanedOnly = args.orphanedOnly === true;
6607
6644
  const searchLower = args.search?.trim().toLowerCase();
@@ -6633,8 +6670,13 @@ var wodNoteListTool = defineAgentTool({
6633
6670
  return { allNotes: notes, linkedNoteIdsForNb: linkedIds, noteIdsWithLinks: withLinks };
6634
6671
  }
6635
6672
  );
6673
+ let excludedCatalogCount = 0;
6636
6674
  const filtered = allNotes.filter((n) => {
6637
6675
  if (isLandingNote(n)) return false;
6676
+ if (!includeCatalog && wodWikiWql.isEntityCatalogNote(n)) {
6677
+ excludedCatalogCount += 1;
6678
+ return false;
6679
+ }
6638
6680
  const isSeedOrFeed = n.seedOrigin === "seed" || n.feedOrigin === "feed";
6639
6681
  if (origin === "user" && isSeedOrFeed) return false;
6640
6682
  if (origin === "feed" && n.feedOrigin !== "feed") return false;
@@ -6659,6 +6701,7 @@ var wodNoteListTool = defineAgentTool({
6659
6701
  }).sort((a, b) => (b.date ?? b.createdAt) - (a.date ?? a.createdAt));
6660
6702
  return {
6661
6703
  totalCount: filtered.length,
6704
+ ...excludedCatalogCount > 0 ? { excludedCatalogCount } : {},
6662
6705
  notes: filtered.slice(0, limit).map((n) => {
6663
6706
  const nbOrigin = wodWikiWql.notebookOriginOfItem(n);
6664
6707
  const resolvedNb = wodWikiWql.notebookOfItem(n);