@hyperscale0/hsx 1.0.0-rc.1 → 1.0.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/README.md +4 -2
  3. package/bin/hsx.ts +2 -0
  4. package/dist/bin/hsx.js +2 -0
  5. package/dist/bin/hsx.js.map +1 -1
  6. package/dist/src/ast.d.ts +6 -0
  7. package/dist/src/ast.d.ts.map +1 -1
  8. package/dist/src/ast.js +24 -0
  9. package/dist/src/ast.js.map +1 -1
  10. package/dist/src/cli.d.ts +3 -1
  11. package/dist/src/cli.d.ts.map +1 -1
  12. package/dist/src/cli.js +25 -5
  13. package/dist/src/cli.js.map +1 -1
  14. package/dist/src/compile.d.ts +1 -3
  15. package/dist/src/compile.d.ts.map +1 -1
  16. package/dist/src/compile.js +1 -2
  17. package/dist/src/compile.js.map +1 -1
  18. package/dist/src/emit.d.ts +1 -2
  19. package/dist/src/emit.d.ts.map +1 -1
  20. package/dist/src/emit.js +1 -223
  21. package/dist/src/emit.js.map +1 -1
  22. package/dist/src/index.d.ts +2 -1
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/index.js +2 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/lsp/server.d.ts +32 -0
  27. package/dist/src/lsp/server.d.ts.map +1 -0
  28. package/dist/src/lsp/server.js +391 -0
  29. package/dist/src/lsp/server.js.map +1 -0
  30. package/dist/src/modules.d.ts +2 -0
  31. package/dist/src/modules.d.ts.map +1 -1
  32. package/dist/src/modules.js +7 -11
  33. package/dist/src/modules.js.map +1 -1
  34. package/dist/src/std-bundle.d.ts +2 -0
  35. package/dist/src/std-bundle.d.ts.map +1 -0
  36. package/dist/src/std-bundle.js +88 -0
  37. package/dist/src/std-bundle.js.map +1 -0
  38. package/dist/src/std-library.d.ts +5 -0
  39. package/dist/src/std-library.d.ts.map +1 -0
  40. package/dist/src/std-library.js +9 -0
  41. package/dist/src/std-library.js.map +1 -0
  42. package/dist/src/version.d.ts +1 -1
  43. package/dist/src/version.d.ts.map +1 -1
  44. package/dist/src/version.js +1 -1
  45. package/dist/src/version.js.map +1 -1
  46. package/docs/README.md +3 -0
  47. package/docs/guide/01-first-program.md +1 -1
  48. package/docs/llms-full.txt +7 -6
  49. package/docs/llms.txt +2 -2
  50. package/docs/playground.md +54 -0
  51. package/docs/reference/cli.md +5 -3
  52. package/docs/reference/diagnostics.md +1 -1
  53. package/docs/reference/grammar.md +1 -1
  54. package/docs/reference/std/advance.md +1 -1
  55. package/docs/reference/std/cancellable_booking.md +1 -1
  56. package/docs/reference/std/captured_payment.md +1 -1
  57. package/docs/reference/std/conditional_disbursement.md +1 -1
  58. package/docs/reference/std/credit_facility.md +1 -1
  59. package/docs/reference/std/held_payment.md +1 -1
  60. package/docs/reference/std/instant_transfer.md +1 -1
  61. package/docs/reference/std/metered.md +1 -1
  62. package/docs/reference/std/pooled_split.md +1 -1
  63. package/docs/reference/std/premium_forward.md +1 -1
  64. package/docs/reference/std/reconciled_payout.md +1 -1
  65. package/docs/reference/std/recurring_collection.md +1 -1
  66. package/docs/reference/std/rotating_pool.md +1 -1
  67. package/docs/reference/std/scheduled.md +1 -1
  68. package/docs/reference/std/security_deposit.md +1 -1
  69. package/docs/reference/std/settlement_batch.md +1 -1
  70. package/docs/reference/std/swap.md +1 -1
  71. package/docs/reference/std/threshold_pool.md +1 -1
  72. package/docs/reference/std/weighted_distribution.md +1 -1
  73. package/docs/reference/types.md +1 -1
  74. package/docs/reference/udl-output.md +2 -3
  75. package/examples/02-imports-and-archetypes/README.md +1 -4
  76. package/examples/04-complete-product/README.md +0 -3
  77. package/package.json +11 -3
  78. package/skills/hsx/SKILL.md +1 -1
  79. package/src/ast.ts +30 -0
  80. package/src/cli.ts +28 -9
  81. package/src/compile.ts +1 -4
  82. package/src/emit.ts +2 -248
  83. package/src/index.ts +8 -6
  84. package/src/lsp/server.ts +460 -0
  85. package/src/modules.ts +12 -10
  86. package/src/std-bundle.ts +91 -0
  87. package/src/std-library.ts +12 -0
  88. package/src/version.ts +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"std-bundle.js","sourceRoot":"","sources":["../../src/std-bundle.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,MAAM,CAAC,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAGnE;IACA;QACE,cAAc;QACd,8zQAA8zQ;KAC/zQ;IACD;QACE,yBAAyB;QACzB,w8OAAw8O;KACz8O;IACD;QACE,qCAAqC;QACrC,k9OAAk9O;KACn9O;IACD;QACE,kCAAkC;QAClC,osXAAosX;KACrsX;IACD;QACE,0CAA0C;QAC1C,w/NAAw/N;KACz/N;IACD;QACE,iCAAiC;QACjC,qqMAAqqM;KACtqM;IACD;QACE,8BAA8B;QAC9B,kp7DAAkp7D;KACnp7D;IACD;QACE,uBAAuB;QACvB,2GAA2G;KAC5G;IACD;QACE,kCAAkC;QAClC,s0bAAs0b;KACv0b;IACD;QACE,yBAAyB;QACzB,2/EAA2/E;KAC5/E;IACD;QACE,8BAA8B;QAC9B,knKAAknK;KACnnK;IACD;QACE,iCAAiC;QACjC,03XAA03X;KAC33X;IACD;QACE,mCAAmC;QACnC,ktNAAktN;KACntN;IACD;QACE,sCAAsC;QACtC,s0CAAs0C;KACv0C;IACD;QACE,+BAA+B;QAC/B,ujqBAAujqB;KACxjqB;IACD;QACE,2BAA2B;QAC3B,mg/BAAmg/B;KACpg/B;IACD;QACE,kCAAkC;QAClC,0sXAA0sX;KAC3sX;IACD;QACE,kCAAkC;QAClC,i8XAAi8X;KACl8X;IACD;QACE,sBAAsB;QACtB,qumCAAqumC;KACtumC;IACD;QACE,gCAAgC;QAChC,+neAA+ne;KAChoe;IACD;QACE,uCAAuC;QACvC,24VAA24V;KAC54V;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface StandardLibrary {
2
+ readonly source: (specifier: string, name: string) => string | undefined;
3
+ }
4
+ export declare const bundledStandardLibrary: StandardLibrary;
5
+ //# sourceMappingURL=std-library.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"std-library.d.ts","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1E;AAED,eAAO,MAAM,sBAAsB,EAAE,eAKpC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { BUNDLED_STD_FILES } from "./std-bundle.js";
2
+ export const bundledStandardLibrary = {
3
+ source(specifier, name) {
4
+ if (specifier !== "std/settlements")
5
+ return undefined;
6
+ return BUNDLED_STD_FILES.get(`settlements/${name}.hsx`);
7
+ },
8
+ };
9
+ //# sourceMappingURL=std-library.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"std-library.js","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMpD,MAAM,CAAC,MAAM,sBAAsB,GAAoB;IACrD,MAAM,CAAC,SAAiB,EAAE,IAAY;QACpC,IAAI,SAAS,KAAK,iBAAiB;YAAE,OAAO,SAAS,CAAC;QACtD,OAAO,iBAAiB,CAAC,GAAG,CAAC,eAAe,IAAI,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** Package version reported by the command line. */
2
- export declare const HSX_VERSION = "1.0.0-rc.1";
2
+ export declare const HSX_VERSION = "1.0.0";
3
3
  /** Canonical UDL contract version emitted by this compiler. */
