oltc-selector 1.0.0 → 1.2.0
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 +1 -1
- package/bin/oltc.js +74 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
填工况,给出 2025 目录里**最低满足**的型号。网页和 `oltc` CLI 共用同一份 `selectOltc` 引擎。
|
|
4
4
|
|
|
5
|
-
**CLI(无报价):** `npm i -g oltc-selector`,命令是 `oltc`。
|
|
5
|
+
**CLI(无报价):** `npm i -g oltc-selector`,命令是 `oltc`。Agent 技能包:`skills/huaming-oltc-selector/`(站点 `/agents/` 可下载 zip)。
|
|
6
6
|
**网页:** [oltc-selector.vercel.app](https://oltc-selector.vercel.app/) · [GitHub Pages](https://erict16.github.io/oltc-selector/)
|
|
7
7
|
|
|
8
8
|
私人辅助,不是厂家官网。型号是起点,出 OS 前要工程确认。
|
package/bin/oltc.js
CHANGED
|
@@ -1757,7 +1757,8 @@ function parseCliArgs(argv) {
|
|
|
1757
1757
|
phases: "III",
|
|
1758
1758
|
json: false,
|
|
1759
1759
|
help: false,
|
|
1760
|
-
pm: 8
|
|
1760
|
+
pm: 8,
|
|
1761
|
+
given: /* @__PURE__ */ new Set()
|
|
1761
1762
|
};
|
|
1762
1763
|
const take = (i, flag) => {
|
|
1763
1764
|
const v = argv[i + 1];
|
|
@@ -1777,62 +1778,73 @@ function parseCliArgs(argv) {
|
|
|
1777
1778
|
continue;
|
|
1778
1779
|
}
|
|
1779
1780
|
if (a === "--octc") {
|
|
1781
|
+
out.given.add("octc");
|
|
1780
1782
|
out.octc = true;
|
|
1781
1783
|
continue;
|
|
1782
1784
|
}
|
|
1783
1785
|
if (a === "--oil") {
|
|
1786
|
+
out.given.add("medium");
|
|
1784
1787
|
out.oil = true;
|
|
1785
1788
|
out.vacuum = false;
|
|
1786
1789
|
continue;
|
|
1787
1790
|
}
|
|
1788
1791
|
if (a === "--vacuum") {
|
|
1792
|
+
out.given.add("medium");
|
|
1789
1793
|
out.vacuum = true;
|
|
1790
1794
|
out.oil = false;
|
|
1791
1795
|
continue;
|
|
1792
1796
|
}
|
|
1793
1797
|
if (a === "--iu" || a === "--imax") {
|
|
1798
|
+
out.given.add("iu");
|
|
1794
1799
|
const [v, n] = take(i, a);
|
|
1795
1800
|
out.iu = num(v, a);
|
|
1796
1801
|
i = n;
|
|
1797
1802
|
continue;
|
|
1798
1803
|
}
|
|
1799
1804
|
if (a === "--mva") {
|
|
1805
|
+
out.given.add("mva");
|
|
1800
1806
|
const [v, n] = take(i, a);
|
|
1801
1807
|
out.mva = num(v, a);
|
|
1802
1808
|
i = n;
|
|
1803
1809
|
continue;
|
|
1804
1810
|
}
|
|
1805
1811
|
if (a === "--kv") {
|
|
1812
|
+
out.given.add("kv");
|
|
1806
1813
|
const [v, n] = take(i, a);
|
|
1807
1814
|
out.kv = num(v, a);
|
|
1808
1815
|
i = n;
|
|
1809
1816
|
continue;
|
|
1810
1817
|
}
|
|
1811
1818
|
if (a === "--um") {
|
|
1819
|
+
out.given.add("um");
|
|
1812
1820
|
const [v, n] = take(i, a);
|
|
1813
1821
|
out.um = num(v, a);
|
|
1814
1822
|
i = n;
|
|
1815
1823
|
continue;
|
|
1816
1824
|
}
|
|
1817
1825
|
if (a === "--ust") {
|
|
1826
|
+
out.given.add("ust");
|
|
1818
1827
|
const [v, n] = take(i, a);
|
|
1819
1828
|
out.ust = num(v, a);
|
|
1820
1829
|
i = n;
|
|
1821
1830
|
continue;
|
|
1822
1831
|
}
|
|
1823
1832
|
if (a === "--step-pct") {
|
|
1833
|
+
out.given.add("stepPct");
|
|
1824
1834
|
const [v, n] = take(i, a);
|
|
1825
1835
|
out.stepPct = num(v, a);
|
|
1826
1836
|
i = n;
|
|
1827
1837
|
continue;
|
|
1828
1838
|
}
|
|
1829
1839
|
if (a === "--k") {
|
|
1840
|
+
out.given.add("k");
|
|
1830
1841
|
const [v, n] = take(i, a);
|
|
1831
1842
|
out.k = num(v, a);
|
|
1832
1843
|
i = n;
|
|
1833
1844
|
continue;
|
|
1834
1845
|
}
|
|
1835
1846
|
if (a === "--conn" || a === "--connection") {
|
|
1847
|
+
out.given.add("conn");
|
|
1836
1848
|
const [v, n] = take(i, a);
|
|
1837
1849
|
const c = v.toUpperCase();
|
|
1838
1850
|
if (c !== "Y" && c !== "D") throw new CliError(`--conn must be Y or D`);
|
|
@@ -1841,6 +1853,7 @@ function parseCliArgs(argv) {
|
|
|
1841
1853
|
continue;
|
|
1842
1854
|
}
|
|
1843
1855
|
if (a === "--reg") {
|
|
1856
|
+
out.given.add("reg");
|
|
1844
1857
|
const [v, n] = take(i, a);
|
|
1845
1858
|
const r = v.toUpperCase();
|
|
1846
1859
|
if (r === "W" || r === "REVERSING") out.reg = "reversing";
|
|
@@ -1852,18 +1865,21 @@ function parseCliArgs(argv) {
|
|
|
1852
1865
|
continue;
|
|
1853
1866
|
}
|
|
1854
1867
|
if (a === "--pm") {
|
|
1868
|
+
out.given.add("pm");
|
|
1855
1869
|
const [v, n] = take(i, a);
|
|
1856
1870
|
out.pm = num(v, a);
|
|
1857
1871
|
i = n;
|
|
1858
1872
|
continue;
|
|
1859
1873
|
}
|
|
1860
1874
|
if (a === "--positions" || a === "--pos") {
|
|
1875
|
+
out.given.add("positions");
|
|
1861
1876
|
const [v, n] = take(i, a);
|
|
1862
1877
|
out.positions = num(v, a);
|
|
1863
1878
|
i = n;
|
|
1864
1879
|
continue;
|
|
1865
1880
|
}
|
|
1866
1881
|
if (a === "--structure") {
|
|
1882
|
+
out.given.add("structure");
|
|
1867
1883
|
const [v, n] = take(i, a);
|
|
1868
1884
|
const s = v.toLowerCase();
|
|
1869
1885
|
const map = {
|
|
@@ -1887,6 +1903,7 @@ function parseCliArgs(argv) {
|
|
|
1887
1903
|
continue;
|
|
1888
1904
|
}
|
|
1889
1905
|
if (a === "--series") {
|
|
1906
|
+
out.given.add("series");
|
|
1890
1907
|
const [v, n] = take(i, a);
|
|
1891
1908
|
const r = v.toUpperCase();
|
|
1892
1909
|
const ok = ["II", "IV", "V", "VI", "VII", "VIII", "AUTO"];
|
|
@@ -1898,6 +1915,7 @@ function parseCliArgs(argv) {
|
|
|
1898
1915
|
continue;
|
|
1899
1916
|
}
|
|
1900
1917
|
if (a === "--mount") {
|
|
1918
|
+
out.given.add("mount");
|
|
1901
1919
|
const [v, n] = take(i, a);
|
|
1902
1920
|
const m = v.toLowerCase().replace("_", "-");
|
|
1903
1921
|
if (m === "in-tank" || m === "intank") out.mount = "in_tank";
|
|
@@ -1908,12 +1926,14 @@ function parseCliArgs(argv) {
|
|
|
1908
1926
|
continue;
|
|
1909
1927
|
}
|
|
1910
1928
|
if (a === "--contact") {
|
|
1929
|
+
out.given.add("contact");
|
|
1911
1930
|
const [v, n] = take(i, a);
|
|
1912
1931
|
out.contact = v;
|
|
1913
1932
|
i = n;
|
|
1914
1933
|
continue;
|
|
1915
1934
|
}
|
|
1916
1935
|
if (a === "--phases") {
|
|
1936
|
+
out.given.add("phases");
|
|
1917
1937
|
const [v, n] = take(i, a);
|
|
1918
1938
|
const p = v.toUpperCase();
|
|
1919
1939
|
if (p !== "I" && p !== "II" && p !== "III") {
|
|
@@ -1924,6 +1944,7 @@ function parseCliArgs(argv) {
|
|
|
1924
1944
|
continue;
|
|
1925
1945
|
}
|
|
1926
1946
|
if (a === "--duty") {
|
|
1947
|
+
out.given.add("octc");
|
|
1927
1948
|
const [v, n] = take(i, a);
|
|
1928
1949
|
const d = v.toLowerCase();
|
|
1929
1950
|
if (d === "octc" || d === "off" || d === "detc") out.octc = true;
|
|
@@ -2035,7 +2056,48 @@ function cliToSelectInput(args) {
|
|
|
2035
2056
|
}
|
|
2036
2057
|
return input;
|
|
2037
2058
|
}
|
|
2038
|
-
|
|
2059
|
+
var MOUNT_ZH = {
|
|
2060
|
+
in_tank: "\u7BB1\u5185",
|
|
2061
|
+
on_tank: "\u7BB1\u9876",
|
|
2062
|
+
dry_type: "\u5E72\u5F0F"
|
|
2063
|
+
};
|
|
2064
|
+
function assumptionsFromArgs(args) {
|
|
2065
|
+
const mark = (key) => args.given.has(key) ? "" : "\uFF08\u9ED8\u8BA4\uFF09";
|
|
2066
|
+
const items = [
|
|
2067
|
+
`conn=${args.conn} ${args.conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${mark("conn")}`
|
|
2068
|
+
];
|
|
2069
|
+
if (args.octc) {
|
|
2070
|
+
const pos = args.positions ?? (args.pm != null && args.pm > 0 ? Math.round(2 * args.pm + 1) : null);
|
|
2071
|
+
items.push(pos != null ? `${pos} \u6863${mark("positions")}` : "\u6863\u6570\u672A\u6307\u5B9A");
|
|
2072
|
+
const s = args.series ?? "auto";
|
|
2073
|
+
items.push(
|
|
2074
|
+
s === "auto" ? `\u63A5\u7EBF=\u81EA\u52A8\uFF08${args.conn === "Y" ? "IV" : "II"}\uFF09${mark("series")}` : `\u63A5\u7EBF=${s}${mark("series")}`
|
|
2075
|
+
);
|
|
2076
|
+
items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
|
|
2077
|
+
return items;
|
|
2078
|
+
}
|
|
2079
|
+
items.push(
|
|
2080
|
+
`reg=${args.reg === "reversing" ? "W \u6B63\u53CD\u8C03" : args.reg === "coarse_fine" ? "G \u7C97\u7EC6\u8C03" : "0 \u7EBF\u6027\u8C03"}${mark("reg")}`
|
|
2081
|
+
);
|
|
2082
|
+
if (args.reg === "linear") {
|
|
2083
|
+
items.push(
|
|
2084
|
+
args.positions != null ? `${args.positions} \u6863${mark("positions")}` : "\u6863\u6570\u672A\u6307\u5B9A"
|
|
2085
|
+
);
|
|
2086
|
+
} else {
|
|
2087
|
+
items.push(`\xB1${args.pm ?? 8} \u6863${mark("pm")}`);
|
|
2088
|
+
}
|
|
2089
|
+
items.push(`${args.oil || !args.vacuum ? "\u6CB9\u6D78" : "\u771F\u7A7A"}${mark("medium")}`);
|
|
2090
|
+
items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
|
|
2091
|
+
return items;
|
|
2092
|
+
}
|
|
2093
|
+
function assumptionsLine(args) {
|
|
2094
|
+
const items = assumptionsFromArgs(args);
|
|
2095
|
+
if (items.every((i) => !i.includes("\uFF08\u9ED8\u8BA4\uFF09") && !i.includes("\u672A\u6307\u5B9A"))) {
|
|
2096
|
+
return null;
|
|
2097
|
+
}
|
|
2098
|
+
return `\u5047\u5B9A\uFF1A${items.join(" \xB7 ")}`;
|
|
2099
|
+
}
|
|
2100
|
+
function formatCliText(input, args) {
|
|
2039
2101
|
const out = selectOltc(input);
|
|
2040
2102
|
if (!out.ok || !out.results.length) {
|
|
2041
2103
|
const err = [...out.errorsZh, ...out.errorsEn].join("\n") || "No type found.";
|
|
@@ -2055,9 +2117,16 @@ function formatCliText(input) {
|
|
|
2055
2117
|
lines.push("\u5176\u4ED6");
|
|
2056
2118
|
for (const a of alts) lines.push(a.model);
|
|
2057
2119
|
}
|
|
2120
|
+
if (args) {
|
|
2121
|
+
const assumed = assumptionsLine(args);
|
|
2122
|
+
if (assumed) {
|
|
2123
|
+
lines.push("");
|
|
2124
|
+
lines.push(assumed);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2058
2127
|
return lines.join("\n") + "\n";
|
|
2059
2128
|
}
|
|
2060
|
-
function formatCliJson(input) {
|
|
2129
|
+
function formatCliJson(input, args) {
|
|
2061
2130
|
const out = selectOltc(input);
|
|
2062
2131
|
const primary = out.results[0] ?? null;
|
|
2063
2132
|
const alts = pickOtherOptions(out.results, 3).map((r) => r.model);
|
|
@@ -2066,6 +2135,7 @@ function formatCliJson(input) {
|
|
|
2066
2135
|
model: primary?.model ?? null,
|
|
2067
2136
|
why: primary?.reasonsZh[0] ?? primary?.reasonsEn[0] ?? null,
|
|
2068
2137
|
alts,
|
|
2138
|
+
assumptions: args ? assumptionsFromArgs(args) : [],
|
|
2069
2139
|
errors: out.errorsZh.length ? out.errorsZh : out.errorsEn
|
|
2070
2140
|
};
|
|
2071
2141
|
return JSON.stringify(payload, null, 2) + "\n";
|
|
@@ -2081,7 +2151,7 @@ function runCli(argv, io = {
|
|
|
2081
2151
|
return 0;
|
|
2082
2152
|
}
|
|
2083
2153
|
const input = cliToSelectInput(args);
|
|
2084
|
-
io.stdout(args.json ? formatCliJson(input) : formatCliText(input));
|
|
2154
|
+
io.stdout(args.json ? formatCliJson(input, args) : formatCliText(input, args));
|
|
2085
2155
|
return 0;
|
|
2086
2156
|
} catch (err) {
|
|
2087
2157
|
const msg = err instanceof Error ? err.message : String(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oltc-selector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Huaming OLTC/OCTC type selection CLI. No prices. Same engine as the web app.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oltc": "bin/oltc.js"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20"
|
|
15
15
|
},
|
|
16
|
-
"license": "
|
|
16
|
+
"license": "MIT",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/erict16/oltc-selector.git"
|