trellis 1.0.8 → 2.0.6

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +564 -83
  3. package/bin/trellis.mjs +2 -0
  4. package/dist/cli/index.js +4718 -0
  5. package/dist/core/index.js +12 -0
  6. package/dist/decisions/index.js +19 -0
  7. package/dist/embeddings/index.js +43 -0
  8. package/dist/index-1j1anhmr.js +4038 -0
  9. package/dist/index-3s0eak0p.js +1556 -0
  10. package/dist/index-8pce39mh.js +272 -0
  11. package/dist/index-a76rekgs.js +67 -0
  12. package/dist/index-cy9k1g6v.js +684 -0
  13. package/dist/index-fd4e26s4.js +69 -0
  14. package/dist/{store/eav-store.js → index-gkvhzm9f.js} +4 -6
  15. package/dist/index-gnw8d7d6.js +51 -0
  16. package/dist/index-vkpkfwhq.js +817 -0
  17. package/dist/index.js +118 -2876
  18. package/dist/links/index.js +55 -0
  19. package/dist/transformers-m9je15kg.js +32491 -0
  20. package/dist/vcs/index.js +110 -0
  21. package/logo.png +0 -0
  22. package/logo.svg +9 -0
  23. package/package.json +79 -76
  24. package/src/cli/index.ts +2340 -0
  25. package/src/core/index.ts +35 -0
  26. package/src/core/kernel/middleware.ts +44 -0
  27. package/src/core/persist/backend.ts +64 -0
  28. package/src/core/store/eav-store.ts +467 -0
  29. package/src/decisions/auto-capture.ts +136 -0
  30. package/src/decisions/hooks.ts +163 -0
  31. package/src/decisions/index.ts +261 -0
  32. package/src/decisions/types.ts +103 -0
  33. package/src/embeddings/chunker.ts +327 -0
  34. package/src/embeddings/index.ts +41 -0
  35. package/src/embeddings/model.ts +95 -0
  36. package/src/embeddings/search.ts +305 -0
  37. package/src/embeddings/store.ts +313 -0
  38. package/src/embeddings/types.ts +85 -0
  39. package/src/engine.ts +1083 -0
  40. package/src/garden/cluster.ts +330 -0
  41. package/src/garden/garden.ts +306 -0
  42. package/src/garden/index.ts +29 -0
  43. package/src/git/git-exporter.ts +286 -0
  44. package/src/git/git-importer.ts +329 -0
  45. package/src/git/git-reader.ts +189 -0
  46. package/src/git/index.ts +22 -0
  47. package/src/identity/governance.ts +211 -0
  48. package/src/identity/identity.ts +224 -0
  49. package/src/identity/index.ts +30 -0
  50. package/src/identity/signing-middleware.ts +97 -0
  51. package/src/index.ts +20 -0
  52. package/src/links/index.ts +49 -0
  53. package/src/links/lifecycle.ts +400 -0
  54. package/src/links/parser.ts +484 -0
  55. package/src/links/ref-index.ts +186 -0
  56. package/src/links/resolver.ts +314 -0
  57. package/src/links/types.ts +108 -0
  58. package/src/mcp/index.ts +22 -0
  59. package/src/mcp/server.ts +1278 -0
  60. package/src/semantic/csharp-parser.ts +493 -0
  61. package/src/semantic/go-parser.ts +585 -0
  62. package/src/semantic/index.ts +34 -0
  63. package/src/semantic/java-parser.ts +456 -0
  64. package/src/semantic/python-parser.ts +659 -0
  65. package/src/semantic/ruby-parser.ts +446 -0
  66. package/src/semantic/rust-parser.ts +784 -0
  67. package/src/semantic/semantic-merge.ts +210 -0
  68. package/src/semantic/ts-parser.ts +681 -0
  69. package/src/semantic/types.ts +175 -0
  70. package/src/sync/index.ts +32 -0
  71. package/src/sync/memory-transport.ts +66 -0
  72. package/src/sync/reconciler.ts +237 -0
  73. package/src/sync/sync-engine.ts +258 -0
  74. package/src/sync/types.ts +104 -0
  75. package/src/vcs/blob-store.ts +124 -0
  76. package/src/vcs/branch.ts +150 -0
  77. package/src/vcs/checkpoint.ts +64 -0
  78. package/src/vcs/decompose.ts +469 -0
  79. package/src/vcs/diff.ts +409 -0
  80. package/src/vcs/engine-context.ts +26 -0
  81. package/src/vcs/index.ts +23 -0
  82. package/src/vcs/issue.ts +800 -0
  83. package/src/vcs/merge.ts +425 -0
  84. package/src/vcs/milestone.ts +124 -0
  85. package/src/vcs/ops.ts +59 -0
  86. package/src/vcs/types.ts +213 -0
  87. package/src/vcs/vcs-middleware.ts +81 -0
  88. package/src/watcher/fs-watcher.ts +217 -0
  89. package/src/watcher/index.ts +9 -0
  90. package/src/watcher/ingestion.ts +116 -0
  91. package/dist/ai/index.js +0 -688
  92. package/dist/cli/server.js +0 -3321
  93. package/dist/cli/tql.js +0 -5282
  94. package/dist/client/tql-client.js +0 -108
  95. package/dist/graph/index.js +0 -2248
  96. package/dist/kernel/logic-middleware.js +0 -179
  97. package/dist/kernel/middleware.js +0 -0
  98. package/dist/kernel/operations.js +0 -32
  99. package/dist/kernel/schema-middleware.js +0 -34
  100. package/dist/kernel/security-middleware.js +0 -53
  101. package/dist/kernel/trellis-kernel.js +0 -2239
  102. package/dist/kernel/workspace.js +0 -91
  103. package/dist/persist/backend.js +0 -0
  104. package/dist/persist/sqlite-backend.js +0 -123
  105. package/dist/query/index.js +0 -1643
  106. package/dist/server/index.js +0 -3309
  107. package/dist/workflows/index.js +0 -3160
