@flux-lang/core 0.1.0 → 0.1.2

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 (2) hide show
  1. package/README.md +117 -0
  2. package/package.json +4 -3
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @flux-lang/core
2
+
3
+ Core library for the **Flux** score language: AST types, parser, canonical IR, and the v0.1 runtime kernel.
4
+
5
+ Flux is a small, declarative language for **procedurally evolving music scores and parts**. The `@flux-lang/core` package is the reference implementation of:
6
+
7
+ - The **Flux v0.1 grammar**.
8
+ - The **FluxDocument IR** (canonical JSON representation).
9
+ - A minimal **runtime kernel** with `docstep` rules and `neighbors.*` semantics.
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @flux-lang/core
17
+ # or
18
+ pnpm add @flux-lang/core
19
+ # or
20
+ yarn add @flux-lang/core
21
+ ````
22
+
23
+ ---
24
+
25
+ ## Basic usage
26
+
27
+ ### Parse source → IR
28
+
29
+ ```ts
30
+ import { parseDocument } from "@flux-lang/core";
31
+
32
+ const source = `
33
+ document {
34
+ meta {
35
+ version = "0.1.0";
36
+ title = "Example";
37
+ }
38
+
39
+ state {
40
+ param tempo : float [40, 72] @ 60;
41
+ }
42
+ }
43
+ `;
44
+
45
+ const doc = parseDocument(source);
46
+ // doc is a FluxDocument (Flux v0.1 IR)
47
+ ```
48
+
49
+ ### Runtime kernel: docstep + neighbors
50
+
51
+ ```ts
52
+ import {
53
+ parseDocument,
54
+ initRuntimeState,
55
+ runDocstepOnce,
56
+ } from "@flux-lang/core";
57
+
58
+ const doc = parseDocument(source);
59
+
60
+ // Build initial RuntimeState from the document
61
+ const state0 = initRuntimeState(doc);
62
+
63
+ // Advance one docstep (applies all mode=docstep rules)
64
+ const state1 = runDocstepOnce(doc, state0);
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Static checks
70
+
71
+ `@flux-lang/core` also exposes a small static checker used by the CLI and VS Code extension:
72
+
73
+ ```ts
74
+ import { parseDocument, checkDocument } from "@flux-lang/core";
75
+
76
+ const doc = parseDocument(source);
77
+ const errors = checkDocument("example.flux", doc);
78
+
79
+ if (errors.length > 0) {
80
+ for (const line of errors) {
81
+ console.error(line);
82
+ }
83
+ }
84
+ ```
85
+
86
+ Typical diagnostics include:
87
+
88
+ * Unknown grid references in `rule ... (grid = main)`.
89
+ * Unsupported `neighbors.*` methods.
90
+ * Obvious runtime timer issues (e.g. non-positive `timer(...)` amounts).
91
+
92
+ ---
93
+
94
+ ## Flux IR contract
95
+
96
+ The canonical IR is the `FluxDocument` type exported from `@flux-lang/core`. It is:
97
+
98
+ * Produced by `parseDocument(source)`.
99
+ * Safe to serialize as JSON and pass across process boundaries.
100
+ * Used by the CLI (`flux parse`) and editor tooling.
101
+
102
+ See the Flux IR spec in the main repo for the full shape and semantics:
103
+
104
+ * GitHub: `https://github.com/cbassuarez/flux` (IR docs live under `packages/core/docs/`)
105
+
106
+ ---
107
+
108
+ ## Related tooling
109
+
110
+ * **CLI:** `@flux-lang/cli` — `flux parse` / `flux check` built on top of this package.
111
+ * **VS Code:** `@flux-lang/vscode-flux` — syntax highlighting + diagnostics using `@flux-lang/core`.
112
+
113
+ ---
114
+
115
+ ## License
116
+
117
+ MIT – see the LICENSE file in the repo root.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flux-lang/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Core AST, parser, and evaluator for the Flux score language.",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Suarez-Solis",
@@ -13,7 +13,8 @@
13
13
  "types": "dist/index.d.ts",
14
14
  "files": [
15
15
  "dist",
16
- "README.md"
16
+ "README.md",
17
+ "LICENSE"
17
18
  ],
18
19
  "exports": {
19
20
  ".": {
@@ -30,4 +31,4 @@
30
31
  "typescript": "^5.6.0",
31
32
  "vitest": "^2.0.0"
32
33
  }
33
- }
34
+ }