@invariant.guru/cli 0.6.9 → 0.7.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
@@ -216,18 +216,29 @@ review*. The token is per project: see [docs/spec-review.md](docs/spec-review.md
216
216
 
217
217
  ### 7. `invariant ui` — see and manage your sessions
218
218
 
219
- Opens a local dashboard for this project: a session board grouped by status,
220
- rendered markdown, a rich editor, review triage, package management, and a
221
- command palette.
219
+ Opens a local dashboard: a session list, rendered markdown, a rich editor, review
220
+ triage, package management, and a command palette.
222
221
 
223
222
  ```bash
224
223
  invariant ui # start on 4200 (or the next free port) and open a browser
225
- invariant ui status # every running instance on this machine
226
- invariant ui stop # stop this project's instance
224
+ invariant ui status # the daemon, and the projects it serves
225
+ invariant ui stop # stop it
227
226
  ```
228
227
 
229
- Each directory gets its own instance on its own port, so several repositories can
230
- be open at once without ever mixing sessions.
228
+ **One server, every project.** Running `invariant ui` in a second repository does
229
+ not start a second server it registers that folder and opens it in the one
230
+ already running. `⌘P` switches between projects; `⇧⌘H` goes to the list of them
231
+ all. Switching is a URL change (`/p/<project>/sessions`), so back, forward,
232
+ reload, bookmarks and a second tab on a second project all work the way you
233
+ would expect, and nothing from one project survives into the next.
234
+
235
+ ```bash
236
+ invariant projects # every registered project
237
+ invariant projects add [path] # register one (defaults to the current folder)
238
+ invariant projects remove # forget one — its files are left alone
239
+ ```
240
+
241
+ The list lives in `~/.invariant/projects.json`.
231
242
 
232
243
  ### Full walkthrough
233
244
 
@@ -558,24 +569,30 @@ See [docs/spec-review.md](docs/spec-review.md) for the document format.
558
569
 
559
570
  ### `invariant ui [port]`
560
571
 
561
- Start (or attach to) the local session UI for the current project, then open a
562
- browser. One instance per directory; the default port is 4200 and the next free
563
- port is used when it is taken.
572
+ Start or attach to the one local UI server on this machine, then open a
573
+ browser on the project you ran it from. The default port is 4200 and the next
574
+ free port is used when it is taken.
575
+
576
+ There is exactly one server. Running `invariant ui` again, here or in another
577
+ repository, attaches to it rather than racing a second one onto another port;
578
+ asking for a different port while it runs is refused rather than silently
579
+ ignored. A folder with no `invariant.json` is fine too — the server opens on the
580
+ project list instead.
564
581
 
565
582
  ```bash
566
- invariant ui # start and open a browser
567
- invariant ui 4300 # ask for a specific port (fails if it is busy)
583
+ invariant ui # start or attach, and open this project
584
+ invariant ui 4300 # ask for a specific port (refused if one is already running)
568
585
  invariant ui --no-open # start without opening a browser
569
- invariant ui status --json # machine-readable status of every instance
570
- invariant ui stop --all # stop every instance on this machine
586
+ invariant ui status --json # machine-readable status
587
+ invariant ui stop # stop the server
571
588
  invariant ui migrate-headers # add <session-meta> headers to legacy sessions
572
589
  ```
573
590
 
574
591
  | Subcommand | Description |
575
592
  |--------|-------------|
576
593
  | *(none)* / `start [port]` | Start or attach, then open a browser |
577
- | `stop` | Stop this project's instance (`--all` for every instance) |
578
- | `status` | Every instance, liveness-checked (`--json`) |
594
+ | `stop` | Stop the server |
595
+ | `status` | The server and its projects, liveness-checked (`--json`) |
579
596
  | `migrate-headers` | Give legacy session files a canonical `<session-meta>` header |
580
597
 
581
598
  | Option | Description |
@@ -584,19 +601,35 @@ invariant ui migrate-headers # add <session-meta> headers to legacy sessions
584
601
  | `--no-open` | Do not open a browser window |
585
602
 
586
603
  The server binds `127.0.0.1` only, checks `Host` and `Origin`, and requires a
587
- per-instance token kept in `~/.invariant/ui.json` (mode 0600). What it can read
588
- and write is limited to the directory it was started in.
604
+ token kept in `~/.invariant/ui.json` (mode 0600). Every request names the project
605
+ it acts on (`/api/p/<project>/…`) and is scoped to that project's directory for
606
+ its whole lifetime, so one project can never read or write another's files.
607
+
608
+ ### `invariant projects`
609
+
610
+ The projects the UI serves, kept in `~/.invariant/projects.json`.
611
+
612
+ ```bash
613
+ invariant projects # list them, with what each is waiting on
614
+ invariant projects add [path] # register a folder (defaults to the current one)
615
+ invariant projects remove [id|path] # forget one — nothing on disk is touched
616
+ ```
617
+
618
+ A project must have been initialized (`invariant init`) before it can be added.
619
+ Removing one only edits the list: re-adding the path brings back every session,
620
+ review and setting exactly as they were.
589
621
 
590
- In the UI: `⌘K` opens the command palette, `⇧⌘V` toggles rendered preview and
591
- editing, `N` starts a session, `?` lists every shortcut. On a review session,
622
+ In the UI: `⌘K` opens the command palette, `⌘P` switches project, `⇧⌘H` goes to
623
+ the project list, `⇧⌘V` toggles rendered preview and editing, `N` starts a
624
+ session, `?` lists every shortcut. On a review session,
592
625
  `j`/`k` move between comments and `s` / `d` / `e` stage, discard, or edit one.
593
626
 
594
627
  #### The Packages page
595
628
 
596
629
  The **Packages** section of the UI is a view over the package commands — it runs
597
630
  the same `invariant install`, `add`, `remove`, `uninstall` and `sync` you would
598
- type, in the directory the UI was started in, and shows you the command before it
599
- runs. It never writes `invariant.json` itself.
631
+ type, in the folder of the project you are currently in, and shows you the
632
+ command before it runs. It never writes `invariant.json` itself.
600
633
 
601
634
  - **The tree is `invariant inspect`.** Selecting a package lists everything it
602
635
  ships, grouped by type, with the active items ticked.
@@ -620,7 +653,7 @@ runs. It never writes `invariant.json` itself.
620
653
 
621
654
  A change made in a terminal shows up in an open page within a couple of seconds.
622
655
 
623
- To work on the UI itself: start a daemon (`invariant ui --no-open`), then run
656
+ To work on the UI itself: start the server (`invariant ui --no-open`), then run
624
657
  `yarn dev:ui` for Vite with hot reload against it — `INVARIANT_UI_PORT=<port>`
625
658
  when the daemon landed on something other than 4200.
626
659