@processfocus/cli 0.1.0-next.2 → 0.1.0-next.3

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 (43) hide show
  1. package/README.md +82 -699
  2. package/dist/bundle-organisation.mjs +2 -0
  3. package/dist/bundled-db-import.mjs +103 -120
  4. package/dist/bundled-graphql-schema.mjs +17 -15
  5. package/dist/command-reference.md +571 -0
  6. package/dist/main.mjs +325 -303
  7. package/dist/pfcli.usage.kdl +377 -0
  8. package/dist/prepare-deployment-artifact.mjs +2 -2
  9. package/dist/resources/cedar/policies.cedar +80 -38
  10. package/dist/resources/cedar/schema.cedarschema +39 -21
  11. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/migration.sql +1 -0
  12. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/snapshot.json +7708 -0
  13. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/migration.sql +14 -0
  14. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/snapshot.json +7852 -0
  15. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/migration.sql +4 -0
  16. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/snapshot.json +7908 -0
  17. package/dist/resources/system-migrations/20261023074259_previous_falcon/migration.sql +1 -0
  18. package/dist/resources/system-migrations/20261023074259_previous_falcon/snapshot.json +7918 -0
  19. package/dist/resources/system-migrations/20261023211931_black_vision/migration.sql +1 -0
  20. package/dist/resources/system-migrations/20261023211931_black_vision/snapshot.json +7928 -0
  21. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/migration.sql +4 -0
  22. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/snapshot.json +7968 -0
  23. package/dist/resources/system-migrations/20261025201326_confused_mordo/migration.sql +25 -0
  24. package/dist/resources/system-migrations/20261025201326_confused_mordo/snapshot.json +8141 -0
  25. package/dist/resources/system-migrations/20261025225809_pink_mysterio/migration.sql +20 -0
  26. package/dist/resources/system-migrations/20261025225809_pink_mysterio/snapshot.json +8350 -0
  27. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/migration.sql +1 -0
  28. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/snapshot.json +8360 -0
  29. package/dist/resources/system-migrations/20261101232313_curved_siren/migration.sql +3 -0
  30. package/dist/resources/system-migrations/20261101232313_curved_siren/snapshot.json +8390 -0
  31. package/dist/resources/system-migrations/20261111225459_real_overlord/migration.sql +13 -0
  32. package/dist/resources/system-migrations/20261111225459_real_overlord/snapshot.json +8511 -0
  33. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/migration.sql +1 -0
  34. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/snapshot.json +8501 -0
  35. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/migration.sql +1 -0
  36. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/snapshot.json +8511 -0
  37. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/migration.sql +3 -0
  38. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/snapshot.json +8511 -0
  39. package/dist/resources/system-migrations/20261119223342_lucky_lester/migration.sql +3 -0
  40. package/dist/resources/system-migrations/20261119223342_lucky_lester/snapshot.json +8367 -0
  41. package/dist/resources/system-migrations/20261123050259_sad_dagger/migration.sql +1 -0
  42. package/dist/resources/system-migrations/20261123050259_sad_dagger/snapshot.json +8377 -0
  43. package/package.json +11 -9
package/README.md CHANGED
@@ -1,736 +1,119 @@
1
1
  # pfcli
2
2
 
3
- Process Focus CLI Tool — scaffold, build, and manage business process organisations.
3
+ `pfcli` builds Process Focus organisations and manages their cloud hosting.
4
+ Use [pforg](../pforg/README.md) to work with Processes, Todos and records inside
5
+ an organisation.
4
6
 
