token-goat 2.6.31 → 2.6.32

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/SECURITY.md +67 -3
  3. package/dist/{token-goat-chunk-VYC34TBW.mjs → token-goat-chunk-3KW5C2KQ.mjs} +1 -1
  4. package/dist/{token-goat-chunk-4WGVGN6W.mjs → token-goat-chunk-3UOG7PSZ.mjs} +12 -3
  5. package/dist/{token-goat-chunk-Q4N6SQWR.mjs → token-goat-chunk-4M7PSAO3.mjs} +8 -8
  6. package/dist/{token-goat-chunk-X7PIWZMB.mjs → token-goat-chunk-5EXIMDHA.mjs} +3 -227
  7. package/dist/{token-goat-chunk-PWD5XZ6C.mjs → token-goat-chunk-DFBD2FFU.mjs} +276 -90
  8. package/dist/{token-goat-chunk-56C3XUQY.mjs → token-goat-chunk-DNEPSN3P.mjs} +4 -4
  9. package/dist/{token-goat-chunk-N2S7UAVU.mjs → token-goat-chunk-GWZJ5SI2.mjs} +12 -2
  10. package/dist/{token-goat-chunk-P7I6LS5H.mjs → token-goat-chunk-N53GXI2Z.mjs} +39 -22
  11. package/dist/{token-goat-chunk-OIBTYBVR.mjs → token-goat-chunk-O7TGKV5I.mjs} +4 -4
  12. package/dist/{token-goat-chunk-XEJBPPD7.mjs → token-goat-chunk-RD6O3PJU.mjs} +150 -89
  13. package/dist/{token-goat-chunk-J6JTYE2B.mjs → token-goat-chunk-TBCLQTPG.mjs} +7 -7
  14. package/dist/{token-goat-chunk-QL2743EW.mjs → token-goat-chunk-W3MX4LQV.mjs} +6 -6
  15. package/dist/{token-goat-chunk-HPY7XE77.mjs → token-goat-chunk-X5OPORR4.mjs} +28 -8
  16. package/dist/{token-goat-chunk-DCGBS2YZ.mjs → token-goat-chunk-YWYITDOS.mjs} +4 -4
  17. package/dist/{token-goat-hook-chunk-YHRJMMEF.mjs → token-goat-hook-chunk-6NF4WM2U.mjs} +151 -90
  18. package/dist/token-goat-hook-chunk-ANFXTEQO.mjs +23 -0
  19. package/dist/{token-goat-hook-chunk-NIVRFAJ4.mjs → token-goat-hook-chunk-DHW6SRHR.mjs} +3 -227
  20. package/dist/{token-goat-hook-chunk-2K7FV2ME.mjs → token-goat-hook-chunk-DJZGX27J.mjs} +275 -89
  21. package/dist/{token-goat-hook-chunk-KNVHTGEX.mjs → token-goat-hook-chunk-J2ZK2FYW.mjs} +1 -1
  22. package/dist/{token-goat-hook-chunk-7WC2H3EW.mjs → token-goat-hook-chunk-K33JMLL7.mjs} +12 -3
  23. package/dist/{token-goat-hook-chunk-JT5RMRIY.mjs → token-goat-hook-chunk-LFYT4DLB.mjs} +4 -4
  24. package/dist/{token-goat-hook-chunk-5AQYD2SZ.mjs → token-goat-hook-chunk-PCP4W65Z.mjs} +4 -4
  25. package/dist/{token-goat-hook-chunk-66W63A4Y.mjs → token-goat-hook-chunk-Q5URQRIF.mjs} +39 -22
  26. package/dist/{token-goat-hook-chunk-K6HLYRRI.mjs → token-goat-hook-chunk-TBJ5PUPQ.mjs} +6 -6
  27. package/dist/{token-goat-hook-chunk-FKZ5RBT4.mjs → token-goat-hook-chunk-TKXOXN4J.mjs} +8 -8
  28. package/dist/{token-goat-hook-chunk-3OJELLK5.mjs → token-goat-hook-chunk-UXD3B4OY.mjs} +4 -4
  29. package/dist/{token-goat-hook-chunk-JVJUBWKT.mjs → token-goat-hook-chunk-VHZECEQD.mjs} +12 -2
  30. package/dist/{token-goat-hook-chunk-SJM4BUZQ.mjs → token-goat-hook-chunk-WBTHUYJP.mjs} +28 -8
  31. package/dist/token-goat-hook.mjs +7 -7
  32. package/dist/token-goat.core.mjs +7 -7
  33. package/package.json +12 -4
  34. package/dist/token-goat-hook-chunk-ULGSXGZK.mjs +0 -23
