@scalequality/cli 0.3.3 → 0.4.1

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
@@ -1,36 +1,80 @@
1
1
  # @scalequality/cli
2
2
 
3
- Run the ScaleQuality AI Workspace coding engine on your own machine, in your
4
- repository folders. The conversation stays in the browser; the files, the
5
- commands and the git working tree stay on your computer.
3
+ Run the ScaleQuality AI Workspace coding engine on your own machine, in any
4
+ folder: a git repository, a folder inside one, or a folder with several
5
+ repositories and other files. The conversation stays in the browser; the files,
6
+ the commands and the git working trees stay on your computer.
6
7
 
7
- ## Connect this computer (recommended)
8
+ ## Connect this computer
8
9
 
9
10
  ```bash
10
11
  npx @scalequality/cli login # prints a code; confirm it in ScaleQuality
11
- npx @scalequality/cli add ~/code/app # a folder the AI Workspace may use
12
- npx @scalequality/cli up # keep the computer connected
12
+ npx @scalequality/cli add ~/code/app # a folder the AI Workspace may use (or pick it in the browser)
13
13
  ```
14
14
 
15
15
  `login` prints a code and an address (`<ScaleQuality>/devices?code=XXXX-XXXX`).
16
16
  Open it while signed in to ScaleQuality and confirm the code; the computer is
17
- then yours, in that organization, and `login` goes on running `up`. Only
18
- confirm a code you started yourself.
17
+ then yours, in that organization. Only confirm a code you started yourself.
18
+
19
+ Right after that, `login` installs a **background service** that keeps the
20
+ computer connected, also after a restart. There is nothing to keep open.
19
21
 
20
22
  | Command | What it does |
21
23
  |---------|--------------|
22
- | `scalequality login [--api URL] [--name NAME] [--no-up]` | Connects this computer (device code, like signing in to a TV app). |
23
- | `scalequality up [--api URL] [--verbose]` | Keeps it connected: sessions started in the AI Workspace run here, in your folders. Ctrl+C disconnects. |
24
+ | `scalequality login [--api URL] [--name NAME]` | Connects this computer (device code, like signing in to a TV app) and installs the background service. |
24
25
  | `scalequality add [PATH]` | Adds a folder (default: the current one). Only folders inside your home folder, never the home folder itself. |
25
- | `scalequality logout [--api URL]` | Disconnects this computer in ScaleQuality and deletes the local credential. |
26
+ | `scalequality service status` | Whether the service is installed and running, what it runs and where it logs. |
27
+ | `scalequality service logs [--lines N]` | The last lines of its log (default 100). |
28
+ | `scalequality service install` | Installs it again, or updates it to the version you run. |
29
+ | `scalequality service start` | Starts it again (the same as `install`), for example after it stopped. |
30
+ | `scalequality service uninstall` | Stops and removes it. The computer stays paired but is not connected until you install it again. |
31
+ | `scalequality logout [--api URL]` | Stops and removes the service, disconnects this computer in ScaleQuality and deletes the local credential. |
32
+
33
+ Every command takes `--api URL` for another ScaleQuality address (for example
34
+ `https://staging.scalequality.io`); each address has its own credential and its
35
+ own service.
36
+
37
+ ### What runs in the background
38
+
39
+ `login` copies this package and its dependencies to
40
+ `~/.scalequality/cli/<version>/` (hard links when the disk allows, so it takes
41
+ no extra space) and registers a per-user service that runs
42
+ `node ~/.scalequality/cli/<version>/node_modules/@scalequality/cli/bin/scalequality.mjs up --service`
43
+ at logon. It never runs from the npx cache, and nothing needs administrator
44
+ rights:
45
+
46
+ | System | Service | Log |
47
+ |--------|---------|-----|
48
+ | macOS | LaunchAgent `~/Library/LaunchAgents/io.scalequality.cli.plist` (RunAtLoad, restarted if it stops unexpectedly), loaded with `launchctl bootstrap gui/<uid>` | `~/Library/Logs/ScaleQuality/scalequality.log` |
49
+ | Linux | systemd user unit `~/.config/systemd/user/scalequality.service` (`Restart=on-failure`) | `~/.local/state/scalequality/logs/scalequality.log` |
50
+ | Windows | Task at logon `ScaleQuality\CLI` (or, where a task cannot be created, a launcher in your Startup folder), started hidden | `%LOCALAPPDATA%\ScaleQuality\Logs\scalequality.log` |
51
+
52
+ On Linux the user service runs while you are logged in; `login` tells you when
53
+ `loginctl enable-linger $USER` is needed to keep it connected after you log out.
54
+ For another address, the names carry its host (for example
55
+ `io.scalequality.cli.staging-scalequality-io-1a2b3c`). The service gets the
56
+ `PATH` you had when you ran `login`, so sessions find git, npm and your
57
+ toolchains; run `scalequality service install` again after changing them.
58
+
59
+ Where a service cannot be installed (a device management profile blocks login
60
+ items, a Linux machine without a systemd user session), `login` says why and
61
+ keeps the computer connected in that terminal instead; keep it open.
62
+
63
+ ### How to disconnect
64
+
65
+ - `scalequality logout`: removes the service and the CLI copy, disconnects the
66
+ computer and deletes the credential.
67
+ - **Disconnect** in the AI Workspace: the service notices at its next poll,
68
+ deletes the credential, removes its own definition and stops.
69
+ - `scalequality service uninstall`: only stops and removes the service (the
70
+ computer stays paired).
26
71
 
