@tiangong-lca/cli 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,146 +1,58 @@
1
1
  # TianGong LCA CLI
2
2
 
3
- `tiangong-lca-cli` is the unified TianGong command-line entrypoint.
3
+ Package: `@tiangong-lca/cli` Executable: `tiangong` Node: `24.x`
4
4
 
5
- Current implementation choices:
5
+ ## Run
6
6
 
7
- - TypeScript on Node 24
8
- - ship built JavaScript artifacts from `dist/`
9
- - direct REST / Edge Function calls instead of MCP
10
- - file-first input and JSON-first output
11
- - one stable command surface for humans, agents, CI, and skills
12
- - explicit npm production runtime dependencies only where they reduce long-term maintenance risk: native `@supabase/supabase-js` and direct `@tiangong-lca/tidas-sdk`
13
-
14
- ## MCP replacement policy
15
-
16
- The CLI replaces MCP with two explicit strategies:
17
-
18
- - strategy 1: call domain APIs directly through `tiangong-lca-edge-functions` (Edge Functions / REST)
19
- - strategy 2: access Supabase directly without MCP through the native `@supabase/supabase-js` client, while keeping deterministic query semantics and stable artifact/report contracts inside the CLI
20
-
21
- This prevents reintroducing a generic MCP transport layer into the CLI runtime.
22
-
23
- ## Implemented commands
24
-
25
- - `tiangong doctor`
26
- - `tiangong search flow`
27
- - `tiangong search process`
28
- - `tiangong search lifecyclemodel`
29
- - `tiangong process get`
30
- - `tiangong process auto-build`
31
- - `tiangong process resume-build`
32
- - `tiangong process publish-build`
33
- - `tiangong process batch-build`
34
- - `tiangong lifecyclemodel auto-build`
35
- - `tiangong lifecyclemodel validate-build`
36
- - `tiangong lifecyclemodel publish-build`
37
- - `tiangong lifecyclemodel build-resulting-process`
38
- - `tiangong lifecyclemodel publish-resulting-process`
39
- - `tiangong lifecyclemodel orchestrate`
40
- - `tiangong review process`
41
- - `tiangong review flow`
42
- - `tiangong review lifecyclemodel`
43
- - `tiangong flow get`
44
- - `tiangong flow list`
45
- - `tiangong flow remediate`
46
- - `tiangong flow publish-version`
47
- - `tiangong flow publish-reviewed-data`
48
- - `tiangong flow build-alias-map`
49
- - `tiangong flow scan-process-flow-refs`
50
- - `tiangong flow plan-process-flow-repairs`
51
- - `tiangong flow apply-process-flow-repairs`
52
- - `tiangong flow regen-product`
53
- - `tiangong flow validate-processes`
54
- - `tiangong publish run`
55
- - `tiangong validation run`
56
- - `tiangong admin embedding-run`
57
-
58
- ## Remaining planned command surface
59
-
60
- The remaining planned placeholders in the documented surface are now limited to `auth *` and `job *`.
61
-
62
- The stable launcher is `bin/tiangong.js`. It loads the compiled runtime at `dist/src/main.js`, while `npm start -- ...` rebuilds and dogfoods the same launcher path.
63
-
64
- ## Quality gate
65
-
66
- The repository enforces:
67
-
68
- - `npm run lint`
69
- - `npm run prettier`
70
- - `npm test`
71
- - `npm run test:coverage`
72
- - `npm run test:coverage:assert-full`
73
- - `npm run prepush:gate`
74
-
75
- `npm run lint` is the required local gate. It runs `eslint`, deprecated API diagnostics, `prettier --check`, a coverage-ignore guard, and `tsc`. Coverage is enforced at 100% for `src/**/*.ts`. Launcher smoke tests remain in the normal test suite, and coverage-ignore pragmas are forbidden as a substitute for test coverage.
76
-
77
- ## Releases
78
-
79
- The public npm package name for this repository is `@tiangong-lca/cli`.
80
-
81
- Normal releases are tag-driven and published by GitHub Actions:
82
-
83
- - open a release-prep PR from `main`
84
- - bump only the CLI package version in `package.json`
85
- - after merge, `.github/workflows/tag-release-from-merge.yml` creates `cli-vX.Y.Z`
86
- - `.github/workflows/publish.yml` publishes from that immutable tag through npm Trusted Publishing
87
-
88
- One-time repository and npm Trusted Publisher setup lives in [docs/release-setup.md](./docs/release-setup.md).
89
-
90
- ## Quick start
91
-
92
- Install Node.js `24.x` with any platform-native path you already use. The CLI only requires a working Node 24 runtime; it does not depend on `bash`, `nvm`, or other Unix-only setup tools. Examples that work well:
93
-
94
- - Windows: the official Node.js `24.x` installer
95
- - macOS: the official Node.js `24.x` installer, `fnm`, or `nvm`
96
- - Linux: your preferred Node 24 package/install method
7
+ Use the published CLI directly:
97
8
 