@@ -8,7 +8,7 @@ import {
8
8
  isRewriteWorthwhile,
9
9
  resolveMinNetSavingsBytes,
10
10
  shlexSplit
11
- } from "./token-goat-hook-chunk-JVJUBWKT.mjs";
11
+ } from "./token-goat-hook-chunk-VHZECEQD.mjs";
12
12
  import {
13
13
  BASH_OUTPUT_SUBDIR,
14
14
  HOOK_EVENTS,
@@ -26,7 +26,7 @@ import {
26
26
  storeBashOutput,
27
27
  storeWebOutput,
28
28
  summarizeOutputDelta
29
- } from "./token-goat-hook-chunk-JT5RMRIY.mjs";
29
+ } from "./token-goat-hook-chunk-LFYT4DLB.mjs";
30
30
  import {
31
31
  BODY_FIRST_TOOL_RESPONSE_KEYS,
32
32
  OUTPUT_FIRST_TOOL_RESPONSE_KEYS,
@@ -117,7 +117,7 @@ import {
117
117
  wasCliReadThisSession,
118
118
  wasFileReadThisSession,
119
119
  wasHintShown
120
- } from "./token-goat-hook-chunk-SJM4BUZQ.mjs";
120
+ } from "./token-goat-hook-chunk-WBTHUYJP.mjs";
121
121
  import {
122
122
  VERSION,
123
123
  detectHarness,
@@ -134,10 +134,10 @@ import {
134
134
  runGit,
135
135
  shortFingerprint,
136
136
  toKB
137
- } from "./token-goat-hook-chunk-NIVRFAJ4.mjs";
137
+ } from "./token-goat-hook-chunk-DHW6SRHR.mjs";
138
138
  import {
139
139
  init_define_import_meta_env
140
- } from "./token-goat-hook-chunk-7WC2H3EW.mjs";
140
+ } from "./token-goat-hook-chunk-K33JMLL7.mjs";
141
141
 
142
142
  // src/relay.ts
143
143
  init_define_import_meta_env();
@@ -585,7 +585,7 @@ init_define_import_meta_env();
585
585
  var TRACKED_SKILL = "token-goat";
586
586
  var MAX_COMMANDS_SHOWN = 8;
587
587
  async function currentCommandNames() {
588
- const { buildProgram } = await import("./token-goat-hook-chunk-YHRJMMEF.mjs");
588
+ const { buildProgram } = await import("./token-goat-hook-chunk-6NF4WM2U.mjs");
589
589
  return flattenCommandNames(buildCommandManifest(buildProgram()));
590
590
  }