5
- ## Overview
6
-
7
- `pfcli` is the command-line interface for the Process Focus business process modeling system. It helps you:
8
-
9
- - Scaffold new organisation directories with working templates
10
- - Build and bundle organisation code for deployment
11
- - Destroy hosted project environments through the existing Backend process
12
- - Import organisation configurations to the database
13
- - Run system and custom database migrations
14
- - Inspect custom-domain certificate status and required DNS records
15
- - Run browser-based CLI authentication
16
- - Open a short-lived Database Shell for hosted environment investigation
17
- - Download hosted environment databases as local SQLite databases
18
- - Serve agent-oriented runtime skill guidance for the installed CLI version
19
-
20
- ## Commands
21
-
22
- ### `init`
23
-
24
- Initialise a new organisation directory with template files, generate a
25
- `package.json` using the released `processfocus` SDK, install dependencies, then
26
- import it so `db/pf.db` and the frontend JWT exist immediately.
27
-
28
- ```bash
29
- pfcli init <org-path> --email <admin-email> --identity-provider <name> [--identity-provider <name> ...]
30
- ```
31
-
32
- **Arguments:**
33
- - `org-path` — Path to the organisation directory to initialise (supports `PF_ORG` env var)
34
-
35
- **Options:**
36
- - `--email` — Admin email used for the scaffolded invitation and Cedar policy (required)
37
- - `--identity-provider` — Identity provider to scaffold; repeat for multiple providers (required, at least one)
38
-
39
- **Example:**
40
- ```bash
41
- pfcli init ./my-org --email admin@example.com --identity-provider google --identity-provider github
42
- PF_ORG=./my-org pfcli init --email admin@example.com --identity-provider google
43
- ```
44
-
45
- Creates the following structure:
46
- ```
47
- my-org/
48
- ├── package.json # Generated org package metadata and npm dependencies
49
- ├── node_modules/ # Normal package-manager installation
50
- ├── db/
51
- │ └── pf.db # Created and seeded by init via import
52
- ├── src/
53
- │ ├── index.ts # Entry point re-export
54
- │ ├── org.ts # Org definition (processes, roles, auth, invitations)
55
- │ └── todo.ts # Sample Todo process
56
- └── cedar/
57
- └── custom.cedar # Cedar authorization policies
58
- ```
59
-
60
- ### `build`
61
-
62
- Build organisation artifacts (bundled JS, GraphQL schema, Cedar policies).
63
-
64
- ```bash
65
- pfcli build <org-path> [options]
66
- ```
67
-
68
- **Arguments:**
69
- - `org-path` — Path to the organisation directory
70
-
71
- **Options:**
72
- - `--output, -o` — Output directory for build artifacts (default: `dist`)
73
-
74
- **Example:**
75
- ```bash
76
- pfcli build ./my-org
77
- pfcli build ./my-org --output ./build
78
- ```
79
-
80
- Outputs:
81
- - `dist/org.js` — Bundled organisation code from `src/index.ts`, including `dbImport`
82
- - `dist/graphql/org.graphql` — Generated GraphQL schema
83
- - `dist/cedar/` — Copied Cedar policy files
84
-
85
- `dist/org.js` is the single import/runtime artifact. `pfcli import` uses the
86
- built bundle's `dbImport` entrypoint rather than loading `src/index.ts` directly.
87
-
88
- ### `deploy`
89
-
90
- Build the org, upload the resulting `dist` artifact, and start the deploy process.
91
-
92
- ```bash
93
- pfcli deploy <org-path> --project <project-number> --env <environment-name>
94
- ```
95
-
96
- **Arguments:**
97
- - `org-path` — Path to the organisation directory
98
-
99
- **Options:**
100
- - `--project` — Project number to deploy (internal project ID also accepted)
101
- - `--env` — Environment name to deploy to (internal environment ID also accepted). Environment names are unique within a project, not just within a stage.
102
- - `--no-wait` — Return after starting the deployment instead of waiting for completion
103
-
104
- **Behavior:**
105
- - Requires valid CLI credentials in `~/.config/pf/credentials.json`
106
- - If missing or expired, command exits with: `Run "pfcli auth login"`
107
- - Runs `pfcli build <org-path>` first
108
- - Zips `<org-path>/dist`
109
- - Requests upload URL via GraphQL `requestUploadUrl`
110
- - Uploads zip to returned `uploadUrl`
111
- - Starts deploy via `startOperationsDeploy`
112
- - Waits for execution completion by default and prints concise execution updates
113
-
114
- ### `destroy`
115
-
116
- Destroy a hosted project environment by starting the existing Backend process.
117
- There is no organisation path or artifact upload.
118
-
119
- ```bash
120
- pfcli destroy --project <project-number> --env <environment-name> --yes
121
- pfcli destroy --project <project-number> --env <environment-name> --yes --no-wait
122
- ```
123
-
124
- **Options:**
125
- - `--project` — Project number to destroy from (internal project ID also accepted)
126
- - `--env` — Environment name to destroy (internal environment ID also accepted)
127
- - `--yes` — Mandatory non-interactive confirmation
128
- - `--no-wait` — Return after starting destruction instead of waiting for completion
129
-
130
- **Behavior:**
131
- - Requires valid credentials from `pfcli auth login`
132
- - Refuses to start unless `--yes` is present and identifies the target project and environment in the error
133
- - Checks the environment name against the project's known environments before starting
134
- - Starts the existing `/operations/destroy-environment` Backend process via `startOperationsDestroyEnvironment`; the CLI does not delete stacks itself
135
- - The Backend process deletes the environment's AWS stacks and environment record
136
- - Waits up to 45 minutes for execution completion by default and surfaces Backend failure details
137
- - Prints only the execution ID when starting; it does not print credentials, signed URLs, or AWS account IDs
138
-
139
- ### `invitation registration-link`
140
-
141
- Mint or rotate a Registration Link locally or in a remote customer environment. Pending Invitations use first-admin passkey bootstrap; `--rotate` can also issue a fresh Passkey Recovery Link for an existing account associated with an accepted or legacy-closed Invitation.
142
-
143
- ```bash
144
- # Local database
145
- pfcli invitation registration-link [org-path] --email <invited-email>
146
- pfcli invitation registration-link [org-path] --email <invited-email> --rotate
147
-
148
- # Remote customer environment
149
- pfcli invitation registration-link --project <project-number> --env <environment-name> --email <invited-email>
150
- pfcli invitation registration-link --project <project-number> --env <environment-name> --email <invited-email> --rotate
151
- ```
152
-
153
- **Arguments:**
154
- - `org-path` — Optional path to the organisation directory (local mode only; may come from `PF_ORG`)
155
-
156
- **Options:**
157
- - `--project` — Project number (internal project ID also accepted; remote mode)
158
- - `--env` — Environment name (internal environment ID also accepted; remote mode)
159
- - `--email` — Email of the pending Invitation
160
- - `--rotate` — Replace an active or expired pending Registration Link, or issue a fresh single-use Passkey Recovery Link for an existing active account
161
-
162
- **Behavior:**
163
- - Local mode resolves its database from `SQLITE_DATABASE_PATH`, `org-path`, or `PF_ORG`
164
- - Local URLs use `FRONTEND_BASE_URL`, `BASE_URL`, or `NEXT_PUBLIC_FRONTEND_URL`, falling back to `http://localhost:3000`
165
- - Remote mode requires `--project` and `--env` together and valid CLI credentials from `pfcli auth login`
166
- - Remote mode does not accept `org-path`
167
- - Identifies the Invitation by Normalized Email (trim + lowercase)
168
- - Prints the Registration Link URL once to stdout on success
169
- - Does not print the URL on failure
170
- - A second generate without `--rotate` fails while a live link exists
171
- - Recovery preserves current roles, existing passkeys, and Invitation history. It refuses deleted Invitations, inactive accounts, accounts without current roles, and disabled passkey providers.
172
- - Revoked pending links cannot be rotated. Restoring their access requires an explicit administrative action.
173
- - Remote recovery additionally requires `recoverProviderUser` permission (initially Cloud Backend Administrators only), alongside user administration and project/environment access.
174
- - Recovery links expire after 24 hours; browser sessions last at most ten minutes. Rotation invalidates all earlier recovery links and sessions for the account.
175
- - Does not log the URL
176
-
177
- CLI tests cover issuing and exchanging a local Registration Link through the
178
- authentication database. Completing passkey registration and signing in remain
179
- a browser acceptance step with a virtual authenticator.
180
-
181
- ### `db upload`
182
-
183
- Upload a local SQLite database artifact through a signed document-store URL and wait for the backend apply flow to finish.
184
-
185
- ```bash
186
- pfcli db upload --project <project-number> --env <environment-name> [--mode data-copy|exact-restore] <sqlite-file>
187
- ```
188
-
189
- **Arguments:**
190
- - `sqlite-file` — Local SQLite database file to upload
191
-
192
- **Options:**
193
- - `--project` — Project number to upload to (internal project ID also accepted)
194
- - `--env` — Environment name to upload to (internal environment ID also accepted)
195
- - `--mode` — Upload semantics. Defaults to `data-copy`; use `exact-restore` only when the uploaded authentication state must replace the target environment's state
196
-
197
- **Behavior:**
198
- - Validates the local file exists, is a regular non-empty SQLite database file, and is readable before requesting an upload URL
199
- - Uploads database bytes only through the signed document-store URL, not through GraphQL
200
- - Starts the backend database apply flow and waits for completion; there is no `--no-wait` option
201
- - `data-copy` preserves the target environment's signing keys, encryption keys, legacy signing keys, and stored frontend JWT while discarding all imported OAuth sessions and other OpenAuth storage
202
- - `exact-restore` applies all uploaded database state, including OpenAuth keys and sessions
203
- - Both modes create and validate a recovery snapshot before changing the uploaded candidate or the Active Environment Database
204
- - For SQLite-engine (`libsql`) targets, requires `journal_mode=WAL` and keeps the existing Turso file-seed cutover
205
- - For TursoDB (`tursodb`) targets, accepts the `journal_mode=delete` artifact produced by `db download`, replays a logical SQL dump into an empty TursoDB candidate through the Console's Turso Cloud layer, filters Turso-owned `__turso_internal_*` objects, and preserves AUTOINCREMENT continuity
206
- - Prints concise JSON status lines with the local input path, byte size, document store path, operation ID, file ID, execution ID, and final `APPLIED` result
207
- - Backend failures after a recovery snapshot is created include the recovery snapshot file ID for manual recovery
208
- - Does not print signed URLs, Turso tokens, SSM parameter values, direct database credentials, AWS credentials, or raw secrets
209
-
210
- ### `db download`
211
-
212
- Download a hosted environment database to a local SQLite database. The CLI asks the console GraphQL API for a short-lived direct download session and authoritative engine metadata, then selects the engine-specific transfer mechanism.
213
-
214
- ```bash
215
- pfcli db download --project <project-number> --env <environment-name> [--output ./backup.sqlite]
216
- ```
217
-
218
- **Options:**
219
- - `--project` — Project number to download from (internal project ID also accepted)
220
- - `--env` — Environment name to download from (internal environment ID also accepted)
221
- - `--output` — Output path for the downloaded database. If omitted, `pfcli` writes a timestamped `pfcli-db-<project>-<env>-<timestamp>.sqlite` path in the current directory
222
-
223
- **Behavior and boundaries:**
224
- - Calls the console GraphQL download-session API using the Process Focus CLI login; GraphQL returns session metadata and short-lived Turso credentials, not database bytes
225
- - Uses Turso Sync unchanged for SQLite-engine (`libsql`) databases; their output is reusable Turso Sync local state and sidecar files may appear beside it
226
- - For TursoDB (`tursodb`), streams the authenticated HTTPS logical dump, removes Turso-owned `__turso_internal_*` objects, replays it into an ordinary SQLite file, and runs `PRAGMA integrity_check` plus `PRAGMA foreign_key_check`
227
- - For TursoDB, builds in owner-private temporary files and atomically replaces `--output` only after validation. An existing output is replaced by a complete logical snapshot, not incrementally updated
228
- - Waits for the engine-specific transfer to complete; there is no `--no-wait` option
229
- - Prints concise JSON status lines with the project, environment, database, output path, session expiry, and final `SYNCED` result
230
- - A failed or timed-out TursoDB download removes temporary dump/database files and leaves an existing output untouched
231
- - Is pull-only in the first version and does not push local changes back to the hosted environment
232
- - SQLite-engine correctness continues to rely on Turso Sync; TursoDB snapshots are validated locally before publication
233
- - Does not use the Database Shell session API, signed document-store URLs, backend snapshot artifacts, or long-running process executions
234
- - Keeps restore through Turso Sync push out of scope; restore support must be designed as a separate workflow
235
- - Does not print Turso tokens, SSM parameter values, direct database credentials, AWS credentials, or raw secrets
236
-
237
- ### `db shell`
238
-
239
- Open an interactive Turso shell against the Active Environment Database for a hosted project environment.
7
+ ## Local development
240
8
 