98
9
  ```bash
99
- npm ci
100
- npm run build
10
+ npx -y @tiangong-lca/cli@latest --help
11
+ npx -y @tiangong-lca/cli@latest doctor
12
+ npx -y @tiangong-lca/cli@latest flow --help
101
13
  ```
102
14
 
103
- Once the package is published, install it with:
15
+ Optional global install:
104
16
 
105
17
  ```bash
106
18
  npm install --global @tiangong-lca/cli
19
+ tiangong --help
107
20
  ```
108
21
 
109
- Initialize `.env` by duplicating `.env.example` to `.env` with your editor or file manager. Any equivalent copy action is fine on macOS, Linux, or Windows.
110
-
111
- Recommended cross-platform launchers:
112
-
113
- - `npm exec tiangong -- ...`
114
- - `node ./bin/tiangong.js ...`
115
- - `node ./dist/src/main.js ...`
116
-
117
- `npm start -- ...` is still available for local CLI development, but it is a rebuild-and-run convenience wrapper rather than the canonical public entrypoint.
118
-
119
- Repository-local quality gate:
22
+ Run from this repository:
120
23
 
121
24
  ```bash
122
- npm run lint
123
- npm test
124
- npm run test:coverage
125
- npm run test:coverage:assert-full
126
- npm run prepush:gate
25
+ npm ci
26
+ npm run build
27
+ node ./bin/tiangong.js --help
127
28
  ```
128
29
 
129
- Current public CLI env contract:
30
+ ## Env
31
+
32
+ Remote commands require:
130
33
 
131
34
  ```bash
132
35
  TIANGONG_LCA_API_BASE_URL=
133
36
  TIANGONG_LCA_API_KEY=
134
- TIANGONG_LCA_REGION=us-east-1
135
37
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY=
38
+ TIANGONG_LCA_REGION=us-east-1
39
+ ```
40
+
41
+ Notes:
42
+
43
+ - `TIANGONG_LCA_API_BASE_URL` accepts the project root, `/functions/v1`, or `/rest/v1`.
44
+ - `TIANGONG_LCA_API_KEY` is the TianGong user API key from the account page, not a Supabase project key.
45
+ - The CLI exchanges `TIANGONG_LCA_API_KEY` for a user session, then reuses the access token for both Edge Functions and direct Supabase access.
46
+
47
+ Optional session control:
48
+
49
+ ```bash
136
50
  TIANGONG_LCA_SESSION_FILE=
137
51
  TIANGONG_LCA_DISABLE_SESSION_CACHE=false
138
52
  TIANGONG_LCA_FORCE_REAUTH=false
139
53
  ```
140
54
 
141
- `TIANGONG_LCA_API_KEY` is the TianGong user API key generated from the account page, not a Supabase project key. The CLI uses it only as a bootstrap credential, exchanges it for a user session with `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, then reuses the resolved access token for both Edge Functions and direct Supabase access.
142
-
143
- Optional review-only env block: ignore it unless `tiangong review process --enable-llm` or `tiangong review flow --enable-llm` is enabled. `TIANGONG_LCA_REVIEW_LLM_BASE_URL` must point to an OpenAI-compatible Responses API base URL; the CLI calls `<base_url>/responses`.
55
+ Optional LLM review env, only for `review process --enable-llm` or `review flow --enable-llm`:
144
56
 
145
57
  ```bash
146
58
  TIANGONG_LCA_REVIEW_LLM_BASE_URL=
@@ -148,221 +60,131 @@ TIANGONG_LCA_REVIEW_LLM_API_KEY=
148
60
  TIANGONG_LCA_REVIEW_LLM_MODEL=
149
61
  ```
150
62
 
151
- Internal/preparatory env surface already normalized in the repo, but not consumed by any current public `tiangong` command:
63
+ ## Search
152
64
 
153
- ```bash
154
- TIANGONG_LCA_KB_SEARCH_API_BASE_URL=
155
- TIANGONG_LCA_KB_SEARCH_API_KEY=
156
- TIANGONG_LCA_KB_SEARCH_REGION=us-east-1
157
-
158
- TIANGONG_LCA_UNSTRUCTURED_API_BASE_URL=
159
- TIANGONG_LCA_UNSTRUCTURED_API_KEY=
160
- TIANGONG_LCA_UNSTRUCTURED_PROVIDER=
161
- TIANGONG_LCA_UNSTRUCTURED_MODEL=
162
- TIANGONG_LCA_UNSTRUCTURED_CHUNK_TYPE=false
163
- TIANGONG_LCA_UNSTRUCTURED_RETURN_TXT=true
65
+ Minimal `search flow` request:
66
+
67
+ ```json
68
+ {
69
+ "query": "soda lime glass",
70
+ "filter": {
71
+ "flowType": "Product flow"
72
+ }
73
+ }
164
74
  ```
165
75
 
