@mulmoclaude/core 5.8.1 → 5.9.0

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.
@@ -3,7 +3,7 @@ import "./errors-zTAsW7dS.js";
3
3
  import { n as writeFileAtomic } from "./root-BcS4-Kge.js";
4
4
  import { n as toPosixRelPath } from "./relPath-DW8MC8VO.js";
5
5
  import { $ as fieldText, D as isCanonicalServerTime, K as COMPUTED_TYPES, Q as storageKindFor, X as isFieldDrivenEvery, Y as embedTargetId, et as fieldTextOrNull, f as parseIsoDate, p as parseIsoDateTime } from "./itemId-C9s-Jd5s.js";
6
- import { C as actionVisible, O as firstUnknownDefault, _ as uniqueRefTargets, b as projectBacklinkRow, c as selectDynamicRecord, f as itemIsDone, g as uniqueEmbedTargets, h as uniqueBacklinkSources, i as ownProp, k as schemaDefaults, n as deriveAll, o as firstDateField, s as resolveIcon, t as defangForPrompt, v as backlinkRows, x as rollupValue, y as coerceNumeric } from "./promptSafety-yG60Vof8.js";
6
+ import { A as schemaDefaults, S as rollupValue, b as coerceNumeric, c as selectDynamicRecord, f as itemIsDone, h as linkedSlugsForFields, i as ownProp, k as firstUnknownDefault, n as deriveAll, o as firstDateField, s as resolveIcon, t as defangForPrompt, w as actionVisible, x as projectBacklinkRow, y as backlinkRows } from "./promptSafety-DFaOnOWN.js";
7
7
  import { B as SCHEMA_FILE$1, C as CollectionQueryZ, G as resolveTemplatePath, H as isUnderRealRoot, O as isRegularFile, S as compileJsonlQuery, V as isContainedInRoot, W as resolveDataDir, Y as isBackendUnavailable, Z as archiveDir, at as isPresetSlug$1, b as queryCsv, c as resolveMutateSet, d as storeFor, f as checkpointSqliteDatabase, gt as stagingSkillDir, i as resolvePrimaryField, j as resolveCreateItemId, m as cacheDir, n as discoverCollections, q as safeSlugName, r as loadCollection, rt as getWorkspaceRoot, s as CollectionSchemaZ, st as log, u as readOnlyRefusal, y as normalizeCsvValue } from "./discovery-CbwHtcwk.js";
8
8
  import { ingestStatePath } from "./feeds/paths.js";
9
9
  import { mirrorSkillWrite } from "./skill-bridge/index.js";
@@ -342,16 +342,11 @@ async function loadTarget(slug, opts) {
342
342
  byId
343
343
  };
344
344
  }
345
- /** Load every ref/embed target and backlink source collection once.
345
+ /** Load each given ref/embed target and backlink source collection once.
346
346
  * Unknown / unloadable targets are simply absent — downstream derefs
347
347
  * resolve to null (em-dash) and backlinks to an empty row set, the
348
348
  * same fail-soft the UI renders. */