241
9
  ```bash
242
- pfcli db shell --project <project> --env <env>
243
- pfcli db shell --project <project> --env <env> --ttl 30m
244
- ```
245
-
246
- **Prerequisites:**
247
- - Authenticate to Process Focus with `pfcli auth login`; Turso organisation membership is not required
248
- - Install the external Turso CLI from https://docs.turso.tech/cli/installation and make `turso` available on `PATH`
249
-
250
- **Options:**
251
- - `--project` — Project number to open a shell for (internal project ID also accepted)
252
- - `--env` — Environment name to open a shell for (internal environment ID also accepted)
253
- - `--ttl` — Session lifetime; bare numbers are seconds, and duration units such as `900s`, `15m`, or `1h` are accepted. The default is 15 minutes. Values over 1 hour are rejected locally with `Database Shell TTL must be 1 hour or less.`
254
-
255
- **Behavior and boundaries:**
256
- - Calls the console GraphQL `createDatabaseShellSession` mutation using the Process Focus CLI login
257
- - Requires the caller to have the Cedar `databaseShell` permission; otherwise the console returns permission denied
258
- - Checks that `turso` is installed before requesting a Database Shell session, so unused database credentials are not minted when the external dependency is missing
259
- - Launches `turso db shell` with inherited terminal input/output and returns the Turso process exit code
260
- - Opens a live read-write shell for the Active Environment Database; changes affect the hosted environment immediately
261
- - Targets only the Active Environment Database, not runtime colors, rollback candidate databases, retained backup databases, downloaded snapshots, or local SQLite files
262
- - Is for live investigation and emergency repair, not database transfer, snapshot download, local SQLite, rollback, restore, or backup workflows; use the dedicated upload, download, rollback, restore, and backup workflows for those cases
263
- - Receives a short-lived Turso database token scoped to one database; the token is not a group token and does not include database attach permissions
264
- - Does not refresh expired sessions automatically; rerun `pfcli db shell` to create a new short-lived session
265
- - Does not persist the Turso token in `pfcli` credentials, Turso config, temp files, or env files
266
- - Prints target metadata and a read-write warning, but does not print the credential-bearing Turso URL
267
- - Audits first-version Database Shell session creation only; individual SQL statements are not audited by Process Focus
268
-
269
- ### Runtime Logs
270
-
271
- Inspect the currently deployed runtime logs through the console GraphQL API.
272
-
273
- ```bash
274
- pfcli logs --project <id> --env <name>
275
- pfcli canary-logs --project <id> --env <name>
276
- ```
277
-
278
- **Commands:**
279
- - `logs` — Show recent primary runtime logs
280
- - `canary-logs` — Show recent canary runtime logs
281
-
282
- **Options:**
283
- - `--project` — Project number whose runtime logs to read (internal ID also accepted)
284
- - `--env` — Environment name whose runtime logs to read
285
-
286
- **V1 output contract:**
287
- - Starts with a concise primary/canary status line
288
- - The status line is `Showing recent primary logs.` or `Showing recent canary logs.`
289
- - Prints each returned log event as timestamp plus raw log message only
290
- - Prints a concise empty-state line when no events are returned
291
- - Does not print deployment color, CloudWatch log group, AWS account ID, AWS region, or stream names
292
- - Leaves raw JSON log messages unchanged; it does not parse, simplify, pretty-print, or redact them
293
- - Shows recent runtime logs returned by the cloud API
294
- - The command descriptions distinguish v1 from follow/streaming modes without promising a time window
295
- - Because redaction is out of scope for v1, raw messages are printed exactly as returned
296
-
297
- **Out of scope for v1:**
298
- - Docker-step build-phase logs, Fargate logs, and CodeBuild logs
299
- - `--follow`, `--since`, `--json`, filtering, redaction, and user-configurable output caps
300
-
301
- ### `stage`
302
-
303
- Manage project stages through the console GraphQL API.
304
-
305
- Requires valid CLI credentials in `~/.config/pf/credentials.json`.
306
-
307
- #### `stage list`
308
-
309
- List the stages for a project.
310
-
311
- ```bash
312
- pfcli stage list --project <project-number>
313
- ```
314
-
315
- **Options:**
316
- - `--project` - Project number to query (internal project ID also accepted)
317
-
318
- **Behavior:**
319
- - Calls the console GraphQL `listProjectStages` query
320
- - Prints one stage name per line
321
- - Prints a clear empty-state message when the project has no stages
322
-
323
- **Example:**
324
- ```bash
325
- pfcli stage list --project 1234-5678-9012
326
- ```
327
-
328
- #### `stage add`
329
-
330
- Create a new stage in a project by starting the existing `/operations/add-stage` process.
331
-
332
- ```bash
333
- pfcli stage add --project <project-number> <stage-name>
334
- ```
335
-
336
- **Options:**
337
- - `--project` - Project number to update (internal project ID also accepted)
338
-
339
- **Arguments:**
340
- - `stage-name` - Stage name to create
341
-
342
- **Behavior:**
343
- - Calls the generated `startOperationsAddStage` mutation
344
- - Waits for execution completion and prints concise execution updates
345
- - Prints `Stage created: <stage-name>` on success
346
- - Prints a clean duplicate-stage error instead of raw database text
347
-
348
- **Example:**
349
- ```bash
350
- pfcli stage add --project 1234-5678-9012 Production
351
- ```
352
-
353
- ### `env`
354
-
355
- Manage project environments through the console GraphQL API.
356
-
357
- Requires valid CLI credentials in `~/.config/pf/credentials.json`.
358
-
359
- #### `env list`
360
-
361
- List the environments for a project, optionally narrowed to a single stage.
362
-
363
- ```bash
364
- pfcli env list --project <project-number> [--stage <stage-name>]
365
- ```
366
-
367
- **Options:**
368
- - `--project` - Project number to query (internal project ID also accepted)
369
- - `--stage` - Optional stage to filter by (internal stage ID also accepted)
370
-
371
- **Behavior:**
372
- - Calls the console GraphQL `listProjectEnvironments` query
373
- - Prints `environment (stage)` when `--stage` is not supplied
374
- - Prints one environment name per line when `--stage` is supplied
375
- - Prints a clear empty-state message when the selected scope has no environments
376
-
377
- **Example:**
378
- ```bash
379
- pfcli env list --project 1234-5678-9012
380
- pfcli env list --project 1234-5678-9012 --stage Production
381
- ```
382
-
383
- #### `env add`
384
-
385
- Create a new environment in a project stage by starting the existing `/operations/add-environment` process.
386
-
387
- ```bash
388
- pfcli env add --project <project-number> --stage <stage-name> <env-name>
389
- ```
390
-
391
- **Options:**
392
- - `--project` - Project number to update (internal project ID also accepted)
393
- - `--stage` - Stage name to target (internal stage ID also accepted)
394
-
395
- **Arguments:**
396
- - `env-name` - Environment name to create
397
-
398
- **Behavior:**
399
- - Calls the generated `startOperationsAddEnvironment` mutation
400
- - Waits for execution completion and prints concise execution updates
401
- - Prints `Environment created: <env-name>` on success
402
- - Relies on the backend process for environment-name validation and stage/project resolution
403
-
404
- **Example:**
405
- ```bash
406
- pfcli env add --project 1234-5678-9012 --stage Production prd
407
- ```
408
-
409
- ### `custom-domain`
410
-
411
- Show custom-domain certificate status and required DNS records through the console GraphQL API.
412
-
413
- Requires valid CLI credentials in `~/.config/pf/credentials.json`.
414
-
415
- ```bash
416
- pfcli custom-domain --project <project-number> --env <environment-name>
417
- ```
418
-
419
- **Options:**
420
- - `--project` — Project number to query (internal project ID also accepted)
421
- - `--env` — Environment name to query (internal environment ID also accepted)
422
-
423
- **Behavior:**
424
- - Calls the console GraphQL `getDnsRecords` query
425
- - The console backend resolves the customer AWS region and does the AWS lookups server-side
426
- - Prints ACM validation CNAME records when present
427
- - Prints the CloudFront site-access CNAME when available
428
- - Prints the default domain when no custom domain is configured
429
-
430
- **Example:**
431
- ```bash
432
- pfcli custom-domain --project 0000-0000-0002 --env prod
433
- ```
434
-
435
- ### `config`
436
-
437
- Manage stage-scoped project config values through the console GraphQL API.
438
-
439
- Requires valid CLI credentials in `~/.config/pf/credentials.json`.
440
-
441
- #### `config list`
442
-
443
- List config parameters for a project stage.
444
-
445
- ```bash
446
- pfcli config list --project <project-number> --stage <stage-name>
447
- ```
448
-
449
- **Options:**
450
- - `--project` — Project number to query (internal project ID also accepted)
451
- - `--stage` — Stage name to query (internal stage ID also accepted)
452
-
453
- **Example:**
454
- ```bash
455
- pfcli config list --project 0000-0000-0002 --stage Development
456
- ```
457
-
458
- #### `config get`
459
-
460
- Get a single config parameter for a project stage.
461
-
462
- ```bash
463
- pfcli config get --project <project-number> --stage <stage-name> --key <key>
464
- ```
465
-
466
- **Options:**
467
- - `--project` — Project number to query (internal project ID also accepted)
468
- - `--stage` — Stage name to query (internal stage ID also accepted)
469
- - `--key` — Config key to fetch
470
-
471
- **Example:**
472
- ```bash
473
- pfcli config get --project 0000-0000-0002 --stage Development --key API_URL
474
- ```
475
-
476
- #### `config set`
477
-
478
- Create or update a config parameter for a project stage.
479
-
480
- ```bash
481
- pfcli config set --project <project-number> --stage <stage-name> <key>
482
- pfcli config set --project <project-number> --stage <stage-name> <key>=<value>
483
- pfcli config set --project <project-number> --stage <stage-name> <key> <value>
484
- ```
485
-
486
- **Options:**
487
- - `--project` — Project number to update (internal project ID also accepted)
488
- - `--stage` — Stage name to update (internal stage ID also accepted)
489
- - `--secret` — Store as a secret value
490
-
491
- **Arguments:**
492
- - One of `<key>` (copy the value from the exported environment variable), `<key>=<value>`, or `<key> <value>`
493
- - The bare `<key>` form fails if the environment variable is unset; an environment variable set to an empty string remains valid
494
-
495
- **Examples:**
496
- ```bash
497
- export API_URL=https://example.com
498
- pfcli config set --project 0000-0000-0002 --stage Development API_URL
499
- pfcli config set --project 0000-0000-0002 --stage Development API_URL=https://example.com
500
- pfcli config set --project 0000-0000-0002 --stage Development API_URL https://example.com
501
- export API_TOKEN='...'
502
- pfcli config set --project 0000-0000-0002 --stage Development API_TOKEN --secret
503
- ```
504
-
505
- #### `config delete`
506
-
507
- Delete a config parameter for a project stage.
508
-
509
- ```bash
510
- pfcli config delete --project <project-number> --stage <stage-name> --key <key>
511
- ```
512
-
513
- **Options:**
514
- - `--project` — Project number to update (internal project ID also accepted)
515
- - `--stage` — Stage name to update (internal stage ID also accepted)
516
- - `--key` — Config key to delete
517
-
518
- **Example:**
519
- ```bash
520
- pfcli config delete --project 0000-0000-0002 --stage Development --key API_URL
521
- ```
522
-
523
- #### `config copy-new`
524
-
525
- Copy config parameters from another stage without overwriting keys that
526
- already exist on the target stage. If `--from-stage` resolves to the same
527
- stage as `--stage`, the command warns and does nothing.
528
-
529
- ```bash
530
- pfcli config copy-new --project <project-number> --stage <target-stage-name> --from-stage <source-stage-name>
531
- ```
532
-
533
- **Options:**
534
- - `--project` — Project number to update (internal project ID also accepted)
535
- - `--stage` — Target stage name to update (internal stage ID also accepted)
536
- - `--from-stage` — Source stage name to copy from (internal stage ID also accepted)
537
-
538
- **Example:**
539
- ```bash
540
- pfcli config copy-new --project 0000-0000-0002 --stage Production --from-stage Development
541
- ```
542
-
543
- ### `import`
544
-
545
- Import organisation to the configured database. Automatically runs system and custom
546
- migrations before importing, so it works on a fresh database.
547
-
548
- ```bash
549
- pfcli import <org-path>
10
+ pfcli init ./my-org --email admin@example.com --identity-provider google
550
11
  ```