166
- No extra generic `SUPABASE_URL`, `SUPABASE_KEY`, or `TIANGONG_LCA_TIDAS_SDK_DIR` env is required. The CLI derives the native `@supabase/supabase-js` client from `TIANGONG_LCA_API_BASE_URL`, bootstraps the user session from `TIANGONG_LCA_API_KEY` plus `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, and loads `@tiangong-lca/tidas-sdk` directly from `package.json` dependencies.
167
-
168
- Command-level env reality:
169
-
170
- | Command group | Required env |
171
- | --- | --- |
172
- | `doctor` | none |
173
- | `search *` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, optional `TIANGONG_LCA_REGION` |
174
- | `admin embedding-run` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, optional `TIANGONG_LCA_REGION` |
175
- | `process get` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` |
176
- | `process auto-build` | none |
177
- | `process resume-build` | none |
178
- | `process publish-build` | none |
179
- | `process batch-build` | none |
180
- | `lifecyclemodel auto-build` | none |
181
- | `lifecyclemodel validate-build` | none |
182
- | `lifecyclemodel publish-build` | none |
183
- | `lifecyclemodel orchestrate` | none |
184
- | `lifecyclemodel build-resulting-process` | none for local-only runs; `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, and `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` when `process_sources.allow_remote_lookup=true` |
185
- | `lifecyclemodel publish-resulting-process` | none |
186
- | `review process` | none for rule-only review; optional `TIANGONG_LCA_REVIEW_LLM_BASE_URL`, `TIANGONG_LCA_REVIEW_LLM_API_KEY`, and `TIANGONG_LCA_REVIEW_LLM_MODEL` when `--enable-llm` is set |
187
- | `review flow` | none for rule-only review; optional `TIANGONG_LCA_REVIEW_LLM_BASE_URL`, `TIANGONG_LCA_REVIEW_LLM_API_KEY`, and `TIANGONG_LCA_REVIEW_LLM_MODEL` when `--enable-llm` is set |
188
- | `review lifecyclemodel` | none |
189
- | `flow get` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` |
190
- | `flow list` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` |
191
- | `flow remediate` | none |
192
- | `flow publish-version` | `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` |
193
- | `flow publish-reviewed-data` | none for local dry-run; `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, and `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY` when `--commit` publishes prepared flow/process rows |
194
- | `flow build-alias-map` | none |
195
- | `flow scan-process-flow-refs` | none |
196
- | `flow plan-process-flow-repairs` | none |
197
- | `flow apply-process-flow-repairs` | none |
198
- | `flow regen-product` | none |
199
- | `flow validate-processes` | none |
200
- | `publish run` | none |
201
- | `validation run` | none |
202
-
203
- This CLI does not currently require KB, TianGong unstructured service, MCP, or `OPENAI_*` env keys for any public command. Optional semantic review now goes through the review-only `TIANGONG_LCA_REVIEW_LLM_*` keys instead of legacy provider-specific names. Those variables are optional as a block and only apply when `--enable-llm` is set on supported review commands. The repo already contains internal helper modules for KB and TianGong unstructured integrations; their env keys are listed in `.env.example` as internal/preparatory only, not as a public command contract.
204
-
205
- Run the CLI:
76
+ Run:
206
77
 
207
78
  ```bash
208
- npm exec tiangong -- --help
209
- npm exec tiangong -- doctor
210
- npm exec tiangong -- doctor --json
211
- npm exec tiangong -- search flow --input ./request.json --dry-run
212
- npm exec tiangong -- process get --id <process-id> --version <version> --json
213
- npm exec tiangong -- process auto-build --input ./examples/process-auto-build.request.json --json
214
- npm exec tiangong -- process resume-build --run-id <run-id> --json
215
- npm exec tiangong -- process publish-build --run-id <run-id> --json
216
- npm exec tiangong -- process batch-build --input ./examples/process-batch-build.request.json --json
217
- npm exec tiangong -- lifecyclemodel auto-build --input ./examples/lifecyclemodel-auto-build.request.json --json
218
- npm exec tiangong -- lifecyclemodel validate-build --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --json
219
- npm exec tiangong -- lifecyclemodel publish-build --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --json
220
- npm exec tiangong -- lifecyclemodel orchestrate plan --input ./lifecyclemodel-orchestrate.request.json --out-dir ./artifacts/lifecyclemodel_recursive/<run_id> --json
221
- npm exec tiangong -- lifecyclemodel build-resulting-process --input ./request.json --json
222
- npm exec tiangong -- lifecyclemodel publish-resulting-process --run-dir ./runs/example --publish-processes --publish-relations --json
223
- npm exec tiangong -- review process --run-root ./artifacts/process_from_flow/<run_id> --run-id <run_id> --out-dir ./review --json
224
- npm exec tiangong -- review flow --rows-file ./flows.json --out-dir ./flow-review --json
225
- npm exec tiangong -- review lifecyclemodel --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --out-dir ./lifecyclemodel-review --json
226
- npm exec tiangong -- flow get --id <flow-id> --version <version> --json
227
- npm exec tiangong -- flow list --id <flow-id> --state-code 100 --limit 20 --json
228
- npm exec tiangong -- flow remediate --input-file ./invalid-flows.jsonl --out-dir ./flow-remediation --json
229
- npm exec tiangong -- flow publish-version --input-file ./ready-flows.jsonl --out-dir ./flow-publish --dry-run --json
230
- npm exec tiangong -- flow publish-reviewed-data --flow-rows-file ./reviewed-flows.jsonl --original-flow-rows-file ./original-flows.jsonl --out-dir ./flow-publish-reviewed --dry-run --json
231
- npm exec tiangong -- flow build-alias-map --old-flow-file ./old-flows.jsonl --new-flow-file ./new-flows.jsonl --out-dir ./flow-alias-map --json
232
- npm exec tiangong -- flow scan-process-flow-refs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-scan --json
233
- npm exec tiangong -- flow plan-process-flow-repairs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --scan-findings ./flow-scan/scan-findings.json --out-dir ./flow-repair-plan --json
234
- npm exec tiangong -- flow apply-process-flow-repairs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --scan-findings ./flow-scan/scan-findings.json --out-dir ./flow-repair-apply --json
235
- npm exec tiangong -- flow regen-product --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-regen --apply --json
236
- npm exec tiangong -- flow validate-processes --original-processes-file ./before.jsonl --patched-processes-file ./after.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-validate --json
237
- npm exec tiangong -- publish run --input ./examples/publish-run.request.json --dry-run
238
- npm exec tiangong -- validation run --input-dir ./tidas-package --engine auto
239
- npm exec tiangong -- admin embedding-run --input ./jobs.json --dry-run
79
+ npx -y @tiangong-lca/cli@latest search flow --input ./search-flow.request.json --json
80
+ npx -y @tiangong-lca/cli@latest search process --input ./search-process.request.json --json
81
+ npx -y @tiangong-lca/cli@latest search lifecyclemodel --input ./search-lifecyclemodel.request.json --json
240
82
  ```
