@quatronic/qore 0.4.0-test.1f7e2c4 → 0.4.0-test.21ae023

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 +34 -759
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -33,764 +33,30 @@ qore traces --env stag --slower-than 1s # slow requests
33
33
  qore logs --env stag --level error # error logs
34
34
  ```
35
35
 
36
- ### Portals
37
-
38
- `qore` talks to `prod` by default. Pass `--portal staging` or
39
- `--portal testing` to use those portals, or `--portal https://your-portal.example` for anything
40
- else (only accepted on `qore login`, which then pins the identity provider
41
- it reports).
42
-
43
- ```sh
44
- qore login --portal staging
45
- ```
46
-
47
- ### Repository context
48
-
49
- Commands like `qore status` need to know which module you mean. By default
50
- that comes from the git remote of the repository you're standing in:
51
- `qore` reads `git remote -v`, prefers `origin`, falls back to `upstream`,
52
- then the rest in git order, and resolves the remote's URL to a module on
53
- the portal. Working from a personal fork whose `origin` the portal doesn't
54
- know? As long as an `upstream` remote points at the real repository, that one
55
- resolves — the context line then says `(upstream)`.
56
-
57
- Outside a repository, with a projects folder set (see `qore init`), the
58
- order is: the project you are standing in; else `[project]` /
59
- `--project <ref>` (`app`, `app/module`, `tenant/app` or `tenant/app/module`,
60
- matched against your local checkouts); else an interactive pick. `qore dev`
61
- and `qore db erd` take the reference as an argument (`qore dev <app>`); `qore
62
- dev`, `qore db erd`, `qore env pull`, `qore run` and `qore status` take
63
- `--project`. `qore run --project`
64
- only chooses which module's secrets are used; the command still runs in the
65
- current directory. `qore env pull --project` writes into the located module,
66
- and a relative `--target` then resolves against that project directory, not
67
- the directory you ran it from.
68
-
69
- A repository that is no module counts as outside one: standing in some other
70
- codebase, `qore dev` asks the portal about its remotes and, when they match no
71
- module (or it has no remote Qore can match), offers your projects just the
72
- same. A repository inside a known project is never asked about, and a portal
73
- that cannot answer keeps today's error.
74
-
75
- Logged out with a projects folder set, the local lookup still runs first: a
76
- folder that holds no projects gives `QORE_PROJECT_NOT_FOUND`; otherwise the
77
- project is located exactly as when logged in (a match, a picker, or
78
- `QORE_CONTEXT_REQUIRED` without a terminal), and the login error comes from
79
- the portal lookup that follows. Only without a projects folder does a logged-out
80
- command outside a project go straight to the login error.
81
-
82
- Pass `--module <slug|id>` to pick a module explicitly (it keeps its meaning and,
83
- like `--app`, still uses the portal lookup when you are not in a project); the flag always wins
84
- over the git remote. Inside a repository, `qore` still looks up the remote's
85
- own module (from the cache, or with one extra request) only so the context
86
- line can tell you when the flag overrides it. If a module is linked to more
87
- than one app you can read, add `--app <slug|id>` to disambiguate.
88
-
89
- Every context-aware command prints a context line to stderr (never stdout,
90
- so it's safe to pipe `--json` output):
91
-
92
- ```
93
- → <Tenant> / <App> / <module> (<source>)
94
- ```
95
-
96
- `<source>` is the remote name that resolved it (`origin`, `upstream`, …),
97
- or `--module` when you passed the flag. If `--module` resolves to a
98
- different module than the repository's own remote would have, it reads
99
- `--module, overrides <remote>`. With `--json`, this same information is
100
- under `data.context` instead, and nothing about it goes to stderr.
101
-
102
- #### `qore status`
103
-
104
- Shows deployment and health per environment for the current module:
105
-
106
- ```sh
107
- qore status
108
- ```
109
-
110
- | Column | Meaning |
111
- |--------|---------|
112
- | ENV | Environment name |
113
- | DEPLOY | Deployment status, or `paused` |
114
- | COMMIT | Deployed commit SHA |
115
- | DEPLOYED | How long ago that commit was deployed |
116
- | APP HEALTH | The app's public health check (not the module's) |
117
-
118
- #### `qore env pull`
119
-
120
- Writes this module's local secrets into an env file in the current
121
- repository:
122
-
123
- ```sh
124
- qore env pull
125
- ```
126
-
127
- - The target file defaults to the module type's own convention (e.g.
128
- `.env.local`), or `.qore.json`'s `envFile`, or `--target <path>` — always
129
- required to stay inside the repository. `envFile` resolves against the
130
- repository root; `--target` against the current directory, or with
131
- `--project` against the located project directory.
132
- - If the file doesn't exist yet, it's seeded from `.env.example` when one is
133
- present.
134
- - Existing values you've hand-edited are kept by default. A key the portal
135
- manages (e.g. `CONN_*`, `DATABASE_URL`) is always taken from the portal.
136
- For any other key that differs between your file and the portal, pass
137
- `--use-portal` to take the portal's value, or answer the interactive
138
- prompt per key (which shows only the **length** of each value, never its
139
- content — see "Values are never printed" below).
140
- - The file is written with mode `0600` via a temp file in the same
141
- directory, then renamed over the target — it's never truncated in place.
142
- (On Windows, POSIX file modes don't apply — setting `0600` there is a
143
- no-op; there's no equivalent file-permission hardening on that platform.)
144
- - When the repository has a `mobile/` directory (an Expo app), the pull also
145
- writes `mobile/.env.local` with the app's **public** staging config:
146
- `EXPO_PUBLIC_SERVER_URL`, `EXPO_PUBLIC_SENTRY_DSN` and
147
- `EXPO_PUBLIC_QORE_ENV=staging`. qore owns those three keys and overwrites
148
- them; every other line in the file is kept. A value the portal does not have
149
- yet is left out rather than written empty, because an empty `EXPO_PUBLIC_*`
150
- value would override the one baked into `app.config.ts`. Until staging is
151
- deployed there is no server URL; the pull says so, and running it again
152
- after the deploy fills it in. A portal too old to serve this config is
153
- skipped with a note, and a failed fetch warns without failing the pull.
154
- `--json` reports it as
155
- `mobile: { target, environment, serverUrl, sentryDsn: <set?>, written }`
156
- (`null` without a `mobile/` directory). `qore dev` does not write this file.
157
-
158
- **First use of a repository** requires confirmation — see "Trust on first
159
- use" below. **Values are never printed**: not in `qore env pull`'s output,
160
- not in the interactive conflict prompt, not in `--verbose` logs, and not in
161
- the portal's own audit trail, which records key names only (see
162
- `app.local_env.fetched`).
163
-
164
- #### `qore roles`
165
-
166
- Run in the app's frontend module. `qore roles sync` does the announcing alone:
167
- local learns every role in `permissions.ts` and your own roles stay as they are.
168
- `qore roles use inspector` reads the roles in
169
- `src/lib/permissions.ts`, tells the portal they exist on `local` (only there —
170
- staging and production learn roles from the code that environment deploys:
171
- `main` for staging, the `production` branch for production), and makes exactly
172
- the named roles yours on `local`. Sign out and back in to the local app
173
- afterwards. `qore roles list` shows the roles in your code, the ones `local`
174
- knows, and yours. Needs write on the module, like `qore env pull`. An announced
175
- role stays on `local`; nothing removes it automatically.
176
-
177
- #### `qore run`
178
-
179
- Runs a command with this module's local secrets injected into its
180
- environment, without ever writing them to disk:
181
-
182
- ```sh
183
- qore run -- node server.js
184
- qore run -- pnpm dev
185
- ```
186
-
187
- - Secrets are fetched fresh on every `run` — never cached — merged with
188
- your current environment, and passed only to the child process.
189
- - The command runs without a shell (`shell: false`); everything after `--`
190
- is passed to it verbatim, including its own flags (a `--json` or
191
- `--no-input` after `--` is the child's, never `qore`'s own). On Windows,
192
- this is true in spirit but not literally for `.cmd` shims (e.g. `pnpm`,
193
- `npm`, or anything installed as a `.cmd` wrapper): `cross-spawn` runs
194
- those through `cmd.exe /d /s /c` under the hood, with its own escaping.
195
- Pressing Ctrl+C there can also surface cmd's own
196
- `Terminate batch job (Y/N)?` prompt.
197
- - The child's exit code, or the signal it was killed with (e.g. Ctrl+C →
198
- 128+signal), becomes `qore run`'s own exit code.
199
- - **Secrets live in the child's environment**, which is inherited by any
200
- process the child spawns (its grandchildren) and is readable by other
201
- processes running as the same user (`/proc/<pid>/environ`, `ps eww`) —
202
- no worse than a `.env.local` on disk, but worth knowing before running an
203
- untrusted command this way.
204
-
205
- #### `qore dev`
206
-
207
- Starts this module's dev server, from a trusted repository:
208
-
209
- ```sh
210
- qore dev
211
- ```
212
-
213
- - **Context + trust**, like `qore run`/`qore env pull` — the same
214
- `--module`/`--app` resolution, the same trust-on-first-use prompt
215
- (`--yes` to skip it non-interactively).
216
- - **Install**, if needed: the package manager comes from package.json's
217
- `"packageManager": "<pnpm|npm|yarn>@<version>"` field, or (absent that)
218
- whichever lockfile is present. `node_modules` missing, or older than the
219
- lockfile, triggers an install; `--no-install` skips this step entirely.
220
- - **Env merge**: this module's local secrets are pulled and merged into its
221
- env file on disk (same target and conflict rules as `qore env pull`) —
222
- unlike `qore run`, which only injects them into the child's environment.
223
- - **`db:up`**, if the repository declares one: run automatically (unless
224
- `--no-services`), then `qore dev` waits for `DB_PORT` to accept
225
- connections before continuing — bounded by `--wait-timeout <s>` (default
226
- `60`), which also bounds a workspace's provider-port wait (below). A
227
- service that needs Docker and finds it missing or not running fails
228
- fast, naming which.
229
- - **Port check**: `PORT` from the merged env must be free; qore never
230
- picks, shifts or suggests a port (see "Ports never move" below).
231
- - **Runs `dev` exactly as `qore run` would** — same package manager, same
232
- child-process semantics, same exit-code passthrough. The script name is
233
- `"dev"` by default, or `dev.script` in `.qore.json` (below).
234
- - `qore dev` in a module repository has no `--json`: the dev server's own
235
- output passes straight through untouched.
236
-
237
- A legacy backend `dev` script (from older templates, which need a
238
- build and a `.env` first) fails fast with `QORE_DEV_UNSUPPORTED`, naming
239
- the old script and the fix — the same code a repository with no `dev`
240
- script at all, or an unsupported package manager, gets.
241
-
242
- **Offline start**: if the portal is unreachable, `qore dev`
243
- still starts — but only when the repository is already trusted **and** its
244
- env file already exists on disk (from a previous `qore dev`/`env pull`).
245
- It starts from that file as last written, with a warning that values may
246
- be stale. This is the one place `qore` starts without confirming secrets
247
- are current; every other command still requires the portal. An untrusted
248
- repository, or one with no env file yet, surfaces the original
249
- "portal unreachable" error instead.
250
-
251
- **In a workspace root** (see "Workspaces" below), `qore dev` starts every
252
- present module of the app, in dependency order, from one process — unless
253
- `--module <slug>` is passed, which takes the module flow above instead
254
- (run it from inside that module's own repository, not the workspace root
255
- itself, or it fails with "Not inside a module repository"). `--app` is
256
- refused in a workspace root: an app is already implied by
257
- `qore.workspace.json`.
258
-
259
- **Shared checkouts.** In the shared layout the modules start from
260
- `modules/<slug>`. A module that another app's `qore dev` already runs from
261
- the same checkout, with its port listening, is not started a second time:
262
-
263
- - a **backend** is reused (`<module> running in qore dev for <app> (pid
264
- <pid>)`) and listed with that app's URL in the summary. This needs the
265
- portal capability `module.local-env-app-neutral`; without it the module is
266
- listed under `! Not running:` as `running in qore dev for <app>`;
267
- - a **frontend** is never reused, because its environment is per app: it is
268
- listed as not running the same way.
269
-
270
- A reused module is only watched. When its port is free for two checks in a
271
- row, qore prints `<module> stopped with qore dev for <app> — restart qore
272
- dev to run it here` (a `reused-stopped` event with `--json`) and does not
273
- restart it. If every module is reused, nothing starts: `qore dev` just
274
- watches, exits `0` once they have all stopped, and `130` (or 128 + signal)
275
- on Ctrl+C or a signal.
276
-
277
- **Ports never move.** If `PORT` (or, for a workspace, a `db:up`'s
278
- `DB_PORT`) is already taken, `qore dev` fails with `QORE_PORT_IN_USE`
279
- naming the port and, when it can determine one, the process already
280
- holding it — it never picks a different port, shifts one, or suggests an
281
- alternative. Ports are part of the local contract between modules
282
- (`CONN_*_URL` values point at fixed ports), so moving one silently would
283
- break every other module that depends on it.
284
-
285
- #### What qore diagnoses
286
-
287
- Beyond the checks above, `qore dev` recognises common failure shapes and adds
288
- a hint rather than leaving a bare error (spec §14.2):
289
-
290
- - **Docker not running**: in a TTY, waits up to 120 s for it (`Ctrl+C` to
291
- stop) instead of failing immediately; non-interactive or `--json` fails at
292
- once.
293
- - **A leftover `qore dev` holds the port**: in a TTY, offers to stop it
294
- (`Stop the previous qore dev (pid N)?`); outside a TTY it's just
295
- `QORE_PORT_IN_USE`.
296
- - **Another checkout of the same module holds `DB_PORT`** (a worktree or a
297
- second clone, whose compose project is named after its own folder): the
298
- error names that checkout and suggests stopping its database there or
299
- running `qore dev` from it. The two checkouts are matched on the managed
300
- keys `QORE_MODULE` and `QORE_CUSTOMER_ID` in their env files, so this needs
301
- no portal call. `qore doctor` reports the same.
302
- - **The dev server exits within seconds of starting**: its tail output is
303
- classified into a hint — a missing dependency (`Cannot find module`), an
304
- invalid/missing env var (a `ZodError`'s keys, never values), a port taken
305
- after the free-port check (`EADDRINUSE`), or a Linux file-watcher limit —
306
- printed after the exit, never rewriting the server's own output. An
307
- unrecognised failure falls back to the tool's last lines plus the command
308
- that ran, never a bare "failed".
309
- - **The portal is unreachable behind a corporate proxy**: the connect error
310
- names `HTTPS_PROXY`/`NODE_EXTRA_CA_CERTS` as things to check.
311
-
312
- `QORE_DEV_EXITED` is not a thrown code: when none of this applies, `qore dev`
313
- just passes the child process's own exit code through.
314
-
315
- #### `qore doctor`
316
-
317
- Runs the same checks `qore` makes before other commands, on demand, without
318
- doing anything else — the first thing to run when something's wrong, and
319
- `--json` makes it attachable to a support ticket:
320
-
321
- ```sh
322
- qore doctor
323
- ```
324
-
325
- - Prints one line per check: `✓` ok, `!` warning, `✗` failing.
326
- - Checks qore's own version, Node, git, GitHub SSH, Docker + compose, every
327
- logged-in portal's session, clock skew, and — inside a workspace or module
328
- repository — each module's port, access and database.
329
- - **Never fetches the local env and never starts anything.** Ports are read
330
- from the env file already on disk; access comes from the ordinary
331
- `GET /api/cli/v1/me` and `.../modules` routes.
332
- - Exit code `0` only when every check passes; a `!` warning never fails it,
333
- only a `✗` does.
334
- - No login profile at all is a warning, not a failure.
335
- - `--json` shape: success is `{"ok":true,"data":{"results":[...],"context":{...}}}`;
336
- on failure it's `{"ok":false,"error":{...,"details":{"results":[...],"context":{...}}}}`
337
- — the full report is always in `details`, even though the top-level error
338
- names only the first failing check. A check that throws still lets the
339
- rest run; it just becomes a `fail` with that error attached.
340
-
341
- #### `qore db erd`
342
-
343
- Opens this module's data model — tables, columns, keys and the relations
344
- between them — in your browser, read live from the module's **local**
345
- Postgres:
346
-
347
- ```sh
348
- qore db erd
349
- qore db erd shop # from anywhere (see qore init); no ref → a pick
350
- qore db erd --no-open # just print the URL
351
- qore db erd --port 4100
352
- qore db erd --json > model.json
353
- ```
354
-
355
- - **Context + trust**, like `qore run`: the same `--module`/`--app`
356
- resolution and the same trust-on-first-use prompt (`--yes` to skip it).
357
- - **In a workspace root** it shows the whole app; **in a module checkout of
358
- a workspace** it asks whether you want the whole app or only that module
359
- (without a terminal, or with `--module`, it stays the module).
360
- - **Where the database comes from:** `DATABASE_URL` in the module's env file
361
- (`.env.local` for a frontend module, otherwise `.env`; or the `envFile`
362
- named in `.qore.json`); when that file is missing or has no (or a blank)
363
- `DATABASE_URL`, it is fetched from the portal for this run only — never
364
- written. A module with no `DATABASE_URL` in either has no database to show.
365
- The URL is whatever the env file holds, or what the portal's local-env
366
- endpoint returns (the local development database).
367
- - **Read-only.** The session is opened with `default_transaction_read_only`
368
- on; the viewer has no write route; only structure is read — never rows.
369
- - **Local only.** The server listens on `127.0.0.1` on a free port (or
370
- `--port`) and refuses requests whose `Host` is not `127.0.0.1:<port>` or
371
- `localhost:<port>`. Stop it with Ctrl+C (exit code 130).
372
- - **Fresh on every load.** Each page load opens a new connection and
373
- introspects again, so after a migration — or a database reset or restart —
374
- a refresh is enough.
375
- - **The viewer** is qore's own, bundled with the CLI and fully offline.
376
- Tables are listed in a palette on the left: drag one onto the canvas, or
377
- click it, to place it, and use `+ N related` to pull in the tables it
378
- references or is referenced by. Switch between Keys only and All columns,
379
- Tidy up to re-layout, Fit to frame everything. `/` searches, `Delete`
380
- removes the selected table, `R` adds its related tables, `Esc` deselects.
381
- The URL hash is the canvas: a link only opens again on the same port, so
382
- share it with a fixed `--port`, or copy just the `#…` part. The reload
383
- button in the top strip re-reads the database without losing the canvas.
384
- Light or dark follows the system, with a toggle.
385
- - **A whole app.** In an app's workspace root (the folder with
386
- `qore.workspace.json`, no `--module`) the canvas shows every module's
387
- database at once: one lane per database (modules that share a database
388
- share a lane), ordered so that what others build on sits left. Foreign keys
389
- stay inside a lane; a reference that crosses databases cannot be a foreign
390
- key, so it is declared as a comment on the column that holds the id:
391
- `COMMENT ON COLUMN app.favourite_spots.spot_id IS '-> api:public.spots.id'`
392
- (the `module:` part is optional, free text may follow). The viewer draws it
393
- as a dashed cable and names the owning lane in the detail pane. A module
394
- without a database has no lane; a database that is down leaves the others
395
- on the canvas, with the error in its lane head.
396
- - `--json` prints `{"ok":true,"data":{"context","source","model"}}`, where
397
- `data.model` is the database model the viewer loads and `data.source` is
398
- `env-file` or `portal`, and starts nothing;
399
- combining it with `--port` or `--no-open` is a usage error (exit 2). In a
400
- workspace root it is `{"ok":true,"data":{"context","databases","model"}}`:
401
- `context.module` is `null`, `context.modules` lists every module with its
402
- lane, `databases` holds one entry per lane with its source, and the model
403
- carries `database` on every table plus `databases` and `refs`. It needs every
404
- database to be reachable.
405
- - Not reachable: `QORE_SERVICE_UNHEALTHY` naming the port and the fix
406
- (`qore dev` / `pnpm db:up`); a taken (or reserved) `--port`: `QORE_PORT_IN_USE`.
407
-
408
- #### `.qore.json`
409
-
410
- An optional file at the repository root that configures `qore env pull`
411
- and `qore dev` for that repository. Schema:
412
- [`schema/qore.schema.json`](./schema/qore.schema.json).
413
-
414
- ```json
415
- {
416
- "$schema": "https://unpkg.com/@quatronic/qore/schema/qore.schema.json",
417
- "envFile": ".env.local",
418
- "localSecrets": ["MY_LOCAL_OVERRIDE"],
419
- "dev": {
420
- "install": true,
421
- "services": ["db:up"],
422
- "script": "dev"
423
- }
424
- }
425
- ```
426
-
427
- - **`dev.install`** — run the package manager's install when needed
428
- (default `true`).
429
- - **`dev.services`** — package.json scripts to run before the dev server,
430
- in order (default: `["db:up"]` if that script exists, else none — each
431
- name must be a real script in package.json).
432
- - **`dev.script`** — the package.json script `qore dev` runs (default
433
- `"dev"`).
434
-
435
- It never holds a portal URL, tenant, app or module id — those are always
436
- resolved from the git remote or `--module`/`--app`, never committed.
437
-
438
- #### Trust on first use
439
-
440
- The first time you run `qore env pull` or `qore run` against a given
441
- repository (for a given module), `qore` asks you to confirm before pulling
442
- secrets into it — trust-on-first-use, recorded locally, not a portal-side
443
- grant. Pass `--yes` to trust non-interactively (CI, scripts) instead of
444
- being prompted.
445
-
446
- #### Resolution cache
447
-
448
- Resolved `git remote` → module lookups are cached at
449
- `<config dir>/qore/cache/repos.json` so repeat commands in the same
450
- repository skip an extra request. It's pure cache — deleting the file is
451
- always harmless, at worst the next command re-resolves.
452
-
453
- If a repository resolves to no module on any portal you're logged in to,
454
- the error lists the portals it tried and, when a staging repository looks
455
- likely, suggests `qore login --portal staging`.
456
-
457
- ### Projects folder & `qore init`
458
-
459
- `qore init` is the guided setup. It runs four steps and reports each as
460
- `done`, `already` or `skipped`, so running it again is safe:
461
-
462
- 1. **Projects folder**: where your apps live (default `~/qore`; `--root <path>`
463
- sets it without asking). Nothing existing is moved.
464
- 2. **Login**: skipped when you are already logged in, and with `--no-input`.
465
- 3. **Tenant**: `already` when a tenant is active (`done` right after the login
466
- step logged you in). Otherwise skipped with
467
- `--no-input` or when you are not logged in (run `qore tenant use <slug>`
468
- later), skipped with no tenants, selected without a prompt when you have
469
- one, a picker when you have several.
470
- 4. **First app**: `--clone <app>` (with `--tenant <slug>` to disambiguate)
471
- clones it; interactively it asks.
472
-
473
- With `--json`, stdout is one document: `{"projectsRoot": "<path>|null",
474
- "steps": {"root"|"login"|"tenant"|"clone": {"status", "detail?"}}}`.
475
-
476
- Apps clone into `<root>/<tenant>/apps/<app>/` and their modules into
477
- `<root>/<tenant>/modules/<module>`, shared by every app of the tenant that
478
- uses them (see "Shared module checkouts" below). A checkout outside the
479
- folder registers itself the first time you use it (`qore clone <app> <dir>`,
480
- `qore dev`, ...); a registered checkout that was deleted is dropped. With a
481
- projects folder set, `qore dev`, `qore env pull`, `qore run` and `qore status`
482
- work from any directory (see Repository context).
483
-
484
- ```sh
485
- qore config root # show the folder and how many projects it holds
486
- qore config root <path> # set it
487
- qore config root --unset # clear it; known projects stay findable
488
- ```
489
-
490
- `qore doctor` checks that the folder exists and is writable.
491
-
492
- ### Workspaces
493
-
494
- `qore clone` sets up a local directory for an app and its modules, each in
495
- its own repository; `qore sync` keeps them in step with the app afterwards.
496
- With a projects folder set, modules are shared between apps (next section);
497
- without one, or with an explicit `qore clone <app> <dir>`, the directory
498
- holds the module repositories itself and the rest of this section applies
499
- as written.
500
-
501
- ```sh
502
- qore clone <app> # clones every module of <app> into ./<app-slug>
503
- qore clone <app> <dir> # ...into <dir> instead
504
- cd <app-slug>
505
- qore status # app-level table, one row per module/environment
506
- cd <module>
507
- qore env pull # no trust prompt — a clone made by qore is already trusted
508
- cd ..
509
- qore sync # clone any module that's new, fetch the rest
510
- qore sync --pull # ...and fast-forward every clean repository with an upstream
511
- qore code [app] [-- <claude args>] # start Claude Code in the app's frontend, every module added (--add-dir)
512
- ```
513
-
514
- - **Where it clones.** Without `[dir]` and with a projects folder set, `qore
515
- clone` puts the app folder at `<root>/<tenant>/apps/<app>` and its modules
516
- in `<root>/<tenant>/modules/`. Without a projects folder it behaves as
517
- described above and prints a tip to run `qore init`; with an explicit `[dir]`
518
- it clones into `<dir>` as before, and with a projects folder set the tip
519
- says that `qore init` shares modules between apps.
520
- - **`--protocol https|ssh`** picks the clone URL (default `https`). `ssh`
521
- rewrites `https://github.com/o/r` to `git@github.com:o/r.git`; your own
522
- git `insteadOf` config still applies on top of either.
523
- - **`--tenant <slug>`** on `qore clone` disambiguates an app slug that
524
- exists in more than one tenant you have access to.
525
- - **The workspace file** is `qore.workspace.json` at the directory `qore
526
- clone` created, holding `{"schemaVersion": 1, "portal": "<apiOrigin>",
527
- "appId": "<uuid>"}`. It never lists modules — those always come from the
528
- portal, so a module added to the app later shows up on the next `qore
529
- sync` with no local change needed. `qore` finds it by walking up from the
530
- current directory (stopping at your home directory). The module commands
531
- (`env pull`, `run`, …), `qore status` and `qore sync` pick up its portal
532
- (and, for a module shared by several apps, its app) automatically when run
533
- from inside the workspace — including from a module's own repository;
534
- `qore clone`, `qore whoami` and `qore tenant` do not read it. An explicit
535
- `--portal` flag always wins over it. `qore status` shows the app-level
536
- table only when run in the directory that holds `qore.workspace.json`
537
- itself (not inside one of its module repositories, which shows that
538
- module).
539
- - **Nothing is ever deleted, moved or overwritten** (in this layout; the
540
- shared layout moves and removes only with your consent, below). A present module
541
- directory is left exactly as it is; `sync` only fetches into it, and
542
- only fast-forwards with `--pull`, and only when the tree is clean and has
543
- an upstream — a dirty tree, one with no upstream, or one that would need
544
- a merge is reported, never touched. `sync` runs a plain `git fetch` (no
545
- `--prune`). A module's directory whose `origin` doesn't point at that
546
- module's repository is reported as re-pointed, and one that isn't a git
547
- repository at all is reported too — neither is repaired; move it aside
548
- and run `qore sync` again. A repository directory in the workspace that
549
- isn't one of the app's modules (typically a module that left the app) is
550
- reported as removed, and left on disk.
551
- - **A target directory that already holds something else** — someone
552
- else's files, or another app's or portal's workspace — makes `qore
553
- clone` fail with `QORE_WORKSPACE_CONFLICT` before writing anything,
554
- including `qore.workspace.json`. Pick a different directory
555
- (`qore clone <app> <dir>`).
556
- - **Per-module clone failures** are diagnosed individually and don't stop
557
- the rest of the run:
558
- - `QORE_GITHUB_NOT_LINKED` — your GitHub account isn't linked in Qore;
559
- link it at the account page, then `qore sync`.
560
- - `QORE_REPO_NO_ACCESS` — you have no seat on the repository; the error
561
- names the dev team(s) that build the module and their maintainers to ask.
562
- - `QORE_REPO_ACCESS_PENDING` — access was granted recently, or your
563
- GitHub organisation invitation isn't accepted yet; the error links the
564
- invitation page.
565
- - `QORE_GIT_AUTH` — git itself couldn't authenticate (no SSH key,
566
- GitHub's SSH host key not accepted yet, no `gh auth login`, or SSO
567
- authorisation needed for the org); the error names the fix.
568
-
569
- `clone`/`sync` exits `0` when at least one module cloned or was already
570
- present and every failure is one of the first three above
571
- (`QORE_GITHUB_NOT_LINKED`, `QORE_REPO_NO_ACCESS`,
572
- `QORE_REPO_ACCESS_PENDING`) — so a developer missing a seat on one module
573
- of a multi-module app still gets a usable workspace for the rest.
574
- `QORE_GIT_AUTH` is not an access failure in this sense: it fails the run
575
- (exit `5`). Any other failure, or a run where nothing succeeded at all,
576
- exits with that failure's own code. With `--json`, once the per-module
577
- loop has run its results are under `data.results` (or
578
- `error.details.results` on failure); an error before that (not logged in,
579
- no workspace, a conflicting target directory) is an ordinary error
580
- document without results.
581
-
582
- #### `qore dev` (workspace root)
583
-
584
- Run from the directory holding `qore.workspace.json` (not inside one of its
585
- module repositories — that takes the single-module flow above), starts
586
- every present module of the app as one supervised run:
587
-
588
- ```sh
589
- qore dev # every present, writable module, in dependency order
590
- qore dev --only api,web # just these (comma-separated)
591
- qore dev --skip docs # all but these
592
- qore dev --kill-others # the first module to exit stops the rest
593
- ```
594
-
595
- - Only **present** modules run (cloned into the workspace); one not cloned
596
- yet is skipped with "not cloned — run `qore sync`". A module without
597
- write access is skipped too (local secrets need write) naming who to
598
- ask; its dependents still start, with a warning that the dependency
599
- they point at (`CONN_*_URL`) won't be running — qore never falls back to
600
- staging. `--only`/`--skip` select by slug; a skip is never fatal by
601
- itself, only when it leaves nothing to start.
602
- - **Every module's install, package-manager check and port check run
603
- first, for every module, before anything starts.** Problems are
604
- collected per module and all reported together — one module's install
605
- failure never hides another's, and nothing starts if any of them failed.
606
- Installs run with bounded parallelism (4 at a time).
607
- - **Start order follows `dependsOn`**: providers before their consumers.
608
- A consumer waits (up to `--wait-timeout`, default `60` s) for each
609
- dependency's `PORT` to accept connections before its own `dev` script
610
- runs; a dependency that doesn't come up in time (or that exited) logs a
611
- warning and the consumer starts anyway. Modules that depend on each
612
- other (a cycle) start together, without waiting, and the cycle is
613
- reported once. A backend under `node --watch` that crashes waits for a
614
- file change instead of exiting, so no exit line appears and its
615
- consumers wait up to `--wait-timeout`.
616
- - **`--kill-others`**: the first module to exit on its own (success or
617
- failure) stops every other module; the others' own exit is then reported
618
- quietly, not as a failure. Without it, `qore dev` keeps every surviving
619
- module running until you stop it yourself.
620
- - **Ctrl+C / SIGTERM/SIGHUP** stops every running module in reverse start
621
- order, `SIGKILL` after a 10 s grace if one doesn't exit on its own; a
622
- second Ctrl+C escalates to `SIGKILL` immediately. A `db:up` service a
623
- module started is left running — `qore dev` only stops the dev servers
624
- it launched directly. During the checks, Ctrl+C / SIGTERM / SIGHUP
625
- stops a running install or `db:up` before `qore dev` exits.
626
- - **Offline start** (same rule as module-level): only when every
627
- module that would start is already trusted and has an env file on disk;
628
- one exception fails the whole run with the original error.
629
-
630
- **Feedback.** Before anything starts, a module not yet cloned is offered as
631
- `Clone <module>, <module> now with qore sync? [Y/n]` (a TTY only, never
632
- with `--json`/`--no-input`; `--yes` does not accept it). A module sync
633
- cannot clone (a conflicting directory, no repository yet, an unsupported
634
- repository URL, GitHub not linked, no repository access) gets its own
635
- warning naming the real next step, and no prompt. While preflight runs, one progress line per
636
- module per step (package manager, install, env, ports) is printed as it
637
- completes. Once every module with a port is either listening or has been
638
- reported as not running, a one-line summary follows: `✔ All modules
639
- running:` (or `✔ Running:` / `! Not running:` when some were skipped) lists
640
- each module with its URL or its reason. A module that crashes while others
641
- keep running gets a restart hint
642
- (`Restart it on its own: qore dev --only <module>`, in another terminal;
643
- the others keep running); on shutdown, a final
644
- line lists what stopped cleanly and what crashed, with how long it ran.
645
- When the failure is about the developer's machine rather than the app
646
- (Docker, Node version, a port busy with something other than a previous
647
- `qore dev`, a package manager), the error is followed by a pointer to
648
- `qore doctor` for a full check.
649
-
650
- **Output.** Every line of a dev server's own stdout/stderr is prefixed per
651
- module and column-aligned:
652
-
653
- ```
654
- api │ listening on 8000
655
- web │ listening on 3001
656
- ```
657
-
658
- qore's own start, ready and exit lines (`▶ api (pid 4121)`,
659
- `✓ api is listening on 8000`, `✗ web exited with code 1`) are not prefixed
660
- and go to stderr, so `--json`'s stdout stays pure NDJSON. A module's own
661
- stdout goes to stdout and its stderr to stderr. Colour is disabled with `--json`, `--no-color` or `NO_COLOR`.
662
-
663
- With `--json` — the only qore command that streams instead of printing one
664
- document — stdout is newline-delimited JSON, one event object per line
665
- (`{"type":"start"|"ready"|"line"|"exit"|"warning"|"skip"|...}`), instead of
666
- the usual single `{"ok":...}` document. An `exit` event carries an optional
667
- `hint` (`{"hint":"..."}`, the same early-exit hint the human renderer prints
668
- as ` → ...`) when the module crashed early with a non-zero code and no
669
- signal — never on a signalled or graceful exit.
670
-
671
- ### Shared module checkouts
672
-
673
- With a projects folder (`qore init`), a tenant's apps share their modules.
674
- A module is cloned once, however many apps use it:
675
-
676
- ```
677
- <root>/<tenant>/modules/<slug>/ one checkout per module (the real repository)
678
- <root>/<tenant>/apps/<app>/ one folder per app, holding no code
679
- <root>/@<portal>/<tenant>/... the same, for a non-production portal
680
- ```
681
-
682
- Without a projects folder, and for `qore clone <app> <dir>`, nothing
683
- changes: the module repositories sit in the workspace directory as before.
684
-
685
- **The app folder** holds `qore.workspace.json` and files that make the
686
- app's modules open together in an editor or Claude Code. `qore clone` and
687
- `qore sync` write them from the portal's module list:
688
-
689
- | File | Purpose |
690
- |---|---|
691
- | `<app>.code-workspace` | VS Code / Cursor: the app folder plus every module in `../../modules/` |
692
- | `.idea/` (`modules.xml`, `<app>.iml`, `vcs.xml`) | WebStorm: the same modules as content roots and Git roots |
693
- | `CLAUDE.md` | which modules the app has, where they are, and which other apps share them |
694
- | `.claude/settings.json` | `permissions.additionalDirectories` for the modules |
695
-
696
- Only what qore owns is rewritten; the rest is yours. In `CLAUDE.md` that is
697
- the block between `<!-- qore:app:start -->` and `<!-- qore:app:end -->` —
698
- write anything you like outside it. In `.code-workspace` qore sets
699
- `folders` and keeps every other key (settings, extensions). In
700
- `.claude/settings.json` it keeps every other key, and any
701
- `additionalDirectories` entry of your own as long as it is not under
702
- `../../modules/`. Your indentation and line endings are kept. A file qore
703
- merges into (`<app>.code-workspace`, `.claude/settings.json`, `CLAUDE.md`)
704
- that is a symlink, or that cannot be parsed, is skipped and named in the
705
- output, never overwritten. The three `.idea` files and `qore.workspace.json`
706
- are qore's alone and are rewritten whole, edits included (qore still never
707
- writes through a symlink). A sync that changes nothing rewrites nothing.
708
-
709
- **Opening an app.**
710
-
711
- - VS Code or Cursor: open `apps/<app>/<app>.code-workspace`.
712
- - WebStorm: open `apps/<app>/` as the project.
713
- - Claude Code: `qore code <app>` (see "`qore code`" below). Plain `claude`
714
- in the app folder is not enough: the folder holds no code, and Claude's
715
- search does not reach other directories unless they are added with
716
- `--add-dir`, which `qore code` does for you.
717
-
718
- **Commands inside `modules/<slug>`.** There is no `qore.workspace.json`
719
- there, so qore asks which apps list the module. One app: it is used. Several:
720
- an interactive run asks, otherwise pass `--app <slug>`. When the portal
721
- puts the module in more apps than are cloned here and one of the cloned
722
- ones is used, qore says so on stderr: `Using app <app> (the only app here
723
- using <module>; also in <apps> — pass --app to choose).`
724
-
725
- **`qore sync`** works for the whole tenant, not only the app you are in:
726
- it reads every app folder of the tenant that it can access, clones what is
727
- missing into `modules/`, fetches every checkout once, and rewrites every
728
- readable app's view files. An app folder it cannot read or access is
729
- reported and left alone, and its modules still count as used.
730
-
731
- **Converting the old layout.** Apps cloned before this layout hold real
732
- repositories at `<tenant>/<app>/<module>`. `qore sync` (or `qore clone` of
733
- such an app) converts what it finds:
734
-
735
- - a module checkout is moved to `modules/<slug>` (when several apps hold a
736
- copy you choose which one moves);
737
- - another app's copy of the same module is removed — only when it is clean;
738
- - the old app folder is retired: `qore.workspace.json` moves to
739
- `apps/<app>/` and a `README.md` stays behind saying where everything
740
- went (an existing README is kept, and reported).
741
-
742
- **Qore asks first**, once, listing every path it would change. Without
743
- your yes nothing is moved or removed and sync reports the changes as kept;
744
- it never asks with `--json`, `--no-input` or without a terminal, so run
745
- `qore sync` interactively to convert. A duplicate is **clean** when it has
746
- no uncommitted changes (untracked files that are not git-ignored count,
747
- whatever your `status.showUntrackedFiles` says), no commits that are not
748
- pushed (a detached HEAD counts), no stashes, and no linked worktrees (`git
749
- worktree add`, inside the clone or elsewhere); when git cannot tell, it is
750
- not clean. A clone with linked worktrees, or one that is itself a linked
751
- worktree, is never removed or moved: move it by hand, then run `git worktree
752
- repair`. A copy that is not clean is kept, with
753
- the reason, and you decide what to do with it. If a move fails — an
754
- editor or a running dev server can hold the folder, notably on Windows —
755
- the error says to stop `qore dev` for the app and run `qore sync` again.
756
- A checkout in `modules/` that no app uses any more is reported as `not used
757
- by any app — left in place`; qore never deletes it.
758
-
759
- Known limits:
760
-
761
- - `qore clone` of an app whose shared module still sits in another app's
762
- old-layout folder clones it a second time into `modules/`; the next
763
- `qore sync` offers to remove the old copy.
764
- - A module cloned by `qore dev` shows in an app's view files after the
765
- next `qore sync`.
766
-
767
- #### `qore code`
768
-
769
- ```sh
770
- qore code # the app you are in
771
- qore code <app> # an app of the tenant you are in
772
- qore code <app> -- --resume # arguments after -- go to claude
773
- ```
774
-
775
- Starts Claude Code in the app's frontend module, with every other module of
776
- the app and the app folder added (`--add-dir`), and sets
777
- `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` so Claude reads the added
778
- modules' `CLAUDE.md` files. An app without a frontend starts in the app
779
- folder. The module list comes from the portal.
780
-
781
- - **Which app.** `<app>` is looked up in the tenant of the current
782
- directory, else in the projects folder (a slug cloned in several places
783
- asks you to run it from inside one). Without `<app>`: from an app folder,
784
- that app; from `modules/<slug>`, the app that uses the module (a picker
785
- when several do, otherwise `Pass an app: used by …`).
786
- - It needs a projects folder and the shared layout. An old-layout
787
- workspace asks you to run `qore sync` first (`qore code needs the shared
788
- layout: run qore sync to convert this workspace.`); modules not cloned yet
789
- are listed with `Run qore sync first.`
790
- - `claude` not found: `QORE_TOOL_MISSING`, "Install Claude Code: npm i -g
791
- @anthropic-ai/claude-code". Otherwise `claude`'s own exit code (or
792
- 128 + signal) is `qore code`'s.
793
- - No `--json`.
36
+ ### Commands
37
+
38
+ The full reference is in [docs/commands.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md) (module commands,
39
+ repository context, `.qore.json`, `qore init`) and [docs/workspaces.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md)
40
+ (app workspaces, shared module checkouts, `qore dev` in a workspace root, `qore code`).
41
+
42
+ | Command | What it does |
43
+ |---------|--------------|
44
+ | `qore login` / `qore logout` / `qore whoami` | Device-code login in your browser; show the logged-in user and active tenant |
45
+ | `qore tenant list` / `qore tenant use <slug>` | List the tenants you have access to; set the active one |
46
+ | `qore version` | CLI + portal version info |
47
+ | [`qore init`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#projects-folder--qore-init) | Guided setup: projects folder, login, tenant, first app |
48
+ | [`qore config root`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#projects-folder--qore-init) | Show, set or clear the projects folder |
49
+ | [`qore config telemetry`](#privacy) | Show crash reporting's state, or turn it `on`/`off` |
50
+ | [`qore status`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-status) | Deployment and health per environment for the current module |
51
+ | [`qore env pull`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-env-pull) | Write this module's local secrets into an env file |
52
+ | [`qore run -- <command>`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-run) | Run a command with those secrets in its environment, without writing them to disk |
53
+ | [`qore roles list` / `sync` / `use`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-roles) | Show your code's roles and yours on `local`; announce them; take some |
54
+ | [`qore dev`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-dev) | Start this module's dev server, or [every module of an app](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#qore-dev-workspace-root) from a workspace root |
55
+ | [`qore doctor`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-doctor) | Run the checks `qore` makes before other commands, on demand |
56
+ | [`qore db erd`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-db-erd) | Open the module's (or app's) data model in your browser, read from the local Postgres |
57
+ | [`qore clone` / `qore sync`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#workspaces) | Set up a local directory for an app and its modules; keep it in step with the app |
58
+ | [`qore code`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#qore-code) | Start Claude Code in the app's frontend module, with every module added |
59
+ | `qore errors` / `qore traces` / `qore logs` | Recent errors, slow requests and logs per environment (examples above) |
794
60
 
795
61
  ### `--json`
796
62
 
@@ -866,6 +132,15 @@ by the Sentry project's "Prevent Storing of IP Addresses" setting, part of its i
866
132
  `qore config telemetry` and `qore doctor` show the current state and where it
867
133
  comes from. A build from source or a fork carries no DSN and sends nothing.
868
134
 
135
+ ## Documentation
136
+
137
+ - [docs/commands.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md) — every module command, repository context,
138
+ `.qore.json`, trust on first use, the projects folder and `qore init`.
139
+ - [docs/workspaces.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md) — `qore clone`/`qore sync`, `qore dev` in a
140
+ workspace root, shared module checkouts and `qore code`.
141
+ - [CLAUDE.md](https://github.com/Quatronic-IT/qore-cli/blob/main/CLAUDE.md) and [docs/internals/](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/internals) — how the CLI is built,
142
+ for contributors.
143
+
869
144
  ## Releasing
870
145
 
871
- See [RELEASING.md](./RELEASING.md).
146
+ See [RELEASING.md](https://github.com/Quatronic-IT/qore-cli/blob/main/RELEASING.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatronic/qore",
3
- "version": "0.4.0-test.1f7e2c4",
3
+ "version": "0.4.0-test.21ae023",
4
4
  "description": "Qore developer CLI",
5
5
  "type": "module",
6
6
  "bin": {