551
12
 
552
- **Arguments:**
553
- - `org-path` — Path to the organisation directory
13
+ This creates an organisation, installs its dependencies and imports it into a
14
+ local database. Configure the selected identity provider before signing in.
554
15
 
555
- **Database path resolution:**
556
- - Uses `SQLITE_DATABASE_PATH` when set
557
- - Otherwise falls back to `<org-path>/db/pf.db`
16
+ Edit the organisation's source, then import again to update the local database,
17
+ or build to produce deployment artifacts:
558
18
 
559
- **Example:**
560
19
  ```bash
561
- SQLITE_DATABASE_PATH=./data.db pfcli import ./my-org
562
- # or rely on default path ./my-org/db/pf.db
563
20
  pfcli import ./my-org
21
+ pfcli build ./my-org
564
22
  ```
565
23
 
566
- ### `migrate`
567
-
568
- Run both system (`__drizzle_migrations_pf`) and org custom
569
- (`__drizzle_migrations_org`) schema migrations. Useful as a standalone
570
- command when you want to migrate without re-importing.
571
-
572
- ```bash
573
- pfcli migrate <org-path>
574
- ```
575
-
576
- **Arguments:**
577
- - `org-path` — Path to the organisation directory
578
-
579
- **Database path resolution:**
580
- - Uses `SQLITE_DATABASE_PATH` when set
581
- - Otherwise falls back to `<org-path>/db/pf.db`
582
-
583
- **Example:**
584
- ```bash
585
- SQLITE_DATABASE_PATH=./data.db pfcli migrate ./my-org
586
- pfcli migrate ./my-org
587
- ```
588
-
589
- ### `migrate-custom`
590
-
591
- Run custom schema migrations for organisation.
592
-
593
- ```bash
594
- pfcli migrate-custom <org-path>
595
- ```
596
-
597
- **Arguments:**
598
- - `org-path` — Path to the organisation directory
599
-
600
- **Database path resolution:**
601
- - Uses `SQLITE_DATABASE_PATH` when set
602
- - Otherwise falls back to `<org-path>/db/pf.db`
603
-
604
- **Example:**
605
- ```bash
606
- SQLITE_DATABASE_PATH=./data.db pfcli migrate-custom ./my-org
607
- pfcli migrate-custom ./my-org
608
- ```
609
-
610
- ### `get-frontend-jwt`
611
-
612
- Read the stored frontend JWT token from the database.
24
+ Import includes schema migrations. Use `--database-path` when the database is
25
+ outside the organisation's default `db/pf.db` location.
613
26
 
