@shapeshift-labs/frontier-lang-cli 0.3.31 → 0.3.33
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 +5 -1
- package/bench/smoke.mjs +7 -1
- package/dist/index.js +64 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -12,8 +12,12 @@ frontier-lang project-native native-import.json --source-only --out restored.ts
|
|
|
12
12
|
frontier-lang native-compile native-import.json --target rust --emit-on-blocked --source-only --out todo.rs
|
|
13
13
|
frontier-lang native-coverage src/todo.ts
|
|
14
14
|
frontier-lang native-capabilities src/todo.ts --target rust
|
|
15
|
+
frontier-lang slice src/parser.ts --symbol parseExpression --focused-command "npm test -- parser-expression" --out parser.slice.json
|
|
16
|
+
frontier-lang test-slice parser.slice.json --source src/parser.ts
|
|
15
17
|
```
|
|
16
18
|
|
|
19
|
+
`slice` extracts a `frontier.lang.semanticSlice` for a symbol, ownership region, native node, or source path. The slice includes source-map links, source hashes, conflict keys, focused commands, fixture hints, and merge-admission metadata so Frontier Swarm workers can operate on surgical context instead of full repo copies. `test-slice` validates that the slice is non-empty, refs resolved, conflict keys exist, source maps are present unless disabled, and supplied current source files still match the recorded hashes.
|
|
20
|
+
|
|
17
21
|
## Related Packages
|
|
18
22
|
|
|
19
23
|
The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
|
|
@@ -208,7 +212,7 @@ npm install -g @shapeshift-labs/frontier-lang-cli
|
|
|
208
212
|
frontier-lang check examples/todo.frontier
|
|
209
213
|
```
|
|
210
214
|
|
|
211
|
-
Commands: `parse`, `check`, `hash`, `ast`, `capabilities`, `to-json`, `from-json`, `import`, `project-native`, `native-compile`, `native-coverage`, `native-capabilities`, `native-diff`, `roundtrip`, `corpus-roundtrip`, `emit`, `emit-ts`, `emit-js`, `emit-rust`, `emit-python`, and `emit-c`.
|
|
215
|
+
Commands: `parse`, `check`, `hash`, `ast`, `capabilities`, `to-json`, `from-json`, `import`, `project-native`, `native-compile`, `native-coverage`, `native-capabilities`, `native-diff`, `slice`, `test-slice`, `roundtrip`, `corpus-roundtrip`, `emit`, `emit-ts`, `emit-js`, `emit-rust`, `emit-python`, and `emit-c`.
|
|
212
216
|
|
|
213
217
|
```sh
|
|
214
218
|
frontier-lang emit app.frontier --target rust --out app.rs
|
package/bench/smoke.mjs
CHANGED
|
@@ -20,4 +20,10 @@ for (let index = 0; index < 25; index += 1) {
|
|
|
20
20
|
await runCli(['native-compile', nativePath, '--target', index % 2 ? 'javascript' : 'rust', '--emit-on-blocked'], { log: (value = '') => lines.push(String(value)) });
|
|
21
21
|
nativeBytes += lines.join('\n').length;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
let sliceBytes = 0;
|
|
24
|
+
for (let index = 0; index < 25; index += 1) {
|
|
25
|
+
const lines = [];
|
|
26
|
+
await runCli(['slice', nativePath, '--symbol', 'addTodo', '--focused-command', 'npm test -- addTodo'], { log: (value = '') => lines.push(String(value)) });
|
|
27
|
+
sliceBytes += lines.join('\n').length;
|
|
28
|
+
}
|
|
29
|
+
console.log(JSON.stringify({ emits: 100, nativeCompiles: 25, slices: 25, bytes, nativeBytes, sliceBytes, durationMs: Number((performance.now() - start).toFixed(2)) }));
|
package/dist/index.js
CHANGED
|
@@ -12,14 +12,18 @@ import {
|
|
|
12
12
|
createNativeSourcePreservation,
|
|
13
13
|
createNativeImportCoverageMatrix,
|
|
14
14
|
createSemanticImportSidecar,
|
|
15
|
+
createSemanticSlice,
|
|
15
16
|
createUniversalAstFromDocument,
|
|
16
17
|
createUniversalCapabilityMatrix,
|
|
17
18
|
diffNativeSources,
|
|
18
19
|
importNativeSource,
|
|
19
20
|
projectNativeImportToSource,
|
|
20
21
|
projectFrontierAst,
|
|
22
|
+
readSemanticSliceJson,
|
|
21
23
|
readUniversalAstJson,
|
|
22
24
|
resolveCapabilityAdapters,
|
|
25
|
+
testSemanticSlice,
|
|
26
|
+
writeSemanticSliceJson,
|
|
23
27
|
writeUniversalAstJson
|
|
24
28
|
} from '@shapeshift-labs/frontier-lang-compiler';
|
|
25
29
|
|
|
@@ -116,6 +120,37 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
|
|
|
116
120
|
metadata: { cli: true, beforePath: file, afterPath }
|
|
117
121
|
}));
|
|
118
122
|
}
|
|
123
|
+
if (command === 'slice') {
|
|
124
|
+
const imported = readNativeImportForProjection(file, source, rest);
|
|
125
|
+
const slice = createSemanticSlice(imported, {
|
|
126
|
+
id: readOption(rest, '--id'),
|
|
127
|
+
entryRefs: sliceEntryRefs(rest),
|
|
128
|
+
includeDependencies: !rest.includes('--no-deps'),
|
|
129
|
+
maxDependencyDepth: readIntegerOption(rest, '--max-depth'),
|
|
130
|
+
includeSourceText: !rest.includes('--no-source-text'),
|
|
131
|
+
maxExcerptBytes: readIntegerOption(rest, '--max-excerpt-bytes'),
|
|
132
|
+
focusedCommands: readOptions(rest, '--focused-command'),
|
|
133
|
+
fixtureHints: readOptions(rest, '--fixture-hint'),
|
|
134
|
+
metadata: { cli: true, inputPath: file }
|
|
135
|
+
});
|
|
136
|
+
if (rest.includes('--json-stable')) {
|
|
137
|
+
const json = writeSemanticSliceJson(slice);
|
|
138
|
+
const outIndex = rest.indexOf('--out');
|
|
139
|
+
if (outIndex >= 0 && rest[outIndex + 1]) writeFileSync(rest[outIndex + 1], json + '\n');
|
|
140
|
+
else io.log(json);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
return outputMaybeFile(io, rest, slice);
|
|
144
|
+
}
|
|
145
|
+
if (command === 'test-slice') {
|
|
146
|
+
const slice = readSemanticSliceJson(source);
|
|
147
|
+
return outputMaybeFile(io, rest, testSemanticSlice(slice, {
|
|
148
|
+
id: readOption(rest, '--id'),
|
|
149
|
+
requireSourceMapLinks: !rest.includes('--no-source-map-links'),
|
|
150
|
+
currentSources: readCurrentSources(rest),
|
|
151
|
+
metadata: { cli: true, inputPath: file }
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
119
154
|
const document = file ? parseFrontierFile(file, source) : parseFrontierSource(source);
|
|
120
155
|
if (command === 'to-json') {
|
|
121
156
|
return io.log(writeUniversalAstJson(createUniversalAstFromDocument(document, {
|
|
@@ -366,6 +401,27 @@ function nativeCapabilityLanguages(imported, args) {
|
|
|
366
401
|
return matches.length ? matches : undefined;
|
|
367
402
|
}
|
|
368
403
|
|
|
404
|
+
function sliceEntryRefs(args) {
|
|
405
|
+
return [
|
|
406
|
+
...readOptions(args, '--ref'),
|
|
407
|
+
...readOptions(args, '--semantic-ref'),
|
|
408
|
+
...readOptions(args, '--symbol').map((value) => `symbol:${value}`),
|
|
409
|
+
...readOptions(args, '--region').map((value) => `region:${value}`),
|
|
410
|
+
...readOptions(args, '--native-node').map((value) => `native:${value}`),
|
|
411
|
+
...readOptions(args, '--path').map((value) => `path:${value}`)
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function readCurrentSources(args) {
|
|
416
|
+
const paths = readOptions(args, '--source');
|
|
417
|
+
if (!paths.length) return undefined;
|
|
418
|
+
const currentSources = {};
|
|
419
|
+
for (const sourcePath of paths) {
|
|
420
|
+
currentSources[sourcePath] = readFileSync(sourcePath, 'utf8');
|
|
421
|
+
}
|
|
422
|
+
return currentSources;
|
|
423
|
+
}
|
|
424
|
+
|
|
369
425
|
function tryParseJson(source) {
|
|
370
426
|
const trimmed = source.trim();
|
|
371
427
|
if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return undefined;
|
|
@@ -388,8 +444,15 @@ function idFragment(value) {
|
|
|
388
444
|
return String(value ?? 'unknown').replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '').toLowerCase() || 'unknown';
|
|
389
445
|
}
|
|
390
446
|
|
|
391
|
-
function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|project-native|native-compile|native-coverage|native-capabilities|native-diff|roundtrip|corpus-roundtrip|emit|emit-ts|emit-js|emit-rust|emit-python|emit-c> <file> [--after file] [--target target] [--language language] [--parser parser] [--platform platform] [--ast] [--sidecar] [--sidecar-only] [--source-only] [--stubs] [--emit-on-blocked] [--all-languages] [--out file] [--strict-effects]'); }
|
|
447
|
+
function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|project-native|native-compile|native-coverage|native-capabilities|native-diff|slice|test-slice|roundtrip|corpus-roundtrip|emit|emit-ts|emit-js|emit-rust|emit-python|emit-c> <file> [--after file] [--target target] [--language language] [--parser parser] [--platform platform] [--symbol name] [--region key] [--ref ref] [--source file] [--focused-command command] [--fixture-hint hint] [--ast] [--sidecar] [--sidecar-only] [--source-only] [--stubs] [--emit-on-blocked] [--all-languages] [--out file] [--strict-effects]'); }
|
|
392
448
|
function readOption(args, flag) { const index = args.indexOf(flag); return index >= 0 ? args[index + 1] : undefined; }
|
|
449
|
+
function readOptions(args, flag) {
|
|
450
|
+
const values = [];
|
|
451
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
452
|
+
if (args[index] === flag && args[index + 1]) values.push(args[index + 1]);
|
|
453
|
+
}
|
|
454
|
+
return values;
|
|
455
|
+
}
|
|
393
456
|
function readIntegerOption(args, flag) {
|
|
394
457
|
const value = readOption(args, flag);
|
|
395
458
|
if (value === undefined) return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshift-labs/frontier-lang-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.33",
|
|
4
4
|
"description": "Command line interface for parsing, checking, hashing, and emitting Frontier Lang projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
"fuzz": "npm run build && node fuzz/smoke.mjs",
|
|
28
28
|
"bench": "npm run build && node bench/smoke.mjs",
|
|
29
29
|
"prepare": "npm run build",
|
|
30
|
-
"prepack": "npm test",
|
|
30
|
+
"prepack": "npm run lint && npm test",
|
|
31
31
|
"pack:dry": "npm pack --dry-run",
|
|
32
32
|
"readme:packages": "node benchmarks/package-readme-sections.mjs",
|
|
33
|
-
"readme:packages:check": "node benchmarks/package-readme-sections.mjs --check"
|
|
33
|
+
"readme:packages:check": "node benchmarks/package-readme-sections.mjs --check",
|
|
34
|
+
"lint": "node scripts/strict-source-policy.mjs"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|
|
36
37
|
"frontier",
|
|
@@ -53,10 +54,10 @@
|
|
|
53
54
|
"access": "public"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@shapeshift-labs/frontier-lang-checker": "0.3.
|
|
57
|
-
"@shapeshift-labs/frontier-lang-compiler": "0.2.
|
|
58
|
-
"@shapeshift-labs/frontier-lang-kernel": "0.3.
|
|
59
|
-
"@shapeshift-labs/frontier-lang-parser": "0.3.
|
|
57
|
+
"@shapeshift-labs/frontier-lang-checker": "0.3.5",
|
|
58
|
+
"@shapeshift-labs/frontier-lang-compiler": "0.2.41",
|
|
59
|
+
"@shapeshift-labs/frontier-lang-kernel": "0.3.9",
|
|
60
|
+
"@shapeshift-labs/frontier-lang-parser": "0.3.5"
|
|
60
61
|
},
|
|
61
62
|
"bin": {
|
|
62
63
|
"frontier-lang": "dist/index.js"
|