@opencode/codemode 0.0.0-dev-210 → 0.0.0-dev-220

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.
@@ -5,7 +5,7 @@ import { checkStringLength } from "./limits.js";
5
5
  import { locate, materialize } from "./errors.js";
6
6
  import { primitivePrototype } from "./intrinsics.js";
7
7
  import { globals } from "./globals.js";
8
- import { assign, Callable, define, frozen, get, hostCursor, IteratorObj, has, hidden, hasPrototype, keys, Native, parseArrayIndex, Arguments, Arr, Fn, GeneratorObj, Obj, PromiseObj, iteratorResult, remove, set, coerceToNumber, coerceToString, } from "./objects.js";
8
+ import { assign, Callable, define, frozen, get, hostCursor, IteratorObj, has, hasOwn, hidden, hasPrototype, keys, Native, parseArrayIndex, Arguments, Arr, Fn, GeneratorObj, Obj, PromiseObj, iteratorResult, remove, set, coerceToNumber, coerceToString, } from "./objects.js";
9
9
  import { preserveConsumerError, toPrimitive } from "./callback.js";
10
10
  import { AsyncBoundary, Await, Call, Interruption, isEval, MAX_CALL_DEPTH, Runner, Slice, Task, Yield, normal, } from "./runner.js";
11
11
  import { describeValue, isOpaque, rejectCircularInsertion, typeofValue } from "./references.js";
@@ -904,13 +904,25 @@ class Frame {
904
904
  return value;
905
905
  throw typeError(`${context} must be a function.`, node);
906
906
  }
907
- // for...in over null/undefined iterates nothing, like JS.
907
+ // for...in over null/undefined iterates nothing, like JS. After the own keys come each prototype's enumerable
908
+ // string keys, skipping any key a nearer level has, even as a non-enumerable property.
908
909
  enumerableKeys(value, node) {
909
910
  if (value instanceof ToolReference)
910
911
  return [...this.ctx.tools.keys(value.path)];
911
912
  if (value === null || value === undefined)
912
913
  return [];
913
- return keys(enumerableSource(this.ctx, "for...in", value, node));
914
+ const source = enumerableSource(this.ctx, "for...in", value, node);
915
+ const chain = [source];
916
+ // A string's characters stand in an array, but its prototype is String.prototype.
917
+ let proto = primitivePrototype(this.ctx.builtins, value) ?? source.proto;
918
+ while (proto !== null) {
919
+ chain.push(proto);
920
+ proto = proto.proto;
921
+ }
922
+ return chain.flatMap((target, depth) => {
923
+ const nearer = chain.slice(0, depth);
924
+ return keys(target).filter((key) => !nearer.some((level) => hasOwn(level, key)));
925
+ });
914
926
  }
915
927
  *evaluateForInStatement(node, labels) {
916
928
  const runner = this.ctx.runner;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/codemode",
4
- "version": "0.0.0-dev-210",
4
+ "version": "0.0.0-dev-220",
5
5
  "description": "Effect-native confined code execution over schema-described tools",
6
6
  "type": "module",
7
7
  "license": "MIT",