dsh-unitverse 0.1.0 → 1.1.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/CHANGELOG.en.md +26 -0
- package/CHANGELOG.md +26 -0
- package/README.en.md +13 -3
- package/README.md +16 -6
- package/lib/{chunk-KLTLDDLU.js → chunk-TYC2FTN7.js} +6 -3
- package/lib/client.js +6 -3
- package/lib/{convert-D6txqQbW.d.cts → convert-DVefQ0C-.d.cts} +2 -2
- package/lib/{convert-D6txqQbW.d.ts → convert-DVefQ0C-.d.ts} +2 -2
- package/lib/convert.cjs +6 -3
- package/lib/convert.d.cts +1 -1
- package/lib/convert.d.ts +1 -1
- package/lib/convert.js +1 -1
- package/lib/index.cjs +9 -3
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -1
- package/package.json +1 -1
package/CHANGELOG.en.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
This project follows [Semantic Versioning](https://semver.org/). Chinese version: [CHANGELOG.md](CHANGELOG.md).
|
|
4
4
|
|
|
5
|
+
## [1.1.0] - 2026-09-10
|
|
6
|
+
|
|
7
|
+
The web converter view kept working, but the model-facing `convert` tool **rejected every single call** since 0.1.0 because of host output validation. This release fixes that blocking defect and repairs the temperature-difference (Δ) output and error text.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **The `convert` tool could not be called at all**: the output schema declared only 7 properties while the engine returned 10 (it also returns `categoryEn`, `fromInput`, `toInput`), so under `additionalProperties: false` every call was rejected by the host with "returned invalid output". All three properties are now declared, keeping the caller's original spelling in the echo.
|
|
12
|
+
- **The Δ marker was dropped from a difference `summary`**: `10 Δ°C → Δ°F` used to read `10 °C = 18 °F`, i.e. it looked like an absolute-scale equality (the absolute `10 °C` is `50 °F`). Echoed units and `summary` now keep the marker: `10 Δ°C = 18 Δ°F (温度)`.
|
|
13
|
+
- **The absolute/Δ mismatch error doubled the marker into `ΔΔ`**: `Δ°C → K` used to suggest `use ΔΔ°C and K consistently` (`ΔΔ°C` is not a valid unit) and offered only one repair. It now prefixes `Δ` only to the side that lacks it and names both repairs: `use both with the Δ marker (Δ°C, ΔK) or both absolute (°C, K)`.
|
|
14
|
+
- Stray trailing space in the unknown-unit error message.
|
|
15
|
+
- Stale delta example in the core JSDoc, `convert(1, 'Δ°C', '°F')` → `convert(1, 'Δ°C', 'Δ°F')`. The original call is rejected as `mixed-delta`, and the comment ships inside `lib/*.d.ts`, so it handed library consumers a wrong example.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Echoed unit names for a difference conversion now carry the `Δ` prefix (`from` / `to` fields and `summary`), which tells an interval apart from an absolute reading. The web view is unaffected — it builds its own display strings and never reads `summary`.
|
|
20
|
+
- Tests grew from 88 to 92: a regression assertion that the output schema and the returned key set stay identical (so a missing declaration can never silently break the tool again), plus dedicated assertions for the delta echo and the non-doubled error hint.
|
|
21
|
+
|
|
22
|
+
### Docs
|
|
23
|
+
|
|
24
|
+
- `README.md` / `README.en.md`: document the full `convert` result shape (10 fields) and the delta echo / dual-repair error behaviour.
|
|
25
|
+
|
|
26
|
+
### Release
|
|
27
|
+
|
|
28
|
+
- npm: `dsh-unitverse@1.1.0`
|
|
29
|
+
- GitHub: https://github.com/runcat-tommy/dsh-unitverse
|
|
30
|
+
|
|
5
31
|
## [0.1.0] - 2026-09-10
|
|
6
32
|
|
|
7
33
|
First release.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
本项目遵循[语义化版本](https://semver.org/lang/zh-CN/)。英文版见 [CHANGELOG.en.md](CHANGELOG.en.md)。
|
|
4
4
|
|
|
5
|
+
## [1.1.0] - 2026-09-10
|
|
6
|
+
|
|
7
|
+
Web 换算视图一直可用,但模型调用的 `convert` 工具自 0.1.0 起**每次调用都会被宿主校验拒绝**——本次修复该致命问题,并修正温度温差(Δ)的输出与报错。
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
|
|
11
|
+
- **`convert` 工具完全无法调用**:输出 schema 只声明了 7 个字段,而引擎实际返回 10 个(另含 `categoryEn`、`fromInput`、`toInput`),在 `additionalProperties: false` 下每次调用都被宿主以 "returned invalid output" 拒绝。现已补齐这三个字段声明,保留调用方原始拼写的回显。
|
|
12
|
+
- **温差结果的 `summary` 丢掉了 Δ**:`10 Δ°C → Δ°F` 曾显示为 `10 °C = 18 °F`,读起来是一个绝对温标等式(绝对的 `10 °C` 应为 `50 °F`)。现在回显单位与 `summary` 均保留 Δ 标记:`10 Δ°C = 18 Δ°F (温度)`。
|
|
13
|
+
- **绝对/Δ 混用的报错会把 Δ 叠成 `ΔΔ`**:`Δ°C → K` 曾提示 `use ΔΔ°C and K consistently`(`ΔΔ°C` 不是合法单位),且只给出一种修法。现改为只给缺 Δ 的一侧补 Δ,并同时列出两种修法:`use both with the Δ marker (Δ°C, ΔK) or both absolute (°C, K)`。
|
|
14
|
+
- 未知单位报错文案末尾多余的尾随空格。
|
|
15
|
+
- 核心库 JSDoc 中过时的温差示例 `convert(1, 'Δ°C', '°F')` 已改为 `convert(1, 'Δ°C', 'Δ°F')`——原示例的调用实际会被 `mixed-delta` 拒绝,而该注释会随 `lib/*.d.ts` 一起发布,会把错误示例带给库使用者。
|
|
16
|
+
|
|
17
|
+
### 变更
|
|
18
|
+
|
|
19
|
+
- 温差换算回显的单位名现在带 `Δ` 前缀(`from` / `to` 字段与 `summary`),据此可区分温差与绝对温标读数。Web 界面不受影响(界面自行拼接显示串,不读 `summary`)。
|
|
20
|
+
- 测试由 88 条增至 92 条:新增"输出 schema 与返回值键集一致"的回归断言(防止"少声明字段导致工具不可调用"再次发生),以及温差回显、报错不叠 Δ 的专项断言。
|
|
21
|
+
|
|
22
|
+
### 文档
|
|
23
|
+
|
|
24
|
+
- `README.md` / `README.en.md`:补全 `convert` 返回结构(10 个字段),说明温差回显保留 Δ 标记及两种修法提示。
|
|
25
|
+
|
|
26
|
+
### 发布
|
|
27
|
+
|
|
28
|
+
- npm:`dsh-unitverse@1.1.0`
|
|
29
|
+
- GitHub:https://github.com/runcat-tommy/dsh-unitverse
|
|
30
|
+
|
|
5
31
|
## [0.1.0] - 2026-09-10
|
|
6
32
|
|
|
7
33
|
首次发布。
|
package/README.en.md
CHANGED
|
@@ -55,9 +55,12 @@ Chinese name** as aliases — e.g. `ft`, `foot`, `feet` and `英尺` are the sam
|
|
|
55
55
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
|
-
Install it as a DSH bundle
|
|
58
|
+
Install it as a DSH bundle — published on npm as `dsh-unitverse`; a local checkout, a tarball or GitHub work too:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
+
# From npm (recommended)
|
|
62
|
+
dsh plugin --profile <profile-name> add dsh-unitverse
|
|
63
|
+
|
|
61
64
|
# From a local checkout
|
|
62
65
|
dsh plugin --profile <profile-name> add ./dsh-unitverse
|
|
63
66
|
|
|
@@ -122,7 +125,7 @@ Tool parameters:
|
|
|
122
125
|
| `from` | string | yes | Source unit: symbol / English / Chinese, case-insensitive |
|
|
123
126
|
| `to` | string | yes | Target unit: symbol / English / Chinese, case-insensitive |
|
|
124
127
|
|
|
125
|
-
Returns a structured result: `{ value, from, to, result, category, categoryZh, summary }
|
|
128
|
+
Returns a structured result: `{ value, from, to, result, category, categoryZh, categoryEn, fromInput, toInput, summary }` (`fromInput` / `toInput` are the caller's original tokens; `from` / `to` are the resolved canonical names).
|
|
126
129
|
|
|
127
130
|
### Examples
|
|
128
131
|
|
|
@@ -149,7 +152,14 @@ Temperature converts as an **absolute scale** by default. For a temperature
|
|
|
149
152
|
```
|
|
150
153
|
|
|
151
154
|
Mixing an absolute and a Δ unit (e.g. `Δ°C` → `K`) is rejected to avoid
|
|
152
|
-
ambiguous "degrees Kelvin"-style semantics
|
|
155
|
+
ambiguous "degrees Kelvin"-style semantics; the error names both repairs (add Δ
|
|
156
|
+
to both, or drop it from both). Delta results keep the Δ marker in the echoed
|
|
157
|
+
units, so an interval is never mistaken for an absolute reading:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
convert(10, "Δ°C", "Δ°F") → summary: "10 Δ°C = 18 Δ°F (温度)"
|
|
161
|
+
convert(10, "°C", "°F") → summary: "10 °C = 50 °F (温度)" ← absolute, a different result
|
|
162
|
+
```
|
|
153
163
|
|
|
154
164
|
## Precision and conventions
|
|
155
165
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-unitverse · Unit Converter
|
|
2
2
|
|
|
3
|
-
English | [中文](
|
|
3
|
+
English | [中文](README.md) · [Changelog](CHANGELOG.en.md)
|
|
4
4
|
|
|
5
5
|
> The name reads **unit + universe**: ten categories of units in one universe.
|
|
6
6
|
> The GUI view tab is still called **单位换算 / Unit Converter**, and the
|
|
@@ -15,11 +15,11 @@ plus both absolute-temperature and temperature-difference (Δ) modes.
|
|
|
15
15
|
|
|
16
16
|
English UI — one independent module per category, listing only that category's units:
|
|
17
17
|
|
|
18
|
-
](assets/preview-en.jpg)
|
|
19
19
|
|
|
20
20
|
Chinese UI — all copy, category names and unit names in Chinese:
|
|
21
21
|
|
|
22
|
-
](assets/preview-zh.jpg)
|
|
23
23
|
|
|
24
24
|
## Features
|
|
25
25
|
|
|
@@ -55,9 +55,12 @@ Chinese name** as aliases — e.g. `ft`, `foot`, `feet` and `英尺` are the sam
|
|
|
55
55
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
|
-
Install it as a DSH bundle
|
|
58
|
+
Install it as a DSH bundle — published on npm as `dsh-unitverse`; a local checkout, a tarball or GitHub work too:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
+
# From npm (recommended)
|
|
62
|
+
dsh plugin --profile <profile-name> add dsh-unitverse
|
|
63
|
+
|
|
61
64
|
# From a local checkout
|
|
62
65
|
dsh plugin --profile <profile-name> add ./dsh-unitverse
|
|
63
66
|
|
|
@@ -122,7 +125,7 @@ Tool parameters:
|
|
|
122
125
|
| `from` | string | yes | Source unit: symbol / English / Chinese, case-insensitive |
|
|
123
126
|
| `to` | string | yes | Target unit: symbol / English / Chinese, case-insensitive |
|
|
124
127
|
|
|
125
|
-
Returns a structured result: `{ value, from, to, result, category, categoryZh, summary }
|
|
128
|
+
Returns a structured result: `{ value, from, to, result, category, categoryZh, categoryEn, fromInput, toInput, summary }` (`fromInput` / `toInput` are the caller's original tokens; `from` / `to` are the resolved canonical names).
|
|
126
129
|
|
|
127
130
|
### Examples
|
|
128
131
|
|
|
@@ -149,7 +152,14 @@ Temperature converts as an **absolute scale** by default. For a temperature
|
|
|
149
152
|
```
|
|
150
153
|
|
|
151
154
|
Mixing an absolute and a Δ unit (e.g. `Δ°C` → `K`) is rejected to avoid
|
|
152
|
-
ambiguous "degrees Kelvin"-style semantics
|
|
155
|
+
ambiguous "degrees Kelvin"-style semantics; the error names both repairs (add Δ
|
|
156
|
+
to both, or drop it from both). Delta results keep the Δ marker in the echoed
|
|
157
|
+
units, so an interval is never mistaken for an absolute reading:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
convert(10, "Δ°C", "Δ°F") → summary: "10 Δ°C = 18 Δ°F (温度)"
|
|
161
|
+
convert(10, "°C", "°F") → summary: "10 °C = 50 °F (温度)" ← absolute, a different result
|
|
162
|
+
```
|
|
153
163
|
|
|
154
164
|
## Precision and conventions
|
|
155
165
|
|
|
@@ -188,7 +188,7 @@ function resolveUnit(token) {
|
|
|
188
188
|
if (def === void 0) {
|
|
189
189
|
throw new UnitConversionError(
|
|
190
190
|
"unknown-unit",
|
|
191
|
-
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit
|
|
191
|
+
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit.`,
|
|
192
192
|
base
|
|
193
193
|
);
|
|
194
194
|
}
|
|
@@ -199,7 +199,8 @@ function resolveUnit(token) {
|
|
|
199
199
|
token
|
|
200
200
|
);
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
const canonical = `${delta ? "\u0394" : ""}${displayNameFor(def, base)}`;
|
|
203
|
+
return { def, delta, canonical };
|
|
203
204
|
}
|
|
204
205
|
function assertFiniteValue(value) {
|
|
205
206
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -217,9 +218,11 @@ function parseRequest(value, from, to) {
|
|
|
217
218
|
);
|
|
218
219
|
}
|
|
219
220
|
if (fromResolved.delta !== toResolved.delta) {
|
|
221
|
+
const bothDelta = `\u0394${fromResolved.def.symbol}, \u0394${toResolved.def.symbol}`;
|
|
222
|
+
const bothAbsolute = `${fromResolved.def.symbol}, ${toResolved.def.symbol}`;
|
|
220
223
|
throw new UnitConversionError(
|
|
221
224
|
"mixed-delta",
|
|
222
|
-
`cannot mix absolute and \u0394 temperature units: use
|
|
225
|
+
`cannot mix absolute and \u0394 temperature units: use both with the \u0394 marker (${bothDelta}) or both absolute (${bothAbsolute}) consistently.`
|
|
223
226
|
);
|
|
224
227
|
}
|
|
225
228
|
return { value, from: fromResolved, to: toResolved };
|
package/lib/client.js
CHANGED
|
@@ -227,7 +227,7 @@ function resolveUnit(token) {
|
|
|
227
227
|
if (def === void 0) {
|
|
228
228
|
throw new UnitConversionError(
|
|
229
229
|
"unknown-unit",
|
|
230
|
-
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit
|
|
230
|
+
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit.`,
|
|
231
231
|
base
|
|
232
232
|
);
|
|
233
233
|
}
|
|
@@ -238,7 +238,8 @@ function resolveUnit(token) {
|
|
|
238
238
|
token
|
|
239
239
|
);
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
const canonical = `${delta ? "\u0394" : ""}${displayNameFor(def, base)}`;
|
|
242
|
+
return { def, delta, canonical };
|
|
242
243
|
}
|
|
243
244
|
function assertFiniteValue(value) {
|
|
244
245
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -256,9 +257,11 @@ function parseRequest(value, from, to) {
|
|
|
256
257
|
);
|
|
257
258
|
}
|
|
258
259
|
if (fromResolved.delta !== toResolved.delta) {
|
|
260
|
+
const bothDelta = `\u0394${fromResolved.def.symbol}, \u0394${toResolved.def.symbol}`;
|
|
261
|
+
const bothAbsolute = `${fromResolved.def.symbol}, ${toResolved.def.symbol}`;
|
|
259
262
|
throw new UnitConversionError(
|
|
260
263
|
"mixed-delta",
|
|
261
|
-
`cannot mix absolute and \u0394 temperature units: use
|
|
264
|
+
`cannot mix absolute and \u0394 temperature units: use both with the \u0394 marker (${bothDelta}) or both absolute (${bothAbsolute}) consistently.`
|
|
262
265
|
);
|
|
263
266
|
}
|
|
264
267
|
return { value, from: fromResolved, to: toResolved };
|
|
@@ -103,7 +103,7 @@ interface ResolvedUnit {
|
|
|
103
103
|
def: UnitDef;
|
|
104
104
|
/** Whether the caller asked for a temperature *difference* (Δ) conversion. */
|
|
105
105
|
delta: boolean;
|
|
106
|
-
/** Canonical
|
|
106
|
+
/** Canonical spelling resolved from the input, e.g. `千米`; keeps any leading Δ marker. */
|
|
107
107
|
canonical: string;
|
|
108
108
|
}
|
|
109
109
|
/** A validated conversion request after both units parsed. */
|
|
@@ -168,7 +168,7 @@ declare function convertRaw(value: number, from: ResolvedUnit, to: ResolvedUnit)
|
|
|
168
168
|
* ```ts
|
|
169
169
|
* convert(100, 'km', 'mi') // 62.13711922
|
|
170
170
|
* convert(25, '°C', '°F') // 77
|
|
171
|
-
* convert(1, 'Δ°C', '
|
|
171
|
+
* convert(1, 'Δ°C', 'Δ°F') // 1.8 (temperature difference; both tokens need Δ)
|
|
172
172
|
* convert(3, '公里/小时', 'm/s') // 0.8333333333
|
|
173
173
|
* ```
|
|
174
174
|
*
|
|
@@ -103,7 +103,7 @@ interface ResolvedUnit {
|
|
|
103
103
|
def: UnitDef;
|
|
104
104
|
/** Whether the caller asked for a temperature *difference* (Δ) conversion. */
|
|
105
105
|
delta: boolean;
|
|
106
|
-
/** Canonical
|
|
106
|
+
/** Canonical spelling resolved from the input, e.g. `千米`; keeps any leading Δ marker. */
|
|
107
107
|
canonical: string;
|
|
108
108
|
}
|
|
109
109
|
/** A validated conversion request after both units parsed. */
|
|
@@ -168,7 +168,7 @@ declare function convertRaw(value: number, from: ResolvedUnit, to: ResolvedUnit)
|
|
|
168
168
|
* ```ts
|
|
169
169
|
* convert(100, 'km', 'mi') // 62.13711922
|
|
170
170
|
* convert(25, '°C', '°F') // 77
|
|
171
|
-
* convert(1, 'Δ°C', '
|
|
171
|
+
* convert(1, 'Δ°C', 'Δ°F') // 1.8 (temperature difference; both tokens need Δ)
|
|
172
172
|
* convert(3, '公里/小时', 'm/s') // 0.8333333333
|
|
173
173
|
* ```
|
|
174
174
|
*
|
package/lib/convert.cjs
CHANGED
|
@@ -205,7 +205,7 @@ function resolveUnit(token) {
|
|
|
205
205
|
if (def === void 0) {
|
|
206
206
|
throw new UnitConversionError(
|
|
207
207
|
"unknown-unit",
|
|
208
|
-
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit
|
|
208
|
+
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit.`,
|
|
209
209
|
base
|
|
210
210
|
);
|
|
211
211
|
}
|
|
@@ -216,7 +216,8 @@ function resolveUnit(token) {
|
|
|
216
216
|
token
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
const canonical = `${delta ? "\u0394" : ""}${displayNameFor(def, base)}`;
|
|
220
|
+
return { def, delta, canonical };
|
|
220
221
|
}
|
|
221
222
|
function assertFiniteValue(value) {
|
|
222
223
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -234,9 +235,11 @@ function parseRequest(value, from, to) {
|
|
|
234
235
|
);
|
|
235
236
|
}
|
|
236
237
|
if (fromResolved.delta !== toResolved.delta) {
|
|
238
|
+
const bothDelta = `\u0394${fromResolved.def.symbol}, \u0394${toResolved.def.symbol}`;
|
|
239
|
+
const bothAbsolute = `${fromResolved.def.symbol}, ${toResolved.def.symbol}`;
|
|
237
240
|
throw new UnitConversionError(
|
|
238
241
|
"mixed-delta",
|
|
239
|
-
`cannot mix absolute and \u0394 temperature units: use
|
|
242
|
+
`cannot mix absolute and \u0394 temperature units: use both with the \u0394 marker (${bothDelta}) or both absolute (${bothAbsolute}) consistently.`
|
|
240
243
|
);
|
|
241
244
|
}
|
|
242
245
|
return { value, from: fromResolved, to: toResolved };
|
package/lib/convert.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { e as ConvertOptions, f as ConvertRequest, g as ConvertResult, R as ResolvedUnit, h as UnitConversionError, k as convert, l as convertDetailed, m as convertRaw, p as parseRequest, r as resolveUnit, q as roundSignificant } from './convert-
|
|
1
|
+
export { e as ConvertOptions, f as ConvertRequest, g as ConvertResult, R as ResolvedUnit, h as UnitConversionError, k as convert, l as convertDetailed, m as convertRaw, p as parseRequest, r as resolveUnit, q as roundSignificant } from './convert-DVefQ0C-.cjs';
|
package/lib/convert.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { e as ConvertOptions, f as ConvertRequest, g as ConvertResult, R as ResolvedUnit, h as UnitConversionError, k as convert, l as convertDetailed, m as convertRaw, p as parseRequest, r as resolveUnit, q as roundSignificant } from './convert-
|
|
1
|
+
export { e as ConvertOptions, f as ConvertRequest, g as ConvertResult, R as ResolvedUnit, h as UnitConversionError, k as convert, l as convertDetailed, m as convertRaw, p as parseRequest, r as resolveUnit, q as roundSignificant } from './convert-DVefQ0C-.js';
|
package/lib/convert.js
CHANGED
package/lib/index.cjs
CHANGED
|
@@ -234,7 +234,7 @@ function resolveUnit(token) {
|
|
|
234
234
|
if (def === void 0) {
|
|
235
235
|
throw new UnitConversionError(
|
|
236
236
|
"unknown-unit",
|
|
237
|
-
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit
|
|
237
|
+
`unknown unit "${base}": it is not a recognized length/area/volume/time/angle/speed/temperature/pressure/energy/power unit.`,
|
|
238
238
|
base
|
|
239
239
|
);
|
|
240
240
|
}
|
|
@@ -245,7 +245,8 @@ function resolveUnit(token) {
|
|
|
245
245
|
token
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
const canonical = `${delta ? "\u0394" : ""}${displayNameFor(def, base)}`;
|
|
249
|
+
return { def, delta, canonical };
|
|
249
250
|
}
|
|
250
251
|
function assertFiniteValue(value) {
|
|
251
252
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -263,9 +264,11 @@ function parseRequest(value, from, to) {
|
|
|
263
264
|
);
|
|
264
265
|
}
|
|
265
266
|
if (fromResolved.delta !== toResolved.delta) {
|
|
267
|
+
const bothDelta = `\u0394${fromResolved.def.symbol}, \u0394${toResolved.def.symbol}`;
|
|
268
|
+
const bothAbsolute = `${fromResolved.def.symbol}, ${toResolved.def.symbol}`;
|
|
266
269
|
throw new UnitConversionError(
|
|
267
270
|
"mixed-delta",
|
|
268
|
-
`cannot mix absolute and \u0394 temperature units: use
|
|
271
|
+
`cannot mix absolute and \u0394 temperature units: use both with the \u0394 marker (${bothDelta}) or both absolute (${bothAbsolute}) consistently.`
|
|
269
272
|
);
|
|
270
273
|
}
|
|
271
274
|
return { value, from: fromResolved, to: toResolved };
|
|
@@ -373,6 +376,9 @@ function apply(ctx) {
|
|
|
373
376
|
result: { type: "number", required: true, description: "Converted value." },
|
|
374
377
|
category: { type: "string", required: true, description: "Category id, e.g. length." },
|
|
375
378
|
categoryZh: { type: "string", required: true, description: "Category name in Chinese." },
|
|
379
|
+
categoryEn: { type: "string", required: true, description: "Category name in English." },
|
|
380
|
+
fromInput: { type: "string", required: true, description: "Source token exactly as passed by the caller." },
|
|
381
|
+
toInput: { type: "string", required: true, description: "Target token exactly as passed by the caller." },
|
|
376
382
|
summary: { type: "string", required: true, description: "Human-readable result line." }
|
|
377
383
|
}
|
|
378
384
|
},
|
package/lib/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
export { A as ALIAS_INDEX, a as AliasIndex, C as CATEGORIES, b as CATEGORY_ORDER, c as CategoryId, d as CategoryMeta, e as ConvertOptions, f as ConvertRequest, g as ConvertResult, D as DELTA_MARKERS, R as ResolvedUnit, U as UNITS, h as UnitConversionError, i as UnitDef, j as buildAliasIndex, k as convert, l as convertDetailed, m as convertRaw, n as findUnit, o as normalizeUnit, p as parseRequest, r as resolveUnit, q as roundSignificant, s as stripDeltaMarker, u as unitsByCategory } from './convert-
|
|
2
|
+
export { A as ALIAS_INDEX, a as AliasIndex, C as CATEGORIES, b as CATEGORY_ORDER, c as CategoryId, d as CategoryMeta, e as ConvertOptions, f as ConvertRequest, g as ConvertResult, D as DELTA_MARKERS, R as ResolvedUnit, U as UNITS, h as UnitConversionError, i as UnitDef, j as buildAliasIndex, k as convert, l as convertDetailed, m as convertRaw, n as findUnit, o as normalizeUnit, p as parseRequest, r as resolveUnit, q as roundSignificant, s as stripDeltaMarker, u as unitsByCategory } from './convert-DVefQ0C-.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* dsh-unitverse — DeepSeek Harness plugin entry.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
export { A as ALIAS_INDEX, a as AliasIndex, C as CATEGORIES, b as CATEGORY_ORDER, c as CategoryId, d as CategoryMeta, e as ConvertOptions, f as ConvertRequest, g as ConvertResult, D as DELTA_MARKERS, R as ResolvedUnit, U as UNITS, h as UnitConversionError, i as UnitDef, j as buildAliasIndex, k as convert, l as convertDetailed, m as convertRaw, n as findUnit, o as normalizeUnit, p as parseRequest, r as resolveUnit, q as roundSignificant, s as stripDeltaMarker, u as unitsByCategory } from './convert-
|
|
2
|
+
export { A as ALIAS_INDEX, a as AliasIndex, C as CATEGORIES, b as CATEGORY_ORDER, c as CategoryId, d as CategoryMeta, e as ConvertOptions, f as ConvertRequest, g as ConvertResult, D as DELTA_MARKERS, R as ResolvedUnit, U as UNITS, h as UnitConversionError, i as UnitDef, j as buildAliasIndex, k as convert, l as convertDetailed, m as convertRaw, n as findUnit, o as normalizeUnit, p as parseRequest, r as resolveUnit, q as roundSignificant, s as stripDeltaMarker, u as unitsByCategory } from './convert-DVefQ0C-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* dsh-unitverse — DeepSeek Harness plugin entry.
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
roundSignificant,
|
|
17
17
|
stripDeltaMarker,
|
|
18
18
|
unitsByCategory
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TYC2FTN7.js";
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
@@ -67,6 +67,9 @@ function apply(ctx) {
|
|
|
67
67
|
result: { type: "number", required: true, description: "Converted value." },
|
|
68
68
|
category: { type: "string", required: true, description: "Category id, e.g. length." },
|
|
69
69
|
categoryZh: { type: "string", required: true, description: "Category name in Chinese." },
|
|
70
|
+
categoryEn: { type: "string", required: true, description: "Category name in English." },
|
|
71
|
+
fromInput: { type: "string", required: true, description: "Source token exactly as passed by the caller." },
|
|
72
|
+
toInput: { type: "string", required: true, description: "Target token exactly as passed by the caller." },
|
|
70
73
|
summary: { type: "string", required: true, description: "Human-readable result line." }
|
|
71
74
|
}
|
|
72
75
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unitverse",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "DSH plugin: universal unit conversion across length, area, volume, time, angle, speed, temperature, pressure, energy and power, with Chinese/English aliases. 单位换算 DSH 插件(长度/面积/体积/时间/角度/速度/温度/压力/热量/功率,支持中英文单位名)。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|