4
4
  export declare const HSX_TARGET_UDL_VERSION = 1;
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** Package version reported by the command line. */
2
- export const HSX_VERSION = "1.0.0-rc.1";
2
+ export const HSX_VERSION = "1.0.0";
3
3
  /** Canonical UDL contract version emitted by this compiler. */
4
4
  export const HSX_TARGET_UDL_VERSION = 1;
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC"}
package/docs/README.md CHANGED
@@ -18,6 +18,9 @@ The generated [reference](./reference/) follows the compiler, UDL vocabulary,
18
18
  and standard-library files. Run `bun run docs:build` after changing one of
19
19
  those sources. `bun run docs:check` compares every generated byte.
20
20
 
21
+ The [browser playground](./playground.md) provides a static editing surface with
22
+ live compilation, diagnostics inspection, and example programs.
23
+
21
24
  Agents can start with [llms.txt](./llms.txt) or load the
22
25
  [HSX skill](../skills/hsx/SKILL.md). [llms-full.txt](./llms-full.txt) combines
23
26
  the guide and generated reference in reading order.
@@ -1,6 +1,6 @@
1
1
  # Your first program
2
2
 
3
- An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with a Business Frame, an origin map, and a cost manifest.
3
+ An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with an origin map and a cost manifest.
4
4
 