241
83
 
242
- ## Process build scaffold
243
-
244
- `tiangong process get` is the CLI-owned read-only process detail surface. It derives a deterministic Supabase read target from `TIANGONG_LCA_API_BASE_URL`, executes through the native `@supabase/supabase-js` client, resolves one process row by `id/version` with a latest-version fallback, and returns one structured JSON payload without reintroducing MCP, Python, or a generic transport layer.
245
-
246
- `tiangong process auto-build` is the first migrated `process_from_flow` slice. It reads one request JSON from `--input`, loads the referenced ILCD flow dataset from `flow_file`, preserves the old run id contract (`pfw_<flow_code>_<flow_uuid8>_<operation>_<UTC_TIMESTAMP>`), and writes a local run scaffold under `artifacts/process_from_flow/<run_id>/` or `--out-dir`.
247
-
248
- The command keeps the legacy per-run layout that later stages still expect, including `input/`, `exports/processes/`, `exports/sources/`, `cache/process_from_flow_state.json`, and `cache/agent_handoff_summary.json`. It also adds CLI-owned manifests such as the normalized request snapshot, flow summary, assembly plan, lineage manifest, invocation index, run manifest, and a compact report artifact.
249
-
250
- `tiangong process resume-build` is the second migrated `process_from_flow` slice. It reopens one existing local run by `--run-id` or `--run-dir`, validates the required run artifacts, takes the local state lock, clears any persisted `stop_after` checkpoint, records `resume-metadata.json` and `resume-history.jsonl`, updates `invocation-index.json`, rewrites `agent_handoff_summary.json`, and emits `process-resume-build-report.json`.
251
-
252
- `tiangong process publish-build` is the third migrated `process_from_flow` slice. It reopens one existing local run by `--run-id` or `--run-dir`, validates `process_from_flow_state.json`, `agent_handoff_summary.json`, `run-manifest.json`, and `invocation-index.json`, collects canonical process/source datasets from `exports/` or state fallbacks, writes `stage_outputs/10_publish/publish-bundle.json`, `publish-request.json`, `publish-intent.json`, rewrites `agent_handoff_summary.json`, updates the run state and invocation index, and emits `process-publish-build-report.json`.
253
-
254
- `tiangong process batch-build` is the fourth migrated `process_from_flow` slice. It reads one batch manifest, prepares a self-contained batch root, fans out multiple local `process auto-build` runs through the CLI-owned contract, writes a structured per-item aggregate report, and preserves deterministic item-level artifact paths for downstream `resume-build` or `publish-build` steps.
255
-
256
- `resume-build`, `publish-build`, and `batch-build` all still stop at local handoff boundaries. They do not execute remote publish CRUD or commit mode themselves; that boundary remains in `tiangong publish run`.
257
-
258
- `tiangong lifecyclemodel auto-build` is the first migrated `lifecyclemodel_automated_builder` slice. It reads one local-run manifest from `--input`, resolves one or more `process-automated-builder` run directories, infers the process graph from shared flow UUIDs, chooses one reference process, computes `@multiplicationFactor`, writes native `json_ordered` lifecyclemodel datasets plus `run-plan.json`, `resolved-manifest.json`, `selection/selection-brief.md`, `discovery/reference-model-summary.json`, `models/**/summary.json`, `connections.json`, and `process-catalog.json`, and keeps the run local-only and read-only.
259
-
260
- The canonical `tiangong-lca-skills/lifecyclemodel-automated-builder` entrypoint now uses a native Node `.mjs` wrapper that delegates directly to `tiangong lifecyclemodel auto-build`. The canonical build path no longer routes through Bash, Python, or MCP.
261
-
262
- `tiangong lifecyclemodel validate-build` is the second migrated `lifecyclemodel_automated_builder` slice. It reopens one existing local lifecyclemodel build run by `--run-dir`, scans `models/*/tidas_bundle/lifecyclemodels/*.json`, runs the unified validation module against each model bundle, writes per-model reports under `reports/model-validations/`, updates `manifests/invocation-index.json`, and emits `reports/lifecyclemodel-validate-build-report.json`.
263
-
264
- `tiangong lifecyclemodel publish-build` is the third migrated `lifecyclemodel_automated_builder` slice. It reopens one existing local lifecyclemodel build run by `--run-dir`, collects native lifecyclemodel payloads from `models/*/tidas_bundle/lifecyclemodels/*.json`, reads the aggregate validation summary when present, writes `stage_outputs/10_publish/publish-bundle.json`, `publish-request.json`, and `publish-intent.json`, updates `manifests/invocation-index.json`, and emits `reports/lifecyclemodel-publish-build-report.json`.
265
-
266
- The current lifecyclemodel build family intentionally keeps three boundaries out of the auto-build slice:
267
-
268
- - no remote lifecyclemodel CRUD
269
- - no reference-model discovery against MCP / KB / LLM services
270
- - no automatic chaining into validate-build or publish-build
271
-
272
- `tiangong lifecyclemodel build-resulting-process` remains local-first, but it no longer hard-fails when a request explicitly enables `process_sources.allow_remote_lookup`. In that mode the CLI derives a deterministic Supabase read target from `TIANGONG_LCA_API_BASE_URL`, resolves missing process datasets by exact `id/version` with a latest-version fallback through the native `@supabase/supabase-js` client, and keeps the same local artifact contract instead of routing through MCP or semantic search.
273
-
274
- `tiangong lifecyclemodel orchestrate` is the native recursive assembly command for multi-node product-system runs. `plan` writes `assembly-plan.json`, `graph-manifest.json`, `lineage-manifest.json`, and `boundary-report.json`; `execute` invokes only native CLI-backed builder slices and records per-invocation results under `invocations/`; `publish` reopens one orchestrator run and prepares `publish-bundle.json` plus `publish-summary.json` from prior local artifacts. The `process_builder` request surface is now intentionally narrow: only CLI-native local-build fields are accepted, and extra builder knobs are rejected during request normalization.
275
-
276
- `tiangong review process` is the first migrated review slice. It reopens one local `process_from_flow` run under `exports/processes/`, replays the existing artifact-first review contract, writes bilingual markdown findings plus structured JSON reports, and keeps optional semantic review behind the CLI-owned `TIANGONG_LCA_REVIEW_LLM_*` abstraction instead of direct `OPENAI_*` calls in a skill script.
277
-
278
- `tiangong review flow` is the flow-side local governance review slice. It accepts exactly one of `--rows-file`, `--flows-dir`, or `--run-root`, materializes explicit local flow snapshots when needed, writes `rule_findings.jsonl`, `llm_findings.jsonl`, `findings.jsonl`, `flow_summaries.jsonl`, `similarity_pairs.jsonl`, `flow_review_summary.json`, `flow_review_zh.md`, `flow_review_en.md`, `flow_review_timing.md`, and `flow_review_report.json`, and keeps optional semantic review behind the same CLI-owned `TIANGONG_LCA_REVIEW_LLM_*` abstraction. The current CLI slice is intentionally local-first and does not implement `--with-reference-context` or local registry enrichment yet.
279
-
280
- `tiangong review lifecyclemodel` is the lifecyclemodel-side local review slice. It reopens one existing lifecyclemodel build run by `--run-dir`, scans `models/*/tidas_bundle/lifecyclemodels/*.json`, reuses `summary.json`, `connections.json`, `process-catalog.json`, and the aggregate `reports/lifecyclemodel-validate-build-report.json` when present, writes `model_summaries.jsonl`, `findings.jsonl`, `lifecyclemodel_review_summary.json`, `lifecyclemodel_review_zh.md`, `lifecyclemodel_review_en.md`, `lifecyclemodel_review_timing.md`, and `lifecyclemodel_review_report.json`, and stays local-first without introducing Python, LangGraph, or skill-local review runtimes.
281
-
282
- `tiangong flow get` is the CLI-owned read-only flow detail surface. It derives a deterministic Supabase read target from `TIANGONG_LCA_API_BASE_URL`, resolves one visible flow row by `id` plus optional `version` / `user_id` / `state_code` through the native `@supabase/supabase-js` client, falls back to the latest visible version when an exact version lookup misses, and rejects ambiguous visible matches instead of guessing.
84
+ Empty search results should be treated as empty whether the response is `[]` or `{"data":[]}`.
283
85
 
