@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.
- package/README.md +4 -4
- package/package.json +2 -1
- package/src/analysis/index.ts +9 -0
- package/src/analysis/taint-analysis.ts +419 -0
- package/src/analysis/type-flow.ts +247 -0
- package/src/cache/incremental-cache.ts +278 -0
- package/src/cache/index.ts +1 -0
- package/src/contract/contract-generator.ts +31 -3
- package/src/contract/contract-reader.ts +1 -0
- package/src/contract/lock-compiler.ts +125 -12
- package/src/contract/schema.ts +4 -0
- package/src/error-handler.ts +2 -1
- package/src/graph/cluster-detector.ts +2 -4
- package/src/graph/dead-code-detector.ts +303 -117
- package/src/graph/graph-builder.ts +21 -161
- package/src/graph/impact-analyzer.ts +1 -0
- package/src/graph/index.ts +2 -0
- package/src/graph/rich-function-index.ts +1080 -0
- package/src/graph/symbol-table.ts +252 -0
- package/src/hash/hash-store.ts +1 -0
- package/src/index.ts +4 -0
- package/src/parser/base-extractor.ts +19 -0
- package/src/parser/boundary-checker.ts +31 -12
- package/src/parser/error-recovery.ts +647 -0
- package/src/parser/function-body-extractor.ts +248 -0
- package/src/parser/go/go-extractor.ts +249 -676
- package/src/parser/index.ts +138 -295
- package/src/parser/language-registry.ts +57 -0
- package/src/parser/oxc-parser.ts +166 -28
- package/src/parser/oxc-resolver.ts +179 -11
- package/src/parser/parser-constants.ts +1 -0
- package/src/parser/rust/rust-extractor.ts +109 -0
- package/src/parser/tree-sitter/parser.ts +400 -66
- package/src/parser/tree-sitter/queries.ts +106 -10
- package/src/parser/types.ts +20 -1
- package/src/search/bm25.ts +21 -8
- package/src/search/direct-search.ts +472 -0
- package/src/search/embedding-provider.ts +249 -0
- package/src/search/index.ts +12 -0
- package/src/search/semantic-search.ts +435 -0
- package/src/security/index.ts +1 -0
- package/src/security/scanner.ts +342 -0
- package/src/utils/artifact-transaction.ts +1 -0
- package/src/utils/atomic-write.ts +1 -0
- package/src/utils/errors.ts +89 -4
- package/src/utils/fs.ts +150 -65
- package/src/utils/json.ts +1 -0
- package/src/utils/language-registry.ts +96 -5
- package/src/utils/minimatch.ts +49 -6
- package/src/utils/path.ts +26 -0
- package/tests/dead-code.test.ts +3 -2
- package/tests/direct-search.test.ts +435 -0
- package/tests/error-recovery.test.ts +143 -0
- package/tests/fixtures/simple-api/src/index.ts +1 -1
- package/tests/go-parser.test.ts +19 -335
- package/tests/js-parser.test.ts +18 -1089
- package/tests/language-registry-all.test.ts +276 -0
- package/tests/language-registry.test.ts +6 -4
- package/tests/parse-diagnostics.test.ts +9 -96
- package/tests/parser.test.ts +42 -771
- package/tests/polyglot-parser.test.ts +117 -0
- package/tests/rich-function-index.test.ts +703 -0
- package/tests/tree-sitter-parser.test.ts +108 -80
- package/tests/ts-parser.test.ts +8 -8
- package/tests/verification.test.ts +175 -0
- package/src/parser/base-parser.ts +0 -16
- package/src/parser/go/go-parser.ts +0 -43
- package/src/parser/javascript/js-extractor.ts +0 -278
- package/src/parser/javascript/js-parser.ts +0 -101
- package/src/parser/typescript/ts-extractor.ts +0 -447
- 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
|
+
});
|