@tiangong-lca/cli 0.0.7 → 0.0.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.
Files changed (59) hide show
  1. package/README.md +97 -16
  2. package/dist/src/cli.js +1429 -131
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/lib/dataset-author.js +100 -0
  5. package/dist/src/lib/dataset-author.js.map +1 -0
  6. package/dist/src/lib/dataset-bilingual.js +545 -0
  7. package/dist/src/lib/dataset-bilingual.js.map +1 -0
  8. package/dist/src/lib/dataset-contract.js +350 -0
  9. package/dist/src/lib/dataset-contract.js.map +1 -0
  10. package/dist/src/lib/dataset-evidence-search.js +636 -0
  11. package/dist/src/lib/dataset-evidence-search.js.map +1 -0
  12. package/dist/src/lib/dataset-import-lca.js +171 -0
  13. package/dist/src/lib/dataset-import-lca.js.map +1 -0
  14. package/dist/src/lib/dataset-remote-refresh.js +166 -0
  15. package/dist/src/lib/dataset-remote-refresh.js.map +1 -0
  16. package/dist/src/lib/dataset-remote-verify.js +543 -0
  17. package/dist/src/lib/dataset-remote-verify.js.map +1 -0
  18. package/dist/src/lib/dataset-validate.js +63 -7
  19. package/dist/src/lib/dataset-validate.js.map +1 -1
  20. package/dist/src/lib/flow-fetch-rows.js +12 -12
  21. package/dist/src/lib/flow-fetch-rows.js.map +1 -1
  22. package/dist/src/lib/flow-payload-validation.js +51 -0
  23. package/dist/src/lib/flow-payload-validation.js.map +1 -0
  24. package/dist/src/lib/flow-publish-reviewed-data.js +16 -0
  25. package/dist/src/lib/flow-publish-reviewed-data.js.map +1 -1
  26. package/dist/src/lib/flow-publish-version.js +182 -12
  27. package/dist/src/lib/flow-publish-version.js.map +1 -1
  28. package/dist/src/lib/{review-flow.js → flow-qa.js} +86 -28
  29. package/dist/src/lib/flow-qa.js.map +1 -0
  30. package/dist/src/lib/identity-preflight.js +1021 -0
  31. package/dist/src/lib/identity-preflight.js.map +1 -0
  32. package/dist/src/lib/{review-lifecyclemodel.js → lifecyclemodel-qa.js} +54 -54
  33. package/dist/src/lib/lifecyclemodel-qa.js.map +1 -0
  34. package/dist/src/lib/process-auto-build.js +147 -0
  35. package/dist/src/lib/process-auto-build.js.map +1 -1
  36. package/dist/src/lib/process-dedup-review.js +51 -0
  37. package/dist/src/lib/process-dedup-review.js.map +1 -1
  38. package/dist/src/lib/process-flow-build-plan.js +1071 -0
  39. package/dist/src/lib/process-flow-build-plan.js.map +1 -0
  40. package/dist/src/lib/process-payload-validation.js +14 -7
  41. package/dist/src/lib/process-payload-validation.js.map +1 -1
  42. package/dist/src/lib/process-publish-build.js +122 -4
  43. package/dist/src/lib/process-publish-build.js.map +1 -1
  44. package/dist/src/lib/{review-process.js → process-qa.js} +259 -117
  45. package/dist/src/lib/process-qa.js.map +1 -0
  46. package/dist/src/lib/process-refresh-references.js +19 -10
  47. package/dist/src/lib/process-refresh-references.js.map +1 -1
  48. package/dist/src/lib/process-required-fields.js +810 -0
  49. package/dist/src/lib/process-required-fields.js.map +1 -0
  50. package/dist/src/lib/process-save-draft-run.js +4 -1
  51. package/dist/src/lib/process-save-draft-run.js.map +1 -1
  52. package/dist/src/lib/publish.js +100 -0
  53. package/dist/src/lib/publish.js.map +1 -1
  54. package/dist/src/lib/runtime-rulesets.js +283 -0
  55. package/dist/src/lib/runtime-rulesets.js.map +1 -0
  56. package/package.json +2 -2
  57. package/dist/src/lib/review-flow.js.map +0 -1
  58. package/dist/src/lib/review-lifecyclemodel.js.map +0 -1
  59. package/dist/src/lib/review-process.js.map +0 -1
