mcp-code-context 2.1.3 → 2.3.1

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 (128) hide show
  1. package/.io/RULES.md +12 -0
  2. package/CHANGELOG.md +118 -58
  3. package/CONTRIBUTING.md +243 -0
  4. package/README.md +58 -7
  5. package/RELEASE_NOTES_v2.2.0.md +286 -0
  6. package/RELEASE_NOTES_v2.3.0.md +228 -0
  7. package/RELEASE_NOTES_v2.3.1.md +110 -0
  8. package/dist/src/ast/writers/safeRename.d.ts +14 -0
  9. package/dist/src/ast/writers/safeRename.js +258 -0
  10. package/dist/src/ast/writers/safeRename.js.map +1 -0
  11. package/dist/src/ast/writers/symbolWriter.d.ts +2 -0
  12. package/dist/src/ast/writers/symbolWriter.js +9 -14
  13. package/dist/src/ast/writers/symbolWriter.js.map +1 -1
  14. package/dist/src/cache/astCache.d.ts +33 -0
  15. package/dist/src/cache/astCache.js +113 -0
  16. package/dist/src/cache/astCache.js.map +1 -0
  17. package/dist/src/handlers/readHandlers.d.ts +70 -0
  18. package/dist/src/handlers/readHandlers.js +431 -0
  19. package/dist/src/handlers/readHandlers.js.map +1 -0
  20. package/dist/src/handlers/utilHandlers.d.ts +31 -0
  21. package/dist/src/handlers/utilHandlers.js +69 -0
  22. package/dist/src/handlers/utilHandlers.js.map +1 -0
  23. package/dist/src/handlers/writeHandlers.d.ts +57 -0
  24. package/dist/src/handlers/writeHandlers.js +475 -0
  25. package/dist/src/handlers/writeHandlers.js.map +1 -0
  26. package/dist/src/index.d.ts +6 -107
  27. package/dist/src/index.js +147 -965
  28. package/dist/src/index.js.map +1 -1
  29. package/dist/src/tools/readFileLines.d.ts +26 -0
  30. package/dist/src/tools/readFileLines.js +77 -0
  31. package/dist/src/tools/readFileLines.js.map +1 -0
  32. package/dist/src/tools/searchCodePattern.d.ts +32 -0
  33. package/dist/src/tools/searchCodePattern.js +80 -0
  34. package/dist/src/tools/searchCodePattern.js.map +1 -0
  35. package/dist/src/utils/arrayUtils.d.ts +12 -0
  36. package/dist/src/utils/arrayUtils.js +27 -0
  37. package/dist/src/utils/arrayUtils.js.map +1 -0
  38. package/dist/src/utils/backupManager.d.ts +13 -6
  39. package/dist/src/utils/backupManager.js +73 -8
  40. package/dist/src/utils/backupManager.js.map +1 -1
  41. package/dist/src/utils/constants.d.ts +46 -0
  42. package/dist/src/utils/constants.js +112 -0
  43. package/dist/src/utils/constants.js.map +1 -0
  44. package/dist/src/utils/ignoreManager.d.ts +8 -0
  45. package/dist/src/utils/ignoreManager.js +49 -0
  46. package/dist/src/utils/ignoreManager.js.map +1 -1
  47. package/dist/src/utils/normalization.d.ts +49 -0
  48. package/dist/src/utils/normalization.js +173 -0
  49. package/dist/src/utils/normalization.js.map +1 -0
  50. package/dist/src/utils/projectRoot.d.ts +17 -0
  51. package/dist/src/utils/projectRoot.js +42 -0
  52. package/dist/src/utils/projectRoot.js.map +1 -0
  53. package/dist/src/utils/secureValidation.d.ts +15 -0
  54. package/dist/src/utils/secureValidation.js +41 -0
  55. package/dist/src/utils/secureValidation.js.map +1 -0
  56. package/dist/src/utils/transactionManager.d.ts +45 -0
  57. package/dist/src/utils/transactionManager.js +102 -0
  58. package/dist/src/utils/transactionManager.js.map +1 -0
  59. package/dist/src/utils/validation.d.ts +87 -0
  60. package/dist/src/utils/validation.js +231 -0
  61. package/dist/src/utils/validation.js.map +1 -0
  62. package/docs/ARCHITECTURE.md +300 -0
  63. package/docs/architecture/ADR-001-modular-handlers.md +119 -0
  64. package/llms.txt +62 -7
  65. package/package.json +5 -5
  66. package/AGENT_INSTRUCTIONS.md +0 -135
  67. package/DEPLOYMENT_INSTRUCTIONS.md +0 -110
  68. package/dist/src/tests/test-confirmation-flow.d.ts +0 -1
  69. package/dist/src/tests/test-confirmation-flow.js +0 -43
  70. package/dist/src/tests/test-confirmation-flow.js.map +0 -1
  71. package/dist/tests/debug-replace.d.ts +0 -1
  72. package/dist/tests/debug-replace.js +0 -17
  73. package/dist/tests/debug-replace.js.map +0 -1
  74. package/dist/tests/test-confirmation-flow.d.ts +0 -1
  75. package/dist/tests/test-confirmation-flow.js +0 -43
  76. package/dist/tests/test-confirmation-flow.js.map +0 -1
  77. package/dist/tests/test-dart.d.ts +0 -1
  78. package/dist/tests/test-dart.js +0 -242
  79. package/dist/tests/test-dart.js.map +0 -1
  80. package/dist/tests/test-php-ast.d.ts +0 -1
  81. package/dist/tests/test-php-ast.js +0 -152
  82. package/dist/tests/test-php-ast.js.map +0 -1
  83. package/dist/tests/test-php.d.ts +0 -1
  84. package/dist/tests/test-php.js +0 -234
  85. package/dist/tests/test-php.js.map +0 -1
  86. package/dist/tests/test-smoke.d.ts +0 -5
  87. package/dist/tests/test-smoke.js +0 -83
  88. package/dist/tests/test-smoke.js.map +0 -1
  89. package/dist/tests/writers/test-crlf-handling.d.ts +0 -4
  90. package/dist/tests/writers/test-crlf-handling.js +0 -73
  91. package/dist/tests/writers/test-crlf-handling.js.map +0 -1
  92. package/dist/tests/writers/test-write-smoke.d.ts +0 -9
  93. package/dist/tests/writers/test-write-smoke.js +0 -346
  94. package/dist/tests/writers/test-write-smoke.js.map +0 -1
  95. package/src/ast/dartCompressor.ts +0 -1013
  96. package/src/ast/phpCompressor.ts +0 -814
  97. package/src/ast/semanticCompressor.ts +0 -808
  98. package/src/ast/writers/dartWriter.ts +0 -648
  99. package/src/ast/writers/phpWriter.ts +0 -508
  100. package/src/ast/writers/pyWriter.ts +0 -446
  101. package/src/ast/writers/symbolWriter.ts +0 -277
  102. package/src/ast/writers/tsWriter.ts +0 -418
  103. package/src/index.ts +0 -1553
  104. package/src/utils/backupManager.ts +0 -66
  105. package/src/utils/confirmationCache.ts +0 -61
  106. package/src/utils/diffEngine.ts +0 -223
  107. package/src/utils/fuzzyMatch.ts +0 -86
  108. package/src/utils/ignoreManager.ts +0 -144
  109. package/tests/test-confirmation-flow.ts +0 -49
  110. package/tests/test-dart.d.ts +0 -1
  111. package/tests/test-dart.js +0 -209
  112. package/tests/test-dart.js.map +0 -1
  113. package/tests/test-dart.ts +0 -265
  114. package/tests/test-php-ast.d.ts +0 -1
  115. package/tests/test-php-ast.js +0 -152
  116. package/tests/test-php-ast.js.map +0 -1
  117. package/tests/test-php-ast.ts +0 -155
  118. package/tests/test-php.d.ts +0 -1
  119. package/tests/test-php.js +0 -234
  120. package/tests/test-php.js.map +0 -1
  121. package/tests/test-php.ts +0 -261
  122. package/tests/test-smoke.d.ts +0 -5
  123. package/tests/test-smoke.js +0 -83
  124. package/tests/test-smoke.js.map +0 -1
  125. package/tests/test-smoke.ts +0 -93
  126. package/tests/writers/test-crlf-handling.ts +0 -100
  127. package/tests/writers/test-write-smoke.ts +0 -568
  128. package/tsconfig.json +0 -19
