@neocompose/cli 0.84.2 → 0.84.3

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.
@@ -21257,6 +21257,7 @@ function createdSessionValuesSince(ctx, checkpoint) {
21257
21257
  return created;
21258
21258
  }
21259
21259
  function exportInitializerCollections(created, writes, ctx) {
21260
+ const inPlace = (value) => value instanceof RuntimeSet ? exportRuntimeSetValue(value, ctx) : value;
21260
21261
  const assignedValues = /* @__PURE__ */ new Set();
21261
21262
  const mutatedIds = /* @__PURE__ */ new Set();
21262
21263
  for (const write of writes) {
@@ -21264,83 +21265,134 @@ function exportInitializerCollections(created, writes, ctx) {
21264
21265
  if (destination !== void 0 && "containerValueId" in destination)
21265
21266
  mutatedIds.add(destination.containerValueId);
21266
21267
  if (write.kind === "assign" && write.valueId === void 0 && typeof write.value === "object" && write.value !== null) {
21267
- assignedValues.add(write.value);
21268
+ assignedValues.add(inPlace(write.value));
21268
21269
  }
21269
21270
  }
21270
21271
  const candidates = /* @__PURE__ */ new Set();
21272
+ const inlineFieldsByRowId = /* @__PURE__ */ new Map();
21271
21273
  for (const row of created) {
21272
- if (assignedValues.has(row.value) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
21274
+ const inlineFields = inlineCollectionFields(row, ctx);
21275
+ if (inlineFields !== null) inlineFieldsByRowId.set(row.id, inlineFields);
21276
+ if (inlineFields !== null || assignedValues.has(inPlace(row.value)) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
21273
21277
  candidates.add(row.id);
21274
21278
  }
21275
21279
  }
21276
21280
  if (candidates.size === 0) return created;
21277
21281
  invalidateEvaluatorIndexes(ctx, null);
21278
21282
  const extra = [];
21279
- const exported = created.map((row) => {
21280
- if (!candidates.has(row.id)) return row;
21281
- const member = memberForValueRow(row, ctx);
21282
- if (member === null) return row;
21283
- if (!isMemberWithEntries(member)) return row;
21284
- if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
21285
- return { ...row, value: [] };
21286
- }
21287
- if (!assignedValues.has(row.value) && !mutatedIds.has(row.id)) return row;
21288
- const values = [];
21283
+ const encode = (member, value, genericEnv, collectionOwnerId) => {
21284
+ const rows = [];
21289
21285
  const declarations = /* @__PURE__ */ new Map();
21290
- const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
21291
- overlayConcreteGenericEntries(
21292
- genericEnv,
21293
- envFromStamp(row.genericBindings)
21294
- );
21295
- const materialized = materializeConstructorArgumentValue({
21286
+ const root = materializeConstructorArgumentValue({
21296
21287
  member,
21297
- value: row.value,
21288
+ value,
21298
21289
  genericEnv,
21299
21290
  ctx,
21300
- createdValues: values,
21291
+ createdValues: rows,
21301
21292
  createdById: /* @__PURE__ */ new Map(),
21302
21293
  storageKeyDeclarations: declarations,
21303
- collectionEntriesAreReferences: assignedValues.has(row.value) ? false : void 0,
21304
- collectionOwnerId: row.id
21294
+ collectionEntriesAreReferences: assignedValues.has(value) ? false : void 0,
21295
+ collectionOwnerId
21305
21296
  });
21306
- const encoded = { ...row, value: materialized.value };
21307
- const children = values.filter((value) => value !== materialized);
21308
- declarations.delete(materialized.id);
21309
- const groupId = constructorGroupForRow(row.id, ctx);
21310
- retargetConstructorGroupDependencies(
21311
- materialized.id,
21312
- groupId ?? row.id,
21313
- ctx
21314
- );
21297
+ const children = rows.filter((row) => row !== root);
21298
+ return { root, children, declarations };
21299
+ };
21300
+ const adopt = (owner, rootId, rows, declarations) => {
21301
+ const groupId = constructorGroupForRow(owner.id, ctx);
21302
+ retargetConstructorGroupDependencies(rootId, groupId ?? owner.id, ctx);
21315
21303
  if (groupId !== null) {
21316
21304
  const state = ctx.__executionState;
21317
21305
  const group = state?.constructorGroups.get(groupId);
21318
- for (const child of children) {
21319
- retargetConstructorGroupDependencies(child.id, groupId, ctx);
21320
- group?.add(child.id);
21321
- state?.constructorGroupByRowId.set(child.id, groupId);
21306
+ for (const row of rows) {
21307
+ retargetConstructorGroupDependencies(row.id, groupId, ctx);
21308
+ group?.add(row.id);
21309
+ state?.constructorGroupByRowId.set(row.id, groupId);
21322
21310
  }
21323
21311
  }
21324
- stampCreatedValuesMapKey(children, row.mapKey);
21312
+ stampCreatedValuesMapKey(rows, owner.mapKey);
21325
21313
  applyDeclaredStorageKeyOverrides({
21326
- createdValues: [encoded, ...children],
21314
+ createdValues: [owner, ...rows],
21327
21315
  declarationByValueId: declarations
21328
21316
  });
21329
- for (const child of children) {
21330
- if (!isLiteralValueContent(child)) {
21317
+ for (const row of rows) {
21318
+ if (!isLiteralValueContent(row)) {
21331
21319
  throw new NSGetterRuntimeError(
21332
21320
  "Initializer collection produced an unevaluated row."
21333
21321
  );
21334
21322
  }
21335
- extra.push(child);
21323
+ extra.push(row);
21336
21324
  }
21337
21325
  for (const [id, declaration] of declarations) {
21338
21326
  ctx.__createdStorageKeyDeclarations?.set(id, declaration);
21339
21327
  }
21328
+ };
21329
+ const exported = created.map((row) => {
21330
+ if (!candidates.has(row.id)) return row;
21331
+ const inlineFields = inlineFieldsByRowId.get(row.id);
21332
+ if (inlineFields !== void 0) {
21333
+ const record4 = { ...inlineFields.record };
21334
+ const encoded2 = { ...row, value: record4 };
21335
+ for (const [key, member2] of inlineFields.members) {
21336
+ const { root: root2, children: children2, declarations: declarations2 } = encode(
21337
+ member2,
21338
+ inPlace(record4[key]),
21339
+ inlineFields.genericEnv
21340
+ );
21341
+ record4[key] = root2.id;
21342
+ adopt(encoded2, root2.id, [root2, ...children2], declarations2);
21343
+ }
21344
+ return encoded2;
21345
+ }
21346
+ const member = memberForValueRow(row, ctx);
21347
+ if (member === null) return row;
21348
+ if (!isMemberWithEntries(member)) return row;
21349
+ if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
21350
+ return { ...row, value: [] };
21351
+ }
21352
+ const value = inPlace(row.value);
21353
+ if (!assignedValues.has(value) && !mutatedIds.has(row.id)) return row;
21354
+ const { root, children, declarations } = encode(
21355
+ member,
21356
+ value,
21357
+ rowGenericEnv(row, ctx),
21358
+ row.id
21359
+ );
21360
+ const encoded = { ...row, value: root.value };
21361
+ declarations.delete(root.id);
21362
+ adopt(encoded, root.id, children, declarations);
21340
21363
  return encoded;
21341
21364
  });
21342
21365
  return [...exported, ...extra];
21343
21366
  }
21367
+ function inlineCollectionFields(row, ctx) {
21368
+ if (typeof row.classId !== "string") return null;
21369
+ if (!isPlainRecord(row.value)) return null;
21370
+ let fields = null;
21371
+ for (const key in row.value) {
21372
+ const value = row.value[key];
21373
+ if (typeof value !== "object" || value === null) continue;
21374
+ const rawMember = memberForCustomSchemaValue(row.classId, key, ctx);
21375
+ if (rawMember === null) continue;
21376
+ fields ??= {
21377
+ record: row.value,
21378
+ members: /* @__PURE__ */ new Map(),
21379
+ genericEnv: rowGenericEnv(row, ctx)
21380
+ };
21381
+ const member = substituteMember(
21382
+ rawMember,
21383
+ fields.genericEnv,
21384
+ ctx.vm.members,
21385
+ cachedResolvedMember(rawMember, ctx)
21386
+ );
21387
+ if (isMemberWithEntries(member)) fields.members.set(key, member);
21388
+ }
21389
+ return fields === null || fields.members.size === 0 ? null : fields;
21390
+ }
21391
+ function rowGenericEnv(row, ctx) {
21392
+ const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
21393
+ overlayConcreteGenericEntries(genericEnv, envFromStamp(row.genericBindings));
21394
+ return genericEnv;
21395
+ }
21344
21396
  function prepareSessionValueExport(ctx, checkpoint, writes) {
21345
21397
  const created = createdSessionValuesSince(ctx, checkpoint);
21346
21398
  if (created.length === 0) return;
@@ -32875,6 +32927,7 @@ function clonedConstructorProvenance(source) {
32875
32927
  }
32876
32928
  function cloneConstructorLiteralValue(value) {
32877
32929
  if (typeof value !== "object" || value === null) return value;
32930
+ if (value instanceof NSSlotReference) return value.targetId;
32878
32931
  if (Array.isArray(value)) {
32879
32932
  return value.map((entry) => cloneConstructorLiteralValue(entry));
32880
32933
  }
@@ -37136,7 +37189,7 @@ var MaterializedValueGraphContext = class _MaterializedValueGraphContext {
37136
37189
  const typeInfo = parameterTypes.get(parameterId);
37137
37190
  return [
37138
37191
  parameterId,
37139
- typeInfo !== void 0 && isAggregateTypeInfo(typeInfo) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
37192
+ typeInfo !== void 0 && (isAggregateTypeInfo(typeInfo) || typeInfo.type === 29 /* Reference */) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
37140
37193
  ];
37141
37194
  }
37142
37195
  )
@@ -37172,6 +37225,41 @@ var MaterializedValueGraphContext = class _MaterializedValueGraphContext {
37172
37225
  ids.push(edge.targetValueId);
37173
37226
  return ids;
37174
37227
  }
37228
+ /** The targets a row's Reference creation data names (P112 §1.1). */
37229
+ referenceArgumentIds(row) {
37230
+ if (!isLiteralValueContent(row)) return [];
37231
+ const args = row.constructorArgs;
37232
+ if (args === void 0 || args === null) return [];
37233
+ const ids = [];
37234
+ for (const parameterId of this.referenceParameterIds(row)) {
37235
+ const argument2 = args[parameterId];
37236
+ if (typeof argument2 === "string") ids.push(argument2);
37237
+ }
37238
+ return ids;
37239
+ }
37240
+ /** Creation data with each Reference argument's target remapped (P112 §1.1). */
37241
+ remapReferenceArguments(row, remap, contextualMember) {
37242
+ const args = row.constructorArgs;
37243
+ if (args === void 0 || args === null) return args;
37244
+ let remapped;
37245
+ for (const parameterId of this.referenceParameterIds(
37246
+ row,
37247
+ contextualMember
37248
+ )) {
37249
+ const argument2 = args[parameterId];
37250
+ if (typeof argument2 !== "string") continue;
37251
+ const target = remap(argument2);
37252
+ if (target !== argument2) (remapped ??= { ...args })[parameterId] = target;
37253
+ }
37254
+ return remapped ?? args;
37255
+ }
37256
+ *referenceParameterIds(row, contextualMember) {
37257
+ for (const [parameterId, typeInfo] of this.constructorParameterTypes(
37258
+ row,
37259
+ contextualMember
37260
+ ))
37261
+ if (typeInfo.type === 29 /* Reference */) yield parameterId;
37262
+ }
37175
37263
  slotEntries(row) {
37176
37264
  const value = row.value;
37177
37265
  switch (this.referenceSlots(row.id, void 0, value)) {
@@ -38193,7 +38281,11 @@ function resolveVirtualInstanceGraph(args) {
38193
38281
  }
38194
38282
  }
38195
38283
  }
38196
- const virtualRow = rewriteExpandedRow(indexed, expansion);
38284
+ const virtualRow = rewriteExpandedRow(
38285
+ indexed,
38286
+ expansion,
38287
+ materializedGraph
38288
+ );
38197
38289
  const location = {
38198
38290
  id: effectiveId2,
38199
38291
  instanceRootId: args.instanceRoot.id,
@@ -39447,7 +39539,7 @@ function indexExpansion(args) {
39447
39539
  membersById
39448
39540
  };
39449
39541
  }
39450
- function rewriteExpandedRow(node, expansion) {
39542
+ function rewriteExpandedRow(node, expansion, graph) {
39451
39543
  const rewrite = (id) => expansion.nodesByExpandedId.get(id)?.virtualId ?? id;
39452
39544
  const row = cloneRow(node.expandedRow);
39453
39545
  row.id = node.virtualId;
@@ -39469,6 +39561,12 @@ function rewriteExpandedRow(node, expansion) {
39469
39561
  if (node.member.kind === 9 /* Lookup */) {
39470
39562
  row.value = remapLookupSelection(row.value, rewrite);
39471
39563
  }
39564
+ if (isLiteralValueContent(row) && row.constructorArgs !== void 0)
39565
+ row.constructorArgs = graph.remapReferenceArguments(
39566
+ row,
39567
+ rewrite,
39568
+ node.member
39569
+ );
39472
39570
  if (typeof row.containerId === "string") {
39473
39571
  row.containerId = rewrite(row.containerId);
39474
39572
  }
@@ -64110,13 +64208,29 @@ function memberSavedForStorage(ctx, memberId, contextSaved, declarationClassId)
64110
64208
  if (isWritableConstraint(classStorage)) return true;
64111
64209
  if (classStorage === 1 /* Immutable */) return false;
64112
64210
  }
64113
- const effective = ctx.storageResolver.effectiveStorages(memberId);
64211
+ let effective = ctx.storageResolver.effectiveStorages(memberId);
64212
+ const visited = /* @__PURE__ */ new Set([memberId]);
64213
+ let currentId = memberId;
64214
+ let baseId = member?.extendsMemberId;
64215
+ while (effective.size === 0 && baseId !== void 0 && !visited.has(baseId)) {
64216
+ if (!isResolvedAbstract(ctx, currentId) && !isResolvedAbstract(ctx, baseId))
64217
+ break;
64218
+ visited.add(baseId);
64219
+ effective = ctx.storageResolver.effectiveStorages(baseId);
64220
+ currentId = baseId;
64221
+ baseId = ctx.exportData.members[baseId]?.extendsMemberId;
64222
+ }
64114
64223
  const hasWritable = effective.has(2 /* Save */) || effective.has(3 /* Session */);
64115
64224
  const hasStatic = effective.has(1 /* Immutable */);
64116
64225
  if (hasWritable && !hasStatic) return true;
64117
64226
  if (hasStatic && !hasWritable) return false;
64118
64227
  return contextSaved;
64119
64228
  }
64229
+ function isResolvedAbstract(ctx, memberId) {
64230
+ return isAbstractMember(
64231
+ resolveMemberById(ctx, memberId, `members.${memberId}`)
64232
+ );
64233
+ }
64120
64234
  function classAllowedStorage(ctx, classId) {
64121
64235
  return ctx.storageResolver.allowedStorage(classId);
64122
64236
  }
@@ -64998,7 +65112,7 @@ function typeInfoConstructedSuffix(ctx, typeInfo, saved, genericEnv, genericBind
64998
65112
  const argType = csharpTypeInfoValueType(
64999
65113
  ctx,
65000
65114
  argInfo,
65001
- saved,
65115
+ true,
65002
65116
  genericEnv,
65003
65117
  genericBindingSaved
65004
65118
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neocompose/cli",
3
- "version": "0.84.2",
3
+ "version": "0.84.3",
4
4
  "description": "Neo Compose native project-source CLI with bidirectional sync.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@ description: >-
9
9
  `@neocompose/cli` or `node cli/bin/neo.mjs` in the neo-compose repository.
10
10
  ---
11
11
 
12
- <!-- reviewed-through-cli: 0.84.2 -->
12
+ <!-- reviewed-through-cli: 0.84.3 -->
13
13
 
14
14
  # Neo Compose CLI
15
15
 
@@ -129,7 +129,7 @@ wrappers.
129
129
  The marker near the top of `SKILL.md` must exactly match the package version:
130
130
 
131
131
  ```html
132
- <!-- reviewed-through-cli: 0.84.2 -->
132
+ <!-- reviewed-through-cli: 0.84.3 -->
133
133
  ```
134
134
 
135
135
  The quoted version above is checked too, so this instruction cannot go stale
@@ -254,6 +254,17 @@ and declarations created in the same push. Preparation materializes the target
254
254
  collection and its required ancestor rows together, preserving the virtual
255
255
  identities. No preliminary push or manual value ID is needed.
256
256
 
257
+ An object Root.neo writes is init-built when its class has an `init` block. A
258
+ declaration binding may name a member inside it, and the push stores that
259
+ member's row so the binding has a target. A reference an `init` block or
260
+ constructor captures, such as `new Rule(Reference(this.Weather))`, stores its
261
+ target's ID and keeps the target's row. Status refuses two forms, because their
262
+ target has no row to check until the push stores it: a value row's reference to
263
+ a member of an init-built object (bind it from a declaration instead), and a
264
+ binding to a class or list an `init` block builds. A project an older CLI pushed
265
+ with such a captured reference stored it without its target; push once to
266
+ repair it.
267
+
257
268
  ## Defaults and localization
258
269
 
259
270
  A class member whose default constructs its declared type emits a contextual