@getmikk/core 2.0.13 → 2.0.15

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 (71) hide show
  1. package/README.md +4 -4
  2. package/package.json +2 -1
  3. package/src/analysis/index.ts +9 -0
  4. package/src/analysis/taint-analysis.ts +419 -0
  5. package/src/analysis/type-flow.ts +247 -0
  6. package/src/cache/incremental-cache.ts +278 -0
  7. package/src/cache/index.ts +1 -0
  8. package/src/contract/contract-generator.ts +31 -3
  9. package/src/contract/contract-reader.ts +1 -0
  10. package/src/contract/lock-compiler.ts +125 -12
  11. package/src/contract/schema.ts +4 -0
  12. package/src/error-handler.ts +2 -1
  13. package/src/graph/cluster-detector.ts +2 -4
  14. package/src/graph/dead-code-detector.ts +303 -117
  15. package/src/graph/graph-builder.ts +21 -161
  16. package/src/graph/impact-analyzer.ts +1 -0
  17. package/src/graph/index.ts +2 -0
  18. package/src/graph/rich-function-index.ts +1080 -0
  19. package/src/graph/symbol-table.ts +252 -0
  20. package/src/hash/hash-store.ts +1 -0
  21. package/src/index.ts +4 -0
  22. package/src/parser/base-extractor.ts +19 -0
  23. package/src/parser/boundary-checker.ts +31 -12
  24. package/src/parser/error-recovery.ts +647 -0
  25. package/src/parser/function-body-extractor.ts +248 -0
  26. package/src/parser/go/go-extractor.ts +249 -676
  27. package/src/parser/index.ts +138 -295
  28. package/src/parser/language-registry.ts +57 -0
  29. package/src/parser/oxc-parser.ts +166 -28
  30. package/src/parser/oxc-resolver.ts +179 -11
  31. package/src/parser/parser-constants.ts +1 -0
  32. package/src/parser/rust/rust-extractor.ts +109 -0
  33. package/src/parser/tree-sitter/parser.ts +400 -66
  34. package/src/parser/tree-sitter/queries.ts +106 -10
  35. package/src/parser/types.ts +20 -1
  36. package/src/search/bm25.ts +21 -8
  37. package/src/search/direct-search.ts +472 -0
  38. package/src/search/embedding-provider.ts +249 -0
  39. package/src/search/index.ts +12 -0
  40. package/src/search/semantic-search.ts +435 -0
  41. package/src/security/index.ts +1 -0
  42. package/src/security/scanner.ts +342 -0
  43. package/src/utils/artifact-transaction.ts +1 -0
  44. package/src/utils/atomic-write.ts +1 -0
  45. package/src/utils/errors.ts +89 -4
  46. package/src/utils/fs.ts +150 -65
  47. package/src/utils/json.ts +1 -0
  48. package/src/utils/language-registry.ts +96 -5
  49. package/src/utils/minimatch.ts +49 -6
  50. package/src/utils/path.ts +26 -0
  51. package/tests/dead-code.test.ts +3 -2
  52. package/tests/direct-search.test.ts +435 -0
  53. package/tests/error-recovery.test.ts +143 -0
  54. package/tests/fixtures/simple-api/src/index.ts +1 -1
  55. package/tests/go-parser.test.ts +19 -335
  56. package/tests/js-parser.test.ts +18 -1089
  57. package/tests/language-registry-all.test.ts +276 -0
  58. package/tests/language-registry.test.ts +6 -4
  59. package/tests/parse-diagnostics.test.ts +9 -96
  60. package/tests/parser.test.ts +42 -771
  61. package/tests/polyglot-parser.test.ts +117 -0
  62. package/tests/rich-function-index.test.ts +703 -0
  63. package/tests/tree-sitter-parser.test.ts +108 -80
  64. package/tests/ts-parser.test.ts +8 -8
  65. package/tests/verification.test.ts +175 -0
  66. package/src/parser/base-parser.ts +0 -16
  67. package/src/parser/go/go-parser.ts +0 -43
  68. package/src/parser/javascript/js-extractor.ts +0 -278
  69. package/src/parser/javascript/js-parser.ts +0 -101
  70. package/src/parser/typescript/ts-extractor.ts +0 -447
  71. package/src/parser/typescript/ts-parser.ts +0 -36