5
5
  This program sends a tip from a listener to a host:
6
6
 
@@ -1,10 +1,10 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # HSX full documentation
4
4
 
5
5
  # Your first program
6
6
 
7
- An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with a Business Frame, an origin map, and a cost manifest.
7
+ An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with an origin map and a cost manifest.
8
8
 
9
9
  This program sends a tip from a listener to a host:
10
10
 
@@ -301,7 +301,7 @@ Exit code `0` means the command accepted the program. Exit code `1` means compil
301
301
  # CLI
302
302
 
303
303
  ```text
304
- hsx 1.0.0-rc.1, the HSX compiler
304
+ hsx 1.0.0, the HSX compiler
305
305
 
306
306
  Usage:
307
307
  hsx check <file.hsx> [--strict]
@@ -309,15 +309,17 @@ Usage:
309
309
  hsx cost <file.hsx> [--json] [--out <file.json>] [--strict]
310
310
  hsx explain <HSX####>
311
311
  hsx format <file.hsx>
312
+ hsx lsp
312
313
  hsx --version
313
314
  hsx --help
314
315
 
315
316
  Commands:
316
317
  check Compile and report diagnostics. Prints nothing when the program is clean.
317
- build Compile and write canonical UDL and its Business Frame as JSON.
318
+ build Compile and write canonical UDL as JSON.
318
319
  cost Compile and print the version-pinned cost manifest as a table or JSON.
319
320
  explain Print one diagnostic title, fix, and source example.
320
321
  format Print the source in the one canonical HSX style.
322
+ lsp Run the language server over stdin and stdout.
321
323
 
322
324
  Options:
323
325
  --json Print the cost manifest as JSON instead of a table.
@@ -1726,12 +1728,11 @@ HSX checks types before it emits UDL. Money and account values carry a currency
1726
1728
 
1727
1729
  # UDL output
1728
1730
 
1729
- An accepted compile returns four artifacts.
1731
+ An accepted compile returns three artifacts.
1730
1732
 
1731
1733
  | Artifact | Contents |
1732
1734
  | -------------- | ----------------------------------------------------------------------------------- |
1733
1735
  | `document` | The canonical UDL object. Serialize it with `serializeUdl` from `@hyperscale0/udl`. |
1734
- | `frame` | The Business Frame paired with the document. |
1735
1736
  | `originMap` | Canonical UDL paths mapped to authored HSX spans. |
1736
1737
  | `costManifest` | The deterministic manifest pinned to the supplied rate card. |
1737
1738
 
package/docs/llms.txt CHANGED
@@ -1,8 +1,8 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # HSX documentation
4
4
 
5
- > Repository guide and generated compiler reference for HSX 1.0.0-rc.1.
5
+ > Repository guide and generated compiler reference for HSX 1.0.0.
6
6
 
7
7
  ## Guide
8
8
 
@@ -0,0 +1,54 @@
1
+ # Browser playground
2
+
3
+ The HSX playground is a static browser application for authoring, editing,
4
+ and inspecting HSX programs without a server. It runs the compiler directly
5
+ in the browser client.
6
+
7
+ ## What it provides
8
+
9
+ - Source editor with line numbers and debounced compilation (200 ms).
10
+ - Verdict badge showing `valid`, `warning`, or `invalid`.
11
+ - Diagnostics panel with stage, code, line and column coordinates, message,
12
+ and suggested fix. Clicking any diagnostic focuses the editor and highlights
13
+ the exact source span.
14
+ - Tabbed output pane showing the lowered canonical UDL document as formatted
15
+ JSON and the UDL cost manifest.
16
+ - Built-in example selector containing the full corpus of test programs and
17
+ standard-library settlements.
18
+ - Pure client execution with no Node runtime dependencies.
19
+
20
+ ## Build the playground
21
+
22
+ Generate the examples manifest, bundle the browser assets, and copy static
23
+ files to `open/hsx/playground/dist/`:
24
+
25
+ ```bash
26
+ bun run --cwd open/hsx playground:build
27
+ ```
28
+
29
+ Verify that the generated static bundle contains no Node specifiers or URL
30
+ resolution calls:
31
+
32
+ ```bash
33
+ bun run --cwd open/hsx playground:check
34
+ ```
35
+
36
+ ## Serve locally
37
+
38
+ The deliverable is the static directory under `open/hsx/playground/dist/`.
39
+ Hosting infrastructure is owner-owed. To run the playground locally, serve
40
+ the output directory with any local static file server.
41
+
42
+ Using Bun:
43
+
44
+ ```bash
45
+ bunx serve open/hsx/playground/dist
46
+ ```
47
+
48
+ Using Python:
49
+
50
+ ```bash
51
+ python3 -m http.server -d open/hsx/playground/dist 8000
52
+ ```
53
+
54
+ Open `http://localhost:8000` in a browser.
@@ -1,9 +1,9 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # CLI
4
4
 