284
- `tiangong flow list` is the CLI-owned deterministic flow enumeration surface. It queries `flows` through the native `@supabase/supabase-js` client while preserving stable `/rest/v1/flows` filter semantics such as repeated `--id`, `--state-code`, and `--type-of-dataset`, defaults to `order=id.asc,version.asc`, and can fetch all matching rows through explicit offset pagination via `--all --page-size <n>` without reintroducing MCP or skill-local transport code.
86
+ ## Read
285
87
 
286
- `tiangong flow remediate` is the first CLI-owned remediation slice for flow governance. It reads one invalid-flow JSON or JSONL input, applies deterministic round1 local remediation, and writes the historical remediation artifacts under one output directory without reintroducing Python or MCP.
287
-
288
- `tiangong flow publish-version` is the first CLI-owned remote write slice for flow governance. It reads one ready-for-publish JSON or JSONL input, derives a deterministic Supabase write target from `TIANGONG_LCA_API_BASE_URL`, performs dry-run or commit mode through the native `@supabase/supabase-js` client against `/rest/v1/flows`, and preserves the historical success-list, remote-failure, and sync-report artifact names for downstream follow-up. It still does not implement round2 retry; post-governance product-side regeneration now lives in `tiangong flow regen-product`.
289
-
290
- `tiangong flow publish-reviewed-data` is the CLI-owned reviewed publish preparation slice for flow governance. It reads reviewed flow rows and/or reviewed process rows from local JSON or JSONL inputs, can use `--original-flow-rows-file` to skip unchanged flow rows before planning publish, supports `skip | append_only_bump | upsert_current_version`, writes `prepared-flow-rows.json`, `prepared-process-rows.json`, `flow-version-map.json`, `skipped-unchanged-flow-rows.json`, `process-flow-ref-rewrite-evidence.jsonl`, and `publish-report.json`, and preserves the historical success-list / remote-failure / sync-report files for downstream follow-up. The native CLI path now covers local process-row preparation, optional process flow-ref rewrites, and commit-time process publish through the same `@supabase/supabase-js` writer layer; no legacy fallback path remains for reviewed process rows.
291
-
292
- `tiangong flow build-alias-map` is the CLI-owned deterministic alias-map slice for flow governance. It reads one or more old flow snapshots plus one or more new flow snapshots, optionally consumes a seed alias map, writes `alias-plan.json`, `alias-plan.jsonl`, `flow-alias-map.json`, `manual-review-queue.jsonl`, and `alias-summary.json`, and keeps the boundary local-only instead of routing through skill-local Python.
293
-
294
- `tiangong flow scan-process-flow-refs` is the CLI-owned standalone process-reference scan slice for flow governance. It reads one local process row set plus one or more local scope/catalog flow row sets, classifies every `referenceToFlowDataSet`, optionally excludes emergy-named processes up front, and writes stable `emergy-excluded-processes.json`, `scan-summary.json`, `scan-findings.json`, and `scan-findings.jsonl` artifacts without falling back to skill-local Python.
295
-
296
- `tiangong flow plan-process-flow-repairs` is the CLI-owned standalone deterministic repair-planning slice for flow governance. It reads one local process row set plus one or more local scope flow row sets, optionally consumes prior `scan-findings`, applies the explicit `disabled | alias-only | alias-or-unique-name` auto-patch boundary, and writes `repair-plan.json`, `repair-plan.jsonl`, `manual-review-queue.jsonl`, and `repair-summary.json`.
297
-
298
- `tiangong flow apply-process-flow-repairs` is the CLI-owned standalone deterministic repair-apply slice for flow governance. It reuses the same local process/scope/alias/scan contract as the planning command, applies only the deterministic subset, emits per-process patch evidence under `process-patches/`, writes `patched-processes.json`, and can sync exact-version rows back into a local `process-pool-file`.
299
-
300
- `tiangong flow regen-product` is the CLI-owned local product-side regeneration slice for flow governance. It reads one local process row set plus one or more local scope/catalog flow row sets, runs `scan -> repair plan -> optional apply -> optional validate` under one run root, writes stable `scan/`, `repair/`, `repair-apply/`, `validate/`, and `flow-regen-product-report.json` artifacts, and keeps exit code `1` reserved for validation failures after `--apply`.
301
-
302
- `tiangong flow validate-processes` is the CLI-owned standalone validation slice for locally patched process rows after governance repair. It reads one original process snapshot, one patched process snapshot, and one or more scope flow snapshots, verifies that only `referenceToFlowDataSet` paths changed, keeps quantitative references stable, optionally runs local TIDAS validation through the CLI-owned validator assembled from the direct `@tiangong-lca/tidas-sdk` dependency, and writes `validation-report.json` plus `validation-failures.jsonl` without falling back to skill-local Python.
88
+ ```bash
89
+ npx -y @tiangong-lca/cli@latest flow get --id <flow-id> --version <version> --json
90
+ npx -y @tiangong-lca/cli@latest flow list --id <flow-id> --state-code 100 --limit 20 --json
91
+ npx -y @tiangong-lca/cli@latest process get --id <process-id> --version <version> --json
92
+ ```
303
93
 