614
- `import`, `refresh-frontend-jwt`, and `get-frontend-jwt` select the frontend
615
- identity using the shared auth helpers: `FRONTEND_JWT_TOKEN`'s
616
- `properties.clientId` takes precedence over `OAUTH_CLIENT_ID`, then `frontend`.
617
- Minting and local development client registration likewise use the JWT's `aud`
618
- before `OAUTH_AUDIENCE`, then `graphql-api`. The default still reads and preserves
619
- the existing `frontend-jwt/frontend` database entry; other identities use their
620
- own entries. Import preserves a matching stored token; refresh regenerates it.
27
+ ## Cloud hosting
621
28
 
622
- Use the same identity/audience configuration for bootstrap import, the auth
623
- server, and the frontend launcher. `OPENAUTH_CLIENTS` is a registry, not a
624
- frontend selector: for a nondefault frontend, also set `OAUTH_CLIENT_ID` (and
625
- `OAUTH_AUDIENCE` where needed), or provide `FRONTEND_JWT_TOKEN` to all these
626
- processes. Its selected registry entry must use `client_jwt` authentication and
627
- the matching audience. No client is inferred from an ambiguous array.
628
- Development auto-registration runs only without `OPENAUTH_CLIENTS` and with
629
- `NODE_ENV=development`. The packaged local runtime uses `NODE_ENV=production`
630
- and requires explicit `OPENAUTH_CLIENTS` before starting its auth server; it
631
- then refreshes/reads the selected stored JWT for the remaining services.
29
+ Hosted builds require `platformRef` on the authored `Organisation`. To verify
30
+ merged public-package changes, use an authorized existing Backend and set
31
+ `platformRef: "trunk"`. For a reproducible deployment, select a full commit SHA.
32
+ The CLI builds with `PF_ENV` set to the target customer environment, so the org
33
+ can select a different ref per environment, for example
34
+ `platformRef: process.env["PF_ENV"] === "prd" ? releaseCommit : "trunk"`.
632
35
 