591
591
  async function recordSkillVersionSnapshot(sessionId, skillName) {
@@ -2470,7 +2470,7 @@ var decodeMap = /* @__PURE__ */ new Map([
2470
2470
  ]);
2471
2471
  var fromCodePoint = (
2472
2472
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/es-builtins
2473
- (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : (codePoint) => {
2473
+ (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : ((codePoint) => {
2474
2474
  let output = "";
2475
2475
  if (codePoint > 65535) {
2476
2476
  codePoint -= 65536;
@@ -2479,7 +2479,7 @@ var fromCodePoint = (
2479
2479
  }
2480
2480
  output += String.fromCharCode(codePoint);
2481
2481
  return output;
2482
- }
2482
+ })
2483
2483
  );
2484
2484
  function replaceCodePoint(codePoint) {
2485
2485
  var _a3;
@@ -4883,17 +4883,51 @@ function parseDocument(data, options) {
4883
4883
  // node_modules/deepmerge-ts/dist/index.mjs
4884
4884
  init_define_import_meta_env();
4885
4885
  var actions = {
4886
- defaultMerge: Symbol("deepmerge-ts: default merge"),
4887
- skip: Symbol("deepmerge-ts: skip")
4886
+ defaultMerge: /* @__PURE__ */ Symbol("deepmerge-ts: default merge"),
4887
+ skip: /* @__PURE__ */ Symbol("deepmerge-ts: skip")
4888
4888
  };
4889
4889
  var actionsInto = {
4890
4890
  defaultMerge: actions.defaultMerge
4891
4891
  };
4892
- function defaultMetaDataUpdater(previousMeta, metaMeta) {
4893
- return metaMeta;
4892
+ function defaultMetaDataUpdater(previousMeta, mergeInfo) {
4893
+ const ancestor = {
4894
+ key: mergeInfo.key,
4895
+ parents: mergeInfo.parents,
4896
+ values: mergeInfo.values,
4897
+ result: mergeInfo.result
4898
+ };
4899
+ const prevHierarchy = previousMeta?.hierarchy;
4900
+ return {
4901
+ ...ancestor,
4902
+ hierarchy: prevHierarchy === void 0 ? [ancestor] : [...prevHierarchy, ancestor]
4903
+ };
4894
4904
  }
4895
4905
  function defaultFilterValues(values, meta) {
4896
- return values.filter((value) => value !== void 0);
4906
+ return values.includes(void 0) ? values.filter((value) => value !== void 0) : values;
4907
+ }
4908
+ function shouldFallbackToDefault(utils, fallback, result) {
4909
+ return result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions[fallback] !== utils.defaultMergeFunctions[fallback];
4910
+ }
4911
+ function resolveCustomMergeFunctions(options, defaultMergeFunctions) {
4912
+ return {
4913
+ ...defaultMergeFunctions,
4914
+ ...Object.fromEntries(Object.entries(options).filter(([key]) => Object.hasOwn(defaultMergeFunctions, key)).map(([key, option2]) => option2 === false ? [key, defaultMergeFunctions.mergeOthers] : typeof option2 === "function" ? [key, option2] : [key, defaultMergeFunctions[key]]))
4915
+ };
4916
+ }
4917
+ function mergeArrays$1(values, utils, meta) {
4918
+ return values.flat();
4919
+ }
4920
+ function mergeSets$1(values, utils, meta) {
4921
+ const result = /* @__PURE__ */ new Set();
4922
+ for (const set of values) {
4923
+ for (const element of set) {
4924
+ result.add(element);
4925
+ }
4926
+ }
4927
+ return result;
4928
+ }
4929
+ function mergeOthers$1(values, utils, meta) {
4930
+ return values.at(-1);
4897
4931
  }
4898
4932
  var ObjectType;
4899
4933
  (function(ObjectType2) {
@@ -4922,78 +4956,127 @@ function getObjectType(object) {
4922
4956
  }
4923
4957
  return ObjectType.OTHER;
4924
4958
  }
4925
- function getKeys(objects) {
4959
+ function getKeysOfObjects(objects) {
4926
4960
  const keys = /* @__PURE__ */ new Set();
4927
- for (const object of objects) {
4928
- for (const key of [...Object.keys(object), ...Object.getOwnPropertySymbols(object)]) {
4929
- keys.add(key);
4961
+ for (const currentObject of objects) {
4962
+ const stringKeys = Object.keys(currentObject);
4963
+ for (const stringKey of stringKeys) {
4964
+ keys.add(stringKey);
4965
+ }
4966
+ const symbols = Object.getOwnPropertySymbols(currentObject);
4967
+ if (symbols.length > 0) {
4968
+ for (const symbol of symbols) {
4969
+ if (Object.prototype.propertyIsEnumerable.call(currentObject, symbol)) {
4970
+ keys.add(symbol);
4971
+ }
4972
+ }
4930
4973
  }
4931
4974
  }
4932
4975
  return keys;
4933
4976
  }
4977
+ function getKeysOfObject(object) {
4978
+ const symbols = Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
4979
+ return [...Object.keys(object), ...symbols];
4980
+ }
4934
4981
  function objectHasProperty(object, property) {
4935
4982
  return typeof object === "object" && Object.prototype.propertyIsEnumerable.call(object, property);
4936
4983
  }
4937
- function getIterableOfIterables(iterables) {
4938
- let mut_iterablesIndex = 0;
4939
- let mut_iterator = iterables[0]?.[Symbol.iterator]();
4940
- return {
4941
- [Symbol.iterator]() {
4942
- return {
4943
- next() {
4944
- do {
4945
- if (mut_iterator === void 0) {
4946
- return { done: true, value: void 0 };
4947
- }
4948
- const result = mut_iterator.next();
4949
- if (result.done === true) {
4950
- mut_iterablesIndex += 1;
4951
- mut_iterator = iterables[mut_iterablesIndex]?.[Symbol.iterator]();
4952
- continue;
4953
- }
4954
- return {
4955
- done: false,
4956
- value: result.value
4957
- };
4958
- } while (true);
4959
- }
4960
- };
4961
- }
4962
- };
4963
- }
4964
- var validRecordToStringValues = ["[object Object]", "[object Module]"];
4965
4984
  function isRecord(value) {
4966
- if (!validRecordToStringValues.includes(Object.prototype.toString.call(value))) {
4985
+ const prototype = Object.getPrototypeOf(value);
4986
+ if (prototype === null || prototype === Object.prototype) {
4987
+ return true;
4988
+ }
4989
+ const objectToString = Object.prototype.toString.call(value);
4990
+ if (objectToString !== "[object Object]" && objectToString !== "[object Module]") {
4967
4991
  return false;
4968
4992
  }
4969
4993
  const { constructor } = value;
4970
4994
  if (constructor === void 0) {
4971
4995
  return true;
4972
4996
  }
4973
- const prototype = constructor.prototype;
4974
- if (prototype === null || typeof prototype !== "object" || !validRecordToStringValues.includes(Object.prototype.toString.call(prototype))) {
4997
+ const constructorPrototype = constructor.prototype;
4998
+ if (constructorPrototype === null || typeof constructorPrototype !== "object") {
4999
+ return false;
5000
+ }
5001
+ const constructorToString = Object.prototype.toString.call(constructorPrototype);
5002
+ if (constructorToString !== "[object Object]" && constructorToString !== "[object Module]") {
4975
5003
  return false;
4976
5004
  }
4977
- if (!prototype.hasOwnProperty("isPrototypeOf")) {
5005
+ if (!Object.hasOwn(constructorPrototype, "isPrototypeOf")) {
4978
5006
  return false;
4979
5007
  }
4980
5008
  return true;
4981
5009
  }
5010
+ function getCyclicReferenceDepth(object, hierarchy, index) {
5011
+ if (hierarchy === void 0 || hierarchy.length === 0) {
5012
+ return 0;
5013
+ }
5014
+ let mut_depth = 1;
5015
+ for (let mut_index = hierarchy.length - 1; mut_index >= 0; mut_index--) {
5016
+ const { parents } = hierarchy[mut_index];
5017
+ if (parents[index] === object || parents.includes(object)) {
5018
+ return mut_depth;
5019
+ }
5020
+ mut_depth += 1;
5021
+ }
5022
+ return 0;
5023
+ }
5024
+ function getMetaDataHierarchy(meta) {
5025
+ return meta?.hierarchy;
5026
+ }
4982
5027
  function mergeRecords$1(values, utils, meta) {
5028
+ if (values.length === 2) {
5029
+ const result = {};
5030
+ const mergeProperty = (key, propValues) => {
5031
+ const updatedMeta = utils.metaDataUpdater(meta, {
5032
+ key,
5033
+ parents: values,
5034
+ values: propValues,
5035
+ result
5036
+ });
5037
+ const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
5038
+ if (propertyResult === actions.skip) {
5039
+ return;
5040
+ }
5041
+ if (key === "__proto__") {
5042
+ Object.defineProperty(result, key, {
5043
+ value: propertyResult,
5044
+ configurable: true,
5045
+ enumerable: true,
5046
+ writable: true
5047
+ });
5048
+ } else {
5049
+ result[key] = propertyResult;
5050
+ }
5051
+ };
5052
+ const firstValue = values[0];
5053
+ const secondValue = values[1];
5054
+ for (const key of getKeysOfObject(firstValue)) {
5055
+ mergeProperty(key, objectHasProperty(secondValue, key) ? [firstValue[key], secondValue[key]] : [firstValue[key]]);
5056
+ }
5057
+ for (const key of getKeysOfObject(secondValue)) {
5058
+ if (!objectHasProperty(firstValue, key)) {
5059
+ mergeProperty(key, [secondValue[key]]);
5060
+ }
5061
+ }
5062
+ return result;
5063
+ }
5064
+ return mergeRecordsGeneral(values, utils, meta);
5065
+ }
5066
+ function mergeRecordsGeneral(values, utils, meta) {
4983
5067
  const result = {};
4984
- for (const key of getKeys(values)) {
5068
+ for (const key of getKeysOfObjects(values)) {
4985
5069
  const propValues = [];
4986
5070
  for (const value of values) {
4987
5071
  if (objectHasProperty(value, key)) {
4988
5072
  propValues.push(value[key]);
4989
5073
  }
4990
5074
  }
4991
- if (propValues.length === 0) {
4992
- continue;
4993
- }
4994
5075
  const updatedMeta = utils.metaDataUpdater(meta, {
4995
5076
  key,
4996
- parents: values
5077
+ parents: values,
5078
+ values: propValues,
5079
+ result
4997
5080
  });
4998
5081
  const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
4999
5082
  if (propertyResult === actions.skip) {
@@ -5012,43 +5095,112 @@ function mergeRecords$1(values, utils, meta) {
5012
5095
  }
5013
5096
  return result;
5014
5097
  }
5015
- function mergeArrays$1(values) {
5016
- return values.flat();
5017
- }
5018
- function mergeSets$1(values) {
5019
- return new Set(getIterableOfIterables(values));
5098
+ function mergeMaps$1(values, utils, meta) {
5099
+ const result = /* @__PURE__ */ new Map();
5100
+ const valuesByKey = /* @__PURE__ */ new Map();
5101
+ for (const map2 of values) {
5102
+ for (const [key, value] of map2) {
5103
+ const mut_keyValues = valuesByKey.get(key);
5104
+ if (mut_keyValues === void 0) {
5105
+ valuesByKey.set(key, [value]);
5106
+ } else {
5107
+ mut_keyValues.push(value);
5108
+ }
5109
+ }
5110
+ }
5111
+ for (const [key, keyValues] of valuesByKey) {
5112
+ const updatedMeta = utils.metaDataUpdater(meta, {
5113
+ key,
5114
+ parents: values,
5115
+ values: keyValues,
5116
+ result
5117
+ });
5118
+ const keyResult = mergeUnknowns(keyValues, utils, updatedMeta);
5119
+ if (keyResult === actions.skip) {
5120
+ continue;
5121
+ }
5122
+ result.set(key, keyResult);
5123
+ }
5124
+ return result;
5020
5125
  }
5021
- function mergeMaps$1(values) {
5022
- return new Map(getIterableOfIterables(values));
5126
+ function resolveCyclicReferences(value, utils, meta) {
5127
+ if (typeof value !== "object" || value === null) {
5128
+ return value;
5129
+ }
5130
+ const hierarchy = getMetaDataHierarchy(meta);
5131
+ const depth = getCyclicReferenceDepth(value, hierarchy, 0);
5132
+ if (depth > 0 && hierarchy !== void 0) {
5133
+ return hierarchy[hierarchy.length - depth]?.result;
5134
+ }
5135
+ const type = getObjectType(value);
5136
+ if (type === ObjectType.RECORD) {
5137
+ const record = value;
5138
+ let mut_changed = false;
5139
+ const result = {};
5140
+ for (const key of getKeysOfObject(record)) {
5141
+ const propVal = record[key];
5142
+ const updatedMeta = utils.metaDataUpdater(meta, {
5143
+ key,
5144
+ parents: [record],
5145
+ values: [propVal],
5146
+ result
5147
+ });
5148
+ const resolvedProp = resolveCyclicReferences(propVal, utils, updatedMeta);
5149
+ if (resolvedProp !== propVal) {
5150
+ mut_changed = true;
5151
+ }
5152
+ if (key === "__proto__") {
5153
+ Object.defineProperty(result, key, {
5154
+ value: resolvedProp,
5155
+ configurable: true,
5156
+ enumerable: true,
5157
+ writable: true
5158
+ });
5159
+ } else {
5160
+ result[key] = resolvedProp;
5161
+ }
5162
+ }
5163
+ return mut_changed ? result : value;
5164
+ }
5165
+ return value;
5023
5166
  }
5024
- function mergeOthers$1(values) {
5025
- return values.at(-1);
5167
+ function mergeCircularReferences$1(values, cyclicDepths, utils, meta) {
5168
+ const depth = cyclicDepths[0];
5169
+ const hierarchy = getMetaDataHierarchy(meta);
5170
+ for (let mut_index = 1; mut_index < values.length; mut_index++) {
5171
+ if (cyclicDepths[mut_index] !== depth) {
5172
+ const lastCyclicDepth = cyclicDepths.at(-1);
5173
+ return lastCyclicDepth === 0 ? resolveCyclicReferences(values.at(-1), utils, meta) : hierarchy?.[hierarchy.length - lastCyclicDepth]?.result;
5174
+ }
5175
+ }
5176
+ return hierarchy?.[hierarchy.length - depth]?.result;
5026
5177
  }
5027
5178
  var mergeFunctions = {
5028
5179
  mergeRecords: mergeRecords$1,
5029
5180
  mergeArrays: mergeArrays$1,
5030
5181
  mergeSets: mergeSets$1,
5031
5182
  mergeMaps: mergeMaps$1,
5183
+ mergeCircularReferences: mergeCircularReferences$1,
5032
5184
  mergeOthers: mergeOthers$1
5033
5185
  };
5034
- function deepmergeCustom(options, rootMetaData) {
5035
- const utils = getUtils(options, customizedDeepmerge);
5186
+ function deepmergeCustom(options = {}, rootMetaData) {
5187
+ const utils = getUtils$1(options, customizedDeepmerge);
5036
5188
  function customizedDeepmerge(...objects) {
5037
- return mergeUnknowns(objects, utils, rootMetaData);
5189
+ return mergeUnknowns(objects, utils, rootMetaData ?? void 0);
5038
5190
  }
5039
5191
  return customizedDeepmerge;
5040
5192
  }
5041
- function getUtils(options, customizedDeepmerge) {
5193
+ function getUtils$1(options, customizedDeepmerge) {
5194
+ const defaultMergeFns = mergeFunctions;
5195
+ const defaultMetaDataUpd = defaultMetaDataUpdater;
5042
5196
  return {
5043
- defaultMergeFunctions: mergeFunctions,
5044
- mergeFunctions: {
5045
- ...mergeFunctions,
5046
- ...Object.fromEntries(Object.entries(options).filter(([key, option2]) => Object.hasOwn(mergeFunctions, key)).map(([key, option2]) => option2 === false ? [key, mergeFunctions.mergeOthers] : [key, option2]))
5047
- },
5048
- metaDataUpdater: options.metaDataUpdater ?? defaultMetaDataUpdater,
5197
+ defaultMergeFunctions: defaultMergeFns,
5198
+ mergeFunctions: resolveCustomMergeFunctions(options, defaultMergeFns),
5199
+ metaDataUpdater: typeof options.metaDataUpdater === "function" ? options.metaDataUpdater : defaultMetaDataUpd,
5049
5200
  deepmerge: customizedDeepmerge,
5050
5201
  useImplicitDefaultMerging: options.enableImplicitDefaultMerging ?? false,
5051
- filterValues: options.filterValues === false ? void 0 : options.filterValues ?? defaultFilterValues,
5202
+ filterValues: options.filterValues === false ? void 0 : typeof options.filterValues === "function" ? options.filterValues : defaultFilterValues,
5203
+ maxDepth: typeof options.maxDepth === "number" && !Number.isNaN(options.maxDepth) && options.maxDepth >= 0 ? options.maxDepth : 1e3,
5052
5204
  actions
5053
5205
  };
5054
5206
  }
@@ -5057,16 +5209,43 @@ function mergeUnknowns(values, utils, meta) {
5057
5209
  if (filteredValues.length === 0) {
5058
5210
  return void 0;
5059
5211
  }
5212
+ const hierarchy = getMetaDataHierarchy(meta);
5213
+ const currentDepth = hierarchy?.length ?? (typeof meta === "number" ? meta : meta?.depth ?? 0);
5214
+ if (utils.maxDepth !== void 0 && currentDepth >= utils.maxDepth) {
5215
+ return mergeOthers(filteredValues, utils, meta);
5216
+ }
5060
5217
  if (filteredValues.length === 1) {
5218
+ if (hierarchy !== void 0) {
5219
+ const depth = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
5220
+ if (depth > 0) {
5221
+ return hierarchy[hierarchy.length - depth]?.result ?? hierarchy[hierarchy.length - depth]?.parents[0];
5222
+ }
5223
+ }
5061
5224
  return mergeOthers(filteredValues, utils, meta);
5062
5225
  }
5063
5226
  const type = getObjectType(filteredValues[0]);
5064
5227
  if (type !== ObjectType.NOT && type !== ObjectType.OTHER) {
5065
- for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
5066
- if (getObjectType(filteredValues[mut_index]) === type) {
5067
- continue;
5228
+ if (filteredValues.length === 2) {
5229
+ if (getObjectType(filteredValues[1]) !== type) {
5230
+ return mergeOthers(filteredValues, utils, meta);
5231
+ }
5232
+ const d0 = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
5233
+ const d1 = getCyclicReferenceDepth(filteredValues[1], hierarchy, 1);
5234
+ if (d0 !== 0 || d1 !== 0) {
5235
+ return mergeCircularReferences(filteredValues, [d0, d1], utils, meta);
5236
+ }
5237
+ } else {
5238
+ const cyclicDepths = new Array(filteredValues.length);
5239
+ cyclicDepths[0] = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
5240
+ for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
5241
+ if (getObjectType(filteredValues[mut_index]) !== type) {
5242
+ return mergeOthers(filteredValues, utils, meta);
5243
+ }
5244
+ cyclicDepths[mut_index] = getCyclicReferenceDepth(filteredValues[mut_index], hierarchy, mut_index);
5245
+ }
5246
+ if (cyclicDepths.some((depth) => depth !== 0)) {
5247
+ return mergeCircularReferences(filteredValues, cyclicDepths, utils, meta);
5068
5248
  }
5069
- return mergeOthers(filteredValues, utils, meta);
5070
5249
  }
5071
5250
  }
5072
5251
  switch (type) {
@@ -5089,35 +5268,42 @@ function mergeUnknowns(values, utils, meta) {
5089
5268
  }
5090
5269
  function mergeRecords(values, utils, meta) {
5091
5270
  const result = utils.mergeFunctions.mergeRecords(values, utils, meta);
5092
- if (result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions.mergeRecords !== utils.defaultMergeFunctions.mergeRecords) {
5271
+ if (shouldFallbackToDefault(utils, "mergeRecords", result)) {
5093
5272
  return utils.defaultMergeFunctions.mergeRecords(values, utils, meta);
5094
5273
  }
5095
5274
  return result;
5096
5275
  }
5097
5276
  function mergeArrays(values, utils, meta) {
5098
5277
  const result = utils.mergeFunctions.mergeArrays(values, utils, meta);
5099
- if (result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions.mergeArrays !== utils.defaultMergeFunctions.mergeArrays) {
5278
+ if (shouldFallbackToDefault(utils, "mergeArrays", result)) {
5100
5279
  return utils.defaultMergeFunctions.mergeArrays(values);
5101
5280
  }
5102
5281
  return result;
5103
5282
  }
5104
5283
  function mergeSets(values, utils, meta) {
5105
5284
  const result = utils.mergeFunctions.mergeSets(values, utils, meta);
5106
- if (result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions.mergeSets !== utils.defaultMergeFunctions.mergeSets) {
5285
+ if (shouldFallbackToDefault(utils, "mergeSets", result)) {
5107
5286
  return utils.defaultMergeFunctions.mergeSets(values);
5108
5287
  }
5109
5288
  return result;
5110
5289
  }
5111
5290
  function mergeMaps(values, utils, meta) {
5112
5291
  const result = utils.mergeFunctions.mergeMaps(values, utils, meta);
5113
- if (result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions.mergeMaps !== utils.defaultMergeFunctions.mergeMaps) {
5114
- return utils.defaultMergeFunctions.mergeMaps(values);
5292
+ if (shouldFallbackToDefault(utils, "mergeMaps", result)) {
5293
+ return utils.defaultMergeFunctions.mergeMaps(values, utils, meta);
5294
+ }
5295
+ return result;
5296
+ }
5297
+ function mergeCircularReferences(values, cyclicDepths, utils, meta) {
5298
+ const result = utils.mergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta);
5299
+ if (shouldFallbackToDefault(utils, "mergeCircularReferences", result)) {
5300
+ return utils.defaultMergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta);
5115
5301
  }
5116
5302
  return result;
5117
5303
  }
5118
5304
  function mergeOthers(values, utils, meta) {
5119
5305
  const result = utils.mergeFunctions.mergeOthers(values, utils, meta);
5120
- if (result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions.mergeOthers !== utils.defaultMergeFunctions.mergeOthers) {
5306
+ if (shouldFallbackToDefault(utils, "mergeOthers", result)) {
5121
5307
  return utils.defaultMergeFunctions.mergeOthers(values);
5122
5308
  }
5123
5309
  return result;
@@ -5431,7 +5617,7 @@ var WhitespaceProcessor = class {
5431
5617
  this.newlineOrNonNewlineStringRe = new RegExp(`(\\n|[^\\n]+)`, "g");
5432
5618
  if (options.preserveNewlines) {
5433
5619
  const wordOrNewlineRe = new RegExp(`\\n|[^\\n${whitespaceCodes}]+`, "gm");
5434
- this.shrinkWrapAdd = function(text, inlineTextBuilder, transform = (str) => str, noWrap = false) {
5620
+ this.shrinkWrapAdd = function(text, inlineTextBuilder, transform = ((str) => str), noWrap = false) {
5435
5621
  if (!text) {
5436
5622
  return;
5437
5623
  }
@@ -5459,7 +5645,7 @@ var WhitespaceProcessor = class {
5459
5645
  };
5460
5646
  } else {
5461
5647
  const wordRe = new RegExp(`[^${whitespaceCodes}]+`, "g");
5462
- this.shrinkWrapAdd = function(text, inlineTextBuilder, transform = (str) => str, noWrap = false) {
5648
+ this.shrinkWrapAdd = function(text, inlineTextBuilder, transform = ((str) => str), noWrap = false) {
5463
5649
  if (!text) {
5464
5650
  return;
5465
5651
  }
@@ -5624,7 +5810,7 @@ var BlockTextBuilder = class {
5624
5810
  }
5625
5811
  /** @returns { (str: string) => string } */
5626
5812
  _getCombinedWordTransformer() {
5627
- const wt = this._wordTransformer ? (str) => applyTransformer(str, this._wordTransformer) : void 0;
5813
+ const wt = this._wordTransformer ? ((str) => applyTransformer(str, this._wordTransformer)) : void 0;
5628
5814
  const ce = this.options.encodeCharacters;
5629
5815
  return wt ? ce ? (str) => ce(wt(str)) : wt : ce;
5630
5816
  }
@@ -6205,7 +6391,7 @@ function composeOptions({
6205
6391
  }) {
6206
6392
  const options = deepMergeWithOptionsComposeRules(defaultOptions, userOptions);
6207
6393
  options.formatters = Object.assign({}, genericFormatters2, packageFormatters, options.formatters);
6208
- options.selectors = mergeDuplicatesPreferLast(options.selectors, (s) => s.selector);
6394
+ options.selectors = mergeDuplicatesPreferLast(options.selectors, ((s) => s.selector));
6209
6395
  if (handleMergedOptions) {
6210
6396
  handleMergedOptions(options);
6211
6397
  }
@@ -6684,7 +6870,7 @@ function handleDeprecatedOptions(options) {
6684
6870
  ([selector, definition]) => ({ ...definition, selector: selector || "*" })
6685
6871
  );
6686
6872
  options.selectors.push(...tagDefinitions);
6687
- options.selectors = mergeDuplicatesPreferLast(options.selectors, (s) => s.selector);
6873
+ options.selectors = mergeDuplicatesPreferLast(options.selectors, ((s) => s.selector));
6688
6874
  }
6689
6875
  function set(obj, path2, value) {
6690
6876
  const valueKey = path2.pop();
@@ -2,7 +2,7 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  init_define_import_meta_env
5
- } from "./token-goat-hook-chunk-7WC2H3EW.mjs";
5
+ } from "./token-goat-hook-chunk-K33JMLL7.mjs";
6
6
 
7
7
  // src/reset.ts
8
8
  init_define_import_meta_env();
@@ -12,11 +12,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
12
12
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
13
  throw Error('Dynamic require of "' + x + '" is not supported');
14
14
  });
15
- var __esm = (fn, res) => function __init() {
16
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ var __esm = (fn, res, err) => function __init() {
16
+ if (err) throw err[0];
17
+ try {
18
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
+ } catch (e) {
20
+ throw err = [e], e;
21
+ }
17
22
  };
18
23
  var __commonJS = (cb, mod) => function __require2() {
19
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
+ try {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ } catch (e) {
27
+ throw mod = 0, e;
28
+ }
20
29
  };
21
30
  var __export = (target, all) => {
22
31
  for (var name in all)
@@ -6,7 +6,7 @@ import {
6
6
  loadBlob,
7
7
  sanitizeFtsQuery,
8
8
  storeBlob
9
- } from "./token-goat-hook-chunk-SJM4BUZQ.mjs";
9
+ } from "./token-goat-hook-chunk-WBTHUYJP.mjs";
10
10
  import {
11
11
  SYMBOL_BODY_CHAR_CAP,
12
12
  extractErrorMessage,
@@ -16,13 +16,13 @@ import {
16
16
  redactSecrets,
17
17
  runGit,
18
18
  shortFingerprint
19
- } from "./token-goat-hook-chunk-NIVRFAJ4.mjs";
19
+ } from "./token-goat-hook-chunk-DHW6SRHR.mjs";
20
20
  import {
21
21
  registerReset
22
- } from "./token-goat-hook-chunk-KNVHTGEX.mjs";
22
+ } from "./token-goat-hook-chunk-J2ZK2FYW.mjs";
23
23
  import {
24
24
  init_define_import_meta_env
25
- } from "./token-goat-hook-chunk-7WC2H3EW.mjs";
25
+ } from "./token-goat-hook-chunk-K33JMLL7.mjs";
26
26
 
27
27
  // src/hooks_cli.ts
28
28
  init_define_import_meta_env();
@@ -2,10 +2,10 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  clearModuleCaches
5
- } from "./token-goat-hook-chunk-KNVHTGEX.mjs";
5
+ } from "./token-goat-hook-chunk-J2ZK2FYW.mjs";
6
6
  import {
7
7
  init_define_import_meta_env
8
- } from "./token-goat-hook-chunk-7WC2H3EW.mjs";
8
+ } from "./token-goat-hook-chunk-K33JMLL7.mjs";
9
9
 
10
10
  // src/batch_serve.ts
11
11
  init_define_import_meta_env();
@@ -23,12 +23,12 @@ function captureOutput() {
23
23
  let errText = "";
24
24
  const realOut = process.stdout.write.bind(process.stdout);
25
25
  const realErr = process.stderr.write.bind(process.stderr);
26
- const sink = (append) => (chunk, enc, cb) => {
26
+ const sink = (append) => ((chunk, enc, cb) => {
27
27
  append(typeof chunk === "string" ? chunk : String(chunk));
28
28
  const done = typeof enc === "function" ? enc : cb;
29
29
  if (typeof done === "function") done();
30
30
  return true;
31
- };
31
+ });
32
32
  process.stdout.write = sink((s) => {
33
33
  out += s;
34
34
  });