@tiangong-lca/cli 0.0.7 → 0.0.8

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 (52) hide show
  1. package/README.md +83 -2
  2. package/dist/src/cli.js +1327 -40
  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-payload-validation.js +51 -0
  21. package/dist/src/lib/flow-payload-validation.js.map +1 -0
  22. package/dist/src/lib/flow-publish-reviewed-data.js +16 -0
  23. package/dist/src/lib/flow-publish-reviewed-data.js.map +1 -1
  24. package/dist/src/lib/flow-publish-version.js +182 -12
  25. package/dist/src/lib/flow-publish-version.js.map +1 -1
  26. package/dist/src/lib/identity-preflight.js +1021 -0
  27. package/dist/src/lib/identity-preflight.js.map +1 -0
  28. package/dist/src/lib/process-auto-build.js +147 -0
  29. package/dist/src/lib/process-auto-build.js.map +1 -1
  30. package/dist/src/lib/process-dedup-review.js +51 -0
  31. package/dist/src/lib/process-dedup-review.js.map +1 -1
  32. package/dist/src/lib/process-flow-build-plan.js +1071 -0
  33. package/dist/src/lib/process-flow-build-plan.js.map +1 -0
  34. package/dist/src/lib/process-payload-validation.js +14 -7
  35. package/dist/src/lib/process-payload-validation.js.map +1 -1
  36. package/dist/src/lib/process-publish-build.js +122 -4
  37. package/dist/src/lib/process-publish-build.js.map +1 -1
  38. package/dist/src/lib/process-refresh-references.js +19 -10
  39. package/dist/src/lib/process-refresh-references.js.map +1 -1
  40. package/dist/src/lib/process-required-fields.js +810 -0
  41. package/dist/src/lib/process-required-fields.js.map +1 -0
  42. package/dist/src/lib/process-save-draft-run.js +4 -1
  43. package/dist/src/lib/process-save-draft-run.js.map +1 -1
  44. package/dist/src/lib/publish.js +100 -0
  45. package/dist/src/lib/publish.js.map +1 -1
  46. package/dist/src/lib/review-flow.js +58 -0
  47. package/dist/src/lib/review-flow.js.map +1 -1
  48. package/dist/src/lib/review-process.js +150 -2
  49. package/dist/src/lib/review-process.js.map +1 -1
  50. package/dist/src/lib/runtime-rulesets.js +283 -0
  51. package/dist/src/lib/runtime-rulesets.js.map +1 -0
  52. package/package.json +2 -2
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
@@ -117,6 +117,66 @@ 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
+ ## 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
+
120
180
  ## Real DB Flow Review
121
181
 
122
182
  1. Search or otherwise collect exact flow refs.
@@ -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
@@ -209,6 +276,8 @@ tiangong-lca review process --rows-file ./process-list-report.json --out-dir ./r
209
276
  tiangong-lca review process --run-root /abs/path/to/process-run --run-id <run_id> --out-dir ./review
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
  ```
@@ -217,10 +286,22 @@ For `publish run`, relative `out_dir` values from either the request body or `--
217
286
 
218
287
  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.
219
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`.
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