633
- ```bash
634
- pfcli get-frontend-jwt <org-path>
635
- ```
36
+ Set `platformSource: "public"` to resolve `platformRef` in the official
37
+ `processfocus/processfocus` mirror. Use a branch name such as `"trunk"` to
38
+ follow that branch. Each Deploy Attempt resolves the branch once and uses the
39
+ same commit for the Dashboard and generic runtime. Starting a new Deploy
40
+ Attempt resolves the branch again and can pick up a newer commit. The build logs
41
+ `Deployment platform SHA` alongside `Deployment Backend SHA`, which identifies
42
+ the revision supplying the AWS deployment code. To reproduce the public inputs
43
+ after the branch advances, keep `platformSource: "public"` and set `platformRef`
44
+ to the logged platform SHA.
636
45
 
637
- **Arguments:**
638
- - `org-path` — Path to the organisation directory (supports `PF_ORG` env var)
46
+ Omitting `platformSource` resolves `platformRef` in the private monorepo
47
+ (`processfocus/monorepo`). If the selected ref cannot be checked out, the
48
+ deployment stops without falling back to another source or to published packages.
639
49
 
640
- **Database path resolution:**
641
- - Uses `SQLITE_DATABASE_PATH` when set
642
- - Otherwise falls back to `<org-path>/db/pf.db`
50
+ Log in to the Console, choose a project and environment, then deploy:
643
51
 
