@shapeshift-labs/frontier-lang-cli 0.3.30 → 0.3.32

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 CHANGED
@@ -11,8 +11,13 @@ frontier-lang native-diff src/todo.before.ts --after src/todo.after.ts --out nat
11
11
  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
+ 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
14
17
  ```
15
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
+
16
21
  ## Related Packages
17
22
 
18
23
  The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
@@ -44,8 +49,8 @@ The published Frontier package family is generated from one shared package catal
44
49
  - [`@shapeshift-labs/frontier-workflow`](https://www.npmjs.com/package/@shapeshift-labs/frontier-workflow): Serializable durable workflow/process manifests for Frontier apps, including steps, waits, approvals, timers, retries, expected patches, compensation, records, timelines, and registry graph output.
45
50
  - [`@shapeshift-labs/frontier-worker`](https://www.npmjs.com/package/@shapeshift-labs/frontier-worker): Serializable worker and edge task descriptors for Frontier apps, including queues, idempotency keys, retry and timeout policy, declared reads/writes/effects, snapshots, patch outputs, produced assets, execution records, logs, trace links, proof hashes, dedupe indexes, and registry graph output.
46
51
  - [`@shapeshift-labs/frontier-queue`](https://www.npmjs.com/package/@shapeshift-labs/frontier-queue): Serializable durable queue state, leases, retries, dedupe keys, patch-carrying jobs, dead-letter records, replay evidence, and queue inspection for Frontier apps.
47
- - [`@shapeshift-labs/frontier-swarm`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm): Hierarchical swarm plans, lanes, compute profiles, ownership policy, semantic ownership regions, task queues, event streams, run records, merge bundles, merge indexes, queue overlays, merge admission, changed-path checks, and proof artifacts for Frontier agent work.
48
- - [`@shapeshift-labs/frontier-swarm-codex`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm-codex): Node Codex CLI adapter for Frontier swarm plans, including prompt rendering, worktree and snapshot workspaces, Codex argument compatibility, browser resource allocation, JSONL capture, verification commands, pid-backed stop, collect/apply workflows, merge indexes, queue overlays, merge bundles, and result artifacts.
52
+ - [`@shapeshift-labs/frontier-swarm`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm): Hierarchical swarm plans, lanes, compute profiles, ownership policy, semantic ownership regions, task queues, event streams, run records, merge bundles, merge indexes, queue overlays, merge admission, coordinator dashboards, changed-path checks, and proof artifacts for Frontier agent work.
53
+ - [`@shapeshift-labs/frontier-swarm-codex`](https://www.npmjs.com/package/@shapeshift-labs/frontier-swarm-codex): Node Codex CLI adapter for Frontier swarm plans, including prompt rendering, worktree and snapshot workspaces, Codex argument compatibility, browser resource allocation, JSONL capture, verification commands, pid-backed stop, collect/apply workflows, merge indexes, queue overlays, merge bundles, normalized job evidence, coordinator query artifacts, and result artifacts.
49
54
  - [`@shapeshift-labs/frontier-lang-kernel`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-kernel): Runtime-neutral semantic source graph, type/lattice/extern declarations, patch bundles, replay, hashing, evidence records, and merge-admission kernel for Frontier Lang.
50
55
  - [`@shapeshift-labs/frontier-lang-parser`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-parser): Dependency-light Frontier Lang parser for modules, entities, state, actions, effects, types, externs, targets, and lattice declarations.
51
56
  - [`@shapeshift-labs/frontier-lang-checker`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-checker): Checker and diagnostics for Frontier Lang semantic documents, including type symbols, effects, regions, lattice laws, CRDT metadata, and patch evidence.
@@ -54,8 +59,14 @@ The published Frontier package family is generated from one shared package catal
54
59
  - [`@shapeshift-labs/frontier-lang-rust`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-rust): Rust projection adapter for Frontier Lang semantic documents, including structs, aliases, and action stubs.
55
60
  - [`@shapeshift-labs/frontier-lang-python`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-python): Python projection adapter for Frontier Lang semantic documents, including dataclasses, typed patch records, and action stubs.
56
61
  - [`@shapeshift-labs/frontier-lang-c`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-c): C header projection adapter for Frontier Lang semantic documents, including structs and action prototypes.
57
- - [`@shapeshift-labs/frontier-lang-compiler`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-compiler): Compiler facade for Frontier Lang source documents, including parse, check, hash, diagnostics, and projection to TypeScript, JavaScript, Rust, Python, and C.
58
- - [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, and projection adapters.
62
+ - [`@shapeshift-labs/frontier-lang-compiler`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-compiler): Compiler facade for Frontier Lang source documents, including parse, check, hash, diagnostics, universal AST envelopes, proof/paradigm semantic summaries, projection to TypeScript, JavaScript, Rust, Python, and C, and native source-import adapters for semantic merge evidence.
63
+ - [`@shapeshift-labs/frontier-lang-swift`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-swift): Swift source-language importer package for Frontier Lang semantic documents, including package-level metadata, SwiftSyntax adapter helpers, native import results, and semantic sidecar generation for SwiftSyntax/SwiftParser-shaped syntax trees.
64
+ - [`@shapeshift-labs/frontier-lang-kotlin`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-kotlin): Kotlin PSI source-language importer package for Frontier Lang semantic documents, including package-level metadata, Kotlin PSI adapter helpers, native import results, and semantic sidecar generation for Kotlin PSI/KtFile-shaped syntax trees.
65
+ - [`@shapeshift-labs/frontier-lang-java`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-java): Java source-language importer package for Frontier Lang semantic documents, including package-level metadata, Java AST adapter helpers, native import results, and semantic sidecar generation for javac/JDT/JavaParser-shaped ASTs.
66
+ - [`@shapeshift-labs/frontier-lang-go`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-go): Go source-language importer package for Frontier Lang semantic documents, including package-level metadata, Go AST adapter helpers, native import results, and semantic sidecar generation for go/ast File or Package trees.
67
+ - [`@shapeshift-labs/frontier-lang-csharp`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-csharp): C# Roslyn source-language importer package for Frontier Lang semantic documents, including package-level metadata, Roslyn adapter helpers, native import results, and semantic sidecar generation for SyntaxTree/SyntaxNode-shaped ASTs.
68
+ - [`@shapeshift-labs/frontier-lang-clang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-clang): Clang AST source-language importer package for Frontier Lang semantic documents, including package-level metadata, Clang AST JSON adapter helpers, native import results, and semantic sidecar generation for C/C++ translation units.
69
+ - [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, compiler facade, universal AST helpers, and projection adapters.
59
70
  - [`@shapeshift-labs/frontier-kv`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv): Serializable in-memory key/value state for Frontier apps, including TTL, versioned compare-and-set, batched patch mutations, scans, watchers, snapshots, JSONL event evidence, and replay verification.
60
71
  - [`@shapeshift-labs/frontier-kv-locks`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-locks): Lease-style lock records on top of Frontier KV, including acquire, renew, release, fencing tokens, expiration, owner evidence, and replayable lock events.
61
72
  - [`@shapeshift-labs/frontier-kv-rate-limit`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-rate-limit): Patch-native rate limit buckets for Frontier KV, including fixed windows, sliding windows, token buckets, deterministic refill, consume evidence, and reset records.
@@ -141,6 +152,12 @@ Package source repositories:
141
152
  - [`siliconjungle/-shapeshift-labs-frontier-lang-python`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-python)
142
153
  - [`siliconjungle/-shapeshift-labs-frontier-lang-c`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-c)
143
154
  - [`siliconjungle/-shapeshift-labs-frontier-lang-compiler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler)
155
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-swift`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-swift)
156
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-kotlin`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-kotlin)
157
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-java`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-java)
158
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-go`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-go)
159
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-csharp`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-csharp)
160
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-clang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-clang)
144
161
  - [`siliconjungle/-shapeshift-labs-frontier-lang-cli`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-cli)
