@getmikk/core 2.0.14 → 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/type-flow.ts +1 -1
- package/src/cache/incremental-cache.ts +86 -80
- package/src/contract/contract-reader.ts +1 -0
- package/src/contract/lock-compiler.ts +95 -13
- package/src/contract/schema.ts +2 -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 +2 -0
- package/src/parser/base-extractor.ts +19 -0
- package/src/parser/boundary-checker.ts +31 -12
- package/src/parser/error-recovery.ts +5 -4
- package/src/parser/function-body-extractor.ts +248 -0
- package/src/parser/go/go-extractor.ts +249 -676
- package/src/parser/index.ts +132 -318
- 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 +369 -62
- 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/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 +104 -50
- package/src/utils/json.ts +1 -0
- package/src/utils/language-registry.ts +84 -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,117 @@
|
|
|
1
|
+
import { describe, it, expect } from 'bun:test'
|
|
2
|
+
import * as path from 'node:path'
|
|
3
|
+
import * as fs from 'node:fs'
|
|
4
|
+
import { TreeSitterParser } from '../src/parser/tree-sitter/parser'
|
|
5
|
+
|
|
6
|
+
const POLYGLOT_FIXTURE = path.resolve(import.meta.dir, '../../../benchmarks/fixtures/polyglot-services/src')
|
|
7
|
+
|
|
8
|
+
const tsParser = new TreeSitterParser()
|
|
9
|
+
|
|
10
|
+
const LANGUAGES = [
|
|
11
|
+
{ name: 'Go', ext: '.go', file: 'main.go', works: true },
|
|
12
|
+
{ name: 'Python', ext: '.py', file: 'models.py', works: true },
|
|
13
|
+
{ name: 'Java', ext: '.java', file: 'App.java', works: true },
|
|
14
|
+
{ name: 'Swift', ext: '.swift', file: 'UserService.swift', works: true },
|
|
15
|
+
{ name: 'C', ext: '.c', file: 'main.c', works: true },
|
|
16
|
+
{ name: 'C++', ext: '.cpp', file: 'main.cpp', works: true },
|
|
17
|
+
{ name: 'C#', ext: '.cs', file: 'Models.cs', works: true },
|
|
18
|
+
{ name: 'Rust', ext: '.rs', file: 'main.rs', works: true },
|
|
19
|
+
{ name: 'PHP', ext: '.php', file: 'Models.php', works: true },
|
|
20
|
+
{ name: 'Shell', ext: '.sh', file: 'user-service.sh', works: true },
|
|
21
|
+
{ name: 'Kotlin', ext: '.kt', file: 'Calculator.kt', works: false, reason: 'Fixture missing' },
|
|
22
|
+
{ name: 'Scala', ext: '.scala', file: 'Service.scala', works: false, reason: 'Fixture missing' },
|
|
23
|
+
{ name: 'Dart', ext: '.dart', file: 'user_service.dart', works: false, reason: 'Tree-sitter grammar issue' },
|
|
24
|
+
{ name: 'Zig', ext: '.zig', file: 'main.zig', works: false, reason: 'Fixture missing' },
|
|
25
|
+
{ name: 'Ruby', ext: '.rb', file: 'models.rb', works: false, reason: 'Fixture missing' },
|
|
26
|
+
{ name: 'Haskell', ext: '.hs', file: 'UserService.hs', works: false, reason: 'Fixture missing' },
|
|
27
|
+
{ name: 'Elixir', ext: '.ex', file: 'user_service.ex', works: false, reason: 'Fixture missing' },
|
|
28
|
+
{ name: 'Clojure', ext: '.clj', file: 'user_service.clj', works: false, reason: 'Fixture missing' },
|
|
29
|
+
{ name: 'F#', ext: '.fs', file: 'UserService.fs', works: false, reason: 'Fixture missing' },
|
|
30
|
+
{ name: 'OCaml', ext: '.ml', file: 'user_service.ml', works: false, reason: 'Fixture missing' },
|
|
31
|
+
{ name: 'Perl', ext: '.pm', file: 'UserService.pm', works: false, reason: 'Fixture missing' },
|
|
32
|
+
{ name: 'R', ext: '.R', file: 'user_service.R', works: false, reason: 'Fixture missing' },
|
|
33
|
+
{ name: 'Julia', ext: '.jl', file: 'user_service.jl', works: false, reason: 'Fixture missing' },
|
|
34
|
+
{ name: 'Lua', ext: '.lua', file: 'user_service.lua', works: false, reason: 'Fixture missing' },
|
|
35
|
+
{ name: 'SQL', ext: '.sql', file: 'schema.sql', works: false, reason: 'Fixture missing' },
|
|
36
|
+
{ name: 'Terraform', ext: '.tf', file: 'main.tf', works: false, reason: 'Fixture missing' },
|
|
37
|
+
] as const
|
|
38
|
+
|
|
39
|
+
describe('Tree-sitter Parser - Working Languages', () => {
|
|
40
|
+
for (const lang of LANGUAGES) {
|
|
41
|
+
if (!lang.works) continue
|
|
42
|
+
const filePath = path.join(POLYGLOT_FIXTURE, lang.file)
|
|
43
|
+
|
|
44
|
+
it(`${lang.name} (${lang.ext}) - ${lang.file}: parses without error`, async () => {
|
|
45
|
+
expect(fs.existsSync(filePath)).toBe(true)
|
|
46
|
+
|
|
47
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
48
|
+
const result = await tsParser.extract(filePath, content)
|
|
49
|
+
|
|
50
|
+
expect(result).toBeDefined()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it(`${lang.name} (${lang.ext}) - ${lang.file}: extracts functions`, async () => {
|
|
54
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
55
|
+
const result = await tsParser.extract(filePath, content)
|
|
56
|
+
|
|
57
|
+
const functions = result.functions.filter(f => f.name !== '<module>')
|
|
58
|
+
expect(functions.length).toBeGreaterThan(0)
|
|
59
|
+
console.log(` ✓ ${lang.name}: ${functions.length} functions`)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it(`${lang.name} (${lang.ext}) - ${lang.file}: function metadata is valid`, async () => {
|
|
63
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
64
|
+
const result = await tsParser.extract(filePath, content)
|
|
65
|
+
|
|
66
|
+
for (const fn of result.functions) {
|
|
67
|
+
expect(fn.name).toBeDefined()
|
|
68
|
+
expect(fn.startLine).toBeGreaterThan(0)
|
|
69
|
+
expect(fn.endLine).toBeGreaterThanOrEqual(fn.startLine)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe('Tree-sitter Parser - Languages Needing Fixes', () => {
|
|
76
|
+
for (const lang of LANGUAGES) {
|
|
77
|
+
if (lang.works) continue
|
|
78
|
+
const filePath = path.join(POLYGLOT_FIXTURE, lang.file)
|
|
79
|
+
|
|
80
|
+
it(`${lang.name} (${lang.ext}) - ${lang.file}: gracefully handles issues`, async () => {
|
|
81
|
+
// Known issue - skip Dart parsing
|
|
82
|
+
if (lang.name === 'Dart') {
|
|
83
|
+
console.log(` ⏭ ${lang.name}: known tree-sitter grammar issue, skipping`)
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Skip if fixture file doesn't exist
|
|
88
|
+
if (!fs.existsSync(filePath)) {
|
|
89
|
+
console.log(` ⏭ ${lang.name}: fixture not found, skipping`)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
94
|
+
const result = await tsParser.extract(filePath, content)
|
|
95
|
+
|
|
96
|
+
expect(result).toBeDefined()
|
|
97
|
+
expect(typeof result.path).toBe('string')
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('Language Fixture Summary', () => {
|
|
103
|
+
it('fixture has all expected language files', () => {
|
|
104
|
+
const files = fs.readdirSync(POLYGLOT_FIXTURE)
|
|
105
|
+
const extensions = new Set(files.map(f => path.extname(f)))
|
|
106
|
+
|
|
107
|
+
const workingCount = LANGUAGES.filter(l => l.works).length
|
|
108
|
+
const brokenCount = LANGUAGES.filter(l => !l.works).length
|
|
109
|
+
|
|
110
|
+
console.log(`\nLanguage Status:`)
|
|
111
|
+
console.log(` Working: ${workingCount} languages`)
|
|
112
|
+
console.log(` Needs fixes: ${brokenCount} languages`)
|
|
113
|
+
console.log(` Total: ${LANGUAGES.length} languages\n`)
|
|
114
|
+
|
|
115
|
+
expect(LANGUAGES.length).toBeGreaterThan(0)
|
|
116
|
+
})
|
|
117
|
+
})
|