644
- **Example:**
645
52
  ```bash
646
- pfcli get-frontend-jwt ./my-org
647
- PF_ORG=./my-org pfcli get-frontend-jwt
648
- ```
649
-
650
- ### `auth login`
651
-
652
- Login through the browser and store CLI credentials locally.
653
-
654
- ```bash
655
- BASE_URL=http://localhost:3000 pfcli auth login
53
+ pfcli auth login --base-url <console-origin>
54
+ pfcli projects
55
+ pfcli env list --project <project-number>
56
+ pfcli deploy ./my-org --project <project-number> --env <environment-name>
57
+ pfcli deploy status --project <project-number> --env <environment-name>
656
58
  ```
657
59
 
658
- **Environment:**
659
- - `BASE_URL` — Required. Frontend base URL used to start CLI auth flow
660
-
661
- Credentials are saved to `~/.config/pf/credentials.json`.
662
- The Dashboard hands credentials back through a state-protected localhost callback.
663
- Delegated sessions require clicking **Allow CLI access** in the Dashboard before
664
- export. Confirm only when you initiated CLI login and trust the local program.
665
- A failed or expired handoff exits with status 1 without replacing existing credentials.
666
- Missing, invalid, or nonpositive credential lifetimes are not accepted as success.
667
- The stored deadline is capped by the JWT's absolute expiry and is not extended
668
- while waiting for the browser launcher. Credentials that expire before callback
669
- receipt or storage are rejected. JWT decoding here is only an expiry hint; the
670
- API still verifies the credential and its current validity.
60
+ Deploy checks for an active Backend execution before building or uploading,
61
+ even with `--no-wait`. Ctrl-C stops waiting, not deployment. After an
62
+ interruption or timeout, run `pfcli deploy status` for the same project and
63
+ environment before retrying. Status reflects the Backend process execution,
64
+ not the underlying CodeBuild runner.
671
65
 
672
- ### `skills`
673
-
674
- Print agent-oriented guidance served by the installed `pfcli` version.
66
+ Configuration belongs to a project's stage. For example, to store an already
67
+ exported environment variable as a secret:
675
68
 
