lawspec 0.31.1 → 0.31.3
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/CHANGELOG.md +89 -2
- package/README.md +85 -9
- package/api.mjs +14 -9
- package/authoring.mjs +899 -0
- package/beam-coverage.mjs +190 -65
- package/beam-doctor.mjs +343 -124
- package/bin/lawspec.mjs +1949 -661
- package/build.json +134 -128
- package/component-packages.mjs +662 -176
- package/component.d.ts +82 -20
- package/component.mjs +317 -94
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/doctor.mjs +558 -299
- package/examples-command.mjs +44 -23
- package/failure-database.mjs +60 -17
- package/files.mjs +122 -62
- package/index.d.ts +585 -312
- package/input-files.mjs +90 -25
- package/launcher.mjs +72 -31
- package/learn/coverage.json +184 -112
- package/learn/curriculum.json +4 -1
- package/learn/vendor/fantomas/{LawSpec.Learn.Formatter.5arcua4vy0.wasm → LawSpec.Learn.Formatter.poiijdbsl9.wasm} +0 -0
- package/learn/vendor/fantomas/dotnet.js +3 -3
- package/learn/vendor/manifest.json +4 -8
- package/lsp.mjs +444 -133
- package/mcp.mjs +250 -0
- package/native-evidence.mjs +668 -182
- package/native-examples.mjs +56 -19
- package/native-host.mjs +136 -42
- package/native-parsers/clojure.LICENSE +121 -0
- package/native-parsers/clojure.wasm +0 -0
- package/native-parsers/csharp.LICENSE +21 -0
- package/native-parsers/csharp.wasm +0 -0
- package/native-parsers/elixir.LICENSE +176 -0
- package/native-parsers/elixir.wasm +0 -0
- package/native-parsers/erlang.LICENSE +201 -0
- package/native-parsers/erlang.wasm +0 -0
- package/native-parsers/fsharp.LICENSE +21 -0
- package/native-parsers/fsharp.wasm +0 -0
- package/native-parsers/gleam.LICENSE +202 -0
- package/native-parsers/gleam.wasm +0 -0
- package/native-parsers/go.LICENSE +21 -0
- package/native-parsers/go.wasm +0 -0
- package/native-parsers/groovy.LICENSE +21 -0
- package/native-parsers/groovy.wasm +0 -0
- package/native-parsers/haskell.LICENSE +21 -0
- package/native-parsers/haskell.wasm +0 -0
- package/native-parsers/java.LICENSE +21 -0
- package/native-parsers/java.wasm +0 -0
- package/native-parsers/javascript.LICENSE +21 -0
- package/native-parsers/javascript.wasm +0 -0
- package/native-parsers/kotlin.LICENSE +9 -0
- package/native-parsers/kotlin.wasm +0 -0
- package/native-parsers/lock.json +114 -0
- package/native-parsers/prolog.LICENSE +21 -0
- package/native-parsers/prolog.wasm +0 -0
- package/native-parsers/python.LICENSE +21 -0
- package/native-parsers/python.wasm +0 -0
- package/native-parsers/rust.LICENSE +21 -0
- package/native-parsers/rust.wasm +0 -0
- package/native-parsers/scala.LICENSE +21 -0
- package/native-parsers/scala.wasm +0 -0
- package/native-parsers/swift.LICENSE +21 -0
- package/native-parsers/swift.wasm +0 -0
- package/native-parsers/typescript.LICENSE +21 -0
- package/native-parsers/typescript.wasm +0 -0
- package/node-events-reporter.mjs +41 -17
- package/package.json +4 -3
- package/project.mjs +338 -0
- package/proof.d.ts +93 -19
- package/proof.mjs +1538 -447
- package/read-only-hpack.mjs +6 -5
- package/scala-build-state.mjs +131 -41
- package/scala-coverage.mjs +57 -34
- package/scalars.mjs +23 -8
- package/templates.mjs +566 -617
- package/test-command.mjs +1671 -521
- package/learn/vendor/fantomas/LawSpec.Learn.Formatter.u1ne3a6xd2.wasm +0 -0
package/authoring.mjs
ADDED
|
@@ -0,0 +1,899 @@
|
|
|
1
|
+
// Generated from templates/npm/authoring.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
// Bounded native syntax checks use upstream Tree-sitter grammars. Findings are
|
|
3
|
+
// review candidates, not proof of semantic or nominal equivalence.
|
|
4
|
+
// ref:DEC-authoring-advisories
|
|
5
|
+
import {readFile, readdir} from 'node:fs/promises';
|
|
6
|
+
import {createHash} from 'node:crypto';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {programTargets, artifactTargets} from './templates.mjs';
|
|
9
|
+
|
|
10
|
+
const extensions = {
|
|
11
|
+
'.java': 'java',
|
|
12
|
+
'.py': 'python',
|
|
13
|
+
'.js': 'javascript',
|
|
14
|
+
'.mjs': 'javascript',
|
|
15
|
+
'.cjs': 'javascript',
|
|
16
|
+
'.ts': 'typescript',
|
|
17
|
+
'.mts': 'typescript',
|
|
18
|
+
'.cts': 'typescript',
|
|
19
|
+
'.tsx': 'tsx',
|
|
20
|
+
'.jsx': 'javascript',
|
|
21
|
+
'.go': 'go',
|
|
22
|
+
'.hs': 'haskell',
|
|
23
|
+
'.lhs': 'literate-haskell',
|
|
24
|
+
'.kt': 'kotlin',
|
|
25
|
+
'.kts': 'kotlin',
|
|
26
|
+
'.rs': 'rust',
|
|
27
|
+
'.erl': 'erlang',
|
|
28
|
+
'.hrl': 'erlang',
|
|
29
|
+
'.ex': 'elixir',
|
|
30
|
+
'.exs': 'elixir',
|
|
31
|
+
'.gleam': 'gleam',
|
|
32
|
+
'.fs': 'fsharp',
|
|
33
|
+
'.fsx': 'fsharp',
|
|
34
|
+
'.fsi': 'fsharp',
|
|
35
|
+
'.cs': 'csharp',
|
|
36
|
+
'.scala': 'scala',
|
|
37
|
+
'.groovy': 'groovy',
|
|
38
|
+
'.clj': 'clojure',
|
|
39
|
+
'.cljc': 'clojure',
|
|
40
|
+
'.swift': 'swift',
|
|
41
|
+
'.pl': 'prolog',
|
|
42
|
+
};
|
|
43
|
+
// Composite targets analyze their emitted host language as well.
|
|
44
|
+
const hostLanguages = {
|
|
45
|
+
javascript: ['javascript', 'typescript', 'tsx'],
|
|
46
|
+
typescript: ['typescript', 'javascript', 'tsx'],
|
|
47
|
+
haskell: ['haskell', 'literate-haskell'],
|
|
48
|
+
kotlin: ['kotlin', 'java'],
|
|
49
|
+
scala: ['scala', 'java'],
|
|
50
|
+
groovy: ['groovy', 'java'],
|
|
51
|
+
clojure: ['clojure', 'java'],
|
|
52
|
+
elixir: ['elixir', 'erlang'],
|
|
53
|
+
gleam: ['gleam', 'erlang'],
|
|
54
|
+
csharp: ['csharp', 'fsharp'],
|
|
55
|
+
prolog: ['prolog', 'python'],
|
|
56
|
+
};
|
|
57
|
+
const declarations = {
|
|
58
|
+
java: [
|
|
59
|
+
'class_declaration',
|
|
60
|
+
'record_declaration',
|
|
61
|
+
'interface_declaration',
|
|
62
|
+
'enum_declaration',
|
|
63
|
+
'method_declaration',
|
|
64
|
+
],
|
|
65
|
+
python: ['class_definition', 'function_definition'],
|
|
66
|
+
javascript: [
|
|
67
|
+
'class_declaration',
|
|
68
|
+
'function_declaration',
|
|
69
|
+
'variable_declarator',
|
|
70
|
+
],
|
|
71
|
+
typescript: [
|
|
72
|
+
'class_declaration',
|
|
73
|
+
'function_declaration',
|
|
74
|
+
'interface_declaration',
|
|
75
|
+
'type_alias_declaration',
|
|
76
|
+
'enum_declaration',
|
|
77
|
+
'variable_declarator',
|
|
78
|
+
],
|
|
79
|
+
go: ['type_spec', 'function_declaration', 'method_declaration'],
|
|
80
|
+
haskell: ['data_type', 'newtype', 'type_synomym', 'function', 'bind'],
|
|
81
|
+
kotlin: [
|
|
82
|
+
'class_declaration',
|
|
83
|
+
'object_declaration',
|
|
84
|
+
'function_declaration',
|
|
85
|
+
'type_alias',
|
|
86
|
+
],
|
|
87
|
+
rust: ['struct_item', 'enum_item', 'type_item', 'function_item'],
|
|
88
|
+
erlang: ['record_decl', 'type_alias', 'fun_decl'],
|
|
89
|
+
elixir: ['call'],
|
|
90
|
+
gleam: ['type_definition', 'type_alias', 'function'],
|
|
91
|
+
fsharp: ['type_definition', 'function_or_value_defn'],
|
|
92
|
+
csharp: [
|
|
93
|
+
'class_declaration',
|
|
94
|
+
'record_declaration',
|
|
95
|
+
'struct_declaration',
|
|
96
|
+
'interface_declaration',
|
|
97
|
+
'enum_declaration',
|
|
98
|
+
'method_declaration',
|
|
99
|
+
],
|
|
100
|
+
scala: [
|
|
101
|
+
'class_definition',
|
|
102
|
+
'object_definition',
|
|
103
|
+
'trait_definition',
|
|
104
|
+
'enum_definition',
|
|
105
|
+
'type_definition',
|
|
106
|
+
'function_definition',
|
|
107
|
+
],
|
|
108
|
+
groovy: [
|
|
109
|
+
'class_declaration',
|
|
110
|
+
'method_declaration',
|
|
111
|
+
'interface_declaration',
|
|
112
|
+
'enum_declaration',
|
|
113
|
+
],
|
|
114
|
+
clojure: ['list_lit'],
|
|
115
|
+
swift: [
|
|
116
|
+
'class_declaration',
|
|
117
|
+
'protocol_declaration',
|
|
118
|
+
'typealias_declaration',
|
|
119
|
+
'function_declaration',
|
|
120
|
+
],
|
|
121
|
+
prolog: ['clause', 'dict'],
|
|
122
|
+
};
|
|
123
|
+
const digest = content => createHash('sha256').update(content).digest('hex');
|
|
124
|
+
const comment = node => /comment|xml_doc/.test(node.type);
|
|
125
|
+
let runtime;
|
|
126
|
+
const languages = new Map();
|
|
127
|
+
const syntaxCache = new Map();
|
|
128
|
+
async function languageFor(language)
|
|
129
|
+
{
|
|
130
|
+
runtime ??= (async () =>
|
|
131
|
+
{
|
|
132
|
+
const module = await import('web-tree-sitter');
|
|
133
|
+
await module.Parser.init();
|
|
134
|
+
const lock = JSON.parse(
|
|
135
|
+
await readFile(
|
|
136
|
+
new URL('./native-parsers/lock.json', import.meta.url),
|
|
137
|
+
'utf8',
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
if (programTargets.some(target => !lock.grammars[target]))
|
|
141
|
+
throw new Error('Parser coverage differs from programTargets');
|
|
142
|
+
return {...module, lock};
|
|
143
|
+
})();
|
|
144
|
+
const api = await runtime;
|
|
145
|
+
if (!languages.has(language))
|
|
146
|
+
{
|
|
147
|
+
const entry = api.lock.grammars[language];
|
|
148
|
+
if (!entry) throw new Error(`No bundled parser for ${language}`);
|
|
149
|
+
const bytes = await readFile(
|
|
150
|
+
new URL('./native-parsers/' + entry.file, import.meta.url),
|
|
151
|
+
);
|
|
152
|
+
if (digest(bytes) !== entry.sha256)
|
|
153
|
+
throw new Error(`Parser digest mismatch for ${language}`);
|
|
154
|
+
languages.set(language, await api.Language.load(bytes));
|
|
155
|
+
}
|
|
156
|
+
return {Parser: api.Parser, language: languages.get(language)};
|
|
157
|
+
}
|
|
158
|
+
function nameNode(node, language)
|
|
159
|
+
{
|
|
160
|
+
if (language === 'prolog')
|
|
161
|
+
{
|
|
162
|
+
let term = node.childForFieldName('term') ?? node;
|
|
163
|
+
if (term.type === 'binary_operation') term = term.childForFieldName('left');
|
|
164
|
+
return term?.childForFieldName('functor') ?? term?.childForFieldName('tag');
|
|
165
|
+
}
|
|
166
|
+
if (language === 'clojure')
|
|
167
|
+
{
|
|
168
|
+
const children = node.namedChildren;
|
|
169
|
+
return ['defrecord', 'deftype', 'defn', 'defn-'].includes(children[0]?.text)
|
|
170
|
+
? children[1]
|
|
171
|
+
: null;
|
|
172
|
+
}
|
|
173
|
+
if (language === 'elixir')
|
|
174
|
+
{
|
|
175
|
+
const head = node.childForFieldName('target')?.text;
|
|
176
|
+
if (!['defmodule', 'def', 'defp'].includes(head)) return null;
|
|
177
|
+
const args = node.namedChildren.find(child => child.type === 'arguments');
|
|
178
|
+
const first = args?.namedChildren[0];
|
|
179
|
+
return first?.childForFieldName('target') ?? first;
|
|
180
|
+
}
|
|
181
|
+
if (language === 'erlang' && node.type === 'fun_decl')
|
|
182
|
+
return node.childForFieldName('clause')?.childForFieldName('name');
|
|
183
|
+
let found =
|
|
184
|
+
node.childForFieldName('name') ?? node.childForFieldName('type_name');
|
|
185
|
+
if (found) return found;
|
|
186
|
+
const pending = [...node.namedChildren];
|
|
187
|
+
while (pending.length)
|
|
188
|
+
{
|
|
189
|
+
const child = pending.shift();
|
|
190
|
+
if (
|
|
191
|
+
/^(identifier|type_identifier|name|simple_identifier|type_name|atom|variable)$/.test(
|
|
192
|
+
child.type,
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
return child;
|
|
196
|
+
if (
|
|
197
|
+
/^(type_name|record_type_defn|union_type_defn|function_declaration_left|function_or_value_defn|function_declaration|function_head|value_declaration_left|identifier_pattern|long_identifier_or_op|long_identifier|type|head)$/.test(
|
|
198
|
+
child.type,
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
pending.unshift(...child.namedChildren);
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
function leaves(node)
|
|
206
|
+
{
|
|
207
|
+
if (comment(node)) return [];
|
|
208
|
+
if (!node.childCount) return [[node.type, node.text]];
|
|
209
|
+
return node.children.flatMap(leaves);
|
|
210
|
+
}
|
|
211
|
+
async function parse(source)
|
|
212
|
+
{
|
|
213
|
+
const language = extensions[path.extname(source.path)];
|
|
214
|
+
if (!language)
|
|
215
|
+
return {
|
|
216
|
+
status: 'unsupported',
|
|
217
|
+
reason: 'No grammar selected for this file extension',
|
|
218
|
+
declarations: [],
|
|
219
|
+
};
|
|
220
|
+
if (Buffer.byteLength(source.content) > 2 * 1024 * 1024)
|
|
221
|
+
return {
|
|
222
|
+
status: 'incomplete',
|
|
223
|
+
reason: 'Native file exceeds the 2 MiB analysis limit',
|
|
224
|
+
declarations: [],
|
|
225
|
+
};
|
|
226
|
+
const key = language + ':' + digest(source.content);
|
|
227
|
+
if (syntaxCache.has(key)) return syntaxCache.get(key);
|
|
228
|
+
let parser, tree;
|
|
229
|
+
try
|
|
230
|
+
{
|
|
231
|
+
const api = await languageFor(language);
|
|
232
|
+
parser = new api.Parser();
|
|
233
|
+
parser.setLanguage(api.language);
|
|
234
|
+
tree = parser.parse(source.content);
|
|
235
|
+
if (!tree || tree.rootNode.hasError)
|
|
236
|
+
return {
|
|
237
|
+
status: 'incomplete',
|
|
238
|
+
reason: 'Tree-sitter reported an ERROR or missing node',
|
|
239
|
+
declarations: [],
|
|
240
|
+
};
|
|
241
|
+
const result = [];
|
|
242
|
+
const imports = [];
|
|
243
|
+
const modules = [];
|
|
244
|
+
const limits = [];
|
|
245
|
+
const stack = [tree.rootNode];
|
|
246
|
+
let count = 0;
|
|
247
|
+
while (stack.length)
|
|
248
|
+
{
|
|
249
|
+
const node = stack.pop();
|
|
250
|
+
if (++count > 100000)
|
|
251
|
+
return {
|
|
252
|
+
status: 'incomplete',
|
|
253
|
+
reason: 'Native syntax exceeds the 100000-node analysis limit',
|
|
254
|
+
declarations: [],
|
|
255
|
+
};
|
|
256
|
+
stack.push(...node.namedChildren);
|
|
257
|
+
if (
|
|
258
|
+
/^(macro_invocation|macro_definition|preproc_call|preproc_if|preproc_ifdef)$/.test(
|
|
259
|
+
node.type,
|
|
260
|
+
) &&
|
|
261
|
+
!(
|
|
262
|
+
language === 'rust' &&
|
|
263
|
+
node.type === 'macro_invocation' &&
|
|
264
|
+
['unimplemented', 'todo', 'panic'].includes(
|
|
265
|
+
node.childForFieldName('macro')?.text,
|
|
266
|
+
) &&
|
|
267
|
+
node.namedChildren
|
|
268
|
+
.filter(child => child.type === 'token_tree')
|
|
269
|
+
.every(tokens =>
|
|
270
|
+
tokens.namedChildren.every(
|
|
271
|
+
child => child.type === 'string_literal',
|
|
272
|
+
),
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
)
|
|
276
|
+
limits.push(
|
|
277
|
+
`Unsupported ${node.type} at line ${node.startPosition.row + 1}`,
|
|
278
|
+
);
|
|
279
|
+
if (
|
|
280
|
+
/^(import_statement|import_from_statement|import_declaration|import_spec|import_header|use_declaration|open_declaration|open_statement|import)$/.test(
|
|
281
|
+
node.type,
|
|
282
|
+
)
|
|
283
|
+
)
|
|
284
|
+
{
|
|
285
|
+
let module =
|
|
286
|
+
node.childForFieldName('source') ??
|
|
287
|
+
node.childForFieldName('module_name') ??
|
|
288
|
+
node.childForFieldName('module') ??
|
|
289
|
+
node.childForFieldName('path') ??
|
|
290
|
+
node.childForFieldName('argument') ??
|
|
291
|
+
node.childForFieldName('name') ??
|
|
292
|
+
node.namedChildren.find(child =>
|
|
293
|
+
/string|identifier|name|module/.test(child.type),
|
|
294
|
+
);
|
|
295
|
+
if (module?.type === 'aliased_import')
|
|
296
|
+
module = module.childForFieldName('name');
|
|
297
|
+
if (module) imports.push(module.text.replace(/^['"]|['"]$/g, ''));
|
|
298
|
+
else
|
|
299
|
+
limits.push(
|
|
300
|
+
`Unresolved import syntax at line ${node.startPosition.row + 1}`,
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
if (
|
|
304
|
+
/^(namespace_declaration|file_scoped_namespace_declaration|package_declaration|package_clause|named_module|module_attribute|header)$/.test(
|
|
305
|
+
node.type,
|
|
306
|
+
)
|
|
307
|
+
)
|
|
308
|
+
{
|
|
309
|
+
const module =
|
|
310
|
+
node.childForFieldName('name') ??
|
|
311
|
+
node.childForFieldName('module') ??
|
|
312
|
+
node.namedChildren.find(child => /identifier|name/.test(child.type));
|
|
313
|
+
if (module) modules.push(module.text);
|
|
314
|
+
}
|
|
315
|
+
if (language === 'clojure' && node.type === 'list_lit')
|
|
316
|
+
{
|
|
317
|
+
const children = node.namedChildren,
|
|
318
|
+
head = children[0]?.text;
|
|
319
|
+
if (head === 'ns' && children[1]) modules.push(children[1].text);
|
|
320
|
+
if ([':require', ':use'].includes(head))
|
|
321
|
+
for (const entry of children.slice(1))
|
|
322
|
+
{
|
|
323
|
+
if (
|
|
324
|
+
entry.type === 'vec_lit' &&
|
|
325
|
+
entry.namedChildren[0]?.type === 'sym_lit'
|
|
326
|
+
)
|
|
327
|
+
imports.push(entry.namedChildren[0].text);
|
|
328
|
+
else limits.push('Unsupported Clojure namespace reference');
|
|
329
|
+
}
|
|
330
|
+
if (
|
|
331
|
+
['defmacro', 'load', 'load-file', 'require', 'use', 'eval'].includes(
|
|
332
|
+
head,
|
|
333
|
+
)
|
|
334
|
+
)
|
|
335
|
+
limits.push(`Dynamic Clojure declaration or reference: ${head}`);
|
|
336
|
+
}
|
|
337
|
+
if (language === 'elixir' && node.type === 'call')
|
|
338
|
+
{
|
|
339
|
+
const head = node.childForFieldName('target')?.text;
|
|
340
|
+
if (['alias', 'import', 'require', 'use'].includes(head))
|
|
341
|
+
{
|
|
342
|
+
const module = node.namedChildren.find(
|
|
343
|
+
child => child.type === 'arguments',
|
|
344
|
+
)?.namedChildren[0];
|
|
345
|
+
if (module?.type === 'alias') imports.push(module.text);
|
|
346
|
+
else limits.push(`Unsupported Elixir ${head} reference`);
|
|
347
|
+
if (head === 'use')
|
|
348
|
+
limits.push('Elixir use may introduce declarations through macros');
|
|
349
|
+
}
|
|
350
|
+
if (head === 'defmacro' || head === 'defmacrop')
|
|
351
|
+
limits.push('Elixir macro declaration requires expansion');
|
|
352
|
+
}
|
|
353
|
+
if (
|
|
354
|
+
language === 'prolog' &&
|
|
355
|
+
node.type === 'compound_term' &&
|
|
356
|
+
['use_module', 'ensure_loaded', 'include', 'reexport'].includes(
|
|
357
|
+
node.childForFieldName('functor')?.text,
|
|
358
|
+
)
|
|
359
|
+
)
|
|
360
|
+
{
|
|
361
|
+
const module = node.childrenForFieldName('argument')[0];
|
|
362
|
+
if (module) imports.push(module.text.replace(/^'|'$/g, ''));
|
|
363
|
+
else limits.push('Unsupported Prolog module reference');
|
|
364
|
+
}
|
|
365
|
+
if (
|
|
366
|
+
language === 'erlang' &&
|
|
367
|
+
/^(import_attribute|include|include_lib)$/.test(node.type)
|
|
368
|
+
)
|
|
369
|
+
{
|
|
370
|
+
const module =
|
|
371
|
+
node.childForFieldName('module') ??
|
|
372
|
+
node.childForFieldName('file') ??
|
|
373
|
+
node.namedChildren[0];
|
|
374
|
+
if (module) imports.push(module.text.replace(/^"|"$/g, ''));
|
|
375
|
+
else limits.push('Unsupported Erlang module reference');
|
|
376
|
+
}
|
|
377
|
+
if (!declarations[language].includes(node.type)) continue;
|
|
378
|
+
const name = nameNode(node, language);
|
|
379
|
+
if (!name) continue;
|
|
380
|
+
const tokens = leaves(node);
|
|
381
|
+
result.push({
|
|
382
|
+
name: name.text,
|
|
383
|
+
kind: node.type,
|
|
384
|
+
line: node.startPosition.row + 1,
|
|
385
|
+
fields:
|
|
386
|
+
language === 'prolog' && node.type === 'dict'
|
|
387
|
+
? node.namedChildren
|
|
388
|
+
.filter(child => child.type === 'dict_pair')
|
|
389
|
+
.map(child => child.childForFieldName('key')?.text)
|
|
390
|
+
.filter(Boolean)
|
|
391
|
+
.sort()
|
|
392
|
+
: [],
|
|
393
|
+
identifiers: tokens
|
|
394
|
+
.filter(([type]) =>
|
|
395
|
+
/identifier|atom|symbol|name|constructor|variable|alias/.test(type),
|
|
396
|
+
)
|
|
397
|
+
.map(([type, text]) =>
|
|
398
|
+
language === 'clojure'
|
|
399
|
+
? text.replace(/\.$/, '')
|
|
400
|
+
: /atom/.test(type)
|
|
401
|
+
? text.replace(/^'|'$/g, '')
|
|
402
|
+
: text,
|
|
403
|
+
),
|
|
404
|
+
model:
|
|
405
|
+
/class|record|struct|enum|interface|type|newtype|dict/.test(
|
|
406
|
+
node.type,
|
|
407
|
+
) ||
|
|
408
|
+
(language === 'elixir' &&
|
|
409
|
+
node.childForFieldName('target')?.text === 'defmodule') ||
|
|
410
|
+
(language === 'clojure' &&
|
|
411
|
+
['defrecord', 'deftype'].includes(node.namedChildren[0]?.text)),
|
|
412
|
+
fingerprint: digest(
|
|
413
|
+
JSON.stringify(
|
|
414
|
+
tokens.map(([type, text]) => [
|
|
415
|
+
type,
|
|
416
|
+
text === name.text ? '$declaration' : text,
|
|
417
|
+
]),
|
|
418
|
+
),
|
|
419
|
+
),
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
const parsed = {
|
|
423
|
+
status: 'complete',
|
|
424
|
+
declarations: result,
|
|
425
|
+
imports,
|
|
426
|
+
modules,
|
|
427
|
+
limits,
|
|
428
|
+
fingerprint: digest(JSON.stringify(leaves(tree.rootNode))),
|
|
429
|
+
};
|
|
430
|
+
// Bound process-local memory; cached summaries contain no parser nodes.
|
|
431
|
+
if (syntaxCache.size >= 128) syntaxCache.clear();
|
|
432
|
+
syntaxCache.set(key, parsed);
|
|
433
|
+
return parsed;
|
|
434
|
+
}
|
|
435
|
+
catch (error)
|
|
436
|
+
{
|
|
437
|
+
return {status: 'incomplete', reason: error.message, declarations: []};
|
|
438
|
+
}
|
|
439
|
+
finally
|
|
440
|
+
{
|
|
441
|
+
tree?.delete();
|
|
442
|
+
parser?.delete();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const rules = [
|
|
446
|
+
'copied-generated',
|
|
447
|
+
'native-model',
|
|
448
|
+
'adapter-identity',
|
|
449
|
+
'manual-conversion',
|
|
450
|
+
];
|
|
451
|
+
export function settleAdvice(advice, exceptions = [])
|
|
452
|
+
{
|
|
453
|
+
if (
|
|
454
|
+
!Array.isArray(exceptions) ||
|
|
455
|
+
exceptions.some(
|
|
456
|
+
e =>
|
|
457
|
+
!e ||
|
|
458
|
+
typeof e.declaration !== 'string' ||
|
|
459
|
+
!e.declaration.trim() ||
|
|
460
|
+
typeof e.reason !== 'string' ||
|
|
461
|
+
!e.reason.trim() ||
|
|
462
|
+
typeof e.rule !== 'string' ||
|
|
463
|
+
!e.rule.trim(),
|
|
464
|
+
)
|
|
465
|
+
)
|
|
466
|
+
throw new Error(
|
|
467
|
+
'Authoring exceptions require a declaration, rule and nonempty reason',
|
|
468
|
+
);
|
|
469
|
+
const findings = advice.findings.map(finding =>
|
|
470
|
+
{
|
|
471
|
+
const exception = exceptions.find(
|
|
472
|
+
e => e.declaration === finding.declaration && e.rule === finding.rule,
|
|
473
|
+
);
|
|
474
|
+
return exception
|
|
475
|
+
? {...finding, status: 'excepted', reason: exception.reason}
|
|
476
|
+
: finding;
|
|
477
|
+
});
|
|
478
|
+
return {
|
|
479
|
+
...advice,
|
|
480
|
+
findings,
|
|
481
|
+
ok:
|
|
482
|
+
!findings.some(f => f.status === 'unresolved') &&
|
|
483
|
+
advice.checks.every(c =>
|
|
484
|
+
['complete', 'not-applicable'].includes(c.status),
|
|
485
|
+
),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
export async function advise(call, input)
|
|
489
|
+
{
|
|
490
|
+
const {nativeSources, exceptions, strict, ...request} = input;
|
|
491
|
+
const result = await call({
|
|
492
|
+
schemaVersion: 5,
|
|
493
|
+
...request,
|
|
494
|
+
advice: true,
|
|
495
|
+
method: request.target ? 'inspect' : 'advise',
|
|
496
|
+
});
|
|
497
|
+
if (result.diagnostics?.length) return result;
|
|
498
|
+
const report = result.advice ?? {findings: [], checks: []};
|
|
499
|
+
if (request.target)
|
|
500
|
+
{
|
|
501
|
+
const native = await analyzeNative(result, request, nativeSources);
|
|
502
|
+
report.findings.push(...native.findings);
|
|
503
|
+
report.checks.push(...native.checks);
|
|
504
|
+
}
|
|
505
|
+
result.advice = settleAdvice(report, exceptions);
|
|
506
|
+
// Required interfaces remain inspect's output; advise returns findings only.
|
|
507
|
+
delete result.interface;
|
|
508
|
+
delete result.files;
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
export async function analyzeNative(result, input, sources)
|
|
512
|
+
{
|
|
513
|
+
const target = input.target;
|
|
514
|
+
const checks = [];
|
|
515
|
+
const findings = [];
|
|
516
|
+
const check = (status, reason) =>
|
|
517
|
+
{
|
|
518
|
+
for (const rule of rules)
|
|
519
|
+
checks.push({
|
|
520
|
+
rule,
|
|
521
|
+
target,
|
|
522
|
+
status,
|
|
523
|
+
...(reason ? {reason} : {}),
|
|
524
|
+
scope: 'declared native syntax; no whole-program type equivalence',
|
|
525
|
+
});
|
|
526
|
+
};
|
|
527
|
+
if (artifactTargets.includes(target))
|
|
528
|
+
{
|
|
529
|
+
check('not-applicable', 'Artifact target has no native application model');
|
|
530
|
+
return {findings, checks};
|
|
531
|
+
}
|
|
532
|
+
if (!programTargets.includes(target))
|
|
533
|
+
{
|
|
534
|
+
check('unsupported', 'Unknown program target');
|
|
535
|
+
return {findings, checks};
|
|
536
|
+
}
|
|
537
|
+
if (!Array.isArray(sources))
|
|
538
|
+
{
|
|
539
|
+
check('incomplete', 'Native sources were not supplied');
|
|
540
|
+
return {findings, checks};
|
|
541
|
+
}
|
|
542
|
+
const invalid = sources.filter(
|
|
543
|
+
source =>
|
|
544
|
+
!source ||
|
|
545
|
+
typeof source.path !== 'string' ||
|
|
546
|
+
typeof source.content !== 'string',
|
|
547
|
+
);
|
|
548
|
+
if (invalid.length)
|
|
549
|
+
{
|
|
550
|
+
check('incomplete', 'Malformed native source');
|
|
551
|
+
return {findings, checks};
|
|
552
|
+
}
|
|
553
|
+
const generated = (result.files ?? []).filter(
|
|
554
|
+
f => f.ownership === 'generated' && extensions[path.extname(f.path)],
|
|
555
|
+
);
|
|
556
|
+
const expected = new Map((result.files ?? []).map(f => [f.path, f]));
|
|
557
|
+
const acceptedDigests = new Map(
|
|
558
|
+
(result.interface?.generatedDigests ?? []).map(file => [
|
|
559
|
+
file.path,
|
|
560
|
+
new Set(file.sha256),
|
|
561
|
+
]),
|
|
562
|
+
);
|
|
563
|
+
const rawCopies = new Map(generated.map(f => [digest(f.content), f.path]));
|
|
564
|
+
for (const [file, digests] of acceptedDigests)
|
|
565
|
+
for (const hash of digests) rawCopies.set(hash, file);
|
|
566
|
+
const baselines = new Map();
|
|
567
|
+
const names = new Set();
|
|
568
|
+
const adapterNames = new Set();
|
|
569
|
+
const boundTypes = input.nativeBindings?.types ?? [];
|
|
570
|
+
const recordShapes = (result.dataTypes ?? [])
|
|
571
|
+
.filter(type => type.constructors.length === 1)
|
|
572
|
+
.map(type => type.constructors[0].fields.map(field => field.name).sort());
|
|
573
|
+
const observedBindings = new Set();
|
|
574
|
+
const boundName = (source, declaration, parsed) =>
|
|
575
|
+
boundTypes.some(binding =>
|
|
576
|
+
{
|
|
577
|
+
const references = [
|
|
578
|
+
binding.native,
|
|
579
|
+
...(binding.constructors ?? []).map(c => c.native),
|
|
580
|
+
].filter(Array.isArray);
|
|
581
|
+
const matched = references.some(ref =>
|
|
582
|
+
{
|
|
583
|
+
const name = ref.at(-1),
|
|
584
|
+
module = ref
|
|
585
|
+
.slice(0, -1)
|
|
586
|
+
.filter(part => part !== 'crate')
|
|
587
|
+
.join('/');
|
|
588
|
+
const file = source.path.replace(/\.[^.]+$/, '');
|
|
589
|
+
const declaredModules = (parsed.modules ?? []).map(value =>
|
|
590
|
+
value.replace(/\.|::/g, '/'),
|
|
591
|
+
);
|
|
592
|
+
return (
|
|
593
|
+
(ref.length > 1 && ref.join('.') === declaration.name) ||
|
|
594
|
+
(name === declaration.name &&
|
|
595
|
+
module &&
|
|
596
|
+
(file === module ||
|
|
597
|
+
file.endsWith('/' + module) ||
|
|
598
|
+
file.endsWith('/' + module + '/' + name) ||
|
|
599
|
+
file === module + '/' + name ||
|
|
600
|
+
declaredModules.includes(module)))
|
|
601
|
+
);
|
|
602
|
+
});
|
|
603
|
+
if (matched) observedBindings.add(binding.type);
|
|
604
|
+
return matched;
|
|
605
|
+
});
|
|
606
|
+
let incomplete = false;
|
|
607
|
+
const relevant = (result.files ?? []).filter(
|
|
608
|
+
f =>
|
|
609
|
+
extensions[path.extname(f.path)] &&
|
|
610
|
+
(f.ownership === 'user' ||
|
|
611
|
+
(/data|types|schema/i.test(f.path) &&
|
|
612
|
+
!/runtime|testing/i.test(f.path))),
|
|
613
|
+
);
|
|
614
|
+
for (const file of relevant)
|
|
615
|
+
{
|
|
616
|
+
const parsed = await parse(file);
|
|
617
|
+
if (parsed.status !== 'complete')
|
|
618
|
+
{
|
|
619
|
+
incomplete = true;
|
|
620
|
+
checks.push({
|
|
621
|
+
rule: 'native-baseline',
|
|
622
|
+
target,
|
|
623
|
+
path: file.path,
|
|
624
|
+
status: parsed.status,
|
|
625
|
+
reason: parsed.reason,
|
|
626
|
+
});
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
for (const declaration of parsed.declarations)
|
|
630
|
+
{
|
|
631
|
+
if (file.ownership === 'user')
|
|
632
|
+
{
|
|
633
|
+
if (!declaration.model) adapterNames.add(declaration.name);
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
if (declaration.model) names.add(declaration.name);
|
|
637
|
+
baselines.set(declaration.fingerprint, {...declaration, path: file.path});
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
for (const item of result.interface?.data ?? [])
|
|
641
|
+
{
|
|
642
|
+
if (item.ownership === 'bound') continue;
|
|
643
|
+
if (item.nativeName) names.add(item.nativeName);
|
|
644
|
+
for (const c of item.constructors ?? [])
|
|
645
|
+
if (c.allocatedName) names.add(c.allocatedName);
|
|
646
|
+
}
|
|
647
|
+
const modulePaths = [...(result.files ?? []), ...sources].map(file =>
|
|
648
|
+
file.path
|
|
649
|
+
.replace(/\.[^.]+$/, '')
|
|
650
|
+
.split(path.sep)
|
|
651
|
+
.join('/'),
|
|
652
|
+
);
|
|
653
|
+
const standard =
|
|
654
|
+
/^(builtins$|node:|java\.|javax\.|scala\.|kotlin\.|System(?:\.|$)|Microsoft\.|std(?:::|\.|$)|core::|alloc::|Data\.|Control\.|GHC\.|Prelude$|typing$|dataclasses$|functools$|fractions$|decimal$|math$|collections$|abc$|sys$|os$|pathlib$|typing_extensions$|gleam\/|erlang$|Elixir\.|clojure\.|library\()/;
|
|
655
|
+
const add = (rule, source, declaration, message) =>
|
|
656
|
+
findings.push({
|
|
657
|
+
rule,
|
|
658
|
+
target,
|
|
659
|
+
path: source.path,
|
|
660
|
+
declaration: `${source.path}::${declaration.name}`,
|
|
661
|
+
line: declaration.line,
|
|
662
|
+
severity: 'warning',
|
|
663
|
+
status: 'unresolved',
|
|
664
|
+
message,
|
|
665
|
+
suggestion:
|
|
666
|
+
'Migrate to the generated interface; retain an application model through explicit checked bindings/codecs, or a declaration-scoped exception with a reason.',
|
|
667
|
+
});
|
|
668
|
+
for (const source of sources)
|
|
669
|
+
{
|
|
670
|
+
if (typeof source.path !== 'string' || typeof source.content !== 'string')
|
|
671
|
+
{
|
|
672
|
+
incomplete = true;
|
|
673
|
+
checks.push({
|
|
674
|
+
rule: 'native-source',
|
|
675
|
+
target,
|
|
676
|
+
status: 'incomplete',
|
|
677
|
+
reason: 'Malformed native source',
|
|
678
|
+
});
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const language = extensions[path.extname(source.path)];
|
|
682
|
+
if (language && !(hostLanguages[target] ?? [target]).includes(language))
|
|
683
|
+
{
|
|
684
|
+
checks.push({
|
|
685
|
+
rule: 'native-language',
|
|
686
|
+
target,
|
|
687
|
+
path: source.path,
|
|
688
|
+
status: 'not-applicable',
|
|
689
|
+
reason: `${language} is outside the selected target's native languages`,
|
|
690
|
+
});
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
const known = expected.get(source.path);
|
|
694
|
+
if (known?.ownership === 'generated')
|
|
695
|
+
{
|
|
696
|
+
if (
|
|
697
|
+
known.content !== source.content &&
|
|
698
|
+
!acceptedDigests.get(source.path)?.has(digest(source.content))
|
|
699
|
+
)
|
|
700
|
+
{
|
|
701
|
+
const original = await parse(known),
|
|
702
|
+
actual = await parse(source);
|
|
703
|
+
if (original.status !== 'complete' || actual.status !== 'complete')
|
|
704
|
+
{
|
|
705
|
+
incomplete = true;
|
|
706
|
+
checks.push({
|
|
707
|
+
rule: 'generated-ownership',
|
|
708
|
+
target,
|
|
709
|
+
path: source.path,
|
|
710
|
+
status: 'incomplete',
|
|
711
|
+
reason:
|
|
712
|
+
'Cannot compare changed generated syntax with the current plan',
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
else if (original.fingerprint !== actual.fingerprint)
|
|
716
|
+
add(
|
|
717
|
+
'copied-generated',
|
|
718
|
+
source,
|
|
719
|
+
{name: '<file>', line: 1},
|
|
720
|
+
'Compiler-owned source differs from the generation plan.',
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
const copy = rawCopies.get(digest(source.content));
|
|
726
|
+
if (copy)
|
|
727
|
+
{
|
|
728
|
+
add(
|
|
729
|
+
'copied-generated',
|
|
730
|
+
source,
|
|
731
|
+
{name: '<file>', line: 1},
|
|
732
|
+
`This file copies compiler-owned ${copy}.`,
|
|
733
|
+
);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const parsed = await parse(source);
|
|
737
|
+
if (parsed.status !== 'complete')
|
|
738
|
+
{
|
|
739
|
+
incomplete = true;
|
|
740
|
+
checks.push({
|
|
741
|
+
rule: 'native-parse',
|
|
742
|
+
target,
|
|
743
|
+
path: source.path,
|
|
744
|
+
status: parsed.status,
|
|
745
|
+
reason: parsed.reason,
|
|
746
|
+
});
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
for (const reason of parsed.limits ?? [])
|
|
750
|
+
{
|
|
751
|
+
incomplete = true;
|
|
752
|
+
checks.push({
|
|
753
|
+
rule: 'native-construct',
|
|
754
|
+
target,
|
|
755
|
+
path: source.path,
|
|
756
|
+
status: 'unsupported',
|
|
757
|
+
reason,
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
for (const imported of parsed.imports ?? [])
|
|
761
|
+
{
|
|
762
|
+
const normalized = imported.replace(/::|\./g, '/').replace(/\/\*$/, '');
|
|
763
|
+
const relative = path.posix
|
|
764
|
+
.normalize(path.posix.join(path.posix.dirname(source.path), imported))
|
|
765
|
+
.replace(/\.[^.]+$/, '');
|
|
766
|
+
const resolved =
|
|
767
|
+
standard.test(imported) ||
|
|
768
|
+
modulePaths.some(
|
|
769
|
+
module =>
|
|
770
|
+
module === relative ||
|
|
771
|
+
module.endsWith('/' + normalized) ||
|
|
772
|
+
module === normalized ||
|
|
773
|
+
module.endsWith('/' + normalized + '/mod') ||
|
|
774
|
+
(target === 'swift' && module.includes('/' + normalized + '/')),
|
|
775
|
+
);
|
|
776
|
+
if (!resolved)
|
|
777
|
+
{
|
|
778
|
+
incomplete = true;
|
|
779
|
+
checks.push({
|
|
780
|
+
rule: 'native-reference',
|
|
781
|
+
target,
|
|
782
|
+
path: source.path,
|
|
783
|
+
status: 'incomplete',
|
|
784
|
+
reason: `Import ${imported} is outside the supplied/generated source inventory; identity resolution is incomplete`,
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
const competitors = new Set();
|
|
789
|
+
for (const declaration of parsed.declarations)
|
|
790
|
+
{
|
|
791
|
+
if (boundName(source, declaration, parsed)) continue;
|
|
792
|
+
const clone = baselines.get(declaration.fingerprint);
|
|
793
|
+
const termShape =
|
|
794
|
+
declaration.fields.length > 0 &&
|
|
795
|
+
recordShapes.some(
|
|
796
|
+
fields =>
|
|
797
|
+
JSON.stringify(fields) === JSON.stringify(declaration.fields),
|
|
798
|
+
);
|
|
799
|
+
if (clone || termShape || names.has(declaration.name))
|
|
800
|
+
{
|
|
801
|
+
competitors.add(declaration.name);
|
|
802
|
+
add(
|
|
803
|
+
'native-model',
|
|
804
|
+
source,
|
|
805
|
+
declaration,
|
|
806
|
+
termShape
|
|
807
|
+
? 'Native dict fields match a generated record schema; review the constructor identity and meaning.'
|
|
808
|
+
: clone
|
|
809
|
+
? `Declaration matches a supported generated syntax shape in ${clone.path}; review its meaning and ownership.`
|
|
810
|
+
: 'Declaration shares a generated model name; review identity and domain meaning.',
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
for (const declaration of parsed.declarations)
|
|
815
|
+
{
|
|
816
|
+
if (
|
|
817
|
+
adapterNames.has(declaration.name) &&
|
|
818
|
+
declaration.identifiers.some(n => competitors.has(n))
|
|
819
|
+
)
|
|
820
|
+
add(
|
|
821
|
+
'adapter-identity',
|
|
822
|
+
source,
|
|
823
|
+
declaration,
|
|
824
|
+
'Adapter refers to a competing local model; check the generated signature and nominal identity.',
|
|
825
|
+
);
|
|
826
|
+
if (
|
|
827
|
+
declaration.identifiers.some(n => names.has(n)) &&
|
|
828
|
+
declaration.identifiers.some(n => competitors.has(n)) &&
|
|
829
|
+
!competitors.has(declaration.name)
|
|
830
|
+
)
|
|
831
|
+
add(
|
|
832
|
+
'manual-conversion',
|
|
833
|
+
source,
|
|
834
|
+
declaration,
|
|
835
|
+
'This function mentions a generated model name and a competing local declaration; review the boundary for migration or supported native bindings.',
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
for (const binding of boundTypes)
|
|
840
|
+
if (!observedBindings.has(binding.type))
|
|
841
|
+
{
|
|
842
|
+
incomplete = true;
|
|
843
|
+
checks.push({
|
|
844
|
+
rule: 'native-binding-reference',
|
|
845
|
+
target,
|
|
846
|
+
status: 'incomplete',
|
|
847
|
+
reason: `Bound model ${binding.type} was not resolved to a declaration in the supplied source inventory`,
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
check(
|
|
851
|
+
incomplete ? 'incomplete' : 'complete',
|
|
852
|
+
incomplete ? 'Some selected syntax could not be analyzed' : undefined,
|
|
853
|
+
);
|
|
854
|
+
return {findings, checks};
|
|
855
|
+
}
|
|
856
|
+
export async function collectNativeSources(root)
|
|
857
|
+
{
|
|
858
|
+
const sources = [];
|
|
859
|
+
const excluded = new Set([
|
|
860
|
+
'node_modules',
|
|
861
|
+
'.git',
|
|
862
|
+
'.stack-work',
|
|
863
|
+
'.artifacts',
|
|
864
|
+
'vendor',
|
|
865
|
+
'target',
|
|
866
|
+
'build',
|
|
867
|
+
'dist',
|
|
868
|
+
'bin',
|
|
869
|
+
'obj',
|
|
870
|
+
'.venv',
|
|
871
|
+
'venv',
|
|
872
|
+
'__pycache__',
|
|
873
|
+
'.gradle',
|
|
874
|
+
'.lawspec',
|
|
875
|
+
]);
|
|
876
|
+
async function walk(directory)
|
|
877
|
+
{
|
|
878
|
+
for (const entry of await readdir(directory, {withFileTypes: true}))
|
|
879
|
+
{
|
|
880
|
+
if (entry.isSymbolicLink())
|
|
881
|
+
throw new Error(
|
|
882
|
+
`Native source symlink requires an explicit source selection: ${path.relative(root, path.join(directory, entry.name))}`,
|
|
883
|
+
);
|
|
884
|
+
const file = path.join(directory, entry.name);
|
|
885
|
+
if (entry.isDirectory())
|
|
886
|
+
{
|
|
887
|
+
if (!entry.name.startsWith('.') && !excluded.has(entry.name))
|
|
888
|
+
await walk(file);
|
|
889
|
+
}
|
|
890
|
+
else if (entry.isFile() && extensions[path.extname(file)])
|
|
891
|
+
sources.push({
|
|
892
|
+
path: path.relative(root, file).split(path.sep).join('/'),
|
|
893
|
+
content: await readFile(file, 'utf8'),
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
await walk(root);
|
|
898
|
+
return sources;
|
|
899
|
+
}
|