5
5
  ```text
6
- hsx 1.0.0-rc.1, the HSX compiler
6
+ hsx 1.0.0, the HSX compiler
7
7
 
8
8
  Usage:
9
9
  hsx check <file.hsx> [--strict]
@@ -11,15 +11,17 @@ Usage:
11
11
  hsx cost <file.hsx> [--json] [--out <file.json>] [--strict]
12
12
  hsx explain <HSX####>
13
13
  hsx format <file.hsx>
14
+ hsx lsp
14
15
  hsx --version
15
16
  hsx --help
16
17
 
17
18
  Commands:
18
19
  check Compile and report diagnostics. Prints nothing when the program is clean.
19
- build Compile and write canonical UDL and its Business Frame as JSON.
20
+ build Compile and write canonical UDL as JSON.
20
21
  cost Compile and print the version-pinned cost manifest as a table or JSON.
21
22
  explain Print one diagnostic title, fix, and source example.
22
23
  format Print the source in the one canonical HSX style.
24
+ lsp Run the language server over stdin and stdout.
23
25
 
24
26
  Options:
25
27
  --json Print the cost manifest as JSON instead of a table.
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # Diagnostics
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # Grammar vocabulary
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # advance
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # cancellable_booking
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # captured_payment
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # conditional_disbursement
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # credit_facility
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # held_payment
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # instant_transfer
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # metered
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # pooled_split
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # premium_forward
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # reconciled_payout
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # recurring_collection
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # rotating_pool
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # scheduled
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # security_deposit
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # settlement_batch
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # swap
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # threshold_pool
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # weighted_distribution
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # Types
4
4
 
@@ -1,13 +1,12 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 1.0.0-rc.1. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 1.0.0. Do not edit. -->
2
2
 
3
3
  # UDL output
4
4
 
5
- An accepted compile returns four artifacts.
5
+ An accepted compile returns three artifacts.
6
6
 
7
7
  | Artifact | Contents |
8
8
  | -------------- | ----------------------------------------------------------------------------------- |
9
9
  | `document` | The canonical UDL object. Serialize it with `serializeUdl` from `@hyperscale0/udl`. |
10
- | `frame` | The Business Frame paired with the document. |
11
10
  | `originMap` | Canonical UDL paths mapped to authored HSX spans. |
12
11
  | `costManifest` | The deterministic manifest pinned to the supplied rate card. |
13
12
 
@@ -46,10 +46,7 @@ asset booth: good { title_transfer: off_platform }
46
46
 
47
47
  `title_transfer: off_platform` records that ownership of the booth changes
48
48
  hands outside the platform. Money stays on-platform; this flag describes the
49
- object. Today `frameFor` emits `offPlatform` as an empty list alongside the
50
- frame's five constant fields (`confidence: "high"`, `conservationGroups: []`,
51
- `offPlatform: []`, `openQuestions: []`, and `rules: []`), so callers never
52
- assume the list carries parsed asset flags.
49
+ object.
53
50
 
54
51
  ## Fees have a side, and the side matters
55
52
 
@@ -78,9 +78,6 @@ tutor_payout_payout_1
78
78
  tutor_payout_payout_2
79
79
  ```