676
69
  ```bash
677
- pfcli skills list
678
- pfcli skills get core
70
+ pfcli config set --project <project-number> --stage <stage-name> API_TOKEN --secret
679
71
  ```
680
72
 
681
- **Behavior:**
682
- - `skills list` prints available skill names and descriptions
683
- - `skills get <name>` prints the matching operational guide as Markdown
684
- - Skill content is version-coupled to the executable, so agents should prefer it over stale cached examples
685
-
686
- ## Workflow
73
+ Redeploy after changing stage configuration. Use `logs` for runtime diagnostics
74
+ and `custom-domain` for certificate status and DNS records.
687
75
 
688
- Typical development workflow:
689
-
690
- ```bash
691
- # 0. (Optional) login from CLI first (stores ~/.config/pf/credentials.json)
692
- BASE_URL=http://localhost:3000 pfcli auth login
76
+ For GitHub Actions authentication, see
77
+ [project OIDC federation](../../docs/authentication/project-workloads.md).
78
+ Manage federated identities with `pfcli workload`; the command name and
79
+ `PFCLI_AUTH_MODE=github-workload` configuration remain unchanged.
693
80
 
694
- # 1. Scaffold a new organisation
695
- pfcli init ./my-org --email admin@example.com --identity-provider google
81
+ Use `pfcli workload save --environment <name>` when the GitHub Actions job
82
+ uses a GitHub Environment. Omit `--environment` to match jobs without one;
83
+ omitting it on an edit removes the previous setting. Adding, changing, or
84
+ removing the setting requires enrollment again. This does not change the
85
+ Process Focus deployment target selected by `pfcli deploy --env`.
696
86
 
697
- # 2. Edit source files (src/todo.ts, src/org.ts, etc.)
87
+ In GitHub workload mode, `deploy`, `db download`, `db upload`, `env add`, and
88
+ `destroy` request their corresponding machine permission. Grant each operation
89
+ on the enrolled project's workload. `PFCLI_WORKLOAD_PROVIDER_USER` is retired
90
+ and explicitly rejected.
91
+ Long-running commands exchange fresh GitHub assertions as needed. Failed
92
+ OIDC authentication never falls back to saved credentials or a client secret.
698
93
 
699
- # 3. (Optional) Re-import after source changes for local development
700
- pfcli import ./my-org
94
+ ## Databases and access
701
95
 
702
- # 4. Build the organisation
703
- pfcli build ./my-org
96
+ - `db download` creates a local copy; local edits do not update the hosted database.
97
+ - `db upload` replaces hosted data. Its default `data-copy` mode preserves the
98
+ destination's authentication identity; `exact-restore` also replaces authentication
99
+ state.
100
+ - `db shell` opens live read-write access using the external
101
+ [Turso CLI](https://docs.turso.tech/cli/installation). It requires Database Shell
102
+ permission. Its short-lived token may be visible in local process listings.
103
+ - `invitation` and `grant role` support operator bootstrap and access management.
104
+ Registration Links, recovery links and frontend JWTs are credentials; keep
105
+ their output private.
106
+ - `destroy` deletes a hosted environment and its AWS stacks and requires `--yes`.
704
107
 
705
- # 5. (Optional) Deploy built dist artifact
706
- pfcli deploy ./my-org --project <project-number> --env <environment-name>
707
-
708
- # 6. (Optional) fetch frontend JWT from DB
709
- pfcli get-frontend-jwt ./my-org
710
- ```
711
-
712
- ## Environment Variables
713
-
714
- | Variable | Description | Used By |
715
- |----------|-------------|---------|
716
- | `PF_ORG` | Default organisation directory path | `init`, `import`, `get-frontend-jwt` |
717
- | `SQLITE_DATABASE_PATH` | Database path override (otherwise defaults to `<org-path>/db/pf.db`) | `import`, `migrate`, `migrate-custom`, `get-frontend-jwt` |
718
- | `BASE_URL` | Frontend base URL for browser auth flow | `auth login` |
719
- | `PFCLI_CREDENTIALS_PATH` | Override credentials file path (test/dev only) | `auth login`, `deploy`, `db shell` |
720
- | `GRAPHQL_SERVER_URL` | Override GraphQL server URL for import-completed callback | `import` |
721
- | `INTERNAL_API_SECRET` | Optional callback secret header for internal import notification | `import` |
722
- | `OAUTH_ISSUER_URL` | Issuer URL used when creating frontend JWT during import | `import` |
723
- | `OAUTH_AUDIENCE` | Audience for generated frontend JWT (default `graphql-api`) | `import` |
724
- | `GOOGLE_CLIENT_ID` | Google OAuth client ID (in org.ts) | org template/runtime |
725
- | `GOOGLE_CLIENT_SECRET` | Google OAuth client secret (in org.ts) | org template/runtime |
726
- | `MY_EMAIL` | Admin email for initial invitation (in org.ts) | org template/runtime |
727
-
728
- ## Help
729
-
730
- Show help for any command:
108
+ ## Command help
731
109
 
732
110
  ```bash
733
111
  pfcli --help
734
- pfcli init --help
735
- pfcli build --help
112
+ pfcli deploy --help
113
+ pfcli deploy status --help
114
+ pfcli --completions bash
736
115
  ```
116
+
117
+ The package also includes a generated [command reference](dist/command-reference.md)
118
+ and [Usage spec](dist/pfcli.usage.kdl). These are created during the build and
119
+ shipped with the release.