package/README.md CHANGED
@@ -17,8 +17,8 @@ checkPaths:
17
17
  - bin/**
18
18
  - src/cli.ts
19
19
  - src/main.ts
20
- lastReviewedAt: 2026-05-08
21
- lastReviewedCommit: 06dbec3287513cf94c5d64c73bd467ed5347f40a
20
+ lastReviewedAt: 2026-06-01
21
+ lastReviewedCommit: 24f96578290267865df3ee1244a96723129bc376
22
22
  ---
23
23
 
24
24
  # TianGong LCA CLI
@@ -77,7 +77,7 @@ TIANGONG_LCA_DISABLE_SESSION_CACHE=false
77
77
  TIANGONG_LCA_FORCE_REAUTH=false
78
78
  ```
79
79
 
80
- Optional LLM review env, only for `review process --enable-llm` or `review flow --enable-llm`:
80
+ Optional LLM review env, only for `qa process --enable-llm` or `qa flow --enable-llm`:
81
81
 
82
82
  ```bash
83
83
  TIANGONG_LCA_REVIEW_LLM_BASE_URL=
@@ -117,11 +117,71 @@ tiangong-lca process get --id <process-id> --version <version> --json
117
117
  tiangong-lca process list --state-code 100 --limit 20 --json
118
118
  ```
119
119
 
120
- ## Real DB Flow Review
120
+ ## Identity Preflight
121
+
122
+ Use identity preflight before generating new process or flow rows. The command compares one target against local candidate rows and emits a machine-readable `IdentityDecision` so automation can reuse, update, block, or route uncertain cases before payload generation.
123
+
124
+ ```bash
125
+ tiangong-lca process identity-preflight --input ./process-preflight.json --out-dir ./process-preflight --json
126
+ tiangong-lca flow identity-preflight --input ./flow-preflight.json --out-dir ./flow-preflight --json
127
+ tiangong-lca process identity-preflight --input ./process-preflight.json --candidate-input ./exports/processes.jsonl --candidate-input ./local-process-catalog --out-dir ./process-preflight --json
128
+ tiangong-lca flow identity-preflight --input ./flow-preflight.json --remote-candidates --remote-query "electricity medium voltage" --remote-limit 20 --out-dir ./flow-preflight --json
129
+ ```
130
+
131
+ Minimal input:
132
+
133
+ ```json
134
+ {
135
+ "target": {
136
+ "name_en": "market for electricity, medium voltage",
137
+ "reference_flow_id": "flow-electricity",
138
+ "operation": "produce"
139
+ },
140
+ "candidates": [
141
+ {
142
+ "id": "existing-process",
143
+ "name_en": "market for electricity, medium voltage",
144
+ "reference_flow_id": "flow-electricity",
145
+ "operation": "produce"
146
+ }
147
+ ]
148
+ }
149
+ ```
150
+
151
+ Key outputs under `--out-dir`:
152
+
153
+ - `outputs/identity-decision.json`
154
+ - `outputs/identity-candidates.jsonl`
155
+ - `outputs/identity-candidate-sources.json`
156
+
157
+ `--candidate-input` is repeatable and accepts JSON, JSONL, or a directory scanned recursively for JSON/JSONL candidate rows. Embedded `candidates` from the request and local-scan candidates are evaluated together. Add `--remote-candidates` when the preflight should also call `process_hybrid_search` or `flow_hybrid_search`; `--remote-query` overrides the target-derived search text and `--remote-limit` caps returned candidate rows. Remote candidate search uses the normal Supabase session env: `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_API_KEY`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, and optional `TIANGONG_LCA_REGION`.
158
+
159
+ Exact process exchange fingerprints with matching identity context block duplicate creation, while weaker inventory-only matches still route to manual review. Flow preflight also blocks alias-equivalent flows when type, reference property, unit, and category/CAS evidence match.
160
+
161
+ ## Build Plan Gate
162
+
163
+ Use build-plan gates after identity preflight and before publish handoff. These commands validate the minimum authoring contract for a process or flow build plan, write a standard `GateReport` for Foundry/skill orchestration, and materialize deterministic canonical TIDAS payloads when no explicit payload is embedded in the plan.
164
+
165
+ ```bash
166
+ tiangong-lca process build-plan validate --input ./process-build-plan.json --out-dir ./process-build-plan --json
167
+ tiangong-lca process build-plan materialize --input ./process-build-plan.json --out-dir ./process-build-plan --json
168
+ tiangong-lca flow build-plan validate --input ./flow-build-plan.json --out-dir ./flow-build-plan --json
169
+ tiangong-lca flow build-plan materialize --input ./flow-build-plan.json --out-dir ./flow-build-plan --json
170
+ ```
171
+
172
+ The minimum plan contract requires an automatic identity decision, EvidenceManifest sources and field bindings, name plan, and the relevant process reference-flow or flow-property fields. Process materialization carries name, quantitative reference, exchange, source evidence, modelling, administrative, and annual supply/production fields from the plan into `processDataSet`; when annual volume is not explicit, it falls back to reference-flow `meanAmount` and then `resultingAmount`. Flow materialization carries name, flow type, reference property, source evidence, administrative, and classification fields into `flowDataSet`. `--report-only` keeps exit code `0` while still reporting blockers.
173
+
174
+ Key outputs under `--out-dir`:
175
+
176
+ - `outputs/build-plan-gate-report.json`
177
+ - `outputs/materialized-process.json`
178
+ - `outputs/materialized-flow.json`
179
+
180
+ ## Real DB Flow QA
121
181
 
122
182
  1. Search or otherwise collect exact flow refs.
123
- 2. Materialize DB rows into local review input.
124
- 3. Review the materialized rows.
183
+ 2. Materialize DB rows into local QA input.
184
+ 3. Run QA on the materialized rows.
125
185
  4. Materialize approved decisions into downstream artifacts.
126
186
 
127
187
  `flow fetch-rows` input:
@@ -165,19 +225,19 @@ tiangong-lca flow fetch-rows \
165
225
  --refs-file ./flow-refs.json \
166
226
  --out-dir ./flow-fetch
167
227
 
168
- tiangong-lca review flow \
169
- --rows-file ./flow-fetch/review-input-rows.jsonl \
170
- --out-dir ./flow-review
228
+ tiangong-lca qa flow \
229
+ --rows-file ./flow-fetch/qa-input-rows.jsonl \
230
+ --out-dir ./flow-qa
171
231
 
172
232
  tiangong-lca flow materialize-decisions \
173
233
  --decision-file ./approved-decisions.json \
174
- --flow-rows-file ./flow-fetch/review-input-rows.jsonl \
234
+ --flow-rows-file ./flow-fetch/qa-input-rows.jsonl \
175
235
  --out-dir ./flow-decisions
176
236
  ```
177
237
 
178
238
  Key `flow fetch-rows` outputs:
179
239
 
180
- - `review-input-rows.jsonl`
240
+ - `qa-input-rows.jsonl`
181
241
  - `fetch-summary.json`
182
242
  - `missing-flow-refs.jsonl`
183
243
  - `ambiguous-flow-refs.jsonl`
@@ -193,11 +253,18 @@ Key `flow materialize-decisions` outputs:
193
253
  ## Other Common Commands
194
254
 
195
255
  ```bash
256
+ tiangong-lca process identity-preflight --input ./process-preflight.json --candidate-input /abs/path/to/process-candidates.jsonl --out-dir /abs/path/to/process-preflight --json
257
+ tiangong-lca flow identity-preflight --input ./flow-preflight.json --candidate-input /abs/path/to/flow-catalog --out-dir /abs/path/to/flow-preflight --json
258
+ tiangong-lca process identity-preflight --input ./process-preflight.json --remote-candidates --remote-limit 20 --out-dir /abs/path/to/process-preflight --json
259
+ tiangong-lca process build-plan validate --input ./process-build-plan.json --out-dir /abs/path/to/process-build-plan --json
260
+ tiangong-lca flow build-plan validate --input ./flow-build-plan.json --out-dir /abs/path/to/flow-build-plan --json
196
261
  tiangong-lca process auto-build --input ./examples/process-auto-build.request.json --out-dir /abs/path/to/process-run --json
197
262
  tiangong-lca process resume-build --run-dir /abs/path/to/process-run --json
198
263
  tiangong-lca process publish-build --run-dir /abs/path/to/process-run --json
199
264
  tiangong-lca process batch-build --input ./examples/process-batch-build.request.json --out-dir /abs/path/to/process-batch --json
200
265
  tiangong-lca dataset validate --input ./rows.jsonl --type auto --out-dir /abs/path/to/dataset-validate --json
266
+ tiangong-lca dataset evidence-search plan --query "中国2026年电力结构数据" --out-dir /abs/path/to/evidence-search --json
267
+ tiangong-lca dataset evidence-search run --input ./evidence-search.request.json --results ./search-results.json --out-dir /abs/path/to/evidence-search --json
201
268
  tiangong-lca dataset references rewrite --input ./rows.jsonl --from flow:<old-id>@<old-version> --to flow:<new-id>@<new-version> --out-dir /abs/path/to/dataset-rewrite --json
202
269
  tiangong-lca lifecyclemodel auto-build --input ./examples/lifecyclemodel-auto-build.request.json --out-dir /abs/path/to/lifecyclemodel-run --json
203
270
  tiangong-lca lifecyclemodel validate-build --run-dir /abs/path/to/lifecyclemodel-run --json
@@ -205,36 +272,50 @@ tiangong-lca lifecyclemodel publish-build --run-dir /abs/path/to/lifecyclemodel-
205
272
  tiangong-lca lifecyclemodel save-draft --input ./lifecyclemodels.jsonl --out-dir /abs/path/to/lifecyclemodel-save-draft --dry-run --json
206
273
  tiangong-lca lifecyclemodel graph --input ./lifecyclemodels.jsonl --out-dir /abs/path/to/lifecyclemodel-graph --format all --json
207
274
  tiangong-lca lifecyclemodel orchestrate plan --input ./lifecyclemodel-orchestrate.request.json --out-dir /abs/path/to/lifecyclemodel-recursive-run --json
208
- tiangong-lca review process --rows-file ./process-list-report.json --out-dir ./review
209
- tiangong-lca review process --run-root /abs/path/to/process-run --run-id <run_id> --out-dir ./review
275
+ tiangong-lca qa process --rows-file ./process-list-report.json --out-dir ./process-qa
276
+ tiangong-lca qa process --run-root /abs/path/to/process-run --run-id <run_id> --out-dir ./process-qa
210
277
  tiangong-lca process save-draft --input ./patched-processes.jsonl --out-dir /abs/path/to/process-save-draft --dry-run --json
211
278
  tiangong-lca process save-draft --input ./patched-processes.jsonl --out-dir /abs/path/to/process-save-draft --commit --json
279
+ tiangong-lca flow publish-version --input-file ./ready-flows.jsonl --out-dir /abs/path/to/flow-publish --dry-run --json
280
+ tiangong-lca flow publish-reviewed-data --flow-rows-file ./reviewed-flows.jsonl --out-dir /abs/path/to/reviewed-publish --dry-run --json
212
281
  tiangong-lca publish run --input ./publish-request.json --dry-run
213
282
  tiangong-lca doctor --json
214
283
  ```
215
284
 
216
285
  For `publish run`, relative `out_dir` values from either the request body or `--out-dir` are resolved against the request file directory, not the shell `cwd`. Use an absolute path when you want a fixed destination independent of the request file location.
217
286
 
218
- For `review process`, `--rows-file` accepts either raw process rows as JSON/JSONL or the full JSON report emitted by `tiangong-lca process list --json`, as long as it contains a `rows` array.
287
+ For `qa process`, `--rows-file` accepts either raw process rows as JSON/JSONL or the full JSON report emitted by `tiangong-lca process list --json`, as long as it contains a `rows` array.
288
+
289
+ For `process identity-preflight` and `flow identity-preflight`, canonical TIDAS wrappers are schema-checked when present. Loose target objects are accepted for early planning and produce `schema_validation.status: "not_applicable"` until materialization. Candidate rows can be embedded in the request, loaded from repeatable `--candidate-input` local files/directories, or fetched through explicit `--remote-candidates` hybrid search; `identity-candidate-sources.json` records scanned files, remote endpoints, queries, filters, and row counts.
290
+
291
+ For `process build-plan` and `flow build-plan`, canonical payloads embedded in the plan are schema-checked during `materialize`. Plan-only materialization now creates deterministic canonical `processDataSet` / `flowDataSet` wrappers from the build plan and validates them with the TIDAS SDK before reporting `passed`.
219
292
 
220
293
  For `process save-draft`, canonical process payloads are validated locally with `ProcessSchema` before any `--commit` write. Schema-invalid rows remain in `outputs/save-draft-rpc/failures.jsonl` instead of being persisted.
221
294
 
295
+ For `flow publish-version`, canonical flow payloads are validated locally with `FlowSchema` before remote visibility planning or writes. The command always writes `flow-publish-version-gate-report.json`; blocked rows are written to the remote-failure JSONL without calling the remote service.
296
+
297
+ For `process publish-build`, canonical process payloads are validated locally with `ProcessSchema` before publish handoff artifacts are written. The gate report is `reports/process-publish-schema-gate.json`.
298
+
299
+ For `publish run`, `verification-report.json` is written next to `publish-report.json` and summarizes the publish ruleset status, blockers, failed entries, deferred entries, and executed entries.
300
+
222
301
  For `lifecyclemodel save-draft`, canonical lifecyclemodel payloads are validated locally with `LifeCycleModelSchema` before any `--commit` write. Schema-invalid rows remain in `outputs/save-draft-bundle/failures.jsonl` instead of being persisted.
223
302
 
303
+ For `dataset evidence-search`, `plan` creates the field-level query matrix and search budget. `run` accepts normalized external search results from browser/web-search tools or a generic JSON provider endpoint, then writes `outputs/evidence-search-plan.json`, `outputs/evidence-search-results.jsonl`, `outputs/evidence-search-report.json`, and `outputs/evidence-search-declaration.json` when evidence is absent or only partial. The CLI records scope and normalization; Codex/skills still own semantic judgement and source selection.
304
+
224
305
  For `dataset references rewrite`, `--commit` executes the state-aware save-draft path for patched process and lifecyclemodel rows; without `--commit`, the command only writes local rewrite artifacts.
225
306
 
226
307
  ## More Docs
227
308
 
228
309
  - `docs/IMPLEMENTATION_GUIDE_CN.md`: maintainer-facing command contract and implementation notes
229
- - `--help`: the canonical command surface for `tiangong-lca`, `tiangong-lca flow`, `tiangong-lca review`, `tiangong-lca process`, `tiangong-lca lifecyclemodel`, and `tiangong-lca publish`
310
+ - `--help`: the canonical command surface for `tiangong-lca`, `tiangong-lca qa`, `tiangong-lca flow`, `tiangong-lca process`, `tiangong-lca lifecyclemodel`, and `tiangong-lca publish`
230
311
  - `tiangong-lca-skills`: use the skill-specific `SKILL.md` and wrapper docs for agent workflows; the CLI README only covers the public invocation contract
231
312
 
232
313
  ## Help
233
314
 
234
315
  ```bash
235
316
  tiangong-lca --help
317
+ tiangong-lca qa --help
236
318
  tiangong-lca flow --help
237
- tiangong-lca review --help
238
319
  tiangong-lca process --help
239
320
  tiangong-lca lifecyclemodel --help
240
321
  tiangong-lca publish --help