@@ -0,0 +1,493 @@
1
+ /**
2
+ * C# Parser Adapter
3
+ *
4
+ * Tier 1 regex-based parser for C# source files.
5
+ * Extracts classes, interfaces, structs, enums, records,
6
+ * methods, properties, fields, using directives, and namespace exports.
7
+ *
8
+ * @see TRL-10
9
+ */
10
+
11
+ import type {
12
+ ParserAdapter,
13
+ ParseResult,
14
+ ASTEntity,
15
+ ASTEntityKind,
16
+ ImportRelation,
17
+ ExportRelation,
18
+ SemanticPatch,
19
+ } from './types.js';
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // Parser Adapter
23
+ // ---------------------------------------------------------------------------
24
+
25
+ export const csharpParser: ParserAdapter = {
26
+ languages: ['csharp'],
27
+
28
+ parse(content: string, filePath: string): ParseResult {
29
+ const fileEntityId = `file:${filePath}`;
30
+
31
+ return {
32
+ fileEntityId,
33
+ filePath,
34
+ language: 'csharp',
35
+ declarations: extractDeclarations(content, filePath),
36
+ imports: extractImports(content),
37
+ exports: extractExports(content),
38
+ };
39
+ },
40
+
41
+ diff(oldResult: ParseResult, newResult: ParseResult): SemanticPatch[] {
42
+ return computeSemanticDiff(oldResult, newResult);
43
+ },
44
+ };
45
+
46
+ // ---------------------------------------------------------------------------
47
+ // Declaration extraction
48
+ // ---------------------------------------------------------------------------
49
+
50
+ const MODIFIERS_RE = /(?:(?:public|private|protected|internal|static|abstract|sealed|virtual|override|partial|readonly|async|extern|unsafe|volatile|new)\s+)*/;
51
+ const TYPE_DEF_RE = new RegExp(`^${MODIFIERS_RE.source}(class|interface|struct|enum|record)\\s+(\\w+)`);
52
+ const METHOD_RE = new RegExp(`^${MODIFIERS_RE.source}(?:\\w[\\w<>\\[\\],\\s?]*?)\\s+(\\w+)\\s*[(<]`);
53
+ const PROP_RE = new RegExp(`^${MODIFIERS_RE.source}(?:\\w[\\w<>\\[\\],\\s?]*?)\\s+(\\w+)\\s*\\{`);
54
+ const FIELD_RE = new RegExp(`^${MODIFIERS_RE.source}(?:\\w[\\w<>\\[\\],\\s?]*?)\\s+(\\w+)\\s*[;=]`);
55
+
56
+ function extractDeclarations(content: string, filePath: string): ASTEntity[] {
57
+ const declarations: ASTEntity[] = [];
58
+ const lines = content.split('\n');
59
+
60
+ let i = 0;
61
+ while (i < lines.length) {
62
+ const trimmed = lines[i].trim();
63
+
64
+ // Skip empty, comments, using, namespace
65
+ if (
66
+ !trimmed ||
67
+ trimmed.startsWith('//') ||
68
+ trimmed.startsWith('/*') ||
69
+ trimmed.startsWith('*') ||
70
+ trimmed.startsWith('using ') ||
71
+ trimmed.startsWith('namespace ')
72
+ ) {
73
+ i++;
74
+ continue;
75
+ }
76
+
77
+ // Collect attributes
78
+ const attributes: string[] = [];
79
+ const attrStart = i;
80
+ while (i < lines.length && lines[i].trim().startsWith('[')) {
81
+ attributes.push(lines[i].trim());
82
+ i++;
83
+ }
84
+ if (i >= lines.length) break;
85
+
86
+ const declLine = lines[i].trim();
87
+
88
+ // Class/Interface/Struct/Enum/Record
89
+ const typeMatch = declLine.match(TYPE_DEF_RE);
90
+ if (typeMatch) {
91
+ const typeKind = typeMatch[1];
92
+ const name = typeMatch[2];
93
+ const kind: ASTEntityKind =
94
+ typeKind === 'interface' ? 'InterfaceDef' :
95
+ typeKind === 'enum' ? 'EnumDef' :
96
+ 'ClassDef';
97
+ const result = extractBraceBlock(
98
+ name, kind, lines,
99
+ attributes.length > 0 ? attrStart : i,
100
+ i, filePath,
101
+ );
102
+ result.entity.children = extractTypeMembers(lines, i, result.endLine, name, filePath);
103
+ declarations.push(result.entity);
104
+ i = result.endLine + 1;
105
+ continue;
106
+ }
107
+
108
+ // If attributes collected but no match, skip
109
+ if (attributes.length > 0) {
110
+ i++;
111
+ continue;
112
+ }
113
+
114
+ i++;
115
+ }
116
+
117
+ return declarations;
118
+ }
119
+
120
+ // ---------------------------------------------------------------------------
121
+ // Block extraction
122
+ // ---------------------------------------------------------------------------
123
+
124
+ interface ExtractionResult {
125
+ entity: ASTEntity;
126
+ endLine: number;
127
+ }
128
+
129
+ function extractBraceBlock(
130
+ name: string,
131
+ kind: ASTEntityKind,
132
+ lines: string[],
133
+ startLine: number,
134
+ defLine: number,
135
+ filePath: string,
136
+ ): ExtractionResult {
137
+ let depth = 0;
138
+ let foundOpen = false;
139
+ let endLine = defLine;
140
+
141
+ for (let i = defLine; i < lines.length; i++) {
142
+ for (const ch of lines[i]) {
143
+ if (ch === '{') { depth++; foundOpen = true; }
144
+ else if (ch === '}') depth--;
145
+ }
146
+ if (foundOpen && depth <= 0) { endLine = i; break; }
147
+ if (i > defLine + 500) { endLine = i; break; }
148
+ endLine = i;
149
+ }
150
+
151
+ const rawText = lines.slice(startLine, endLine + 1).join('\n');
152
+ const startOffset = lines.slice(0, startLine).join('\n').length + (startLine > 0 ? 1 : 0);
153
+
154
+ return {
155
+ entity: {
156
+ id: makeEntityId(filePath, kind, name),
157
+ kind,
158
+ name,
159
+ scopePath: name,
160
+ span: [startOffset, startOffset + rawText.length],
161
+ rawText,
162
+ signature: normalizeSignature(rawText),
163
+ children: [],
164
+ },
165
+ endLine,
166
+ };
167
+ }
168
+
169
+ // ---------------------------------------------------------------------------
170
+ // Type member extraction
171
+ // ---------------------------------------------------------------------------
172
+
173
+ const CONTROL_FLOW = new Set(['if', 'for', 'foreach', 'while', 'switch', 'catch', 'using', 'lock', 'try', 'else', 'return', 'throw', 'new', 'yield', 'await']);
174
+
175
+ function extractTypeMembers(
176
+ lines: string[],
177
+ startLine: number,
178
+ endLine: number,
179
+ parentName: string,
180
+ filePath: string,
181
+ ): ASTEntity[] {
182
+ const children: ASTEntity[] = [];
183
+ let depth = 0;
184
+
185
+ for (let i = startLine; i <= endLine; i++) {
186
+ const line = lines[i];
187
+ const depthBefore = depth;
188
+
189
+ for (const ch of line) {
190
+ if (ch === '{') depth++;
191
+ else if (ch === '}') depth--;
192
+ }
193
+
194
+ if (depthBefore !== 1) continue;
195
+
196
+ const trimmed = line.trim();
197
+ if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*') || trimmed.startsWith('[')) continue;
198
+
199
+ // Nested type
200
+ const nestedMatch = trimmed.match(TYPE_DEF_RE);
201
+ if (nestedMatch) {
202
+ const typeKind = nestedMatch[1];
203
+ const name = nestedMatch[2];
204
+ const kind: ASTEntityKind =
205
+ typeKind === 'interface' ? 'InterfaceDef' :
206
+ typeKind === 'enum' ? 'EnumDef' :
207
+ 'ClassDef';
208
+ children.push({
209
+ id: makeEntityId(filePath, kind, `${parentName}.${name}`),
210
+ kind,
211
+ name,
212
+ scopePath: `${parentName}.${name}`,
213
+ span: [0, 0],
214
+ rawText: trimmed,
215
+ signature: normalizeSignature(trimmed),
216
+ children: [],
217
+ });
218
+ continue;
219
+ }
220
+
221
+ // Constructor: ClassName(
222
+ const ctorMatch = trimmed.match(new RegExp(`^${MODIFIERS_RE.source}${parentName}\\s*\\(`));
223
+ if (ctorMatch) {
224
+ children.push({
225
+ id: makeEntityId(filePath, 'Constructor', `${parentName}.${parentName}`),
226
+ kind: 'Constructor',
227
+ name: parentName,
228
+ scopePath: `${parentName}.${parentName}`,
229
+ span: [0, 0],
230
+ rawText: trimmed,
231
+ signature: normalizeSignature(trimmed),
232
+ children: [],
233
+ });
234
+ continue;
235
+ }
236
+
237
+ // Property: type Name { get; set; } or type Name {
238
+ const propMatch = trimmed.match(PROP_RE);
239
+ if (propMatch) {
240
+ const name = propMatch[1];
241
+ if (!CONTROL_FLOW.has(name)) {
242
+ // Check if it looks like a property (has get/set or => or the { is property accessor)
243
+ const restOfLine = trimmed.slice(trimmed.indexOf(name) + name.length).trim();
244
+ if (restOfLine.startsWith('{') && (
245
+ restOfLine.includes('get') || restOfLine.includes('set') ||
246
+ restOfLine.includes('=>') || !restOfLine.includes('(')
247
+ )) {
248
+ children.push({
249
+ id: makeEntityId(filePath, 'PropertyDef', `${parentName}.${name}`),
250
+ kind: 'PropertyDef',
251
+ name,
252
+ scopePath: `${parentName}.${name}`,
253
+ span: [0, 0],
254
+ rawText: trimmed,
255
+ signature: normalizeSignature(trimmed),
256
+ children: [],
257
+ });
258
+ continue;
259
+ }
260
+ }
261
+ }
262
+
263
+ // Method: returnType Name( or returnType Name<T>(
264
+ const methodMatch = trimmed.match(METHOD_RE);
265
+ if (methodMatch) {
266
+ const name = methodMatch[1];
267
+ if (!CONTROL_FLOW.has(name) && name !== parentName) {
268
+ children.push({
269
+ id: makeEntityId(filePath, 'MethodDef', `${parentName}.${name}`),
270
+ kind: 'MethodDef',
271
+ name,
272
+ scopePath: `${parentName}.${name}`,
273
+ span: [0, 0],
274
+ rawText: trimmed,
275
+ signature: normalizeSignature(trimmed),
276
+ children: [],
277
+ });
278
+ continue;
279
+ }
280
+ }
281
+
282
+ // Field: type name ; or type name =
283
+ const fieldMatch = trimmed.match(FIELD_RE);
284
+ if (fieldMatch) {
285
+ const name = fieldMatch[1];
286
+ if (!CONTROL_FLOW.has(name) && name !== 'var') {
287
+ children.push({
288
+ id: makeEntityId(filePath, 'PropertyDef', `${parentName}.${name}`),
289
+ kind: 'PropertyDef',
290
+ name,
291
+ scopePath: `${parentName}.${name}`,
292
+ span: [0, 0],
293
+ rawText: trimmed,
294
+ signature: normalizeSignature(trimmed),
295
+ children: [],
296
+ });
297
+ }
298
+ }
299
+ }
300
+ return children;
301
+ }
302
+
303
+ // ---------------------------------------------------------------------------
304
+ // Import extraction (using directives)
305
+ // ---------------------------------------------------------------------------
306
+
307
+ function extractImports(content: string): ImportRelation[] {
308
+ const imports: ImportRelation[] = [];
309
+ const lines = content.split('\n');
310
+
311
+ for (const line of lines) {
312
+ const trimmed = line.trim();
313
+
314
+ // using Namespace;
315
+ let match = trimmed.match(/^using\s+([A-Z][\w.]+)\s*;/);
316
+ if (match) {
317
+ imports.push({
318
+ source: match[1],
319
+ specifiers: [match[1].split('.').pop()!],
320
+ isDefault: false,
321
+ isNamespace: true,
322
+ rawText: trimmed,
323
+ span: [0, trimmed.length],
324
+ });
325
+ continue;
326
+ }
327
+
328
+ // using static Namespace.Class;
329
+ match = trimmed.match(/^using\s+static\s+([A-Z][\w.]+)\s*;/);
330
+ if (match) {
331
+ imports.push({
332
+ source: match[1],
333
+ specifiers: [match[1].split('.').pop()!],
334
+ isDefault: false,
335
+ isNamespace: false,
336
+ rawText: trimmed,
337
+ span: [0, trimmed.length],
338
+ });
339
+ continue;
340
+ }
341
+
342
+ // using Alias = Namespace.Type;
343
+ match = trimmed.match(/^using\s+(\w+)\s*=\s*([^;]+);/);
344
+ if (match) {
345
+ imports.push({
346
+ source: match[2].trim(),
347
+ specifiers: [match[1]],
348
+ isDefault: true,
349
+ isNamespace: false,
350
+ rawText: trimmed,
351
+ span: [0, trimmed.length],
352
+ });
353
+ }
354
+ }
355
+
356
+ return imports;
357
+ }
358
+
359
+ // ---------------------------------------------------------------------------
360
+ // Export extraction
361
+ // ---------------------------------------------------------------------------
362
+
363
+ function extractExports(content: string): ExportRelation[] {
364
+ const exports: ExportRelation[] = [];
365
+ const lines = content.split('\n');
366
+
367
+ for (const line of lines) {
368
+ const trimmed = line.trim();
369
+
370
+ // Public types are exported
371
+ const match = trimmed.match(/^public\s+(?:(?:abstract|sealed|static|partial)\s+)*(class|interface|struct|enum|record)\s+(\w+)/);
372
+ if (match) {
373
+ exports.push({
374
+ name: match[2],
375
+ isDefault: false,
376
+ rawText: trimmed.split('{')[0].trim(),
377
+ span: [0, 0],
378
+ });
379
+ }
380
+ }
381
+
382
+ return exports;
383
+ }
384
+
385
+ // ---------------------------------------------------------------------------
386
+ // Semantic diff
387
+ // ---------------------------------------------------------------------------
388
+
389
+ function computeSemanticDiff(
390
+ oldResult: ParseResult,
391
+ newResult: ParseResult,
392
+ ): SemanticPatch[] {
393
+ const patches: SemanticPatch[] = [];
394
+ const fileId = newResult.fileEntityId;
395
+
396
+ const oldDecls = new Map(oldResult.declarations.map(d => [d.id, d]));
397
+ const newDecls = new Map(newResult.declarations.map(d => [d.id, d]));
398
+
399
+ for (const [id, entity] of newDecls) {
400
+ if (!oldDecls.has(id)) {
401
+ const oldEntity = findRenamedEntity(entity, oldResult.declarations, newDecls);
402
+ if (oldEntity) {
403
+ patches.push({ kind: 'symbolRename', entityId: oldEntity.id, oldName: oldEntity.name, newName: entity.name });
404
+ } else {
405
+ patches.push({ kind: 'symbolAdd', entity });
406
+ }
407
+ }
408
+ }
409
+
410
+ for (const [id, entity] of oldDecls) {
411
+ if (!newDecls.has(id)) {
412
+ const wasRenamed = findRenamedEntity(entity, newResult.declarations, oldDecls);
413
+ if (!wasRenamed) {
414
+ patches.push({ kind: 'symbolRemove', entityId: id, entityName: entity.name });
415
+ }
416
+ }
417
+ }
418
+
419
+ for (const [id, newEntity] of newDecls) {
420
+ const oldEntity = oldDecls.get(id);
421
+ if (oldEntity && oldEntity.signature !== newEntity.signature) {
422
+ patches.push({
423
+ kind: 'symbolModify', entityId: id, entityName: newEntity.name,
424
+ oldSignature: oldEntity.signature, newSignature: newEntity.signature,
425
+ oldRawText: oldEntity.rawText, newRawText: newEntity.rawText,
426
+ });
427
+ }
428
+ }
429
+
430
+ const oldImports = new Map(oldResult.imports.map(imp => [imp.source, imp]));
431
+ const newImports = new Map(newResult.imports.map(imp => [imp.source, imp]));
432
+
433
+ for (const [source, imp] of newImports) {
434
+ const oldImp = oldImports.get(source);
435
+ if (!oldImp) {
436
+ patches.push({ kind: 'importAdd', fileId, source, specifiers: imp.specifiers, rawText: imp.rawText });
437
+ } else if (JSON.stringify(oldImp.specifiers.sort()) !== JSON.stringify(imp.specifiers.sort())) {
438
+ patches.push({ kind: 'importModify', fileId, source, oldSpecifiers: oldImp.specifiers, newSpecifiers: imp.specifiers });
439
+ }
440
+ }
441
+ for (const [source] of oldImports) {
442
+ if (!newImports.has(source)) {
443
+ patches.push({ kind: 'importRemove', fileId, source });
444
+ }
445
+ }
446
+
447
+ const oldExports = new Map(oldResult.exports.map(exp => [exp.name, exp]));
448
+ const newExports = new Map(newResult.exports.map(exp => [exp.name, exp]));
449
+ for (const [name, exp] of newExports) {
450
+ if (!oldExports.has(name)) {
451
+ patches.push({ kind: 'exportAdd', fileId, name, rawText: exp.rawText });
452
+ }
453
+ }
454
+ for (const [name] of oldExports) {
455
+ if (!newExports.has(name)) {
456
+ patches.push({ kind: 'exportRemove', fileId, name });
457
+ }
458
+ }
459
+
460
+ return patches;
461
+ }
462
+
463
+ // ---------------------------------------------------------------------------
464
+ // Helpers
465
+ // ---------------------------------------------------------------------------
466
+
467
+ function findRenamedEntity(
468
+ entity: ASTEntity,
469
+ candidates: ASTEntity[],
470
+ existingIds: Map<string, ASTEntity>,
471
+ ): ASTEntity | null {
472
+ for (const candidate of candidates) {
473
+ if (candidate.kind !== entity.kind) continue;
474
+ if (candidate.name === entity.name) continue;
475
+ if (existingIds.has(candidate.id)) continue;
476
+ const normalizedOld = candidate.signature.replace(new RegExp(candidate.name, 'g'), '___');
477
+ const normalizedNew = entity.signature.replace(new RegExp(entity.name, 'g'), '___');
478
+ if (normalizedOld === normalizedNew) return candidate;
479
+ }
480
+ return null;
481
+ }
482
+
483
+ function makeEntityId(filePath: string, kind: string, name: string): string {
484
+ return `${kind}:${filePath}:${name}`;
485
+ }
486
+
487
+ function normalizeSignature(text: string): string {
488
+ return text
489
+ .replace(/\/\/[^\n]*/g, '')
490
+ .replace(/\/\*[\s\S]*?\*\//g, '')
491
+ .replace(/\s+/g, ' ')
492
+ .trim();
493
+ }