@tiangong-lca/cli 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,14 +31,14 @@ checkPaths:
31
31
  - test/auth-identity*.test.ts
32
32
  - test/public-auth-identity-receipt.test.ts
33
33
  - test/lca-release*.test.ts
34
- lastReviewedAt: 2026-08-31
35
- lastReviewedCommit: 499c910d07bb6a5e2e1cd8e4403a5a617d4269bb
36
- lastReviewedNote: 'Reviewed for Issue #260: CLI 0.1.7 removes the password-equivalent API-key bootstrap and historical runner; OAuth or an explicit verified headless token is required for every user-authenticated remote command.'
34
+ lastReviewedAt: 2026-09-04
35
+ lastReviewedCommit: b15c074b1f10314e4835fd64cb7079c8aa9fec3d
36
+ lastReviewedNote: 'Reviewed for CLI #272: release-only 0.1.9 after support export #270; runtime, dependencies, lock bytes, public exports and publication mechanics are unchanged.'
37
37
  ---
38
38
 
39
39
  # TianGong LCA CLI
40
40
 
41
- Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.7` Node: `24.19.0`
41
+ Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.8` Node: `24.19.0`
42
42
 
43
43
  Repository development is single-track on pnpm `11.24.0` and TypeScript `7.0.2`. The published package remains a clean, package-manager-neutral consumer artifact: it contains runtime files only, not pnpm, TypeScript, Oxlint, tests, source-only tooling, or repository lockfiles.
44
44
 
@@ -104,7 +104,8 @@ One-off published run:
104
104
 
105
105
  ```bash
106
106
  pnpm dlx @tiangong-lca/cli@latest --help
107
- pnpm dlx @tiangong-lca/cli@latest doctor
107
+ pnpm dlx @tiangong-lca/cli@latest auth login
108
+ pnpm dlx @tiangong-lca/cli@latest auth doctor-auth --json
108
109
  pnpm dlx @tiangong-lca/cli@latest flow --help
109
110
  ```
110
111
 
@@ -113,7 +114,8 @@ Install the published CLI:
113
114
  ```bash
114
115
  pnpm add --global @tiangong-lca/cli
115
116
  tiangong-lca --help
116
- tiangong-lca doctor
117
+ tiangong-lca auth login
118
+ tiangong-lca auth doctor-auth --json
117
119
  tiangong-lca flow --help
118
120
  ```
119
121
 
@@ -138,12 +140,17 @@ The packed ESM, CJS dynamic-import, and TypeScript consumers exercise every publ
138
140
 
139
141
  ## Env
140
142
 
141
- Remote commands require:
143
+ Official Production requires **no environment setup**. Run `tiangong-lca auth login` from a trusted terminal and finish authorization in your browser. The CLI bundles the public Production project URL, publishable key, CLI OAuth client ID, registered loopback callback, and region as one profile in `src/lib/env.ts`. These are application configuration, not user credentials; no client secret is used. Skills and external consumers must reuse the CLI rather than copy this profile.
144
+
145
+ Before the first login, `auth status --json` and `auth doctor-auth --json` return `login-required` (exit 1), not a missing-client configuration error. `doctor --json` reports the public profile fields as `source: "default"`; this is configuration readiness, not proof of a logged-in user.
146
+
147
+ Only Dev, self-hosted, or a custom public client needs explicit configuration. Supply the complete matching tuple from that environment's administrator:
142
148
 
143
149
  ```bash
144
- TIANGONG_LCA_API_BASE_URL=
145
- TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY=
146
- TIANGONG_LCA_OAUTH_CLIENT_ID=
150
+ TIANGONG_LCA_API_BASE_URL=https://<your-project>.supabase.co/functions/v1
151
+ TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY=<that-project-publishable-key>
152
+ TIANGONG_LCA_OAUTH_CLIENT_ID=<that-project-registered-public-client-id>
153
+ TIANGONG_LCA_OAUTH_REDIRECT_URI=http://127.0.0.1:49191/oauth/callback
147
154
  TIANGONG_LCA_REGION=us-east-1
148
155
  ```
149
156
 
@@ -151,8 +158,10 @@ Notes:
151
158
 
152
159
  - `TIANGONG_LCA_API_BASE_URL` accepts the project root, `/functions/v1`, or `/rest/v1`.