304
- ## Publish and validation
94
+ ## Real DB Flow Review
95
+
96
+ 1. Search or otherwise collect exact flow refs.
97
+ 2. Materialize DB rows into local review input.
98
+ 3. Review the materialized rows.
99
+ 4. Materialize approved decisions into downstream artifacts.
100
+
101
+ `flow fetch-rows` input:
102
+
103
+ ```json
104
+ [
105
+ {
106
+ "id": "7a285e9a-a9f6-4b86-ab17-6ea17367400c",
107
+ "version": "01.01.001",
108
+ "state_code": 100,
109
+ "cluster_id": "cluster-0001",
110
+ "source": "search-flow"
111
+ }
112
+ ]
113
+ ```
305
114
 
306
- `tiangong process publish-build` is the process-side local publish handoff command. It prepares the local bundle/request/intent artifacts expected by `tiangong publish run` without reintroducing Python, MCP, or legacy remote writers into the CLI.
115
+ `flow materialize-decisions` input:
116
+
117
+ ```json
118
+ [
119
+ {
120
+ "cluster_id": "cluster-0001",
121
+ "decision": "merge_keep_one",
122
+ "canonical_flow": {
123
+ "id": "7a285e9a-a9f6-4b86-ab17-6ea17367400c",
124
+ "version": "01.01.001"
125
+ },
126
+ "flow_refs": [
127
+ "7a285e9a-a9f6-4b86-ab17-6ea17367400c@01.01.001",
128
+ "017acdd0-7fd7-44cb-a410-1d559e59c506@01.01.001"
129
+ ],
130
+ "reason": "approved_same_product_flow"
131
+ }
132
+ ]
133
+ ```
307
134
 