27
72
  The credential is stored in `~/.scalequality/credentials.json`, readable only
28
73
  by you (mode 0600), one entry per ScaleQuality address; ScaleQuality keeps only
29
74
  its hash. It opens only this computer's queue: each session gets its own
30
- one-time secret, and no repository token is ever sent to your computer. You can
31
- also disconnect the computer from the AI Workspace.
75
+ one-time secret, and no repository token is ever sent to your computer.
32
76
 
33
- While `up` runs, the AI Workspace can:
77
+ ### What the AI Workspace can do while the computer is connected
34
78
 
35
79
  - start a session in one of your folders (at most 3 at once);
36
80
  - add a folder you pick there (it is checked here: it must exist, be inside
@@ -49,14 +93,14 @@ While `up` runs, the AI Workspace can:
49
93
  without them. Only text is imported; tool results are left out and each tool
50
94
  call becomes a one-line summary.
51
95
 
52
- ### What `up` counts to suggest an import
96
+ ### What the service counts to suggest an import
53
97
 
54
- When `up` starts, and then at most once every 6 hours while it runs, it counts
98
+ When the service starts, and then at most once every 6 hours while it runs, it counts
55
99
  the Claude Code and Codex conversations on this computer, so the AI Workspace
56
100
  can offer to import them. It reads the same files the import list reads
57
101
  (`~/.claude/projects/*/*.jsonl`, or `CLAUDE_CONFIG_DIR`; `~/.codex/sessions/**/rollout-*.jsonl`,
58
102
  or `CODEX_HOME`), at most the 500 most recent, each only up to its first
59
- message, and prints one line such as:
103
+ message, and writes one line to its log, such as:
60
104
 
61
105
  ```
62
106
  Found 28 Claude Code and 11 Codex conversations on this computer. You can import them from the browser.
@@ -71,31 +115,30 @@ A Claude Code conversation continued on the same computer and folder resumes
71
115
  from its own transcript: a copy without secrets is written into the engine's
72
116
  folder (`~/.scalequality/workspace`); the original file is never changed.
73
117
 
74
- Every command a session wants to run is confirmed in the terminal where `up`
75
- runs, one question at a time. Without a terminal (for example, `up` started in
76
- the background) those commands are denied.
77
-
78
- ## One session with a code
118
+ ## One session with a code (older screens)
79
119
 
80
- ```bash
81
- cd path/to/your/repository
82
- npx @scalequality/cli connect <code>
83
- ```
120
+ `scalequality connect <code>` still works for a one-time code from an older AI
121
+ Workspace screen: it runs one session in the current folder (`--dir PATH`,
122
+ `--api URL`, `--verbose`) and ends when you press Ctrl+C twice. It is not listed
123
+ in the help: `login` replaces it.
84
124
 
85
- Get the command, with its code, in the AI Workspace: choose **Use a folder on
86
- your computer**. The code opens only that session; treat it like a password. No
87
- login is needed.
125
+ Requires Node.js 18 or newer and git. Any folder works; the CLI never runs
126
+ `git init`, clones or fetches for you.
88
127
 
89
- Options:
128
+ ## Any folder
90
129
 
91
- | Flag | Default | Meaning |
92
- |------|---------|---------|
93
- | `--dir PATH` | current folder | The repository folder to work in |
94
- | `--api URL` | `https://app.scalequality.io` | ScaleQuality address (for example `https://staging.scalequality.io`) |
95
- | `--verbose` | off | Also print diagnostic logs |
96
-
97
- Requires Node.js 18 or newer and git. The folder must be the root of a git
98
- repository; the CLI never runs `git init`, clones or fetches for you.
130
+ - **A git repository**: its change is compared with `HEAD`.
131
+ - **A folder inside a repository**: the engine works in that folder; the
132
+ repository tracks its change (only that folder's files).
133
+ - **A folder that is not a repository** (for example `~/GIT` with many
134
+ repositories inside): the repositories in it are found (up to 4 levels down,
135
+ skipping `node_modules`, build output and hidden folders) and each one keeps
136
+ its own change against its own `HEAD`. Files outside every repository are
137
+ copied before the engine first changes them, into
138
+ `~/.scalequality/workspace/sessions/` (never into your folder), so you can
139
+ review, discard or rewind those changes too. Copies of sessions unused for 30
140
+ days are removed. Changes made by shell commands to files outside a
141
+ repository are not tracked.
99
142
 
100
143
  ## What runs where
101
144
 
@@ -103,10 +146,11 @@ On your machine:
103
146
 
104
147
  - the coding engine (Claude Agent SDK), reading and editing files **only inside
105
148
  the folder**;
106
- - the commands it wants to run, **each one after you allow it** in the
107
- terminal;
108
- - the diff of your folder against `HEAD` at connect time, which is what the
109
- browser shows and what a pull request carries.
149
+ - the commands it wants to run, **each one after you approve it in the
150
+ browser** (or after an "always allow" rule you created covers it);
151
+ - the diff of each repository against its `HEAD` at connect time (and of the
152
+ other files against their copies), which is what the browser shows and what
153
+ a pull request carries.
110
154
 
111
155
  In ScaleQuality:
112
156
 
@@ -127,32 +171,39 @@ read credential stores such as `~/.ssh`, `~/.aws`, `~/.netrc`, your home
127
171
  only a fixed list of variables (PATH, HOME, locale, toolchain locations, proxies
128
172
  and CA settings) reaches the engine and its commands.
129
173
 
130
- ## Permission prompts
131
-
132
- Before any command runs you see it in the terminal:
133
-
134
- ```
135
- The workspace wants to run a command in /home/you/repo
136
- model's description: Run the tests
137
- $ npm test
138
- y run once a always allow this exact command in this folder n deny
139
- >
140
- ```
141
-
142
- - `y` runs it once.
143
- - `a` allows that exact command, in this folder, until you disconnect.
144
- - `n` denies it; you can type a reason, which the model receives.
145
-
146
- Pressing Enter alone never approves. File edits are not asked: they are shown
147
- in the browser as they happen, and each file can be discarded there.
148
-
149
- ## Stopping
150
-
151
- - `connect`: `Ctrl+C` once stops the current request (a pending command is
152
- denied); `Ctrl+C` again disconnects, after saving the session's checkpoint.
153
- - `up`: `Ctrl+C` saves every running session and disconnects the computer.
154
- - Your folder keeps every change. Closing the session in the browser also
155
- ends it here.
174
+ ## Approving commands
175
+
176
+ Before any command runs on your computer, the AI Workspace shows an approval
177
+ card in the browser with the command, the folder, why it asks and a suggested
178
+ rule:
179
+
180
+ - **Run once** runs it this time.
181
+ - **Always allow** stores a rule for this computer and folder, either the exact
182
+ command or a prefix such as `npm test*`, and runs it. A prefix never covers
183
+ anything chained, piped, substituted or redirected after it (`npm test && …`
184
+ is asked again), and never a shell, `sudo`, `npx` or inline code.
185
+ - **Deny** tells the model it did not run.
186
+
187
+ Publishing (`git push`, remotes, `gh`, `npm publish`, image pushes), remote
188
+ shells and copies, cloud and infrastructure CLIs and credential reads are never
189
+ remembered: each run is asked again, and what the workspace policy denies is
190
+ never offered at all. Rules are listed and deleted in the AI Workspace; a
191
+ deleted rule stops applying in running sessions right away.
192
+
193
+ A card nobody answers in 10 minutes is withdrawn and the command does not run;
194
+ stopping the request in the browser withdraws it too. File edits are not asked:
195
+ they show in the browser as they happen, and each file can be discarded there.
196
+
197
+ ## Troubleshooting
198
+
199
+ - `scalequality service status` and `scalequality service logs`.
200
+ - `scalequality up --verbose` runs the same loop in the terminal, with
201
+ diagnostic lines. It does not start while the service runs; stop the service
202
+ first (`scalequality service uninstall`, then `scalequality service install`
203
+ afterwards).
204
+ - Ctrl+C in `up`, or stopping the service, saves every running session first.
205
+ Your folder keeps every change; closing the session in the browser also ends
206
+ it on the computer.
156
207
 
157
208
  ## For maintainers
158
209
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // ScaleQuality CLI. The engine of every command (connect, login, up, add,
3
- // logout) is built in the ScaleQuality ai-governance service
2
+ // ScaleQuality CLI. The engine of every command (login, add, service, logout,
3
+ // and the unlisted up and connect) is built in the ScaleQuality ai-governance service
4
4
  // (src/main/workspace-connect.ts) and copied into dist/connect.cjs by `npm run sync`.
5
5
  import { createRequire } from 'node:module'
6
6
  import { existsSync, readFileSync } from 'node:fs'
@@ -15,23 +15,25 @@ const HELP = `ScaleQuality CLI ${pkg.version}
15
15
  Usage:
16
16
  scalequality login [--api URL] [--name NAME]
17
17
  Connect this computer to your ScaleQuality account (you confirm a code in
18
- ScaleQuality), then keep it connected.
19
- scalequality up [--api URL]
20
- Keep this computer connected: the AI Workspace can run sessions in the
21
- folders you added and import your Claude Code and Codex conversations.
18
+ ScaleQuality). It then installs a background service that keeps this
19
+ computer connected, also after a restart.
22
20
  scalequality add [PATH]
23
21
  Add a folder (default: the current one) for the AI Workspace to use.
22
+ scalequality service <install|uninstall|status|logs>
23
+ The background service: reinstall it, remove it, see whether it runs,
24
+ read its log.
24
25
  scalequality logout [--api URL]
25
- Disconnect this computer and delete its local credential.
26
- scalequality connect <code> [--api URL] [--dir PATH]
27
- Work on this repository folder for one session, with a code from the AI
28
- Workspace ("Use a folder on your computer"). No login needed.
26
+ Stop and remove the background service, disconnect this computer and
27
+ delete its local credential.
29
28
  scalequality --help
30
29
  scalequality --version
31
30
 
32
- Run "scalequality <command> --help" for the options of a command.`
31
+ Commands the AI Workspace wants to run on this computer are approved in the
32
+ browser. Run "scalequality <command> --help" for the options of a command.`
33
33
 
34
- const COMMANDS = new Set(['connect', 'login', 'up', 'add', 'logout'])
34
+ // `up` (the loop the service runs, for troubleshooting) and `connect <code>`
35
+ // (one session by one-time code, kept for older screens) work but are not listed.
36
+ const COMMANDS = new Set(['connect', 'login', 'up', 'add', 'logout', 'service'])
35
37
  const [command] = process.argv.slice(2)
36
38
 
37
39
  if (!command || command === '--help' || command === '-h' || command === 'help') {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "sdkVersion": "0.3.281",
3
- "sha256": "08314a95264b9909caa6a812f0bba154465f35fb82a3ffb541fdaeb5c3b95ee5",
4
- "sourceCommit": "982edf3dc5d3c2e1473b4f13d0695caaed4eeaed"
3
+ "sha256": "0ff62b12b532e9895f9d7a755279f885c6523b4ecfcae73d5013f5fc3a94d2a1",
4
+ "sourceCommit": "50f66eee84e1a3b82aeb80716af93bf1b3102b38"
5
5
  }