145
162
  - [`siliconjungle/-shapeshift-labs-frontier-lang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang)
146
163
  - [`siliconjungle/-shapeshift-labs-frontier-kv`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv)
@@ -195,7 +212,7 @@ npm install -g @shapeshift-labs/frontier-lang-cli
195
212
  frontier-lang check examples/todo.frontier
196
213
  ```
197
214
 
198
- Commands: `parse`, `check`, `hash`, `ast`, `capabilities`, `to-json`, `from-json`, `import`, `project-native`, `native-compile`, `native-coverage`, `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`.
199
216
 
200
217
  ```sh
201
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
- console.log(JSON.stringify({ emits: 100, nativeCompiles: 25, bytes, nativeBytes, durationMs: Number((performance.now() - start).toFixed(2)) }));
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
@@ -6,18 +6,24 @@ import { parseFrontierFile, parseFrontierSource } from '@shapeshift-labs/frontie
6
6
  import { checkDocument } from '@shapeshift-labs/frontier-lang-checker';
7
7
  import { hashDocumentBase } from '@shapeshift-labs/frontier-lang-kernel';
8
8
  import {
9
+ NativeImportLanguageProfiles,
9
10
  compileNativeSource,
10
11
  compileFrontierDocument,
11
12
  createNativeSourcePreservation,
12
13
  createNativeImportCoverageMatrix,
13
14
  createSemanticImportSidecar,
15
+ createSemanticSlice,
14
16
  createUniversalAstFromDocument,
17
+ createUniversalCapabilityMatrix,
15
18
  diffNativeSources,
16
19
  importNativeSource,
17
20
  projectNativeImportToSource,
18
21
  projectFrontierAst,
22
+ readSemanticSliceJson,
19
23
  readUniversalAstJson,
20
24
  resolveCapabilityAdapters,
25
+ testSemanticSlice,
26
+ writeSemanticSliceJson,
21
27
  writeUniversalAstJson
22
28
  } from '@shapeshift-labs/frontier-lang-compiler';
23
29
 
@@ -84,6 +90,15 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
84
90
  const imported = importNativeFile(file, source, rest, { language });
85
91
  return outputMaybeFile(io, rest, createNativeImportCoverageMatrix({ imports: [imported] }));
86
92
  }
93
+ if (command === 'native-capabilities') {
94
+ const imported = readNativeImportForProjection(file, source, rest);
95
+ const target = readOption(rest, '--target');
96
+ return outputMaybeFile(io, rest, createUniversalCapabilityMatrix({
97
+ imports: [imported],
98
+ languages: nativeCapabilityLanguages(imported, rest),
99
+ targets: target ? [target] : undefined
100
+ }));
101
+ }
87
102
  if (command === 'native-diff') {
88
103
  const afterPath = readOption(rest, '--after');
89
104
  if (!afterPath) throw new Error('native-diff requires --after <file>');
@@ -105,6 +120,37 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
105
120
  metadata: { cli: true, beforePath: file, afterPath }
106
121
  }));
107
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
+ }
108
154
  const document = file ? parseFrontierFile(file, source) : parseFrontierSource(source);
109
155
  if (command === 'to-json') {
110
156
  return io.log(writeUniversalAstJson(createUniversalAstFromDocument(document, {
@@ -344,6 +390,38 @@ function readNativeImportForProjection(file, source, args) {
344
390
  return parsed;
345
391
  }
346
392
 
393
+ function nativeCapabilityLanguages(imported, args) {
394
+ if (args.includes('--all-languages')) return undefined;
395
+ const language = imported?.language;
396
+ if (!language) return undefined;
397
+ const normalized = String(language).toLowerCase();
398
+ const matches = NativeImportLanguageProfiles.filter((profile) => (
399
+ profile.language === normalized || profile.aliases?.includes(normalized)
400
+ ));
401
+ return matches.length ? matches : undefined;
402
+ }
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
+
347
425
  function tryParseJson(source) {
348
426
  const trimmed = source.trim();
349
427
  if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return undefined;
@@ -366,8 +444,15 @@ function idFragment(value) {
366
444
  return String(value ?? 'unknown').replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '').toLowerCase() || 'unknown';
367
445
  }
368
446
 
369
- function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|project-native|native-compile|native-coverage|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] [--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]'); }
370
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
+ }
371
456
  function readIntegerOption(args, flag) {
372
457
  const value = readOption(args, flag);
373
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.30",
3
+ "version": "0.3.32",
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",
@@ -54,8 +55,8 @@
54
55
  },
55
56
  "dependencies": {
56
57
  "@shapeshift-labs/frontier-lang-checker": "0.3.4",
57
- "@shapeshift-labs/frontier-lang-compiler": "0.2.31",
58
- "@shapeshift-labs/frontier-lang-kernel": "0.3.4",
58
+ "@shapeshift-labs/frontier-lang-compiler": "0.2.40",
59
+ "@shapeshift-labs/frontier-lang-kernel": "0.3.8",
59
60
  "@shapeshift-labs/frontier-lang-parser": "0.3.4"
60
61
  },
61
62
  "bin": {