oltc-selector 2.3.2 → 2.4.1

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 (3) hide show
  1. package/README.md +6 -7
  2. package/bin/oltc.js +160 -50
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -35,7 +35,7 @@ oltc --line "220/110/35kV-125MVA 225±8x1,25%/115/35kV YNa0d11"
35
35
  # 3xCM2I-500/252D-10193W, plus the type at Um 126 / 170 / 252
36
36
  ```
37
37
 
38
- Output is in Chinese by default; `--lang en` gives English. Every run asks npm for a newer version and prints a notice when there is one. Nothing is installed for you.
38
+ Output is in Chinese by default; `--lang en` gives English. An error on a Chinese run prints in Chinese, then English. Every run asks npm for a newer version and prints a notice when there is one. Nothing is installed for you.
39
39
 
40
40
  <details>
41
41
  <summary><b>All flags</b></summary>
@@ -46,7 +46,7 @@ Output is in Chinese by default; `--lang en` gives English. Every run asks npm f
46
46
  |------|---------|---------|
47
47
  | `--line "text"` | Tender line: MVA, kV ratio with ±N×x%, vector group. Flags given beside it win. | |
48
48
  | `--iu` / `--imax` | Max through-current Imax (A). **No** safety factor. | required unless `--mva` |
49
- | `--mva` `--kv` | Transformer MVA + tap-side kV → Imax (min tap + `--k`). With `--iu`, `--kv` alone sets the winding voltage for the 220/330 kV and `--market` rules | |
49
+ | `--mva` `--kv` | Transformer MVA + tap-side kV → Imax (min tap + `--k`). With `--iu`, `--kv` alone sets the winding voltage for the 220/330 kV rules | |
50
50
  | `--k` | Safety factor ≥ 1, **capacity path only** | 1.0 |
51
51
  | `--step-pct` | Step as a percent (1.25 means 1.25 %), capacity path only | 1.25 |
52
52
  | `--os-imax` | Capacity path: the Imax the OS or maker states at the lowest tap (`--imax` beside `--mva` means this) | |
@@ -55,11 +55,10 @@ Output is in Chinese by default; `--lang en` gives English. Every run asks npm f
55
55
  | `--winding star\|delta` | Tapped winding connection (two-winding) | star |
56
56
  | `--hv` `--mv` | Autotransformer HV / MV rated kV | |
57
57
  | `--earth-um` | OLTC insulation to earth from the OS; overrides the rule | |
58
- | `--market` | Buyer's country for a neutral's assumed Um. Rules exist for `IT` and `TR`; another code prints a note and is not used | |
59
58
  | `--across-li` `--across-ac` | Stated LI / AC withstand across the tap winding (kV): sets the selector grade B/C/D/DE | |
60
59
  | `--um` | Equipment Um (kV) | derived from `--kv` if omitted |
61
60
  | `--ust` | Step voltage (V) | 0, or derived on MVA path |
62
- | `--conn Y\|D` | Switch star / delta on the `--iu` path (with `--mva`, use `--tap`) | Y |
61
+ | `--conn Y\|D` | Switch star / delta on the `--iu` path. With `--mva` or `--line` it is an error: use `--tap` | Y |
63
62
  | `--reg W\|G\|0` | Reversing / coarse-fine / linear | W |
64
63
  | `--pm` | ± steps, a whole number | 8 |
65
64
  | `--pos` / `--positions` | Operating positions (linear and off-circuit; on W/G the Fig. 3-3 row with that count) | |
@@ -92,7 +91,7 @@ Every flag with a value also takes `--flag=value`. A flag that cannot take effec
92
91
 
93
92
  <br>
94
93
 
95
- **`--json`** prints one object. For bad input (a flag that cannot be read) the object holds only `ok`, `version`, `model` and `errors`.
94
+ **`--json`** prints one object, and nothing on stderr. For bad input (a flag that cannot be read) the object holds only `ok`, `version`, `model` and `errors`.
96
95
 
97
96
  | Key | Holds |
98
97
  |-----|-------|
@@ -104,8 +103,8 @@ Every flag with a value also takes `--flag=value`. A flag that cannot take effec
104
103
  | `line` | The `--line` read-back: `kind`, `mva`, `voltagesKv`, `vectorGroup`, `warnings` (or `null`) |
105
104
  | `basis` | Where current, Ust and Um came from on the capacity path (or `null`) |
106
105
  | `umChoices` | The type at each Um class when the insulation to earth is open |
107
- | `assumptions` | Every default that was applied, as text |
108
- | `errors` | Why there is no type |
106
+ | `assumptions` | Every default that was applied, as text. The text output names only those that could change the type |
107
+ | `errors` | Why there is no type. Chinese then English; English alone with `--lang en` |
109
108
 
110
109
  </details>
111
110
 
package/bin/oltc.js CHANGED
@@ -1,7 +1,106 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // lib/appVersion.ts
4
- var APP_VERSION = "2.3.2";
4
+ var APP_VERSION = "2.4.1";
5
+
6
+ // lib/cliErrorsZh.ts
7
+ var WHAT_ZH = {
8
+ "MVA and kV": "\u5BB9\u91CF\u548C\u7535\u538B",
9
+ "the MVA rating": "\u5BB9\u91CF",
10
+ "the kV ratio": "\u7535\u538B\u6BD4",
11
+ "the kV ratio and range": "\u7535\u538B\u6BD4\u548C\u8C03\u538B\u8303\u56F4"
12
+ };
13
+ var ROWS = [
14
+ [/^(\S+) must be greater than 0 \(got (.+)\)$/, "$1 \u5FC5\u987B\u5927\u4E8E 0\uFF08\u6536\u5230 $2\uFF09"],
15
+ [/^(\S+) must not be negative \(got (.+)\)$/, "$1 \u4E0D\u80FD\u4E3A\u8D1F\uFF08\u6536\u5230 $2\uFF09"],
16
+ [/^Ambiguous number for (\S+): (.+)\. Write 1200 or 1\.2 \(no thousands separator\)\.$/, "$1 \u7684\u6570\u5B57\u6709\u6B67\u4E49\uFF1A$2\u3002\u8BF7\u5199 1200 \u6216 1.2\uFF0C\u4E0D\u8981\u7528\u5343\u5206\u4F4D\u3002"],
17
+ [/^Invalid number for (\S+): (.*)$/, "$1 \u7684\u6570\u5B57\u65E0\u6548\uFF1A$2"],
18
+ [
19
+ /^Unknown flag: (\S+?)\.(?: Did you mean (\S+)\?)?.* Run oltc --help for the list\.$/,
20
+ (m) => `\u672A\u77E5\u53C2\u6570\uFF1A${m[1]}\u3002${m[2] ? `\u662F\u4E0D\u662F\u60F3\u5199 ${m[2]}\uFF1F` : ""}\u8FD0\u884C oltc --help \u67E5\u770B\u5168\u90E8\u53C2\u6570\u3002`
21
+ ],
22
+ [/^(\S+) takes no value$/, "$1 \u4E0D\u5E26\u503C"],
23
+ [/^Missing value for (\S+)$/, "$1 \u7F3A\u5C11\u503C"],
24
+ [/^(\S+) is given twice$/, "$1 \u7ED9\u4E86\u4E24\u6B21"],
25
+ [/^--lang must be en or zh$/, "--lang \u53EA\u80FD\u662F en \u6216 zh"],
26
+ [/^--octc conflicts with --duty oltc\. Drop one\.$/, "--octc \u548C --duty oltc \u77DB\u76FE\uFF0C\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
27
+ [/^Give --oil or --vacuum, not both$/, "--oil \u548C --vacuum \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
28
+ [/^Give --iu or --imax, not both$/, "--iu \u548C --imax \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
29
+ [/^--market is removed\./, "--market \u5DF2\u5220\u9664\u3002\u5F00\u5173\u5BF9\u5730\u7EDD\u7F18\u8BF7\u7528 --earth-um\uFF0C\u8DE8\u8C03\u538B\u7ED5\u7EC4\u7684\u8010\u538B\u8BF7\u7528 --across-li / --across-ac\u3002"],
30
+ [/^--conn must be Y or D$/, "--conn \u53EA\u80FD\u662F Y \u6216 D"],
31
+ [/^--kind must be two or auto$/, "--kind \u53EA\u80FD\u662F two \u6216 auto"],
32
+ [/^--tap must be neutral\|line\|junction\|mv-line$/, "--tap \u53EA\u80FD\u662F neutral\u3001line\u3001junction \u6216 mv-line"],
33
+ [/^--winding must be star or delta$/, "--winding \u53EA\u80FD\u662F star \u6216 delta"],
34
+ [/^--reg must be W, G, or 0$/, "--reg \u53EA\u80FD\u662F W\u3001G \u6216 0"],
35
+ [/^--pm must be a whole number of at least 1$/, "--pm \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E 1 \u7684\u6574\u6570"],
36
+ [/^(\S+) must be a whole number of at least 2$/, "$1 \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E 2 \u7684\u6574\u6570"],
37
+ [/^--structure must be auto\|combined\|compound\|cage\|drum$/, "--structure \u53EA\u80FD\u662F auto\u3001combined\u3001compound\u3001cage \u6216 drum"],
38
+ [/^--series must be II\|IV\|V\|VI\|VII\|VIII$/, "--series \u53EA\u80FD\u662F II\u3001IV\u3001V\u3001VI\u3001VII \u6216 VIII"],
39
+ [/^--mount must be in-tank\|on-tank\|dry\|reactor$/, "--mount \u53EA\u80FD\u662F in-tank\u3001on-tank\u3001dry \u6216 reactor"],
40
+ [/^--contact must look like 6x5 or 12x11D$/, "--contact \u7684\u5199\u6CD5\u5982 6x5 \u6216 12x11D"],
41
+ [/^--phases must be I, II, or III$/, "--phases \u53EA\u80FD\u662F I\u3001II \u6216 III"],
42
+ [/^--minus must be a whole number of steps$/, "--minus \u5FC5\u987B\u662F\u6574\u6570\u7EA7\u6570"],
43
+ [/^--mid must be 1 or 3$/, "--mid \u53EA\u80FD\u662F 1 \u6216 3"],
44
+ [/^--duty must be oltc or octc$/, "--duty \u53EA\u80FD\u662F oltc \u6216 octc"],
45
+ [/^--range must look like \+4\/-12 or \+4\/-12x1\.25%$/, "--range \u7684\u5199\u6CD5\u5982 +4/-12 \u6216 +4/-12x1.25%"],
46
+ [/^--mid (\S+) does not fit (\S+): the Fig\. 3-3 row has mid (\S+)\.$/, "--mid $1 \u548C $2 \u4E0D\u5339\u914D\uFF1A\u6837\u672C\u56FE 3-3 \u5BF9\u5E94\u7684\u4E2D\u95F4\u4F4D\u662F $3\u3002"],
47
+ [
48
+ /^--line reads an autotransformer without both HV and MV kV: (.*)\. Give --hv and --mv\.$/s,
49
+ "--line \u8BFB\u51FA\u662F\u81EA\u8026\u53D8\uFF0C\u4F46\u7F3A\u9AD8\u538B\u6216\u4E2D\u538B\u7535\u538B\uFF1A$1\u3002\u8BF7\u7ED9 --hv \u548C --mv\u3002"
50
+ ],
51
+ [
52
+ /^Could not read (MVA and kV|the MVA rating|the kV ratio|the kV ratio and range) from --line: (.*)\. Write it like "25MVA 110±8x1\.25%\/10\.5kV YNd11", or give --mva\/--kv \(or --hv\/--mv\) instead\.$/s,
53
+ (m) => `--line \u8BFB\u4E0D\u51FA${WHAT_ZH[m[1]]}\uFF1A${m[2]}\u3002\u8BF7\u5199\u6210 "25MVA 110\xB18x1.25%/10.5kV YNd11" \u8FD9\u6837\uFF0C\u6216\u6539\u7528 --mva/--kv\uFF08\u81EA\u8026\u53D8\u7528 --hv/--mv\uFF09\u3002`
54
+ ],
55
+ [/^--kind auto with --mva needs --hv and --mv$/, "--kind auto \u914D --mva \u65F6\u9700\u8981 --hv \u548C --mv"],
56
+ [/^--mva requires --kv \(tap-side rated voltage\)$/, "--mva \u9700\u8981 --kv\uFF08\u8C03\u538B\u4FA7\u989D\u5B9A\u7535\u538B\uFF09"],
57
+ [/^--series is off-circuit wiring: add --octc$/, "--series \u662F\u65E0\u8F7D\u63A5\u7EBF\u65B9\u5F0F\uFF1A\u8BF7\u52A0 --octc"],
58
+ [/^--contact is an off-circuit contact: add --octc$/, "--contact \u662F\u65E0\u8F7D\u89E6\u5934\u89C4\u683C\uFF1A\u8BF7\u52A0 --octc"],
59
+ [/^--structure (\S+) is off-circuit: add --octc \(on-load takes combined or compound\)$/, "--structure $1 \u662F\u65E0\u8F7D\u7ED3\u6784\uFF1A\u8BF7\u52A0 --octc\uFF08\u6709\u8F7D\u7528 combined \u6216 compound\uFF09"],
60
+ [/^--structure (\S+) is on-load only: with --octc use cage or drum$/, "--structure $1 \u53EA\u7528\u4E8E\u6709\u8F7D\uFF1A--octc \u65F6\u7528 cage \u6216 drum"],
61
+ [/^--vacuum does not apply with --octc /, "--vacuum \u4E0D\u9002\u7528\u4E8E --octc\uFF08\u65E0\u8F7D\u5F00\u5173\u4E0D\u5207\u65AD\u7535\u6D41\uFF09"],
62
+ [/^--oil does not apply with --mount dry$/, "--oil \u4E0D\u9002\u7528\u4E8E --mount dry"],
63
+ [/^--vacuum does not apply with --mount reactor /, "--vacuum \u4E0D\u9002\u7528\u4E8E --mount reactor\uFF08\u7535\u6297\u5668\u5F00\u5173\u662F\u6CB9\u6D78\u7684\uFF09"],
64
+ [/^--conn D conflicts with --tap neutral: /, "--conn D \u548C --tap neutral \u77DB\u76FE\uFF1A\u4E2D\u6027\u70B9\u662F\u661F\u5F62\uFF08Y\uFF09\u3002\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
65
+ [/^--conn Y conflicts with --tap line: /, "--conn Y \u548C --tap line \u77DB\u76FE\uFF1A\u7EBF\u7AEF\u662F\u89D2\u5F62\uFF08D\uFF09\u3002\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
66
+ [/^--conn does not apply with --mva: /, "--conn \u4E0D\u7528\u4E8E --mva\uFF1AY \u6216 D \u7531\u5F00\u5173\u4F4D\u7F6E\u51B3\u5B9A\u3002\u7EBF\u7AEF\u7528 --tap line\uFF0C\u89D2\u5F62\u7ED5\u7EC4\u7528 --winding delta\u3002"],
67
+ [/^--hv and --mv are autotransformer voltages: /, "--hv \u548C --mv \u662F\u81EA\u8026\u53D8\u7684\u7535\u538B\uFF1A\u8BF7\u52A0 --kind auto\uFF08\u53CC\u7ED5\u7EC4\u7528 --kv\uFF09"],
68
+ [/^--minus sets the lowest-tap current on the --mva path; /, "--minus \u53EA\u5728 --mva \u8DEF\u5F84\u4E0A\u7528\u6765\u7B97\u6700\u4F4E\u6863\u7535\u6D41\uFF1B--iu \u8DEF\u5F84\u8BF7\u76F4\u63A5\u7ED9\u7535\u6D41"],
69
+ [/^Give --um or --earth-um, not both: (\S+) and (\S+) disagree\.$/, "--um \u548C --earth-um \u53EA\u80FD\u7ED9\u4E00\u4E2A\uFF1A$1 \u548C $2 \u4E0D\u4E00\u81F4\u3002"],
70
+ [/^--step-pct is a percent: 1\.25 means 1\.25 %\. (\S+) is too small\.$/, "--step-pct \u662F\u767E\u5206\u6570\uFF1A1.25 \u8868\u793A 1.25%\u3002$1 \u592A\u5C0F\u3002"],
71
+ [/^--pm (\S+) and --pos (\S+) disagree\. Give one of them\.$/, "--pm $1 \u548C --pos $2 \u4E0D\u4E00\u81F4\uFF0C\u8BF7\u53EA\u7ED9\u4E00\u4E2A\u3002"],
72
+ [/^Give --iu or --mva\/--kv, not both /, "--iu \u548C --mva/--kv \u53EA\u80FD\u7ED9\u4E00\u79CD\uFF08--mva \u65C1\u8FB9\u7684\u8BA2\u8D27\u89C4\u8303 Imax \u7528 --os-imax\uFF09"],
73
+ [/^--os-imax needs --mva\/--kv; /, "--os-imax \u9700\u8981 --mva/--kv\uFF1B--iu \u8DEF\u5F84\u4E0A\u7535\u6D41\u76F4\u63A5\u7528 --iu"],
74
+ [/^--k applies only on the --mva path /, "--k \u53EA\u7528\u4E8E --mva \u8DEF\u5F84\uFF08--iu \u4E0D\u4E58\u5B89\u5168\u7CFB\u6570\uFF09"],
75
+ [/^--k must be ≥ 1$/, "--k \u5FC5\u987B\u4E0D\u5C0F\u4E8E 1"],
76
+ [/^--step-pct needs --mva\/--kv; give --ust on the --iu path$/, "--step-pct \u9700\u8981 --mva/--kv\uFF1B--iu \u8DEF\u5F84\u8BF7\u7ED9 --ust"],
77
+ [/^Give --um or --earth-um, not both, when no winding voltage \(--kv\) is given$/, "\u6CA1\u7ED9\u7ED5\u7EC4\u7535\u538B\uFF08--kv\uFF09\u65F6\uFF0C--um \u548C --earth-um \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
78
+ [/^Need --iu \(Imax\) or --mva plus --kv$/, "\u9700\u8981 --iu\uFF08\u6700\u5927\u7535\u6D41\uFF09\uFF0C\u6216 --mva \u52A0 --kv"],
79
+ [/^Need --um, or --mva\/--kv so Um can be derived$/, "\u9700\u8981 --um\uFF0C\u6216\u7ED9 --mva/--kv \u4EE5\u63A8\u51FA Um"],
80
+ [/^Engine emitted a non-catalogue type: (.*)$/, "\u5F15\u64CE\u7ED9\u51FA\u4E86\u6837\u672C\u518C\u91CC\u6CA1\u6709\u7684\u578B\u53F7\uFF1A$1"],
81
+ [/^Bad transformer data$/, "\u53D8\u538B\u5668\u53C2\u6570\u6709\u8BEF"],
82
+ [/^No type found\.$/, "\u6CA1\u6709\u627E\u5230\u578B\u53F7\u3002"]
83
+ ];
84
+ function cliErrorZh(en) {
85
+ for (const [re, to] of ROWS) {
86
+ const m = en.match(re);
87
+ if (!m) continue;
88
+ return typeof to === "function" ? to(m) : to.replace(/\$(\d)/g, (_, d) => m[Number(d)] ?? "");
89
+ }
90
+ return null;
91
+ }
92
+ var HAS_HAN = /[一-鿿]/;
93
+ function cliErrorLines(message, lang) {
94
+ const lines = message.split("\n").filter((l) => l !== "");
95
+ if (lang === "en") return lines;
96
+ if (lines.some((l) => HAS_HAN.test(l))) return lines;
97
+ const whole = cliErrorZh(message);
98
+ if (whole) return [whole, ...lines];
99
+ return lines.flatMap((l) => {
100
+ const zh = cliErrorZh(l);
101
+ return zh ? [zh, l] : [l];
102
+ });
103
+ }
5
104
 
6
105
  // lib/decimal.ts
7
106
  var GROUPED = /^\d{1,3}([,,]\d{3})+$/;
@@ -3045,6 +3144,9 @@ function normalizeTenderText(raw) {
3045
3144
  }
3046
3145
  function parseVectorGroup(raw) {
3047
3146
  const text = raw.replace(
3147
+ /(?<![A-Za-z0-9])(yn|zn|y|d|z)((?:(?:yn|zn|y|d|z|a)\d{1,2}){1,3})(?![A-Za-z0-9])/g,
3148
+ (_m, head, rest) => head.toUpperCase() + rest
3149
+ ).replace(
3048
3150
  /\b(?:YN|Yn|Y|D|ZN|Z)(?:(?:yn|y|d|zn|z|a)[0-9Oo]{0,2}){1,3}(?![A-Za-z0-9])/g,
3049
3151
  (g) => g.replace(/(?<=(?:yn|y|d|zn|z|a)\d?)[Oo]/g, "0")
3050
3152
  ).replace(/(?<![A-Za-z])Y[oO0](?![A-Za-z0-9])/g, "YN").replace(/[Δ△]/g, "D").replace(/\b(YN|Yn|Y|D|ZN|Z)\s*-\s*(?=(?:yn|y|d|zn|z|YN|Yn|Y|D)\s*\d)/g, "$1").replace(
@@ -3285,6 +3387,9 @@ var DRY_TYPE = /\bdry[\s-]?type\b|\bcast[\s-]?resin\b|\bresin[\s-]?(?:cast|encap
3285
3387
  var OFF_CIRCUIT_TAP = new RegExp(
3286
3388
  [
3287
3389
  String.raw`\b(?:DETC|OCTC|NLTC)\b`,
3390
+ // 2026-11-14: "Dyn11 off-circuit ±2x2.5%" names no tap word. "Off-circuit"
3391
+ // and "de-energized" are never loss words; "no-load" is, so it still needs one.
3392
+ String.raw`\b(?:off[\s-]?circuit|de-?energi[sz]ed)\b`,
3288
3393
  String.raw`\b(?:off[\s-]?(?:circuit|load)|no[\s-]?load|de-?energi[sz]ed)\s+tap`,
3289
3394
  String.raw`\btap[\s-]?chang\w*\s*[(:,-]?\s*(?:off[\s-]?(?:circuit|load)|no[\s-]?load|de-?energi[sz]ed)`,
3290
3395
  String.raw`(?:conmutador|cambiador)[^,;.]{0,30}(?:sin\s+carga|desenergizad)`,
@@ -4155,12 +4260,9 @@ function parseCliArgs(rawArgv) {
4155
4260
  continue;
4156
4261
  }
4157
4262
  if (a === "--market") {
4158
- out.given.add("market");
4159
- const [v, n] = take(i, a);
4160
- if (!/^[A-Za-z]{2}$/.test(v)) throw new CliError(`--market must be a 2-letter country code (IT, TR, RU\u2026)`);
4161
- out.market = v.toUpperCase();
4162
- i = n;
4163
- continue;
4263
+ throw new CliError(
4264
+ "--market is removed. State the insulation to earth with --earth-um, and the across-tap levels with --across-li / --across-ac."
4265
+ );
4164
4266
  }
4165
4267
  if (a === "--across-li" || a === "--across-ac") {
4166
4268
  const key = a === "--across-li" ? "acrossLi" : "acrossAc";
@@ -4539,7 +4641,7 @@ Flags:
4539
4641
  --line="\u2026" keeps a line that starts with a dash.
4540
4642
  --mva MVA --kv kV Capacity path: Imax from rated I, minus steps, --step-pct, --k
4541
4643
  With --iu, --kv alone gives the winding voltage (220 kV
4542
- combined-only, 330 kV grade, --market) and Um if omitted.
4644
+ combined-only, 330 kV grade) and Um if omitted.
4543
4645
  --kind two|auto Transformer kind (--auto = --kind auto). Default two-winding.
4544
4646
  --tap P Where the OLTC sits: neutral|line (two-winding),
4545
4647
  junction|mv-line (autotransformer, series/common junction
@@ -4551,9 +4653,6 @@ Flags:
4551
4653
  --earth-um kV OLTC insulation to earth from the OS or maker (catalogue
4552
4654
  class). Overrides the rule: line end = winding system,
4553
4655
  neutral \u226472.5 full else 72.5 assumed, autotransformer = HV.
4554
- --market CC Buyer's country for a neutral's assumed Um: IT (line
4555
- class up to 252), TR (126 on 220 kV class and above).
4556
- Needs --kv (or --mva/--kv).
4557
4656
  --um kV Equipment Um (OLTC). With --kv, derived if omitted.
4558
4657
  --ust V Step voltage. With --mva/--kv/--step-pct, derived if omitted;
4559
4658
  given, it is the OS figure and a floor (never lowers Ust).
@@ -4563,7 +4662,7 @@ Flags:
4563
4662
  --step-pct % Step as percent (1.25 means 1.25%). Capacity path only.
4564
4663
  --k n Safety factor on capacity path only (default 1.0, same as the web app).
4565
4664
  --conn Y|D Switch connection (star point / line end). Default Y.
4566
- On the capacity path, legacy: Y = star neutral, D = delta line end.
4665
+ --iu path only. With --mva or --line it is an error: use --tap.
4567
4666
  --reg W|G|0 Reversing / coarse-fine / linear. Default W.
4568
4667
  --pm N \xB1 steps. Default 8.
4569
4668
  --range +a/-b[xs%] Uneven range, e.g. +4/-12x1.25%. W/G takes the Fig. 3-3
@@ -4683,8 +4782,7 @@ function computeCliDuty(args) {
4683
4782
  ...earth != null ? { earthUmKv: earth } : {},
4684
4783
  ...args.osImax != null && args.osImax > 0 ? { statedMaxA: args.osImax } : {},
4685
4784
  // --ust used to replace Ust after deriveDuty: basis.stepV disagreed (D3).
4686
- ...args.ust != null && args.ust > 0 ? { statedStepV: args.ust } : {},
4687
- ...args.market ? { market: args.market } : {}
4785
+ ...args.ust != null && args.ust > 0 ? { statedStepV: args.ust } : {}
4688
4786
  });
4689
4787
  }
4690
4788
  function checkConflicts(args) {
@@ -4717,6 +4815,11 @@ function checkConflicts(args) {
4717
4815
  throw new CliError("--conn D conflicts with --tap neutral: a neutral tap point is star (Y). Drop one.");
4718
4816
  }
4719
4817
  const typed = (...flags) => flags.some((f) => args.typed?.has(f));
4818
+ if (typed("--conn", "--connection") && args.mva != null) {
4819
+ throw new CliError(
4820
+ "--conn does not apply with --mva: the tap point sets Y or D. Use --tap line for a line end, --winding delta for a delta winding."
4821
+ );
4822
+ }
4720
4823
  if (typed("--conn", "--connection") && typed("--tap") && args.conn === "Y" && args.tap === "line_end") {
4721
4824
  throw new CliError("--conn Y conflicts with --tap line: a line-end tap point is delta (D). Drop one.");
4722
4825
  }
@@ -4767,9 +4870,6 @@ function cliToSelectInput(args) {
4767
4870
  if (args.stepPct != null && args.mva == null) {
4768
4871
  throw new CliError("--step-pct needs --mva/--kv; give --ust on the --iu path");
4769
4872
  }
4770
- if (args.market && args.mva == null && !iuHasVoltage(args)) {
4771
- throw new CliError("--market needs the winding voltage: add --kv (or --mva/--kv)");
4772
- }
4773
4873
  const duty = cliDuty(args);
4774
4874
  let conn = args.conn;
4775
4875
  if (duty && args.mva != null) {
@@ -4806,7 +4906,6 @@ function cliToSelectInput(args) {
4806
4906
  ...duty?.combinedOnly ? { combinedOnly: true } : {},
4807
4907
  ...duty?.ok && args.kind !== "auto" ? { tapWindingKv: duty.umSystemKv } : {},
4808
4908
  // 2026-11-04 r3 ORDERS-11: buyer practice on the grade (TR 72.5C neutrals).
4809
- ...args.market ? { market: args.market } : {},
4810
4909
  throughCurrentA: iu,
4811
4910
  umKv: um,
4812
4911
  stepVoltageV: ust,
@@ -4871,12 +4970,11 @@ function assumptionsFromArgs(args, family) {
4871
4970
  items.push(`\u5BF9\u5730 Um ${args.earthUm}\uFF08\u62DB\u6807\u884C\u4E2D\u6027\u70B9 BIL ${args.line.neutralBilKv} kV\uFF09`);
4872
4971
  }
4873
4972
  if (duty?.umAssumed) items.push(`\u5BF9\u5730 Um ${duty.umKv}\uFF08\u672A\u6307\u5B9A\uFF09`);
4874
- if (args.market) items.push(`\u5E02\u573A=${args.market}`);
4875
4973
  } else {
4876
4974
  const conn = cliConnection(args);
4877
4975
  const derived = tapSetsConnection(args);
4878
4976
  items.push(
4879
- `conn=${conn} ${conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${derived ? "" : mark("conn")}`
4977
+ `${conn} ${conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${derived ? "" : mark("conn")}`
4880
4978
  );
4881
4979
  if (args.kind === "auto") items.push("\u81EA\u8026\u53D8");
4882
4980
  if (derived) {
@@ -4888,10 +4986,10 @@ function assumptionsFromArgs(args, family) {
4888
4986
  if (args.mva != null) {
4889
4987
  items.push(args.given.has("k") ? `k=${args.k}` : "k=1.0\uFF08\u9ED8\u8BA4\uFF09");
4890
4988
  items.push(
4891
- args.given.has("stepPct") ? `step=${args.stepPct}%` : "step=1.25%\uFF08\u9ED8\u8BA4\uFF09"
4989
+ args.given.has("stepPct") ? `\u6BCF\u7EA7 ${args.stepPct}%` : "\u6BCF\u7EA7 1.25%\uFF08\u9ED8\u8BA4\uFF09"
4892
4990
  );
4893
4991
  if (!args.given.has("minus") && !args.given.has("range")) {
4894
- items.push(`\u6700\u4F4E\u6863\u6309 \u2212${cliMinusSteps(args)} \u7B97\uFF08\u2212\u6863\u672A\u6307\u5B9A\uFF0C+a/\u2212b \u7528 --range \u6216 --minus\uFF09`);
4992
+ items.push(`\u6700\u4F4E\u6863\u6309 \u2212${cliMinusSteps(args)}\uFF08\u672A\u6307\u5B9A\uFF09`);
4895
4993
  }
4896
4994
  if (args.lineRangeAssumed && args.range) {
4897
4995
  const { plus, minus } = args.range;
@@ -4926,7 +5024,7 @@ function assumptionsFromArgs(args, family) {
4926
5024
  return items;
4927
5025
  }
4928
5026
  items.push(
4929
- `reg=${args.reg === "reversing" ? "W \u6B63\u53CD\u8C03" : args.reg === "coarse_fine" ? "G \u7C97\u7EC6\u8C03" : "0 \u7EBF\u6027\u8C03"}${mark("reg")}`
5027
+ `${args.reg === "reversing" ? "W \u6B63\u53CD\u8C03" : args.reg === "coarse_fine" ? "G \u7C97\u7EC6\u8C03" : "0 \u7EBF\u6027\u8C03"}${mark("reg")}`
4930
5028
  );
4931
5029
  const uneven = args.range && args.range.plus !== args.range.minus ? `+${args.range.plus}/\u2212${args.range.minus}` : null;
4932
5030
  if (args.reg === "linear") {
@@ -4954,21 +5052,31 @@ function assumptionsFromArgs(args, family) {
4954
5052
  items.push(phases);
4955
5053
  return items;
4956
5054
  }
4957
- function assumptionsLine(args, family) {
4958
- const items = assumptionsFromArgs(args, family);
4959
- if (items.every((i) => !i.includes("\uFF08\u9ED8\u8BA4\uFF09") && !i.includes("\u672A\u6307\u5B9A"))) {
4960
- return null;
4961
- }
4962
- return `\u5047\u5B9A\uFF1A${items.join(" \xB7 ")}`;
5055
+ var QUIET_ASSUMPTIONS = [
5056
+ /^(双绕组|自耦变)(默认)$/,
5057
+ /^(星形|角形)绕组(默认)$/,
5058
+ /^k=1\.0(默认)$/,
5059
+ /^(真空|油浸)(默认)$/,
5060
+ /^相数=.+(默认)$/,
5061
+ // The note and the per-class line under the type already say it.
5062
+ /^对地 Um [\d.]+(未指定)$/,
5063
+ // The engine's own note says the step voltage was not given.
5064
+ /^Ust 未指定/,
5065
+ new RegExp(`^(${Object.values(MOUNT_ZH).map((m) => m.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")).join("|")})\uFF08\u9ED8\u8BA4\uFF09$`)
5066
+ ];
5067
+ function assumptionsShown(args, family) {
5068
+ const assumed = (i) => i.includes("\uFF08\u9ED8\u8BA4") || i.includes("\u672A\u6307\u5B9A") || i.includes("\u62DB\u6807\u884C");
5069
+ const workedOut = (i) => /(由 |(±|→/.test(i) || i.startsWith("\u5F00\u5173\u5728") && !args.given.has("tap") || /^[YD] (星点|线端)$/.test(i) && args.mva == null && !args.given.has("conn");
5070
+ return assumptionsFromArgs(args, family).filter((i) => assumed(i) || workedOut(i)).filter((i) => !QUIET_ASSUMPTIONS.some((re) => re.test(i))).map((i) => i.replace(/(默认)$/, ""));
4963
5071
  }
4964
5072
  var round1 = (n) => Math.round(n * 10) / 10;
4965
5073
  var ASSUMPTION_EN = [
5074
+ [/^最低档按 −(\d+)(未指定)$/, "lowest tap at \u2212$1 (not stated)"],
4966
5075
  ["\uFF08\u9ED8\u8BA4\uFF0C\u62DB\u6807\u884C\u672A\u5199\u5168\uFF09", " (default; the line does not give it all)"],
4967
5076
  ["\uFF08\u9ED8\u8BA4\uFF09", " (default)"],
4968
5077
  ["\uFF08\u672A\u6307\u5B9A\uFF09", " (not stated)"],
4969
5078
  ["\uFF08\u5F85 OS \u6838\u5BF9\uFF09", " (check the OS)"],
4970
5079
  [/(只给一项:等级不低于 Um 默认)/, " (one value only: grade not below the Um default)"],
4971
- [/^最低档按 −(\d+) 算(−档未指定,\+a\/−b 用 --range 或 --minus)$/, "lowest tap at \u2212$1 (minus not stated; give +a/\u2212b with --range or --minus)"],
4972
5080
  [/^无载开关取 ([\d.]+) kV 绕组的范围((默认,)?招标行有两个调压范围)$/, "off-circuit range from the $1 kV winding (two ranges on the line)"],
4973
5081
  [/^对地 Um ([\d.]+)(招标行中性点 BIL ([\d.]+) kV)$/, "Um to earth $1 (line neutral BIL $2 kV)"],
4974
5082
  ["Ust \u672A\u6307\u5B9A\uFF08\u7EA7\u7535\u538B\u3001\u7EA7\u5BB9\u91CF\u672A\u6821\u9A8C\uFF09", "Ust not stated (step voltage and capacity not checked)"],
@@ -4980,13 +5088,13 @@ var ASSUMPTION_EN = [
4980
5088
  ["\u81EA\u8026\u53D8", "autotransformer"],
4981
5089
  ["\u53CC\u7ED5\u7EC4", "two-winding"],
4982
5090
  [/^容量 /, "power "],
5091
+ [/^每级 /, "step "],
4983
5092
  ["\u661F\u5F62\u7ED5\u7EC4", "star winding"],
4984
5093
  ["\u89D2\u5F62\u7ED5\u7EC4", "delta winding"],
4985
5094
  [/^调压绕组间 /, "across tap winding "],
4986
5095
  [/^调压绕组 /, "tapped winding "],
4987
5096
  [/^调压范围 /, "range "],
4988
5097
  ["\u5BF9\u5730 Um", "Um to earth"],
4989
- ["\u5E02\u573A=", "market="],
4990
5098
  ["\u661F\u70B9", "star point"],
4991
5099
  ["\u7EBF\u7AEF", "line end"],
4992
5100
  ["\u4E2D\u6027\u70B9", "neutral"],
@@ -5020,7 +5128,7 @@ function assumptionEn(item) {
5020
5128
  }
5021
5129
  function basisLineEn(d) {
5022
5130
  const div = d.currentDivisor === "three" ? "3" : "\u221A3";
5023
- const um = d.umRule === "explicit" ? `Um to earth ${d.umKv} (stated)` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `neutral Um ${d.umKv}${d.umAssumed ? " (check the OS)" : ""}` : `${d.umSystemKv} kV system Um ${d.actualUmKv} \u2192 class ${d.umKv}`;
5131
+ const um = d.umRule === "explicit" ? `Um to earth ${d.umKv} (stated)` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `neutral Um ${d.umKv}` : `${d.umSystemKv} kV system Um ${d.actualUmKv} \u2192 class ${d.umKv}`;
5024
5132
  const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
5025
5133
  const max = d.maxRule === "stated" ? "OS Imax" : "lowest tap";
5026
5134
  if (!(d.ratedA > 0)) return `Imax as given \xB7 ${um}`;
@@ -5028,7 +5136,7 @@ function basisLineEn(d) {
5028
5136
  }
5029
5137
  function basisLineZh(d) {
5030
5138
  const div = d.currentDivisor === "three" ? "3" : "\u221A3";
5031
- const um = d.umRule === "explicit" ? `\u5BF9\u5730 Um ${d.umKv}\uFF08\u6307\u5B9A\uFF09` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `\u4E2D\u6027\u70B9 Um ${d.umKv}${d.umAssumed ? "\uFF08\u5F85 OS \u6838\u5BF9\uFF09" : ""}` : `${d.umSystemKv} kV \u7CFB\u7EDF Um ${d.actualUmKv} \u2192 ${d.umKv} \u7EA7`;
5139
+ const um = d.umRule === "explicit" ? `\u5BF9\u5730 Um ${d.umKv}\uFF08\u6307\u5B9A\uFF09` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `\u4E2D\u6027\u70B9 Um ${d.umKv}` : `${d.umSystemKv} kV \u7CFB\u7EDF Um ${d.actualUmKv} \u2192 ${d.umKv} \u7EA7`;
5032
5140
  const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
5033
5141
  const max = d.maxRule === "stated" ? "OS Imax" : "\u6700\u4F4E\u6863";
5034
5142
  if (!(d.ratedA > 0)) return `Imax \u6309\u7ED9\u5B9A\u503C \xB7 ${um}`;
@@ -5052,11 +5160,6 @@ function cliNotes(args, input, primaryUmKv, en, engineNotes = []) {
5052
5160
  en ? `Um ${input.umKv} kV is not a class of this type: sized at Um ${primaryUmKv} kV.` : `Um ${input.umKv} kV \u4E0D\u662F\u8BE5\u578B\u53F7\u7684\u7535\u538B\u7B49\u7EA7\uFF0C\u6309 Um ${primaryUmKv} kV \u9009\u3002`
5053
5161
  );
5054
5162
  }
5055
- if (args.market && args.market !== "IT" && args.market !== "TR") {
5056
- notes.push(
5057
- en ? `--market ${args.market} has no rule (IT and TR only): not used.` : `--market ${args.market} \u6CA1\u6709\u5BF9\u5E94\u89C4\u5219\uFF08\u53EA\u6709 IT\u3001TR\uFF09\uFF0C\u672A\u4F7F\u7528\u3002`
5058
- );
5059
- }
5060
5163
  return notes;
5061
5164
  }
5062
5165
  function lineKindLabel(t, en) {
@@ -5109,7 +5212,7 @@ function formatCliText(input, args) {
5109
5212
  if (choices.length > 1) {
5110
5213
  const list = choices.map((c) => `Um ${c.um} \u2192 ${c.model ?? (en ? "none" : "\u65E0")}`).join(" \xB7 ");
5111
5214
  lines.push(
5112
- en ? `Insulation to earth open: ${list} (take it from the tender's neutral / tap-winding insulation; use --earth-um)` : `\u5BF9\u5730\u7EDD\u7F18\u672A\u5B9A\uFF1A${list}\uFF08\u6309\u62DB\u6807\u7684\u4E2D\u6027\u70B9/\u8C03\u538B\u7ED5\u7EC4\u7EDD\u7F18\u53D6\uFF0C\u7528 --earth-um\uFF09`
5215
+ en ? `By insulation class: ${list} (set it with --earth-um)` : `\u5404\u7EDD\u7F18\u7B49\u7EA7\u5BF9\u5E94\u578B\u53F7\uFF1A${list}\uFF08\u7528 --earth-um \u6307\u5B9A\uFF09`
5113
5216
  );
5114
5217
  }
5115
5218
  if (args?.line) {
@@ -5121,14 +5224,14 @@ function formatCliText(input, args) {
5121
5224
  }
5122
5225
  if (alts.length) {
5123
5226
  lines.push("");
5124
- lines.push(en ? "Other" : "\u5176\u4ED6");
5227
+ lines.push(en ? "Other types that cover the duty" : "\u5176\u4ED6\u53EF\u9009");
5125
5228
  for (const a of alts) lines.push(a.model);
5126
5229
  }
5127
5230
  if (args) {
5128
- const assumed = assumptionsLine(args, primary.seriesCode);
5129
- if (assumed) {
5231
+ const shown = assumptionsShown(args, primary.seriesCode);
5232
+ if (shown.length) {
5130
5233
  lines.push("");
5131
- lines.push(en ? `Assumed: ${assumptionsFromArgs(args, primary.seriesCode).map(assumptionEn).join(" \xB7 ")}` : assumed);
5234
+ lines.push(en ? `Assumed: ${shown.map(assumptionEn).join(" \xB7 ")}` : `\u5047\u5B9A\uFF1A${shown.join(" \xB7 ")}`);
5132
5235
  }
5133
5236
  }
5134
5237
  return lines.join("\n") + "\n";
@@ -5197,7 +5300,8 @@ function formatCliJson(input, args) {
5197
5300
  })(),
5198
5301
  umChoices: args ? umChoicesFor(args, input) : [],
5199
5302
  assumptions: args ? assumptionsFromArgs(args, primary?.seriesCode).map((a) => en ? assumptionEn(a) : a) : [],
5200
- errors: [...en ? out.errorsEn : out.errorsZh.length ? out.errorsZh : out.errorsEn, ...hint ? [hint] : []]
5303
+ // Same lines as the text output: Chinese then English, or English alone.
5304
+ errors: [...en ? out.errorsEn : [...out.errorsZh, ...out.errorsEn], ...hint ? [hint] : []]
5201
5305
  };
5202
5306
  return JSON.stringify(payload, null, 2) + "\n";
5203
5307
  }
@@ -5235,11 +5339,17 @@ function runCli(argv2, io = {
5235
5339
  return 0;
5236
5340
  }
5237
5341
  const wantsJson = argv2.includes("--json");
5342
+ const langAt = argv2.findIndex((a) => a === "--lang" || a.startsWith("--lang="));
5343
+ const langArg = langAt < 0 ? void 0 : argv2[langAt].includes("=") ? argv2[langAt].split("=")[1] : argv2[langAt + 1];
5344
+ const envLang = typeof process !== "undefined" ? process.env?.OLTC_LANG : void 0;
5345
+ const lang = (langArg ?? envLang ?? "zh").toLowerCase() === "en" ? "en" : "zh";
5238
5346
  try {
5239
5347
  const args = parseCliArgs(argv2);
5240
5348
  if (args.version) {
5241
- io.stdout(`oltc-selector ${APP_VERSION}
5242
- `);
5349
+ io.stdout(
5350
+ wantsJson ? JSON.stringify({ ok: true, version: APP_VERSION }, null, 2) + "\n" : `oltc-selector ${APP_VERSION}
5351
+ `
5352
+ );
5243
5353
  return 0;
5244
5354
  }
5245
5355
  const input = cliToSelectInput(args);
@@ -5252,12 +5362,12 @@ function runCli(argv2, io = {
5252
5362
  return 0;
5253
5363
  } catch (err) {
5254
5364
  const msg = err instanceof Error ? err.message : String(err);
5365
+ const lines = cliErrorLines(msg, lang);
5255
5366
  if (wantsJson) {
5256
- io.stdout(
5257
- JSON.stringify({ ok: false, version: APP_VERSION, model: null, errors: msg.split("\n") }, null, 2) + "\n"
5258
- );
5367
+ io.stdout(JSON.stringify({ ok: false, version: APP_VERSION, model: null, errors: lines }, null, 2) + "\n");
5368
+ return 1;
5259
5369
  }
5260
- io.stderr(msg.endsWith("\n") ? msg : msg + "\n");
5370
+ io.stderr(lines.join("\n") + "\n");
5261
5371
  return 1;
5262
5372
  }
5263
5373
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oltc-selector",
3
- "version": "2.3.2",
3
+ "version": "2.4.1",
4
4
  "description": "OLTC/OCTC type selection CLI. No prices. Same engine as the web app.",
5
5
  "bin": {
6
6
  "oltc": "bin/oltc.js"