308
- `tiangong process batch-build` is the process-side local batch orchestration command. It keeps batch execution file-first and JSON-first, reuses the single-run `process auto-build` contract for each item, and emits one batch report instead of pushing shell loops or Python coordinators back onto the caller.
135
+ Run:
309
136
 
310
- `tiangong lifecyclemodel validate-build` is the lifecyclemodel-side local validation command. It keeps validation file-first, reuses the unified `tiangong validation run` module under the hood, and writes both per-model reports and one aggregate build report without reintroducing Python or MCP into the CLI.
137
+ ```bash
138
+ npx -y @tiangong-lca/cli@latest flow fetch-rows \
139
+ --refs-file ./flow-refs.json \
140
+ --out-dir ./flow-fetch
141
+
142
+ npx -y @tiangong-lca/cli@latest review flow \
143
+ --rows-file ./flow-fetch/review-input-rows.jsonl \
144
+ --out-dir ./flow-review
145
+
146
+ npx -y @tiangong-lca/cli@latest flow materialize-decisions \
147
+ --decision-file ./approved-decisions.json \
148
+ --flow-rows-file ./flow-fetch/review-input-rows.jsonl \
149
+ --out-dir ./flow-decisions
150
+ ```
311
151
 
312
- `tiangong lifecyclemodel publish-build` is the lifecyclemodel-side local publish handoff command. It prepares the local bundle/request/intent artifacts expected by `tiangong publish run` without reintroducing Python, MCP, or legacy remote writers into the CLI.
152
+ Key `flow fetch-rows` outputs:
313
153
 
314
- `tiangong lifecyclemodel publish-resulting-process` is the lifecyclemodel-side local publish handoff command. It reads a prior resulting-process run, writes `publish-bundle.json` and `publish-intent.json`, and preserves the old builder's artifact contract without reintroducing Python or MCP into the CLI.
154
+ - `review-input-rows.jsonl`
155
+ - `fetch-summary.json`
156
+ - `missing-flow-refs.jsonl`
157
+ - `ambiguous-flow-refs.jsonl`
315
158
 
316
- `tiangong publish run` is the CLI-side publish contract boundary. It normalizes publish requests, ingests upstream `publish-bundle.json` inputs, writes `normalized-request.json`, `collected-inputs.json`, `relation-manifest.json`, and `publish-report.json`, and keeps commit-mode execution behind explicit executors instead of reintroducing MCP-specific logic into the CLI.
159
+ Key `flow materialize-decisions` outputs:
317
160
 
318
- `tiangong validation run` is the CLI-side validation boundary. It standardizes local TIDAS package validation through one JSON report shape, supports `--engine auto|sdk`, and keeps the local package-validation path inside the CLI-owned validator assembled from the direct `@tiangong-lca/tidas-sdk` dependency instead of shelling out to `tidas-tools` or loading sibling-repo artifacts.
161
+ - `flow-dedup-canonical-map.json`
162
+ - `flow-dedup-rewrite-plan.json`
163
+ - `manual-semantic-merge-seed.current.json`
164
+ - `decision-summary.json`
165
+ - `blocked-clusters.json`
319
166
 
320
- Run the built artifact directly:
167
+ ## Other Common Commands
321
168
 