@@ -1,83 +0,0 @@
1
- /**
2
- * Smoke test — validates all 3 tools work against this project's own source.
3
- * Run with: node dist/test-smoke.js
4
- */
5
- import { IgnoreManager } from "../src/utils/ignoreManager.js";
6
- import { compressFile, extractSymbol } from "../src/ast/semanticCompressor.js";
7
- import * as fs from "node:fs";
8
- import * as path from "node:path";
9
- import { fileURLToPath } from "node:url";
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
- const PROJECT_ROOT = path.resolve(__dirname, "..");
13
- function log(label, value) {
14
- console.log(` ✓ ${label}: ${value}`);
15
- }
16
- async function main() {
17
- console.log("\n🧪 Smoke Test: mcp-code-context\n");
18
- // --- Test 1: IgnoreManager ---
19
- console.log("─── Test 1: IgnoreManager ───");
20
- const ig = new IgnoreManager(PROJECT_ROOT);
21
- const files = ig.walkDirectory();
22
- log("Files discovered", files.length);
23
- log("node_modules excluded", files.every(f => !f.includes("node_modules")) ? "YES" : "FAIL");
24
- log("dist excluded", files.every(f => !f.includes(path.sep + "dist" + path.sep)) ? "YES" : "FAIL");
25
- // --- Test 2: Semantic Compression ---
26
- console.log("\n─── Test 2: Semantic Compression (TypeScript) ───");
27
- const indexPath = path.join(PROJECT_ROOT, "src", "index.ts");
28
- const indexContent = fs.readFileSync(indexPath, "utf-8");
29
- const compressed = compressFile(indexPath, indexContent);
30
- log("Original lines", indexContent.split("\n").length);
31
- log("Compressed lines", compressed.split("\n").length);
32
- log("Contains function signatures", compressed.includes("function") ? "YES" : "FAIL");
33
- log("Bodies stripped (/* ... */)", compressed.includes("/* ... */") ? "YES" : "FAIL");
34
- // --- Test 3: Symbol Extraction ---
35
- console.log("\n─── Test 3: Symbol Extraction ───");
36
- const compressorPath = path.join(PROJECT_ROOT, "src", "ast", "semanticCompressor.ts");
37
- const compressorContent = fs.readFileSync(compressorPath, "utf-8");
38
- const symbol = extractSymbol(compressorContent, "compressFile", compressorPath);
39
- log("Symbol 'compressFile' found", symbol ? "YES" : "FAIL");
40
- log("Symbol length", symbol ? symbol.split("\n").length + " lines" : "0");
41
- const missing = extractSymbol(compressorContent, "nonExistentFunction", compressorPath);
42
- log("Missing symbol returns null", missing === null ? "YES" : "FAIL");
43
- // --- Test 4: Python Compression ---
44
- console.log("\n─── Test 4: Python Compression (synthetic) ───");
45
- const pythonSample = `
46
- import os
47
- from pathlib import Path
48
-
49
- class FileProcessor:
50
- """Processes files in a directory."""
51
-
52
- def __init__(self, root: str):
53
- """Initialize with root directory."""
54
- self.root = root
55
- self.files: list[str] = []
56
-
57
- def scan(self, pattern: str = "*") -> list[str]:
58
- """Scan for files matching pattern."""
59
- for f in Path(self.root).glob(pattern):
60
- self.files.append(str(f))
61
- return self.files
62
-
63
- def process_all(directory: str) -> int:
64
- """Process all files in directory."""
65
- processor = FileProcessor(directory)
66
- files = processor.scan()
67
- for f in files:
68
- print(f"Processing {f}")
69
- return len(files)
70
- `;
71
- const pyCompressed = compressFile("test.py", pythonSample);
72
- log("Python compressed lines", pyCompressed.split("\n").length);
73
- log("Contains class signature", pyCompressed.includes("class FileProcessor") ? "YES" : "FAIL");
74
- log("Contains method signature", pyCompressed.includes("def scan") ? "YES" : "FAIL");
75
- log("Contains docstring", pyCompressed.includes("Processes files") ? "YES" : "FAIL");
76
- log("Body replaced with ...", pyCompressed.includes("...") ? "YES" : "FAIL");
77
- console.log("\n✅ All smoke tests passed!\n");
78
- }
79
- main().catch((err) => {
80
- console.error("\n❌ Smoke test failed:", err);
81
- process.exit(1);
82
- });
83
- //# sourceMappingURL=test-smoke.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-smoke.js","sourceRoot":"","sources":["test-smoke.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAEnD,SAAS,GAAG,CAAC,KAAa,EAAE,KAAsB;IAChD,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAEnD,gCAAgC;IAChC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC;IACjC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,GAAG,CAAC,uBAAuB,EAAE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,CAAC,CAAC;IACrF,GAAG,CAAC,oBAAoB,EAAE,YAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACrF,GAAG,CAAC,wBAAwB,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAE7E,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAC/C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,93 +0,0 @@
1
- /**
2
- * Smoke test — validates all 3 tools work against this project's own source.
3
- * Run with: node dist/test-smoke.js
4
- */
5
-
6
- import { IgnoreManager } from "../src/utils/ignoreManager.js";
7
- import { compressFile, extractSymbol } from "../src/ast/semanticCompressor.js";
8
- import * as fs from "node:fs";
9
- import * as path from "node:path";
10
- import { fileURLToPath } from "node:url";
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
14
- const PROJECT_ROOT = path.resolve(__dirname, "..");
15
-
16
- function log(label: string, value: string | number) {
17
- console.log(` ✓ ${label}: ${value}`);
18
- }
19
-
20
- async function main() {
21
- console.log("\n🧪 Smoke Test: mcp-code-context\n");
22
-
23
- // --- Test 1: IgnoreManager ---
24
- console.log("─── Test 1: IgnoreManager ───");
25
- const ig = new IgnoreManager(PROJECT_ROOT);
26
- const files = ig.walkDirectory();
27
- log("Files discovered", files.length);
28
- log("node_modules excluded", files.every(f => !f.includes("node_modules")) ? "YES" : "FAIL");
29
- log("dist excluded", files.every(f => !f.includes(path.sep + "dist" + path.sep)) ? "YES" : "FAIL");
30
-
31
- // --- Test 2: Semantic Compression ---
32
- console.log("\n─── Test 2: Semantic Compression (TypeScript) ───");
33
- const indexPath = path.join(PROJECT_ROOT, "src", "index.ts");
34
- const indexContent = fs.readFileSync(indexPath, "utf-8");
35
- const compressed = compressFile(indexPath, indexContent);
36
- log("Original lines", indexContent.split("\n").length);
37
- log("Compressed lines", compressed.split("\n").length);
38
- log("Contains function signatures", compressed.includes("function") ? "YES" : "FAIL");
39
- log("Bodies stripped (/* ... */)", compressed.includes("/* ... */") ? "YES" : "FAIL");
40
-
41
- // --- Test 3: Symbol Extraction ---
42
- console.log("\n─── Test 3: Symbol Extraction ───");
43
- const compressorPath = path.join(PROJECT_ROOT, "src", "ast", "semanticCompressor.ts");
44
- const compressorContent = fs.readFileSync(compressorPath, "utf-8");
45
- const symbol = extractSymbol(compressorContent, "compressFile", compressorPath);
46
- log("Symbol 'compressFile' found", symbol ? "YES" : "FAIL");
47
- log("Symbol length", symbol ? symbol.split("\n").length + " lines" : "0");
48
-
49
- const missing = extractSymbol(compressorContent, "nonExistentFunction", compressorPath);
50
- log("Missing symbol returns null", missing === null ? "YES" : "FAIL");
51
-
52
- // --- Test 4: Python Compression ---
53
- console.log("\n─── Test 4: Python Compression (synthetic) ───");
54
- const pythonSample = `
55
- import os
56
- from pathlib import Path
57
-
58
- class FileProcessor:
59
- """Processes files in a directory."""
60
-
61
- def __init__(self, root: str):
62
- """Initialize with root directory."""
63
- self.root = root
64
- self.files: list[str] = []
65
-
66
- def scan(self, pattern: str = "*") -> list[str]:
67
- """Scan for files matching pattern."""
68
- for f in Path(self.root).glob(pattern):
69
- self.files.append(str(f))
70
- return self.files
71
-
72
- def process_all(directory: str) -> int:
73
- """Process all files in directory."""
74
- processor = FileProcessor(directory)
75
- files = processor.scan()
76
- for f in files:
77
- print(f"Processing {f}")
78
- return len(files)
79
- `;
80
- const pyCompressed = compressFile("test.py", pythonSample);
81
- log("Python compressed lines", pyCompressed.split("\n").length);
82
- log("Contains class signature", pyCompressed.includes("class FileProcessor") ? "YES" : "FAIL");
83
- log("Contains method signature", pyCompressed.includes("def scan") ? "YES" : "FAIL");
84
- log("Contains docstring", pyCompressed.includes("Processes files") ? "YES" : "FAIL");
85
- log("Body replaced with ...", pyCompressed.includes("...") ? "YES" : "FAIL");
86
-
87
- console.log("\n✅ All smoke tests passed!\n");
88
- }
89
-
90
- main().catch((err) => {
91
- console.error("\n❌ Smoke test failed:", err);
92
- process.exit(1);
93
- });
@@ -1,100 +0,0 @@
1
- /**
2
- * Test CRLF handling in Dart writer
3
- */
4
-
5
- import { replaceDartSymbol, insertDartCode, renameDartSymbol, removeDartSymbol } from "../../src/ast/writers/dartWriter.js";
6
-
7
- function assert(condition: boolean, label: string, detail?: string): void {
8
- if (!condition) {
9
- console.error(`❌ FAIL: ${label}`);
10
- if (detail) console.error(` ${detail}`);
11
- process.exit(1);
12
- }
13
- console.log(`✅ PASS: ${label}`);
14
- }
15
-
16
- function section(title: string): void {
17
- console.log(`\n${"=".repeat(60)}`);
18
- console.log(title);
19
- console.log("=".repeat(60));
20
- }
21
-
22
- function testCRLFReplace(): void {
23
- section("CRLF: Replace Symbol");
24
-
25
- const dartCRLF = "class BadgeService {\r\n static void update({int? cart}) {\r\n if (cart != null) {\r\n print(cart);\r\n }\r\n }\r\n}\r\n";
26
-
27
- const newMethod = " static void update({int? cart}) {\r\n if (cart != null) {\r\n print('Updated: $cart');\r\n }\r\n }";
28
-
29
- const result = replaceDartSymbol(dartCRLF, "update", newMethod);
30
-
31
- assert(result.success, "CRLF Replace: Should succeed", result.error);
32
- assert(result.newContent.includes("Updated"), "CRLF Replace: Should contain new content");
33
- assert(!result.error, "CRLF Replace: Should not have error", result.error);
34
- }
35
-
36
- function testCRLFInsert(): void {
37
- section("CRLF: Insert Symbol");
38
-
39
- const dartCRLF = "class Test {\r\n void method1() {\r\n print('1');\r\n }\r\n}\r\n";
40
-
41
- const newMethod = "void method2() {\r\n print('2');\r\n}";
42
-
43
- const result = insertDartCode(dartCRLF, newMethod, "method1", "after");
44
-
45
- assert(result.success, "CRLF Insert: Should succeed", result.error);
46
- assert(result.newContent.includes("method2"), "CRLF Insert: Should contain new method");
47
- }
48
-
49
- function testCRLFRename(): void {
50
- section("CRLF: Rename Symbol");
51
-
52
- const dartCRLF = "class Test {\r\n void oldName() {\r\n print('test');\r\n }\r\n}\r\n";
53
-
54
- const result = renameDartSymbol(dartCRLF, "oldName", "newName");
55
-
56
- assert(result.success, "CRLF Rename: Should succeed");
57
- assert(result.newContent.includes("newName"), "CRLF Rename: Should contain new name");
58
- assert(!result.newContent.includes("oldName"), "CRLF Rename: Should not contain old name");
59
- }
60
-
61
- function testCRLFRemove(): void {
62
- section("CRLF: Remove Symbol");
63
-
64
- const dartCRLF = "class Test {\r\n void method1() {\r\n print('1');\r\n }\r\n void method2() {\r\n print('2');\r\n }\r\n}\r\n";
65
-
66
- const result = removeDartSymbol(dartCRLF, "method1");
67
-
68
- assert(result.success, "CRLF Remove: Should succeed");
69
- assert(!result.newContent.includes("method1"), "CRLF Remove: Should not contain removed method");
70
- assert(result.newContent.includes("method2"), "CRLF Remove: Should preserve other methods");
71
- }
72
-
73
- function testMixedLineEndings(): void {
74
- section("Mixed Line Endings");
75
-
76
- // Mixed CRLF and LF
77
- const mixed = "class Test {\r\n void method1() {\n print('1');\r\n }\n}\r\n";
78
-
79
- const result = replaceDartSymbol(mixed, "method1", " void method1() {\n print('updated');\n }");
80
-
81
- assert(result.success, "Mixed: Should handle mixed line endings");
82
- assert(result.newContent.includes("updated"), "Mixed: Should contain new content");
83
- }
84
-
85
- async function main(): Promise<void> {
86
- console.log("\n🧪 Testing CRLF Handling in Dart Writer\n");
87
-
88
- testCRLFReplace();
89
- testCRLFInsert();
90
- testCRLFRename();
91
- testCRLFRemove();
92
- testMixedLineEndings();
93
-
94
- console.log("\n✅ All CRLF tests passed!\n");
95
- }
96
-
97
- main().catch((err) => {
98
- console.error("Test suite failed:", err);
99
- process.exit(1);
100
- });