80
80
 
81
- The Business Frame's `mechanics` come back as `escrow` and `marketplace`,
82
- derived from the settlement bricks rather than declared.
83
-
84
81
  One program carries at most **20** money events (`MONEY_EVENT_BUDGET`). This
85
82
  one uses nine. Every installment anchor, fee leg, cancellation leg, and
86
83
  abandonment refund counts one, so the budget is the real ceiling on how much
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperscale0/hsx",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0",
4
4
  "description": "The strictly typed HSX language: compile total financial programs into canonical UDL.",
5
5
  "keywords": [
6
6
  "hsx",
@@ -40,6 +40,10 @@
40
40
  "types": "./dist/src/cost.d.ts",
41
41
  "default": "./dist/src/cost.js"
42
42
  },
43
+ "./lsp": {
44
+ "types": "./dist/src/lsp/server.d.ts",
45
+ "default": "./dist/src/lsp/server.js"
46
+ },
43
47
  "./package.json": "./package.json",
44
48
  "./std/*": "./std/*"
45
49
  },
@@ -67,17 +71,21 @@
67
71
  },
68
72
  "scripts": {
69
73
  "build": "tsc -p tsconfig.build.json",
70
- "check": "bun test && bun run docs:check && tsc -p tsconfig.json && bun run build && bun scripts/check-bin.ts",
74
+ "check": "bun test && bun run docs:check && bun run std:check && bun run playground:check && tsc -p tsconfig.json && bun run build && bun scripts/check-bin.ts",
71
75
  "docs:build": "bun scripts/docs/build.ts",
72
76
  "docs:check": "bun scripts/docs/check.ts",
73
77
  "examples:build": "bun scripts/examples/build.ts",
78
+ "playground:build": "bun scripts/build-playground.ts",
79
+ "playground:check": "bun scripts/build-playground.ts --check",
74
80
  "postpack": "bun scripts/pack-exports.ts restore",
75
81
  "prepack": "bun run build && bun scripts/pack-exports.ts apply",
82
+ "std:bundle": "bun scripts/bundle-std.ts",
83
+ "std:check": "bun scripts/bundle-std.ts --check",
76
84
  "test": "bun test",
77
85
  "typecheck": "tsc -p tsconfig.json"
78
86
  },