322
169
  ```bash
323
- node ./bin/tiangong.js doctor
324
- node ./bin/tiangong.js process get --id <process-id> --json
325
- node ./bin/tiangong.js flow get --id <flow-id> --json
326
- node ./bin/tiangong.js flow list --state-code 100 --limit 20 --json
327
- node ./bin/tiangong.js flow publish-reviewed-data --flow-rows-file ./reviewed-flows.jsonl --out-dir ./flow-publish-reviewed --dry-run --json
328
- node ./bin/tiangong.js flow build-alias-map --old-flow-file ./old-flows.jsonl --new-flow-file ./new-flows.jsonl --out-dir ./flow-alias-map --json
329
- node ./bin/tiangong.js flow scan-process-flow-refs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-scan --json
330
- node ./bin/tiangong.js flow plan-process-flow-repairs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --scan-findings ./flow-scan/scan-findings.json --out-dir ./flow-repair-plan --json
331
- node ./bin/tiangong.js flow apply-process-flow-repairs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --scan-findings ./flow-scan/scan-findings.json --out-dir ./flow-repair-apply --json
332
- node ./bin/tiangong.js flow regen-product --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-regen --apply --json
333
- node ./bin/tiangong.js process auto-build --input ./examples/process-auto-build.request.json --json
334
- node ./bin/tiangong.js process resume-build --run-id <run-id> --json
335
- node ./bin/tiangong.js process publish-build --run-id <run-id> --json
336
- node ./bin/tiangong.js process batch-build --input ./examples/process-batch-build.request.json --json
337
- node ./bin/tiangong.js lifecyclemodel auto-build --input ./examples/lifecyclemodel-auto-build.request.json --json
338
- node ./bin/tiangong.js lifecyclemodel validate-build --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --json
339
- node ./bin/tiangong.js lifecyclemodel publish-build --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --json
340
- node ./bin/tiangong.js lifecyclemodel orchestrate plan --input ./lifecyclemodel-orchestrate.request.json --out-dir ./artifacts/lifecyclemodel_recursive/<run_id> --json
341
- node ./bin/tiangong.js flow publish-version --input-file ./ready-flows.jsonl --out-dir ./flow-publish --dry-run --json
342
- node ./bin/tiangong.js publish run --input ./examples/publish-run.request.json --dry-run --json
343
- node ./bin/tiangong.js validation run --input-dir ./package --engine auto --json
344
- node ./dist/src/main.js doctor --json
170
+ npx -y @tiangong-lca/cli@latest review process --run-root ./artifacts/process_from_flow/<run_id> --run-id <run_id> --out-dir ./review
171
+ npx -y @tiangong-lca/cli@latest publish run --input ./publish-request.json --dry-run
172
+ npx -y @tiangong-lca/cli@latest doctor --json
345
173
  ```
346
174
 
347
- ## Examples
348
-
349
- Minimal example requests are available under `examples/`:
175
+ ## More Docs
350
176
 
351
- - `examples/process-auto-build.request.json`
352
- - `examples/process-batch-build.request.json`
353
- - `examples/lifecyclemodel-auto-build.request.json`
354
- - `examples/publish-run.request.json`
177
+ - `docs/IMPLEMENTATION_GUIDE_CN.md`: maintainer-facing command contract and implementation notes
178
+ - `--help`: the canonical command surface for `tiangong`, `tiangong flow`, `tiangong review`, `tiangong process`, `tiangong lifecyclemodel`, and `tiangong publish`
179
+ - `tiangong-lca-skills`: use the skill-specific `SKILL.md` and wrapper docs for agent workflows; the CLI README only covers the public invocation contract
355
180
 
356
- ## Workspace usage
181
+ ## Help
357
182
 
358
- `tiangong-lca-skills` should stay as thin Node `.mjs` wrappers over this CLI instead of keeping parallel runtimes. The current contract is:
359
-
360
- - skills call `tiangong` as the stable entrypoint
361
- - deleted Python, MCP, and OpenClaw runtimes are not supported compatibility paths
362
- - new capability must land as a native `tiangong <noun> <verb>` command before a skill depends on it
363
-
364
- ## Docs
365
-
366
- - Chinese setup guide: [DEV_CN.md](./DEV_CN.md)
367
- - Detailed implementation guide: [docs/IMPLEMENTATION_GUIDE_CN.md](./docs/IMPLEMENTATION_GUIDE_CN.md)
368
- - Skills migration checklist: [docs/SKILLS_TO_CLI_MIGRATION_CHECKLIST_CN.md](./docs/SKILLS_TO_CLI_MIGRATION_CHECKLIST_CN.md)
183
+ ```bash
184
+ npx -y @tiangong-lca/cli@latest --help
185
+ npx -y @tiangong-lca/cli@latest flow --help
186
+ npx -y @tiangong-lca/cli@latest review --help
187
+ npx -y @tiangong-lca/cli@latest process --help
188
+ npx -y @tiangong-lca/cli@latest lifecyclemodel --help
189
+ npx -y @tiangong-lca/cli@latest publish --help
190
+ ```