153
160
  - `TIANGONG_LCA_OAUTH_CLIENT_ID` is the environment-specific registered public CLI client; it is not a secret.
161
+ - Blank public fields and the exact official Production URL aliases use the bundled profile. Any non-Production URL, client, key, or callback disables profile completion; incomplete custom configuration fails before browser/network access. An explicit custom URL cannot be combined with the known Production key or client. Changing `--base-url` also requires a matching complete environment.
154
162
  - Run `tiangong-lca auth login` once in a trusted terminal. All Edge Function and direct Supabase commands then reuse the OAuth access token and rotate the refresh token on demand.
155
- - For approved headless execution, set `TIANGONG_LCA_AUTH_MODE=access-token` and inject one short-lived `TIANGONG_LCA_ACCESS_TOKEN`. It is verified online, kept only in process memory, and never refreshed.
163
+ - For approved headless execution, explicitly set the destination `TIANGONG_LCA_API_BASE_URL`, its `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, and `TIANGONG_LCA_AUTH_MODE=access-token`, then inject one short-lived `TIANGONG_LCA_ACCESS_TOKEN`. A token alone never selects Production. It is verified online, kept only in process memory, and never refreshed.
164
+ - Bundled configuration does not enable implicit remote publishing. Local-first publish executor selection still requires explicit configured remote runtime; existing `--commit`, remote-lookup, identity, and approval gates are unchanged.
156
165
 
157
166
  Optional session control:
158
167
 
@@ -180,6 +189,16 @@ The callback URI must exactly match the URI registered with the selected Supabas
180
189
 
181
190
  Local logout does not revoke the server grant. To invalidate every refresh token for the CLI client, open Account → Connected applications and disconnect TianGong CLI.
182
191
 
192
+ ## Canonical support export
193
+
194
+ ```sh
195
+ tiangong-lca dataset support-cache export --out-dir ./new-support-export --expected-project-ref <project-ref> --expected-user-id <user-id> --json
196
+ ```
197
+
198
+ Export visible flow properties and unit groups through the CLI OAuth session. The default state filter is `100`; repeat `--state-code` to request other RLS-scoped states. The directory must be new. Two complete ordered reads must agree before private row files and an atomic `export-report.json` completion marker are published. The report includes identity, counts and file hashes; its observed stability is not a database transaction snapshot.
199
+
200
+ Limits are 100,000 rows per table, 1,000 pages per table scan, 8 MiB per response, 64 MiB total response bytes and a 120-second operation deadline. An incomplete or changed read fails without publishing a completion marker. Use a fresh directory for a new attempt; no business data is written.
201
+
183
202
  ## Auth Identity Receipt
184
203
 
185
204
  Use the identity receipt before a production-backed case or any later owner-draft write gate:
package/dist/src/cli.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { DotEnvLoadResult } from './lib/dotenv.js';
2
2
  import type { FetchLike } from './lib/http.js';
3
+ import { type RunDatasetSupportCacheExportOptions, type DatasetSupportCacheExportReport } from './lib/dataset-support-cache.js';
3
4
  import { inspectSupabaseAuthStatus, loginWithSupabaseOAuth, logoutSupabaseUserSession } from './lib/supabase-session.js';
4
5
  import { type AuthIdentityReceipt, type RunAuthIdentityReceiptOptions } from './lib/auth-identity-receipt.js';
5
6
  import { type LifecyclemodelAutoBuildReport, type RunLifecyclemodelAutoBuildOptions } from './lib/lifecyclemodel-auto-build.js';
@@ -68,6 +69,7 @@ import { runFlowIdentity } from './lib/dataset-maintenance-flow-identity-run.js'
68
69
  import { verifyFlowIdentity } from './lib/dataset-maintenance-flow-identity-verify.js';
69
70
  import { type DatasetSourceUploadAttachmentsReport, type RunDatasetSourceUploadAttachmentsOptions } from './lib/dataset-source-upload-attachments.js';
70
71
  export type CliDeps = {
72
+ runDatasetSupportCacheExportImpl?: (options: RunDatasetSupportCacheExportOptions) => Promise<DatasetSupportCacheExportReport>;
71
73
  env: NodeJS.ProcessEnv;
72
74
  dotEnvStatus: DotEnvLoadResult;
73
75
  fetchImpl: FetchLike;
package/dist/src/cli.js CHANGED
@@ -3,6 +3,7 @@ import { buildDoctorReport, readRuntimeEnv } from './lib/env.js';
3
3
  import { CliError, toErrorPayload } from './lib/errors.js';
4
4
  import { stringifyJson } from './lib/io.js';
5
5
  import { loadCliPackageVersion } from './lib/package-version.js';
6
+ import { runDatasetSupportCacheExport, } from './lib/dataset-support-cache.js';
6
7
  import { requireSupabaseRestRuntime } from './lib/supabase-client.js';
7
8
  import { inspectSupabaseAuthStatus, loginWithSupabaseOAuth, logoutSupabaseUserSession, } from './lib/supabase-session.js';
8
9
  import { OAUTH_LOGIN_TIMEOUT_MAX_MS } from './lib/oauth-loopback.js';
@@ -93,7 +94,7 @@ Implemented Commands:
93
94
  auth login | status | whoami | doctor-auth | logout | identity-receipt
94
95
  search flow | process | lifecyclemodel
95
96
  process get | list | identity-preflight | build-plan | scope-statistics | dedup-review | auto-build | resume-build | publish-build | complete-required-fields | save-draft | batch-build | refresh-references | verify-rows
96
- dataset contract get | context-pack | classification children/path/audit/apply | curation-queue build/next/verify | import-lca convert | author | patch apply | save-draft | source upload-attachments | validate | verify-remote | bilingual extract/apply/validate | evidence-search plan/run | references rewrite/refresh-remote | maintenance clear-account/plan/apply/verify/flow-identity
97
+ dataset support-cache export | contract get | context-pack | classification children/path/audit/apply | curation-queue build/next/verify | import-lca convert | author | patch apply | save-draft | source upload-attachments | validate | verify-remote | bilingual extract/apply/validate | evidence-search plan/run | references rewrite/refresh-remote | maintenance clear-account/plan/apply/verify/flow-identity
97
98
  flow get | list | identity-preflight | build-plan | fetch-rows | materialize-decisions | remediate | publish-version | publish-reviewed-data | build-alias-map | scan-process-flow-refs | plan-process-flow-repairs | apply-process-flow-repairs | regen-product | validate-processes
98
99
  lifecyclemodel auto-build | validate-build | publish-build | save-draft | graph | build-resulting-process | publish-resulting-process | orchestrate
99
100
  qa process | flow | lifecyclemodel
@@ -243,7 +244,8 @@ Options:
243
244
  --json Print compact JSON; default output is pretty JSON
244
245
  -h, --help
245
246
 
246
- Required env:
247
+ Official Production requires no environment configuration. Run auth login directly.
248
+ For a custom environment, configure its complete public tuple (never mix projects):
247
249
  TIANGONG_LCA_API_BASE_URL
248
250
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
249
251
  TIANGONG_LCA_OAUTH_CLIENT_ID
@@ -287,7 +289,8 @@ Safety:
287
289
  tokens, full email addresses, session paths, or credential-derived fingerprints. Production guards
288
290
  must pass both expected assertions and require assertions.mode="intent-bound".
289
291
 
290
- Required env:
292
+ Official Production uses the bundled public profile and a prior "tiangong-lca auth login".
293
+ For a custom environment, configure:
291
294
  TIANGONG_LCA_API_BASE_URL
292
295
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
293
296
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
@@ -323,7 +326,8 @@ Options:
323
326
  --timeout-ms <n> Request timeout in milliseconds
324
327
  -h, --help
325
328
 
326
- Required env:
329
+ Official Production: run "tiangong-lca auth login" with no env setup.
330
+ Custom environment (complete matching tuple required):
327
331
  TIANGONG_LCA_API_BASE_URL
328
332
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
329
333
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
@@ -345,7 +349,8 @@ Options:
345
349
  --timeout-ms <n> Request timeout in milliseconds
346
350
  -h, --help
347
351
 
348
- Required env:
352
+ Official Production: run "tiangong-lca auth login" with no env setup.
353
+ Custom environment (complete matching tuple required):
349
354
  TIANGONG_LCA_API_BASE_URL
350
355
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
351
356
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
@@ -388,7 +393,8 @@ Options:
388
393
  --timeout-ms <n> Request timeout in milliseconds (default 60000)
389
394
  -h, --help
390
395
 
391
- Required environment:
396
+ Official Production: run "tiangong-lca auth login" with no env setup.
397
+ Custom environment (complete matching tuple required):
392
398
  TIANGONG_LCA_API_BASE_URL
393
399
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
394
400
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
@@ -445,6 +451,7 @@ function renderDatasetHelp() {
445
451
  tiangong-lca dataset <subcommand> [options]
446
452
 
447
453
  Implemented Subcommands:
454
+ support-cache export Export complete observed canonical support rows through OAuth
448
455
  contract get Write TIDAS schema / methodology / ruleset contract artifacts
449
456
  context-pack Write an AI-ready TIDAS contract context pack
450
457
  classification Navigate bundled TIDAS classification schemas or apply selected classifications
@@ -1049,7 +1056,7 @@ Options:
1049
1056
  -h, --help
1050
1057
 
1051
1058
  Environment:
1052
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1059
+ Official Production profile (no env setup), or a complete custom URL/key/client; prior auth login
1053
1060
 
1054
1061
  Outputs written under --out-dir:
1055
1062
  - outputs/remote-verification-report.json
@@ -1265,7 +1272,7 @@ Options:
1265
1272
 
1266
1273
  Environment:
1267
1274
  none for local dry-run
1268
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1275
+ Official Production profile (no env setup), or a complete custom URL/key/client; prior auth login
1269
1276
  when --commit executes remote writes
1270
1277
 
1271
1278
  Outputs written under --out-dir:
@@ -1379,7 +1386,8 @@ Options:
1379
1386
  --json Print compact JSON
1380
1387
  -h, --help
1381
1388
 
1382
- Required env:
1389
+ Official Production: run "tiangong-lca auth login" with no env setup.
1390
+ Custom environment (complete matching tuple required):
1383
1391
  TIANGONG_LCA_API_BASE_URL
1384
1392
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1385
1393
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1407,7 +1415,8 @@ Options:
1407
1415
  --json Print compact JSON
1408
1416
  -h, --help
1409
1417
 
1410
- Required env:
1418
+ Official Production: run "tiangong-lca auth login" with no env setup.
1419
+ Custom environment (complete matching tuple required):
1411
1420
  TIANGONG_LCA_API_BASE_URL
1412
1421
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1413
1422
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1448,7 +1457,8 @@ Options:
1448
1457
  --json Print compact JSON
1449
1458
  -h, --help
1450
1459
 
1451
- Required env:
1460
+ Official Production: run "tiangong-lca auth login" with no env setup.
1461
+ Custom environment (complete matching tuple required):
1452
1462
  TIANGONG_LCA_API_BASE_URL
1453
1463
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1454
1464
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1495,7 +1505,8 @@ Options:
1495
1505
  --json Print compact JSON
1496
1506
  -h, --help
1497
1507
 
1498
- Environment:
1508
+ Official Production: run "tiangong-lca auth login" with no env setup.
1509
+ Custom environment (complete matching tuple required):
1499
1510
  TIANGONG_LCA_API_BASE_URL
1500
1511
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1501
1512
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1527,7 +1538,7 @@ Options:
1527
1538
 
1528
1539
  Environment:
1529
1540
  none for local dry-run
1530
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1541
+ Official Production profile (no env setup), or a complete custom URL/key/client; prior auth login
1531
1542
  when --commit publishes prepared rows
1532
1543
 
1533
1544
  Outputs written under --out-dir:
@@ -1761,6 +1772,8 @@ Options:
1761
1772
  -h, --help
1762
1773
 
1763
1774
  Remote lookup env (only when process_sources.allow_remote_lookup=true):
1775
+ Official Production uses its bundled profile and a prior "tiangong-lca auth login".
1776
+ A custom environment requires the complete matching tuple:
1764
1777
  TIANGONG_LCA_API_BASE_URL
1765
1778
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1766
1779
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1792,7 +1805,7 @@ Options:
1792
1805
 
1793
1806
  Environment:
1794
1807
  none for local dry-run
1795
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1808
+ Official Production profile (no env setup), or a complete custom URL/key/client; prior auth login
1796
1809
  when --commit executes remote writes
1797
1810
 
1798
1811
  Local gate:
@@ -1956,7 +1969,8 @@ Options:
1956
1969
  --json Print compact JSON
1957
1970
  -h, --help
1958
1971
 
1959
- Required env:
1972
+ Official Production: run "tiangong-lca auth login" with no env setup.
1973
+ Custom environment (complete matching tuple required):
1960
1974
  TIANGONG_LCA_API_BASE_URL
1961
1975
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1962
1976
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -1983,7 +1997,8 @@ Options:
1983
1997
  --json Print compact JSON
1984
1998
  -h, --help
1985
1999
 
1986
- Required env:
2000
+ Official Production: run "tiangong-lca auth login" with no env setup.
2001
+ Custom environment (complete matching tuple required):
1987
2002
  TIANGONG_LCA_API_BASE_URL
1988
2003
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1989
2004
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -2135,7 +2150,7 @@ Options:
2135
2150
 
2136
2151
  Environment:
2137
2152
  none for local dry-run
2138
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
2153
+ Official Production profile (no env setup), or a complete custom URL/key/client; prior auth login
2139
2154
  when --commit executes remote writes
2140
2155
 
2141
2156
  Local gate:
@@ -2189,7 +2204,8 @@ Options:
2189
2204
  --json Print compact JSON
2190
2205
  -h, --help
2191
2206
 
2192
- Required env:
2207
+ Official Production: run "tiangong-lca auth login" with no env setup.
2208
+ Custom environment (complete matching tuple required):
2193
2209
  TIANGONG_LCA_API_BASE_URL
2194
2210
  TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
2195
2211
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
@@ -6307,6 +6323,46 @@ export async function executeCli(argv, deps) {
6307
6323
  stderr: '',
6308
6324
  };
6309
6325
  }
6326
+ if (command === 'dataset' && subcommand === 'support-cache') {
6327
+ const help = 'Usage: tiangong-lca dataset support-cache export --out-dir <fresh-dir> [--state-code <int>] [--page-size <1..5000>] [--timeout-ms <1..120000>] [--expected-project-ref <ref>] [--expected-user-id <uuid>] [--json]';
6328
+ const action = commandArgs[0];
6329
+ if (!action || action === '--help' || action === '-h')
6330
+ return { exitCode: 0, stdout: help + '\n', stderr: '' };
6331
+ if (action !== 'export')
6332
+ throw new CliError('dataset support-cache action must be export.', {
6333
+ code: 'DATASET_SUPPORT_CACHE_ACTION_INVALID',
6334
+ exitCode: 2,
6335
+ });
6336
+ const { values } = parseArgs({
6337
+ args: commandArgs.slice(1),
6338
+ strict: true,
6339
+ allowPositionals: false,
6340
+ options: {
6341
+ 'out-dir': { type: 'string' },
6342
+ 'state-code': { type: 'string', multiple: true },
6343
+ 'page-size': { type: 'string' },
6344
+ 'timeout-ms': { type: 'string' },
6345
+ 'expected-project-ref': { type: 'string' },
6346
+ 'expected-user-id': { type: 'string' },
6347
+ json: { type: 'boolean' },
6348
+ help: { type: 'boolean', short: 'h' },
6349
+ },
6350
+ });
6351
+ if (values.help)
6352
+ return { exitCode: 0, stdout: help + '\n', stderr: '' };
6353
+ const report = await (deps.runDatasetSupportCacheExportImpl ?? runDatasetSupportCacheExport)({
6354
+ outDir: values['out-dir'] ?? '',
6355
+ env: deps.env,
6356
+ fetchImpl: deps.fetchImpl,
6357
+ cliVersion: loadCliPackageVersion(import.meta.url),
6358
+ stateCodes: values['state-code']?.map((value) => value.trim() ? Number(value) : Number.NaN),
6359
+ pageSize: values['page-size'] === undefined ? undefined : Number(values['page-size']),
6360
+ timeoutMs: values['timeout-ms'] === undefined ? undefined : Number(values['timeout-ms']),
6361
+ expectedProjectRef: values['expected-project-ref'],
6362
+ expectedUserId: values['expected-user-id'],
6363
+ });
6364
+ return { exitCode: 0, stdout: stringifyJson(report, values.json ?? false), stderr: '' };
6365
+ }
6310
6366
  if (command === 'dataset' && subcommand === 'verify-remote') {
6311
6367
  const datasetFlags = parseDatasetRemoteVerifyFlags(commandArgs);
6312
6368
  if (datasetFlags.help) {