79
87
  "dependencies": {
80
- "@hyperscale0/udl": "1.0.0-rc.1"
88
+ "@hyperscale0/udl": "1.0.0"
81
89
  },
82
90
  "devDependencies": {
83
91
  "@types/bun": "1.4.0",
@@ -480,4 +480,4 @@ port snapshot_entitlements {
480
480
 
481
481
  ## Output boundary
482
482
 
483
- Use `compile` or the CLI to obtain canonical UDL, the Business Frame, the origin map, and the cost manifest. The engine reads UDL and never HSX. When a task needs direct UDL work, use the UDL skill instead.
483
+ Use `compile` or the CLI to obtain canonical UDL, the origin map, and the cost manifest. The engine reads UDL and never HSX. When a task needs direct UDL work, use the UDL skill instead.
package/src/ast.ts CHANGED
@@ -35,6 +35,36 @@ export function lineColAt(source: string, offset: number): LineCol {
35
35
  return { column: clamped - lineStart + 1, line };
36
36
  }
37
37
 
38
+ const utf8Encoder = new TextEncoder();
39
+
40
+ /**
41
+ * Convert a UTF-8 byte offset to a UTF-16 code-unit offset over a string.
42
+ * Walks Unicode code points, counting UTF-8 bytes and UTF-16 code units.
43
+ * Clamps to [0, source.length].
44
+ */
45
+ export function byteOffsetToCodeUnit(
46
+ source: string,
47
+ byteOffset: number,
48
+ ): number {
49
+ if (byteOffset <= 0) return 0;
50
+ let currentByte = 0;
51
+ let codeUnit = 0;
52
+
53
+ for (const char of source) {
54
+ const charBytes = utf8Encoder.encode(char).length;
55
+ if (currentByte + charBytes > byteOffset) {
56
+ return codeUnit;
57
+ }
58
+ currentByte += charBytes;
59
+ codeUnit += char.length;
60
+ if (currentByte === byteOffset) {
61
+ return codeUnit;
62
+ }
63
+ }
64
+
65
+ return source.length;
66
+ }
67
+
38
68
  /**
39
69
  * One source scanned once, so many offsets resolve without rescanning it.
40
70
  * `lineColAt` walks from offset zero every time, which turns a run of d
package/src/cli.ts CHANGED
@@ -15,6 +15,7 @@ import { compile, type CompileResult } from "./compile.ts";
15
15
  import type { UdlCostManifest, UdlCostTable } from "./cost.ts";
16
16
  import { hsxDiagnostics } from "./diagnostics.ts";
17
17
  import { format } from "./format.ts";
18
+ import { startLspServer } from "./lsp/server.ts";
18
19
  import { HSX_TARGET_UDL_VERSION, HSX_VERSION } from "./version.ts";
19
20
 
20
21
  /** Filesystem and streams, injected so the CLI stays testable. */
@@ -23,6 +24,8 @@ export interface Io {
23
24
  readonly out: (line: string) => void;
24
25
  readonly readFile: (path: string) => Promise<string>;
25
26
  readonly writeFile: (path: string, contents: string) => Promise<void>;
27
+ readonly stdin?: NodeJS.ReadableStream;
28
+ readonly stdout?: NodeJS.WritableStream;
26
29
  }
27
30
 
28
31
  /**
@@ -41,15 +44,17 @@ Usage:
41
44
  hsx cost <file.hsx> [--json] [--out <file.json>] [--strict]
42
45
  hsx explain <HSX####>
43
46
  hsx format <file.hsx>
47
+ hsx lsp
44
48
  hsx --version
45
49
  hsx --help
46
50
 
47
51
  Commands:
48
52
  check Compile and report diagnostics. Prints nothing when the program is clean.
49
- build Compile and write canonical UDL and its Business Frame as JSON.
53
+ build Compile and write canonical UDL as JSON.
50
54
  cost Compile and print the version-pinned cost manifest as a table or JSON.
51
55
  explain Print one diagnostic title, fix, and source example.
52
56
  format Print the source in the one canonical HSX style.
57
+ lsp Run the language server over stdin and stdout.
53
58
 
54
59
  Options:
55
60
  --json Print the cost manifest as JSON instead of a table.
@@ -73,6 +78,15 @@ export async function runCli(argv: readonly string[], io: Io): Promise<number> {
73
78
  return OK;
74
79
  }
75
80
  if (command === "explain") return explainDiagnostic(rest, io);
81
+ if (command === "lsp") {
82
+ const input = io.stdin ?? process.stdin;
83
+ const output = io.stdout ?? process.stdout;
84
+ return new Promise<number>((resolve) => {
85
+ startLspServer(input, output, {
86
+ onExit: resolve,
87
+ });
88
+ });
89
+ }
76
90
  if (
77
91
  command !== "check" &&
78
92
  command !== "build" &&
@@ -142,14 +156,7 @@ export async function runCli(argv: readonly string[], io: Io): Promise<number> {
142
156
  );
143
157
  return refused ? REFUSED : OK;
144
158
  }
145
- const json = `${JSON.stringify(
146
- {
147
- document: result.artifacts.document,
148
- frame: result.artifacts.frame,
149
- },
150
- null,
151
- 2,
152
- )}\n`;
159
+ const json = `${JSON.stringify(result.artifacts.document, null, 2)}\n`;
153
160
  if (parsed.out === undefined) {
154
161
  io.out(json.trimEnd());
155
162
  } else {
@@ -323,3 +330,15 @@ function diagnosticLines(
323
330
  function messageOf(cause: unknown): string {
324
331
  return cause instanceof Error ? cause.message : String(cause);
325
332
  }
333
+
334
+ if (import.meta.main) {
335
+ const { readFile, writeFile } = await import("node:fs/promises");
336
+ process.exitCode = await runCli(process.argv.slice(2), {
337
+ err: (line) => process.stderr.write(`${line}\n`),
338
+ out: (line) => process.stdout.write(`${line}\n`),
339
+ readFile: (path) => readFile(path, "utf8"),
340
+ writeFile: (path, contents) => writeFile(path, contents, "utf8"),
341
+ stdin: process.stdin,
342
+ stdout: process.stdout,
343
+ });
344
+ }
package/src/compile.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The HSX compiler driver: source text in, three-verdict result out.
3
3
  *
4
- * - `valid`: the program lowers cleanly; the IR document and frame are ready
4
+ * - `valid`: the program lowers cleanly; the IR document is ready
5
5
  * for the independent checker.
6
6
  * - `warning`: the program lowers, and the compiler's lint voice has notes
7
7
  * the author should read (the artifacts are still present and usable).
@@ -55,8 +55,6 @@ export interface CompileDiagnostic {
55
55
  interface CompileArtifacts {
56
56
  /** The canonical UDL document. */
57
57
  readonly document: Json;
58
- /** The congruent Business Frame. */
59
- readonly frame: Json;
60
58
  /** Canonical UDL paths bound to their narrowest authored source terms. */
61
59
  readonly originMap: readonly CompileOriginMapEntry[];
62
60
  /** Deterministic compile-time cost, pinned to one versioned table. */
@@ -215,7 +213,6 @@ export function compile(
215
213
  artifacts: {
216
214
  document: lowered.value.document,
217
215
  costManifest: cost.manifest,
218
- frame: lowered.value.frame,
219
216
  originMap: lowered.value.originMap.map(compileOrigin),
220
217
  },
221
218
  diagnostics,