349
- async function loadLinkedTargets(schema, opts) {
350
- const slugs = [.../* @__PURE__ */ new Set([
351
- ...uniqueRefTargets(schema),
352
- ...uniqueEmbedTargets(schema),
353
- ...uniqueBacklinkSources(schema)
354
- ])];
349
+ async function loadLinkedTargets(slugs, opts) {
355
350
  const loaded = {};
356
351
  for (const slug of slugs) {
357
352
  const target = await loadTarget(slug, opts);
@@ -369,7 +364,7 @@ function toRefRecords(linked) {
369
364
  * DERIVED source records (`byId`), so `display`/`filter` on a derived
370
365
  * source column (an invoice `total`) works. */
371
366
  function projectBacklinks(field, schema, enriched, linked) {
372
- const source = linked[field.from];
367
+ const source = ownProp(linked, field.from);
373
368
  if (!source) return [];
374
369
  const selfId = fieldText(enriched[schema.primaryKey]);
375
370
  return backlinkRows(field, selfId, Object.values(source.byId)).map((row) => projectBacklinkRow(row, field.display, source.schema.primaryKey));
@@ -402,7 +397,7 @@ function projectRollups(schema, record, linked) {
402
397
  for (const [key, field] of Object.entries(schema.fields)) {
403
398
  if (field.type !== "rollup") continue;
404
399
  if (out === record) out = { ...record };
405
- const source = linked[field.from];
400
+ const source = ownProp(linked, field.from);
406
401
  const selfId = fieldText(record[schema.primaryKey]);
407
402
  out[key] = source ? rollupValue(field, selfId, Object.values(source.byId)) : null;
408
403
  }
@@ -411,10 +406,12 @@ function projectRollups(schema, record, linked) {
411
406
  /** Enrich records with every host-computed field: derived formulas
412
407
  * evaluated (cross-collection derefs included), toggles projected,
413
408
  * embeds resolved. Loads each linked collection ONCE per call. Input
414
- * records are not mutated. */
415
- async function enrichItems(collection, items, opts = {}) {
409
+ * records are not mutated. With `fields`, only the collections those
410
+ * fields read are loaded, so values OUTSIDE `fields` may be incomplete —
411
+ * the caller must project to `fields`. */
412
+ async function enrichItems(collection, items, opts = {}, fields) {
416
413
  const { schema } = collection;
417
- const linked = await loadLinkedTargets(schema, opts);
414
+ const linked = await loadLinkedTargets(linkedSlugsForFields(schema, fields), opts);
418
415
  const refRecords = toRefRecords(linked);
419
416
  return items.map((item) => projectComputed(schema, deriveAll(schema, projectRollups(schema, item, linked), refRecords), linked));
420
417
  }
@@ -1772,7 +1769,7 @@ async function handleGetItems(collection, args, deps) {
1772
1769
  const { ids, fields } = args;
1773
1770
  const { items, missing } = await loadRequestedItems(collection, ids, deps);
1774
1771
  if (!ids && !fields && items.length > 200) return `manageCollection: refused — '${collection.slug}' has ${items.length} records, over the unselective limit of 200. Pass \`ids\` for specific records or \`fields\` to project only the columns you need.`;
1775
- const enriched = await enrichItems(collection, items, deps);
1772
+ const enriched = await enrichItems(collection, items, deps, fields);
1776
1773
  const projected = fields ? enriched.map((item) => projectFields(item, fields, collection.schema.primaryKey)) : enriched;
1777
1774
  const warning = !ids || missing.length > 0 ? await recordIssuesWarning(collection, deps) : void 0;
1778
1775
  return JSON.stringify({
@@ -2477,4 +2474,4 @@ function makeManageCollectionTool(deps = {}) {
2477
2474
  //#endregion
2478
2475
  export { recordFieldProblem as A, stagedSkillDir as B, applyMutateAction as C, validateCollectionRecords as D, STORE_UNREADABLE as E, buildCollectionActionSeedPrompt as F, promptPathsFor as I, readCustomViewHtml as L, enrichItems as M, runQueryOverRows as N, validateRecordObject as O, buildActionSeedPrompt as P, readCustomViewI18n as R, schemaRelations as S, MAX_RECORD_ISSUES as T, resolveEvery as _, MAX_UNSELECTIVE_ITEMS as a, computeCollectionIcon as b, deleteCollection as c, computeSuccessor as d, daysInMonth as f, parseCivil as g, maybeSpawnSuccessor as h, MAX_SCHEMA_ISSUES as i, runCollectionQuery as j, compileRecordZ as k, deleteCollectionRefusalMessage as l, isTriggerDue as m, MAX_PUT_ITEMS as n, makeManageCollectionTool as o, formatCivil as p, MAX_PUT_LINT as r, deleteCustomView as s, MAX_ITEMS_FILE_BYTES as t, advanceTriggerDate as u, successorId as v, firstMutateParamProblem as w, buildWorkspaceOntology as x, ONE_SECOND_MS as y, readSkillTemplate as z };
2479
2476
 
2480
- //# sourceMappingURL=server-iYXYObKb.js.map
2477
+ //# sourceMappingURL=server-CVCc6JAO.js.map