@shapeshift-labs/frontier-lang-compiler 0.2.7 → 0.2.9
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 +117 -0
- package/bench/smoke.mjs +73 -2
- package/dist/index.d.ts +414 -0
- package/dist/index.js +2963 -143
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,123 @@ console.log(imported.nativeSource.ast.rootId);
|
|
|
38
38
|
console.log(imported.patch.operations.length);
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
Native imports include source maps, semantic merge candidates, and a loss summary for admission queues and dashboards. Informational losses produce `ready-with-losses`, warning losses produce `needs-review`, and error losses or failed import evidence produce `blocked`:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { classifyNativeImportReadiness, summarizeNativeImportLosses } from '@shapeshift-labs/frontier-lang-compiler';
|
|
45
|
+
|
|
46
|
+
const summary = summarizeNativeImportLosses(imported.losses, { evidence: imported.evidence });
|
|
47
|
+
const readiness = classifyNativeImportReadiness(imported.losses, { evidence: imported.evidence });
|
|
48
|
+
|
|
49
|
+
console.log(summary.categories);
|
|
50
|
+
console.log(readiness.readiness);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Ask the compiler what is actually covered before sending native imports into a merge queue:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import {
|
|
57
|
+
createNativeImportCoverageMatrix,
|
|
58
|
+
importNativeSource
|
|
59
|
+
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
60
|
+
|
|
61
|
+
const imported = importNativeSource({
|
|
62
|
+
language: 'python',
|
|
63
|
+
sourcePath: 'todo.py',
|
|
64
|
+
sourceText: 'def add_todo(title):\n return title\n'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const matrix = createNativeImportCoverageMatrix({ imports: [imported] });
|
|
68
|
+
const python = matrix.languages.find((entry) => entry.language === 'python');
|
|
69
|
+
|
|
70
|
+
console.log(python.imports.readiness); // scanner imports are intentionally review-required
|
|
71
|
+
console.log(python.parserAdapters); // host-owned exact parsers such as LibCST can be injected
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Create a compact semantic sidecar for swarm merge admission. This is the artifact a coordinator can index instead of reading a worker directory by hand:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import {
|
|
78
|
+
createSemanticImportSidecar,
|
|
79
|
+
importNativeSource
|
|
80
|
+
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
81
|
+
|
|
82
|
+
const imported = importNativeSource({
|
|
83
|
+
language: 'typescript',
|
|
84
|
+
sourcePath: 'src/runtime.ts',
|
|
85
|
+
sourceText: `
|
|
86
|
+
export class Runtime {
|
|
87
|
+
step(frame: number) { return frame + 1; }
|
|
88
|
+
}
|
|
89
|
+
`
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const sidecar = createSemanticImportSidecar(imported);
|
|
93
|
+
|
|
94
|
+
console.log(sidecar.summary.emptySemanticIndex); // false when symbols were found
|
|
95
|
+
console.log(sidecar.ownershipRegions[0].key); // source#src/runtime.ts#class#Runtime
|
|
96
|
+
console.log(sidecar.patchHints[0].supportedOperations); // source-region patch operations
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Project a native import back to source. Exact source is preserved only when the supplied text matches the import hash; otherwise the compiler emits declaration stubs with review-required loss evidence:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import {
|
|
103
|
+
importNativeSource,
|
|
104
|
+
projectNativeImportToSource
|
|
105
|
+
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
106
|
+
|
|
107
|
+
const sourceText = 'export function step(frame) { return frame + 1; }\n';
|
|
108
|
+
const imported = importNativeSource({
|
|
109
|
+
language: 'javascript',
|
|
110
|
+
sourcePath: 'src/runtime.js',
|
|
111
|
+
sourceText
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const projection = projectNativeImportToSource(imported, { sourceText });
|
|
115
|
+
|
|
116
|
+
console.log(projection.mode); // "preserved-source"
|
|
117
|
+
console.log(projection.readiness.readiness); // "ready"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Use injected parser adapters when a real language parser is available but should not become a compiler runtime dependency:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
import {
|
|
124
|
+
createBabelNativeImporterAdapter,
|
|
125
|
+
importNativeProject,
|
|
126
|
+
runNativeImporterAdapter
|
|
127
|
+
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
128
|
+
|
|
129
|
+
const babelAdapter = createBabelNativeImporterAdapter({
|
|
130
|
+
parserModule: await import('@babel/parser')
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const imported = await runNativeImporterAdapter(babelAdapter, {
|
|
134
|
+
sourcePath: 'src/todo.ts',
|
|
135
|
+
sourceText
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const project = await importNativeProject({
|
|
139
|
+
projectRoot: 'src',
|
|
140
|
+
adapters: [babelAdapter],
|
|
141
|
+
sources: [
|
|
142
|
+
{ language: 'typescript', adapter: babelAdapter.id, sourcePath: 'src/todo.ts', sourceText },
|
|
143
|
+
{ language: 'python', sourcePath: 'tools/todo.py', sourceText: pythonSource }
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(imported.universalAst.sourceMaps.length);
|
|
148
|
+
console.log(project.semanticIndex.symbols.length);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The built-in adapter factories are dependency-light wrappers for caller-owned parsers or ASTs:
|
|
152
|
+
|
|
153
|
+
- `createEstreeNativeImporterAdapter`
|
|
154
|
+
- `createBabelNativeImporterAdapter`
|
|
155
|
+
- `createTypeScriptCompilerNativeImporterAdapter`
|
|
156
|
+
- `createTreeSitterNativeImporterAdapter`
|
|
157
|
+
|
|
41
158
|
## Related Packages
|
|
42
159
|
|
|
43
160
|
The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
|
package/bench/smoke.mjs
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
compileFrontierSource,
|
|
4
|
+
createEstreeNativeImporterAdapter,
|
|
5
|
+
createNativeImportCoverageMatrix,
|
|
6
|
+
createSemanticImportSidecar,
|
|
7
|
+
importNativeSource,
|
|
8
|
+
projectNativeImportToSource,
|
|
9
|
+
runNativeImporterAdapter
|
|
10
|
+
} from '../dist/index.js';
|
|
3
11
|
|
|
4
12
|
const source = `
|
|
5
13
|
module Bench @id("mod_bench")
|
|
@@ -22,4 +30,67 @@ let bytes = 0;
|
|
|
22
30
|
for (let index = 0; index < 250; index += 1) {
|
|
23
31
|
bytes += compileFrontierSource(source, { target: targets[index % targets.length] }).output.length;
|
|
24
32
|
}
|
|
25
|
-
|
|
33
|
+
const compileDurationMs = performance.now() - start;
|
|
34
|
+
|
|
35
|
+
const importStart = performance.now();
|
|
36
|
+
const estreeAdapter = createEstreeNativeImporterAdapter();
|
|
37
|
+
let nativeSymbols = 0;
|
|
38
|
+
const nativeImportResults = [];
|
|
39
|
+
for (let index = 0; index < 150; index += 1) {
|
|
40
|
+
const imported = index % 2 === 0
|
|
41
|
+
? importNativeSource({
|
|
42
|
+
language: 'javascript',
|
|
43
|
+
sourcePath: `src/bench-${index}.js`,
|
|
44
|
+
sourceText: `export function bench${index}() { return ${index}; }\n`
|
|
45
|
+
})
|
|
46
|
+
: await runNativeImporterAdapter(estreeAdapter, {
|
|
47
|
+
sourcePath: `src/bench-${index}.js`,
|
|
48
|
+
sourceText: `export function bench${index}() { return ${index}; }\n`,
|
|
49
|
+
adapterOptions: {
|
|
50
|
+
ast: {
|
|
51
|
+
type: 'Program',
|
|
52
|
+
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 42 } },
|
|
53
|
+
body: [{
|
|
54
|
+
type: 'FunctionDeclaration',
|
|
55
|
+
id: { type: 'Identifier', name: `bench${index}` },
|
|
56
|
+
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 42 } }
|
|
57
|
+
}]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
nativeSymbols += imported.semanticIndex?.symbols?.length ?? 0;
|
|
62
|
+
nativeImportResults.push(imported);
|
|
63
|
+
}
|
|
64
|
+
const importDurationMs = performance.now() - importStart;
|
|
65
|
+
|
|
66
|
+
const matrixStart = performance.now();
|
|
67
|
+
const coverageMatrix = createNativeImportCoverageMatrix({ imports: nativeImportResults });
|
|
68
|
+
const matrixDurationMs = performance.now() - matrixStart;
|
|
69
|
+
|
|
70
|
+
const sidecarStart = performance.now();
|
|
71
|
+
const semanticSidecars = nativeImportResults.map((imported) => createSemanticImportSidecar(imported));
|
|
72
|
+
const sidecarDurationMs = performance.now() - sidecarStart;
|
|
73
|
+
const sidecarOwnershipRegions = semanticSidecars.reduce((sum, sidecar) => sum + sidecar.ownershipRegions.length, 0);
|
|
74
|
+
|
|
75
|
+
const projectionStart = performance.now();
|
|
76
|
+
const nativeProjections = nativeImportResults.map((imported) => projectNativeImportToSource(imported));
|
|
77
|
+
const projectionDurationMs = performance.now() - projectionStart;
|
|
78
|
+
const projectionBytes = nativeProjections.reduce((sum, projection) => sum + projection.sourceText.length, 0);
|
|
79
|
+
|
|
80
|
+
console.log(JSON.stringify({
|
|
81
|
+
compiles: 250,
|
|
82
|
+
bytes,
|
|
83
|
+
compileDurationMs: Number(compileDurationMs.toFixed(2)),
|
|
84
|
+
nativeImports: 150,
|
|
85
|
+
nativeSymbols,
|
|
86
|
+
nativeImportDurationMs: Number(importDurationMs.toFixed(2)),
|
|
87
|
+
coverageMatrixLanguages: coverageMatrix.summary.languages,
|
|
88
|
+
coverageMatrixImports: coverageMatrix.summary.imports,
|
|
89
|
+
coverageMatrixDurationMs: Number(matrixDurationMs.toFixed(2)),
|
|
90
|
+
semanticSidecars: semanticSidecars.length,
|
|
91
|
+
sidecarOwnershipRegions,
|
|
92
|
+
sidecarDurationMs: Number(sidecarDurationMs.toFixed(2)),
|
|
93
|
+
nativeProjections: nativeProjections.length,
|
|
94
|
+
projectionBytes,
|
|
95
|
+
projectionDurationMs: Number(projectionDurationMs.toFixed(2))
|
|
96
|
+
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
NativeAstNode,
|
|
12
12
|
NativeAstRecord,
|
|
13
13
|
NativeSourceNode,
|
|
14
|
+
SemanticMergeCandidateRecord,
|
|
15
|
+
SemanticMergeReadiness,
|
|
14
16
|
SemanticIndexRecord,
|
|
15
17
|
SemanticNode,
|
|
16
18
|
SemanticPatchBundle,
|
|
@@ -71,6 +73,255 @@ export interface CapabilityResolution {
|
|
|
71
73
|
readonly reason?: string;
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
export type NativeImportTaxonomyKind =
|
|
77
|
+
| 'exactAstImport'
|
|
78
|
+
| 'declarationsOnly'
|
|
79
|
+
| 'opaqueBodies'
|
|
80
|
+
| 'macroExpansion'
|
|
81
|
+
| 'preprocessor'
|
|
82
|
+
| 'metaprogramming'
|
|
83
|
+
| 'generatedCode'
|
|
84
|
+
| 'sourcePreservation'
|
|
85
|
+
| 'parserDiagnostics'
|
|
86
|
+
| 'unsupportedSyntax'
|
|
87
|
+
| 'partialSemanticIndex'
|
|
88
|
+
| 'sourceMapApproximation'
|
|
89
|
+
| string;
|
|
90
|
+
|
|
91
|
+
export type NativeImportKnownLossKind =
|
|
92
|
+
| 'declarationOnlyCoverage'
|
|
93
|
+
| 'opaqueNative'
|
|
94
|
+
| 'macroExpansion'
|
|
95
|
+
| 'preprocessor'
|
|
96
|
+
| 'metaprogramming'
|
|
97
|
+
| 'generatedCode'
|
|
98
|
+
| 'sourcePreservation'
|
|
99
|
+
| 'parserDiagnostic'
|
|
100
|
+
| 'unsupportedSyntax'
|
|
101
|
+
| 'partialSemanticIndex'
|
|
102
|
+
| 'sourceMapApproximation'
|
|
103
|
+
| string;
|
|
104
|
+
|
|
105
|
+
export interface NativeImportLossSummaryOptions {
|
|
106
|
+
readonly exactAst?: boolean;
|
|
107
|
+
readonly evidence?: readonly EvidenceRecord[];
|
|
108
|
+
readonly parser?: string;
|
|
109
|
+
readonly scanKind?: string;
|
|
110
|
+
readonly semanticStatus?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface NativeImportLossSummary {
|
|
114
|
+
readonly total: number;
|
|
115
|
+
readonly hasLosses: boolean;
|
|
116
|
+
readonly exactAst: boolean;
|
|
117
|
+
readonly highestSeverity: 'none' | NativeAstLossRecord['severity'];
|
|
118
|
+
readonly semanticMergeReadiness: SemanticMergeReadiness;
|
|
119
|
+
readonly readinessReasons: readonly string[];
|
|
120
|
+
readonly categories: readonly NativeImportTaxonomyKind[];
|
|
121
|
+
readonly bySeverity: Readonly<Record<NativeAstLossRecord['severity'], number>>;
|
|
122
|
+
readonly byKind: Readonly<Record<string, number>>;
|
|
123
|
+
readonly blockingLossIds: readonly string[];
|
|
124
|
+
readonly reviewLossIds: readonly string[];
|
|
125
|
+
readonly informationalLossIds: readonly string[];
|
|
126
|
+
readonly failedEvidenceIds: readonly string[];
|
|
127
|
+
readonly parser?: string;
|
|
128
|
+
readonly scanKind?: string;
|
|
129
|
+
readonly semanticStatus?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface NativeImportReadinessClassification {
|
|
133
|
+
readonly readiness: SemanticMergeReadiness;
|
|
134
|
+
readonly reasons: readonly string[];
|
|
135
|
+
readonly summary: NativeImportLossSummary;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface NativeImportLanguageProfile {
|
|
139
|
+
readonly language: FrontierSourceLanguage;
|
|
140
|
+
readonly aliases: readonly string[];
|
|
141
|
+
readonly extensions: readonly string[];
|
|
142
|
+
readonly supportsLightweightScan: boolean;
|
|
143
|
+
readonly parserAdapters: readonly string[];
|
|
144
|
+
readonly projectionTargets: readonly FrontierCompileTarget[];
|
|
145
|
+
readonly knownLossKinds: readonly NativeImportKnownLossKind[];
|
|
146
|
+
readonly defaultReadiness: SemanticMergeReadiness;
|
|
147
|
+
readonly notes: readonly string[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface NativeImportCoverageLanguage {
|
|
151
|
+
readonly language: FrontierSourceLanguage;
|
|
152
|
+
readonly aliases: readonly string[];
|
|
153
|
+
readonly extensions: readonly string[];
|
|
154
|
+
readonly supportsLightweightScan: boolean;
|
|
155
|
+
readonly parserAdapters: readonly string[];
|
|
156
|
+
readonly projectionTargets: readonly FrontierCompileTarget[];
|
|
157
|
+
readonly knownLossKinds: readonly NativeImportKnownLossKind[];
|
|
158
|
+
readonly defaultReadiness: SemanticMergeReadiness;
|
|
159
|
+
readonly notes: readonly string[];
|
|
160
|
+
readonly imports: {
|
|
161
|
+
readonly total: number;
|
|
162
|
+
readonly parsers: readonly string[];
|
|
163
|
+
readonly readiness: SemanticMergeReadiness;
|
|
164
|
+
readonly readinessReasons: readonly string[];
|
|
165
|
+
readonly symbols: number;
|
|
166
|
+
readonly sourceMaps: number;
|
|
167
|
+
readonly sourceMapMappings: number;
|
|
168
|
+
readonly losses: number;
|
|
169
|
+
readonly lossKinds: Readonly<Record<string, number>>;
|
|
170
|
+
readonly lossCategories: readonly NativeImportTaxonomyKind[];
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface NativeImportCoverageMatrix {
|
|
175
|
+
readonly kind: 'frontier.lang.nativeImportCoverageMatrix';
|
|
176
|
+
readonly version: 1;
|
|
177
|
+
readonly generatedAt: number;
|
|
178
|
+
readonly languages: readonly NativeImportCoverageLanguage[];
|
|
179
|
+
readonly summary: {
|
|
180
|
+
readonly languages: number;
|
|
181
|
+
readonly lightweightScanners: number;
|
|
182
|
+
readonly parserAdapterSlots: number;
|
|
183
|
+
readonly imports: number;
|
|
184
|
+
readonly symbols: number;
|
|
185
|
+
readonly sourceMaps: number;
|
|
186
|
+
readonly sourceMapMappings: number;
|
|
187
|
+
readonly losses: number;
|
|
188
|
+
readonly byReadiness: Readonly<Record<string, number>>;
|
|
189
|
+
readonly lossKinds: Readonly<Record<string, number>>;
|
|
190
|
+
};
|
|
191
|
+
readonly metadata: {
|
|
192
|
+
readonly compileTargets: readonly FrontierCompileTarget[];
|
|
193
|
+
readonly note: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface NativeImportCoverageMatrixOptions {
|
|
198
|
+
readonly languages?: readonly NativeImportLanguageProfile[];
|
|
199
|
+
readonly imports?: readonly NativeSourceImportResult[];
|
|
200
|
+
readonly adapters?: readonly NativeImporterAdapter[];
|
|
201
|
+
readonly generatedAt?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface SemanticImportOwnershipRegion {
|
|
205
|
+
readonly id: string;
|
|
206
|
+
readonly key: string;
|
|
207
|
+
readonly granularity: 'symbol' | string;
|
|
208
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
209
|
+
readonly sourcePath?: string;
|
|
210
|
+
readonly sourceHash?: string;
|
|
211
|
+
readonly symbolId?: string;
|
|
212
|
+
readonly symbolName?: string;
|
|
213
|
+
readonly symbolKind?: string;
|
|
214
|
+
readonly nativeAstNodeId?: string;
|
|
215
|
+
readonly sourceSpan?: SourceSpan;
|
|
216
|
+
readonly precision?: 'exact' | 'declaration' | 'line' | 'estimated' | 'unknown' | string;
|
|
217
|
+
readonly mergePolicy?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface SemanticImportSidecarSymbol {
|
|
221
|
+
readonly id: string;
|
|
222
|
+
readonly name?: string;
|
|
223
|
+
readonly kind?: string;
|
|
224
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
225
|
+
readonly nativeAstNodeId?: string;
|
|
226
|
+
readonly semanticOccurrenceId?: string;
|
|
227
|
+
readonly sourceMapMappingId?: string;
|
|
228
|
+
readonly sourceSpan?: SourceSpan;
|
|
229
|
+
readonly signatureHash?: string;
|
|
230
|
+
readonly ownershipRegionId: string;
|
|
231
|
+
readonly ownershipKey: string;
|
|
232
|
+
readonly readiness: SemanticMergeReadiness;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface SemanticImportPatchHint {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly kind: 'source-region-patch' | string;
|
|
238
|
+
readonly ownershipRegionId: string;
|
|
239
|
+
readonly ownershipKey: string;
|
|
240
|
+
readonly sourcePath?: string;
|
|
241
|
+
readonly sourceHash?: string;
|
|
242
|
+
readonly sourceSpan?: SourceSpan;
|
|
243
|
+
readonly readiness: SemanticMergeReadiness;
|
|
244
|
+
readonly precision?: string;
|
|
245
|
+
readonly supportedOperations: readonly string[];
|
|
246
|
+
readonly projection: {
|
|
247
|
+
readonly sourceLanguage?: FrontierSourceLanguage | string;
|
|
248
|
+
readonly targetPath?: string;
|
|
249
|
+
readonly requiresSourceMap: boolean;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface SemanticImportSidecarImportEntry {
|
|
254
|
+
readonly id: string;
|
|
255
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
256
|
+
readonly sourcePath?: string;
|
|
257
|
+
readonly sourceHash?: string;
|
|
258
|
+
readonly parser?: string;
|
|
259
|
+
readonly nativeSourceId?: string;
|
|
260
|
+
readonly nativeAstId?: string;
|
|
261
|
+
readonly semanticIndexId?: string;
|
|
262
|
+
readonly universalAstId?: string;
|
|
263
|
+
readonly symbolCount: number;
|
|
264
|
+
readonly sourceMapCount: number;
|
|
265
|
+
readonly sourceMapMappingCount: number;
|
|
266
|
+
readonly readiness: SemanticMergeReadiness;
|
|
267
|
+
readonly emptySemanticIndex: boolean;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface SemanticImportSidecar {
|
|
271
|
+
readonly kind: 'frontier.lang.semanticImportSidecar';
|
|
272
|
+
readonly version: 1;
|
|
273
|
+
readonly id: string;
|
|
274
|
+
readonly generatedAt: number;
|
|
275
|
+
readonly language?: FrontierSourceLanguage | 'mixed' | string;
|
|
276
|
+
readonly projectRoot?: string;
|
|
277
|
+
readonly imports: readonly SemanticImportSidecarImportEntry[];
|
|
278
|
+
readonly symbols: readonly SemanticImportSidecarSymbol[];
|
|
279
|
+
readonly ownershipRegions: readonly SemanticImportOwnershipRegion[];
|
|
280
|
+
readonly sourceMaps: {
|
|
281
|
+
readonly total: number;
|
|
282
|
+
readonly mappings: number;
|
|
283
|
+
readonly ids: readonly string[];
|
|
284
|
+
};
|
|
285
|
+
readonly patchHints: readonly SemanticImportPatchHint[];
|
|
286
|
+
readonly mergeCandidates: readonly {
|
|
287
|
+
readonly id?: string;
|
|
288
|
+
readonly readiness?: SemanticMergeReadiness;
|
|
289
|
+
readonly reasons: readonly string[];
|
|
290
|
+
readonly risk?: string;
|
|
291
|
+
readonly operationCount: number;
|
|
292
|
+
}[];
|
|
293
|
+
readonly losses: {
|
|
294
|
+
readonly total: number;
|
|
295
|
+
readonly byKind: Readonly<Record<string, number>>;
|
|
296
|
+
readonly bySeverity: Readonly<Record<string, number>>;
|
|
297
|
+
readonly categories: readonly NativeImportTaxonomyKind[];
|
|
298
|
+
readonly blockingLossIds: readonly string[];
|
|
299
|
+
readonly reviewLossIds: readonly string[];
|
|
300
|
+
};
|
|
301
|
+
readonly evidence: {
|
|
302
|
+
readonly total: number;
|
|
303
|
+
readonly failed: readonly string[];
|
|
304
|
+
readonly ids: readonly string[];
|
|
305
|
+
};
|
|
306
|
+
readonly summary: {
|
|
307
|
+
readonly imports: number;
|
|
308
|
+
readonly symbols: number;
|
|
309
|
+
readonly ownershipRegions: number;
|
|
310
|
+
readonly sourceMapMappings: number;
|
|
311
|
+
readonly readiness: SemanticMergeReadiness;
|
|
312
|
+
readonly emptySemanticIndex: boolean;
|
|
313
|
+
};
|
|
314
|
+
readonly metadata?: Record<string, unknown>;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface SemanticImportSidecarOptions {
|
|
318
|
+
readonly id?: string;
|
|
319
|
+
readonly generatedAt?: number;
|
|
320
|
+
readonly regionPrefix?: string;
|
|
321
|
+
readonly targetPath?: string;
|
|
322
|
+
readonly metadata?: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
|
|
74
325
|
export interface NativeImporterAdapterDiagnostic {
|
|
75
326
|
readonly id?: string;
|
|
76
327
|
readonly severity?: 'info' | 'warning' | 'error';
|
|
@@ -115,6 +366,8 @@ export interface ImportNativeSourceOptions {
|
|
|
115
366
|
readonly patchId?: string;
|
|
116
367
|
readonly author?: string;
|
|
117
368
|
readonly target?: CompileTarget;
|
|
369
|
+
readonly targetPath?: string;
|
|
370
|
+
readonly targetHash?: string;
|
|
118
371
|
readonly semanticIndex?: SemanticIndexRecord;
|
|
119
372
|
readonly sourceMapId?: string;
|
|
120
373
|
readonly sourceMaps?: readonly SourceMapRecord[];
|
|
@@ -157,6 +410,56 @@ export interface NativeImporterAdapter {
|
|
|
157
410
|
readonly parse: (input: NativeImporterAdapterParseInput) => NativeImporterAdapterParseResult | Promise<NativeImporterAdapterParseResult>;
|
|
158
411
|
}
|
|
159
412
|
|
|
413
|
+
export interface JavaScriptNativeImporterAdapterOptions {
|
|
414
|
+
readonly id?: string;
|
|
415
|
+
readonly language?: FrontierSourceLanguage;
|
|
416
|
+
readonly parser?: string;
|
|
417
|
+
readonly version?: string;
|
|
418
|
+
readonly capabilities?: readonly string[];
|
|
419
|
+
readonly supportedExtensions?: readonly string[];
|
|
420
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
421
|
+
readonly ast?: unknown;
|
|
422
|
+
readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
|
|
423
|
+
readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
424
|
+
readonly babelParser?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
425
|
+
readonly parserOptions?: Record<string, unknown> | ((input: NativeImporterAdapterParseInput) => Record<string, unknown>);
|
|
426
|
+
readonly maxNodes?: number;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface TypeScriptCompilerNativeImporterAdapterOptions {
|
|
430
|
+
readonly id?: string;
|
|
431
|
+
readonly language?: FrontierSourceLanguage;
|
|
432
|
+
readonly parser?: string;
|
|
433
|
+
readonly version?: string;
|
|
434
|
+
readonly capabilities?: readonly string[];
|
|
435
|
+
readonly supportedExtensions?: readonly string[];
|
|
436
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
437
|
+
readonly typescript?: unknown;
|
|
438
|
+
readonly ts?: unknown;
|
|
439
|
+
readonly sourceFile?: unknown;
|
|
440
|
+
readonly createSourceFile?: (input: NativeImporterAdapterParseInput, typescript?: unknown) => unknown;
|
|
441
|
+
readonly scriptTarget?: unknown;
|
|
442
|
+
readonly scriptKind?: unknown;
|
|
443
|
+
readonly maxNodes?: number;
|
|
444
|
+
readonly includeTokens?: boolean;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface TreeSitterNativeImporterAdapterOptions {
|
|
448
|
+
readonly id?: string;
|
|
449
|
+
readonly language?: FrontierSourceLanguage;
|
|
450
|
+
readonly parser?: string | { readonly parse?: (sourceText: string) => unknown };
|
|
451
|
+
readonly parserName?: string;
|
|
452
|
+
readonly version?: string;
|
|
453
|
+
readonly capabilities?: readonly string[];
|
|
454
|
+
readonly supportedExtensions?: readonly string[];
|
|
455
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
456
|
+
readonly parserInstance?: { readonly parse: (sourceText: string) => unknown };
|
|
457
|
+
readonly treeSitterParser?: { readonly parse: (sourceText: string) => unknown };
|
|
458
|
+
readonly parse?: (input: NativeImporterAdapterParseInput) => unknown;
|
|
459
|
+
readonly tree?: unknown;
|
|
460
|
+
readonly maxNodes?: number;
|
|
461
|
+
}
|
|
462
|
+
|
|
160
463
|
export interface NativeImporterAdapterSummary {
|
|
161
464
|
readonly id: string;
|
|
162
465
|
readonly language: FrontierSourceLanguage;
|
|
@@ -181,15 +484,126 @@ export type NativeImporterAdapterImportResult = NativeSourceImportResult & {
|
|
|
181
484
|
readonly diagnostics: readonly NativeImporterAdapterDiagnostic[];
|
|
182
485
|
};
|
|
183
486
|
|
|
487
|
+
export interface NativeProjectSourceInput extends ImportNativeSourceOptions {
|
|
488
|
+
readonly adapter?: NativeImporterAdapter | string;
|
|
489
|
+
readonly adapterOptions?: Record<string, unknown>;
|
|
490
|
+
readonly adapterMetadata?: Record<string, unknown>;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface ImportNativeProjectOptions {
|
|
494
|
+
readonly id?: string;
|
|
495
|
+
readonly name?: string;
|
|
496
|
+
readonly language?: FrontierSourceLanguage | 'mixed';
|
|
497
|
+
readonly projectRoot?: string;
|
|
498
|
+
readonly documentId?: string;
|
|
499
|
+
readonly documentName?: string;
|
|
500
|
+
readonly documentMetadata?: Record<string, unknown>;
|
|
501
|
+
readonly universalAstId?: string;
|
|
502
|
+
readonly universalAstMetadata?: Record<string, unknown>;
|
|
503
|
+
readonly semanticIndexId?: string;
|
|
504
|
+
readonly patchId?: string;
|
|
505
|
+
readonly author?: string;
|
|
506
|
+
readonly metadata?: Record<string, unknown>;
|
|
507
|
+
readonly adapterOptions?: Record<string, unknown>;
|
|
508
|
+
readonly adapterMetadata?: Record<string, unknown>;
|
|
509
|
+
readonly adapters?: readonly NativeImporterAdapter[];
|
|
510
|
+
readonly adapterResolver?: (source: NativeProjectSourceInput, adapters: readonly NativeImporterAdapter[]) => NativeImporterAdapter | undefined;
|
|
511
|
+
readonly sources: readonly NativeProjectSourceInput[];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export interface NativeProjectImportResult {
|
|
515
|
+
readonly kind: 'frontier.lang.projectImportResult';
|
|
516
|
+
readonly version: 1;
|
|
517
|
+
readonly id: string;
|
|
518
|
+
readonly language: FrontierSourceLanguage | 'mixed';
|
|
519
|
+
readonly projectRoot?: string;
|
|
520
|
+
readonly imports: readonly NativeSourceImportResult[];
|
|
521
|
+
readonly document: FrontierLangDocument;
|
|
522
|
+
readonly patch: SemanticPatchBundle;
|
|
523
|
+
readonly nativeSources: readonly NativeSourceNode[];
|
|
524
|
+
readonly semanticIndex?: SemanticIndexRecord;
|
|
525
|
+
readonly universalAst: FrontierUniversalAstEnvelope;
|
|
526
|
+
readonly sourceMaps: readonly SourceMapRecord[];
|
|
527
|
+
readonly losses: readonly NativeAstLossRecord[];
|
|
528
|
+
readonly evidence: readonly EvidenceRecord[];
|
|
529
|
+
readonly mergeCandidates: readonly SemanticMergeCandidateRecord[];
|
|
530
|
+
readonly metadata?: Record<string, unknown>;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export type NativeSourceProjectionMode = 'preserved-source' | 'native-source-stubs';
|
|
534
|
+
|
|
535
|
+
export interface ProjectNativeImportToSourceOptions {
|
|
536
|
+
readonly id?: string;
|
|
537
|
+
readonly language?: FrontierSourceLanguage | string;
|
|
538
|
+
readonly sourcePath?: string;
|
|
539
|
+
readonly expectedSourceHash?: string;
|
|
540
|
+
readonly sourceText?: string;
|
|
541
|
+
readonly preservedSourceText?: string;
|
|
542
|
+
readonly exactSourceText?: string;
|
|
543
|
+
readonly sourceHash?: string;
|
|
544
|
+
readonly verifySourceHash?: boolean;
|
|
545
|
+
readonly preferPreservedSource?: boolean;
|
|
546
|
+
readonly stubBanner?: string | false;
|
|
547
|
+
readonly evidenceId?: string;
|
|
548
|
+
readonly parser?: string;
|
|
549
|
+
readonly semanticStatus?: string;
|
|
550
|
+
readonly nativeSource?: NativeSourceNode;
|
|
551
|
+
readonly nativeAst?: NativeAstRecord;
|
|
552
|
+
readonly semanticIndex?: SemanticIndexRecord;
|
|
553
|
+
readonly metadata?: Record<string, unknown>;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export interface NativeSourceProjectionDeclaration {
|
|
557
|
+
readonly name: string;
|
|
558
|
+
readonly kind: string;
|
|
559
|
+
readonly symbolId?: string;
|
|
560
|
+
readonly nativeAstNodeId?: string;
|
|
561
|
+
readonly sourceSpan?: SourceSpan;
|
|
562
|
+
readonly ownershipRegionId?: string;
|
|
563
|
+
readonly metadata?: Record<string, unknown>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export interface NativeSourceProjectionResult {
|
|
567
|
+
readonly kind: 'frontier.lang.nativeSourceProjection';
|
|
568
|
+
readonly version: 1;
|
|
569
|
+
readonly id: string;
|
|
570
|
+
readonly language: FrontierSourceLanguage | string;
|
|
571
|
+
readonly sourcePath?: string;
|
|
572
|
+
readonly sourceHash?: string;
|
|
573
|
+
readonly mode: NativeSourceProjectionMode;
|
|
574
|
+
readonly sourceText: string;
|
|
575
|
+
readonly outputHash: string;
|
|
576
|
+
readonly declarations: readonly NativeSourceProjectionDeclaration[];
|
|
577
|
+
readonly losses: readonly NativeAstLossRecord[];
|
|
578
|
+
readonly lossSummary: NativeImportLossSummary;
|
|
579
|
+
readonly readiness: NativeImportReadinessClassification;
|
|
580
|
+
readonly evidence: readonly EvidenceRecord[];
|
|
581
|
+
readonly metadata: Record<string, unknown>;
|
|
582
|
+
}
|
|
583
|
+
|
|
184
584
|
export declare const FrontierCompileTargets: readonly FrontierCompileTarget[];
|
|
585
|
+
export declare const NativeImportTaxonomyKinds: readonly NativeImportTaxonomyKind[];
|
|
586
|
+
export declare const NativeImportLossKinds: readonly NativeImportKnownLossKind[];
|
|
587
|
+
export declare const NativeImportReadinessBySeverity: Readonly<Record<NativeImportLossSummary['highestSeverity'], SemanticMergeReadiness>>;
|
|
588
|
+
export declare const NativeImportLanguageProfiles: readonly NativeImportLanguageProfile[];
|
|
185
589
|
export declare function normalizeCompileTarget(target?: string): FrontierCompileTarget;
|
|
186
590
|
export declare function compileFrontierSource(source: string, options?: FrontierCompileOptions): FrontierCompileResult;
|
|
187
591
|
export declare function compileFrontierDocument(document: FrontierLangDocument, options?: FrontierCompileOptions): FrontierCompileResult;
|
|
188
592
|
export declare function projectFrontierAst(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: FrontierCompileEmitOptions): FrontierTargetAst;
|
|
189
593
|
export declare function renderTargetAst(ast: FrontierTargetAst, target?: FrontierCompileOptions['target']): string;
|
|
190
594
|
export declare function resolveCapabilityAdapters(document: FrontierLangDocument, target?: FrontierCompileOptions['target'], options?: { readonly platform?: string }): readonly CapabilityResolution[];
|
|
595
|
+
export declare function summarizeNativeImportLosses(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportLossSummary;
|
|
596
|
+
export declare function classifyNativeImportReadiness(losses?: readonly NativeAstLossRecord[], options?: NativeImportLossSummaryOptions): NativeImportReadinessClassification;
|
|
597
|
+
export declare function createNativeImportCoverageMatrix(options?: NativeImportCoverageMatrixOptions): NativeImportCoverageMatrix;
|
|
598
|
+
export declare function createSemanticImportSidecar(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: SemanticImportSidecarOptions): SemanticImportSidecar;
|
|
599
|
+
export declare function createEstreeNativeImporterAdapter(options?: JavaScriptNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
600
|
+
export declare function createBabelNativeImporterAdapter(options?: JavaScriptNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
601
|
+
export declare function createTypeScriptCompilerNativeImporterAdapter(options?: TypeScriptCompilerNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
602
|
+
export declare function createTreeSitterNativeImporterAdapter(options?: TreeSitterNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
191
603
|
export declare function runNativeImporterAdapter(adapter: NativeImporterAdapter, input: RunNativeImporterAdapterOptions): Promise<NativeImporterAdapterImportResult>;
|
|
604
|
+
export declare function projectNativeImportToSource(importResult: NativeSourceImportResult | NativeProjectImportResult, options?: ProjectNativeImportToSourceOptions): NativeSourceProjectionResult;
|
|
192
605
|
export declare function importNativeSource(input: ImportNativeSourceOptions): NativeSourceImportResult;
|
|
606
|
+
export declare function importNativeProject(input: ImportNativeProjectOptions): Promise<NativeProjectImportResult>;
|
|
193
607
|
export declare function createUniversalAstFromDocument(document: FrontierLangDocument, input?: {
|
|
194
608
|
readonly id?: string;
|
|
195
609
|
readonly semanticIndex?: SemanticIndexRecord;
|