statelyai 0.12.8 → 0.14.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.
package/README.md CHANGED
@@ -32,6 +32,8 @@ npm install --global statelyai
32
32
  | Set up local discovery | `statelyai init --local --scan` | Local `statelyai.json` |
33
33
  | Set up project sync | `statelyai init --scan` | Remote project and local `statelyai.json` |
34
34
  | Inspect project machines | `statelyai status` | Nothing |
35
+ | Connect to a Studio project | `statelyai link --project <id>` | Project association in `statelyai.json` |
36
+ | Associate an existing machine | `statelyai link <file> --machine <id>` | Selected source machine ID comment |
35
37
  | Preview project uploads | `statelyai push --dry-run` | Nothing |
36
38
  | Upload local machines | `statelyai push [file]` | Remote machines and local `@statelyai` IDs |
37
39
  | Download project machines | `statelyai pull` | Linked local files and new files under `newMachinesDir` |
@@ -40,7 +42,7 @@ npm install --global statelyai
40
42
 
41
43
  ## Quick start
42
44
 
43
- <!-- project initialization and sync flow from InitCommand, PushCommand, PullCommand, and projectConfig.ts -->
45
+ <!-- project initialization and sync flow from InitCommand, LinkCommand, PushCommand, PullCommand, and projectConfig.ts -->
44
46
 
45
47
  For hosted Stately, authenticate once:
46
48
 
@@ -48,10 +50,11 @@ For hosted Stately, authenticate once:
48
50
  statelyai login
49
51
  ```
50
52
 
51
- Initialize the current repository and scan for XState files:
53
+ Initialize local discovery, then choose the Studio project:
52
54
 
53
55
  ```bash
54
- statelyai init --scan
56
+ statelyai init --local --scan
57
+ statelyai link --project <project-id-or-url>
55
58
  ```
56
59
 
57
60
  `--scan` suggests `include` globs and asks before saving them. Without
@@ -66,8 +69,8 @@ statelyai init --local --scan
66
69
  statelyai status
67
70
  ```
68
71
 
69
- Run `statelyai init` later to connect the local config to a Studio project
70
- without losing its discovery globs.
72
+ Run `statelyai link` later to choose a Studio project without losing discovery
73
+ globs. Plain `init` still supports the existing connected setup for compatibility.
71
74
 
72
75
  To list machines without creating any config:
73
76
 
@@ -114,6 +117,67 @@ migrated to the shared machine key on the next save.
114
117
  New states keep their generated coordinates when clear, or move beside
115
118
  existing states when they would overlap restored layout.
116
119
 
120
+ ## Local setup and Studio linking
121
+
122
+ <!-- association workflow from src/link.ts and LinkCommand in src/cli.ts -->
123
+
124
+ Local configuration, Studio association, and data sync are separate steps:
125
+
126
+ ```bash
127
+ statelyai init --local --scan
128
+ statelyai login
129
+ statelyai link --project <project-id-or-url>
130
+ statelyai push --dry-run
131
+ statelyai push
132
+ ```
133
+
134
+ `link` without flags offers a project picker in an interactive terminal. In
135
+ scripts, pass `--project` or explicitly create a project:
136
+
137
+ ```bash
138
+ statelyai link --create --name "Checkout" --visibility Private
139
+ ```
140
+
141
+ Link an existing remote machine to local source without uploading or downloading
142
+ its definition:
143
+
144
+ ```bash
145
+ statelyai link ./test.ts --machine <machine-id-or-url>
146
+ ```
147
+
148
+ The remote machine must belong to the connected project. For a file containing
149
+ multiple machines, select one with `--machine-index 0` (zero-based). This changes
150
+ only the selected machine's `@statelyai id` comment. It does not compare or
151
+ reconcile the two definitions. Review `push --dry-run` and choose `push` or `pull`
152
+ when ready to sync; `linked` describes association, not equality.
153
+
154
+ Use `--force` to replace an existing project or machine association. Changing the
155
+ project retains existing source machine IDs. `link` preserves discovery globs and
156
+ local writeback settings; it does not scan or include new files automatically.
157
+ Plain `init` retains its existing Studio-connected behavior for compatibility.
158
+ The executable remains `statelyai`.
159
+
160
+ ```mermaid
161
+ stateDiagram-v2
162
+ [*] --> Unconfigured
163
+ Unconfigured --> Local: init --local
164
+ Unconfigured --> Connected: init (compatibility)
165
+ Unconfigured --> Connected: link
166
+ Local --> Connected: link
167
+ state Connected {
168
+ [*] --> LocalOnly
169
+ LocalOnly --> Linked: link file --machine (association only)
170
+ LocalOnly --> Linked: push (create remote + upload + ID)
171
+ Linked --> Linked: push (upload)
172
+ Linked --> Linked: pull (download)
173
+ }
174
+ ```
175
+
176
+ Authentication is independent of this state machine. `open`, `scan`, and
177
+ `push --dry-run` do not establish machine links. `--scan` proposes source globs;
178
+ a new config without it has an empty `include` list. Project-wide `pull` creates
179
+ remote-only files only when `newMachinesDir` is configured.
180
+
117
181
  ## Authentication
118
182
 
119
183
  <!-- authentication flags, environment resolution, and credential storage from src/cli.ts and src/credentials.ts -->
@@ -252,6 +316,20 @@ Use `--json` for automation or `--auth` to show only credential resolution.
252
316
 
253
317
  Flags: `--config <path>`, `--base-url <url>`, `--json`, `--auth`.
254
318
 
319
+ ### `link`
320
+
321
+ Connect to Studio without moving machine definitions:
322
+
323
+ ```bash
324
+ statelyai link --project <project-id-or-url>
325
+ statelyai link --create --name "Checkout"
326
+ statelyai link ./test.ts --machine <machine-id-or-url>
327
+ ```
328
+
329
+ Flags: `--project <id|url>` or `--create`, `--name`, `--visibility`,
330
+ `--machine <id|url>`, `--machine-index <zero-based-index>`, `--config`,
331
+ `--base-url`, `--force`. See [Local setup and Studio linking](#local-setup-and-studio-linking).
332
+
255
333
  ### `init`
256
334
 
257
335
  Create a local config or reuse a Studio project and write `statelyai.json`.
@@ -270,6 +348,16 @@ Flags:
270
348
  - `--force` replaces an existing config.
271
349
  - `--base-url <url>` overrides the Studio API origin.
272
350
 
351
+ ### Alternate XState runtimes
352
+
353
+ <!-- source profile selection from packages/editor-sync/src/internal/sourceLocations.ts -->
354
+
355
+ `open` recognizes v6 transition-function syntax in alternate runtimes such as
356
+ `@airconsole/xstate6`, including named `setup` variables. A separate `xstate` v5
357
+ dependency does not determine the version of a machine using that runtime.
358
+ Importing a machine for visualization does not execute its authored actions or
359
+ async actor implementation.
360
+
273
361
  ### `scan`
274
362
 
275
363
  List every local XState machine without authentication or `statelyai.json`:
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as run } from "./cli-B2Dd5vY-.mjs";
2
+ import { C as run } from "./cli-BtgsQvTR.mjs";
3
3
 
4
4
  //#region src/bin.ts
5
5
  run();