@lousy-agents/cli 5.3.7 → 5.3.8

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.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@biomejs/biome": "2.4.2",
21
- "@lousy-agents/mcp": "5.3.6",
21
+ "@lousy-agents/mcp": "5.3.7",
22
22
  "@modelcontextprotocol/server-sequential-thinking": "2025.12.18",
23
23
  "@testcontainers/postgresql": "11.13.0",
24
24
  "@types/node": "24.12.0",
@@ -944,9 +944,9 @@
944
944
  }
945
945
  },
946
946
  "node_modules/@lousy-agents/mcp": {
947
- "version": "5.3.6",
948
- "resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.3.6.tgz",
949
- "integrity": "sha512-UCRk7Zsyp1bReP7mGqY5nmbg7tnsLbUR4athLqJMEIv/QUdbMThuiBUvVvjx7WN0DUhkXVyPZ5v4fpv+t6ivqA==",
947
+ "version": "5.3.7",
948
+ "resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.3.7.tgz",
949
+ "integrity": "sha512-hllvyzgnqXhAWyWQILyzFSpx8ke+OtCg7IDikZghwBbbMsDRxXZg/umBJ9nzuT8CoU9jtNGQP7OvQJEDpR9mSw==",
950
950
  "dev": true,
951
951
  "license": "MIT",
952
952
  "dependencies": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.4.2",
29
- "@lousy-agents/mcp": "5.3.6",
29
+ "@lousy-agents/mcp": "5.3.7",
30
30
  "@modelcontextprotocol/server-sequential-thinking": "2025.12.18",
31
31
  "@testcontainers/postgresql": "11.13.0",
32
32
  "@types/node": "24.12.0",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@biomejs/biome": "2.3.14",
23
- "@lousy-agents/mcp": "5.3.6",
23
+ "@lousy-agents/mcp": "5.3.7",
24
24
  "@modelcontextprotocol/server-sequential-thinking": "2025.12.18",
25
25
  "@types/node": "24.12.0",
26
26
  "@upstash/context7-mcp": "2.1.4",
package/dist/index.js CHANGED
@@ -27663,14 +27663,26 @@ const bigIntsStringify = /([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
27663
27663
  const noiseStringify =
27664
27664
  /([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
27665
27665
 
27666
- /** @typedef {(key: string, value: any, context?: { source: string }) => any} Reviver */
27666
+ /**
27667
+ * @typedef {(this: any, key: string | number | undefined, value: any) => any} Replacer
27668
+ * @typedef {(key: string | number | undefined, value: any, context?: { source: string }) => any} Reviver
27669
+ */
27667
27670
 
27668
27671
  /**
27669
- * Function to serialize value to a JSON string.
27670
- * Converts BigInt values to a custom format (strings with digits and "n" at the end) and then converts them to proper big integers in a JSON string.
27671
- * @param {*} value - The value to convert to a JSON string.
27672
- * @param {(Function|Array<string>|null)} [replacer] - A function that alters the behavior of the stringification process, or an array of strings to indicate properties to exclude.
27673
- * @param {(string|number)} [space] - A string or number to specify indentation or pretty-printing.
27672
+ * Converts a JavaScript value to a JSON string.
27673
+ *
27674
+ * Supports serialization of BigInt values using two strategies:
27675
+ * 1. Custom format "123n" "123" (universal fallback)
27676
+ * 2. Native JSON.rawJSON() (Node.js 22+, fastest) when available
27677
+ *
27678
+ * All other values are serialized exactly like native JSON.stringify().
27679
+ *
27680
+ * @param {*} value The value to convert to a JSON string.
27681
+ * @param {Replacer | Array<string | number> | null} [replacer]
27682
+ * A function that alters the behavior of the stringification process,
27683
+ * or an array of strings/numbers to indicate properties to exclude.
27684
+ * @param {string | number} [space]
27685
+ * A string or number to specify indentation or pretty-printing.
27674
27686
  * @returns {string} The JSON string representation.
27675
27687
  */
27676
27688
  const JSONStringify = (value, replacer, space) => {
@@ -27695,8 +27707,7 @@ const JSONStringify = (value, replacer, space) => {
27695
27707
  const convertedToCustomJSON = originalStringify(
27696
27708
  value,
27697
27709
  (key, value) => {
27698
- const isNoise =
27699
- typeof value === "string" && Boolean(value.match(noiseValue));
27710
+ const isNoise = typeof value === "string" && noiseValue.test(value);
27700
27711
 
27701
27712
  if (isNoise) return value.toString() + "n"; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing
27702
27713
 
@@ -27719,33 +27730,71 @@ const JSONStringify = (value, replacer, space) => {
27719
27730
  return denoisedJSON;
27720
27731
  };
27721
27732
 
27733
+ const featureCache = new Map();
27734
+
27722
27735
  /**
27723
- * Support for JSON.parse's context.source feature detection.
27724
- * @type {boolean}
27736
+ * Detects if the current JSON.parse implementation supports the context.source feature.
27737
+ *
27738
+ * Uses toString() fingerprinting to cache results and automatically detect runtime
27739
+ * replacements of JSON.parse (polyfills, mocks, etc.).
27740
+ *
27741
+ * @returns {boolean} true if context.source is supported, false otherwise.
27725
27742
  */
27726
- const isContextSourceSupported = () =>
27727
- JSON.parse("1", (_, __, context) => !!context && context.source === "1");
27743
+ const isContextSourceSupported = () => {
27744
+ const parseFingerprint = JSON.parse.toString();
27745
+
27746
+ if (featureCache.has(parseFingerprint)) {
27747
+ return featureCache.get(parseFingerprint);
27748
+ }
27749
+
27750
+ try {
27751
+ const result = JSON.parse(
27752
+ "1",
27753
+ (_, __, context) => !!context?.source && context.source === "1",
27754
+ );
27755
+ featureCache.set(parseFingerprint, result);
27756
+
27757
+ return result;
27758
+ } catch {
27759
+ featureCache.set(parseFingerprint, false);
27760
+
27761
+ return false;
27762
+ }
27763
+ };
27728
27764
 
27729
27765
  /**
27730
- * Convert marked big numbers to BigInt
27731
- * @type {Reviver}
27766
+ * Reviver function that converts custom-format BigInt strings back to BigInt values.
27767
+ * Also handles "noise" strings that accidentally match the BigInt format.
27768
+ *
27769
+ * @param {string | number | undefined} key The object key.
27770
+ * @param {*} value The value being parsed.
27771
+ * @param {object} [context] Parse context (if supported by JSON.parse).
27772
+ * @param {Reviver} [userReviver] User's custom reviver function.
27773
+ * @returns {any} The transformed value.
27732
27774
  */
27733
27775
  const convertMarkedBigIntsReviver = (key, value, context, userReviver) => {
27734
27776
  const isCustomFormatBigInt =
27735
- typeof value === "string" && value.match(customFormat);
27777
+ typeof value === "string" && customFormat.test(value);
27736
27778
  if (isCustomFormatBigInt) return BigInt(value.slice(0, -1));
27737
27779
 
27738
- const isNoiseValue = typeof value === "string" && value.match(noiseValue);
27780
+ const isNoiseValue = typeof value === "string" && noiseValue.test(value);
27739
27781
  if (isNoiseValue) return value.slice(0, -1);
27740
27782
 
27741
27783
  if (typeof userReviver !== "function") return value;
27784
+
27742
27785
  return userReviver(key, value, context);
27743
27786
  };
27744
27787
 
27745
27788
  /**
27746
- * Faster (2x) and simpler function to parse JSON.
27747
- * Based on JSON.parse's context.source feature, which is not universally available now.
27748
- * Does not support the legacy custom format, used in the first version of this library.
27789
+ * Fast JSON.parse implementation (~2x faster than classic fallback).
27790
+ * Uses JSON.parse's context.source feature to detect integers and convert
27791
+ * large numbers directly to BigInt without string manipulation.
27792
+ *
27793
+ * Does not support legacy custom format from v1 of this library.
27794
+ *
27795
+ * @param {string} text JSON string to parse.
27796
+ * @param {Reviver} [reviver] Transform function to apply to each value.
27797
+ * @returns {any} Parsed JavaScript value.
27749
27798
  */
27750
27799
  const JSONParseV2 = (text, reviver) => {
27751
27800
  return JSON.parse(text, (key, value, context) => {
@@ -27770,9 +27819,21 @@ const stringsOrLargeNumbers =
27770
27819
  const noiseValueWithQuotes = /^"-?\d+n+"$/; // Noise - strings that match the custom format before being converted to it
27771
27820
 
27772
27821
  /**
27773
- * Function to parse JSON.
27774
- * If JSON has number values greater than Number.MAX_SAFE_INTEGER, we convert those values to a custom format, then parse them to BigInt values.
27775
- * Other types of values are not affected and parsed as native JSON.parse() would parse them.
27822
+ * Converts a JSON string into a JavaScript value.
27823
+ *
27824
+ * Supports parsing of large integers using two strategies:
27825
+ * 1. Classic fallback: Marks large numbers with "123n" format, then converts to BigInt
27826
+ * 2. Fast path (JSONParseV2): Uses context.source feature (~2x faster) when available
27827
+ *
27828
+ * All other JSON values are parsed exactly like native JSON.parse().
27829
+ *
27830
+ * @param {string} text A valid JSON string.
27831
+ * @param {Reviver} [reviver]
27832
+ * A function that transforms the results. This function is called for each member
27833
+ * of the object. If a member contains nested objects, the nested objects are
27834
+ * transformed before the parent object is.
27835
+ * @returns {any} The parsed JavaScript value.
27836
+ * @throws {SyntaxError} If text is not valid JSON.
27776
27837
  */
27777
27838
  const JSONParse = (text, reviver) => {
27778
27839
  if (!text) return originalParse(text, reviver);
@@ -27784,7 +27845,7 @@ const JSONParse = (text, reviver) => {
27784
27845
  stringsOrLargeNumbers,
27785
27846
  (text, digits, fractional, exponential) => {
27786
27847
  const isString = text[0] === '"';
27787
- const isNoise = isString && Boolean(text.match(noiseValueWithQuotes));
27848
+ const isNoise = isString && noiseValueWithQuotes.test(text);
27788
27849
 
27789
27850
  if (isNoise) return text.substring(0, text.length - 1) + 'n"'; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing
27790
27851