@@ -0,0 +1,109 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { hashContent } from '../../hash/file-hasher.js'
3
+ import { BaseExtractor } from '../base-extractor.js'
4
+ import { LanguageRegistry } from '../language-registry.js'
5
+ import type { ParsedFile, ParsedFunction, ParsedClass, ParsedImport, ParsedExport } from '../types.js'
6
+
7
+ export class RustExtractor extends BaseExtractor {
8
+ constructor() {
9
+ super();
10
+ }
11
+
12
+ async extract(filePath: string, content: string): Promise<ParsedFile> {
13
+ const lines = content.split('\n');
14
+ const functions: ParsedFunction[] = [];
15
+ const classes: ParsedClass[] = []; // Structs/Enums
16
+ const imports: ParsedImport[] = [];
17
+ const exports: ParsedExport[] = [];
18
+
19
+ for (let i = 0; i < lines.length; i++) {
20
+ const line = lines[i].trim();
21
+
22
+ // Minimal Function Detection: pub fn name(...)
23
+ const fnMatch = /^(?:pub(?:\([^)]+\))?\s+)?fn\s+([a-z_][a-z0-9_]*)/.exec(line);
24
+ if (fnMatch) {
25
+ const name = fnMatch[1];
26
+ functions.push({
27
+ id: `fn:${filePath}:${name}`,
28
+ name,
29
+ file: filePath,
30
+ startLine: i + 1,
31
+ endLine: i + 1, // Placeholder
32
+ params: [],
33
+ returnType: 'unknown',
34
+ isExported: line.startsWith('pub'),
35
+ isAsync: line.includes('async fn'),
36
+ calls: [],
37
+ hash: hashContent(line),
38
+ purpose: '',
39
+ edgeCasesHandled: [],
40
+ errorHandling: [],
41
+ detailedLines: []
42
+ });
43
+ if (line.startsWith('pub')) {
44
+ exports.push({ name, type: 'function', file: filePath });
45
+ }
46
+ }
47
+
48
+ // Minimal Import Detection: use path::to::pkg;
49
+ const useMatch = /^use\s+([^;]+);/.exec(line);
50
+ if (useMatch) {
51
+ const path = useMatch[1].trim();
52
+ const parts = path.split('::');
53
+ imports.push({
54
+ source: path,
55
+ resolvedPath: '',
56
+ names: [parts[parts.length - 1]],
57
+ isDefault: false,
58
+ isDynamic: false
59
+ });
60
+ }
61
+
62
+ // Minimal Struct Detection: pub struct Name { ... }
63
+ const structMatch = /^(?:pub(?:\([^)]+\))?\s+)?(?:struct|enum|trait)\s+([A-Z][A-Za-z0-9_]*)/.exec(line);
64
+ if (structMatch) {
65
+ const name = structMatch[1];
66
+ classes.push({
67
+ id: `cls:${filePath}:${name}`,
68
+ name,
69
+ file: filePath,
70
+ startLine: i + 1,
71
+ endLine: i + 1, // Placeholder
72
+ isExported: line.startsWith('pub'),
73
+ methods: [],
74
+ properties: [],
75
+ hash: hashContent(line),
76
+ purpose: ''
77
+ });
78
+ if (line.startsWith('pub')) {
79
+ const type = line.includes('struct') ? 'class' : 'interface';
80
+ exports.push({ name, type, file: filePath });
81
+ }
82
+ }
83
+ }
84
+
85
+ return {
86
+ path: filePath.replace(/\\/g, '/'),
87
+ language: 'rust' as any,
88
+ functions,
89
+ classes,
90
+ variables: [],
91
+ generics: [],
92
+ imports,
93
+ exports,
94
+ routes: [],
95
+ calls: [],
96
+ hash: hashContent(content),
97
+ parsedAt: Date.now()
98
+ };
99
+ }
100
+ }
101
+
102
+ // Automatically register with the LanguageRegistry
103
+ LanguageRegistry.getInstance().register({
104
+ name: 'rust',
105
+ extensions: ['.rs'],
106
+ treeSitterGrammar: '',
107
+ extractor: new RustExtractor(),
108
+ semanticFeatures: { hasTypeSystem: true, hasGenerics: true, hasMacros: true, hasAnnotations: false, hasPatternMatching: true }
109
+ });