dsh-any-deepseek 0.0.29 → 0.0.30

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 (2) hide show
  1. package/lib/client.js +34 -10
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -118,27 +118,51 @@ window.__ModuleLoader__.load({
118
118
  parts.push(`${window.name} ${Math.round(window.remainingPercent)}%${suffix}`);
119
119
  }
120
120
  if (available === false) parts.push("(余额不足)");
121
- if (row.reading.note !== void 0 && row.reading.note !== "") parts.push(describeNote(row.reading.note, now));
121
+ /**
122
+ * The note — but only when it adds something the line does not already say.
123
+ *
124
+ * 🔴 **This guard was missing in the first cut of 0.0.29, and the live payload caught it.**
125
+ * Rendering the note unconditionally made OpenCode Go's line
126
+ * `rolling 93%(还有 2 小时) · weekly 50%(还有 5 天) · monthly 23%(还有 2 天) ·
127
+ * subscription usage windows; the credit balance is not readable with an API key`
128
+ * — three windows that already answer the question, followed by a sentence explaining a
129
+ * limitation the reader did not ask about. The panel has ONE line per channel.
130
+ *
131
+ * The rule: a note that only *explains why a field is absent* is redundant once that field's
132
+ * absence is already visible (no amounts shown ⇒ obviously no amount). A note that carries a
133
+ * FACT — Ollama's `period … → …` is the only source of its cycle end — must be rendered.
134
+ * `describeNote` reports which kind it is, so the decision lives in one place rather than as a
135
+ * string comparison here.
136
+ */
137
+ if (row.reading.note !== void 0 && row.reading.note !== "") {
138
+ const described = describeNote(row.reading.note, now);
139
+ if (described !== void 0) parts.push(described);
140
+ else if (parts.length === 0) parts.push(row.reading.note);
141
+ }
122
142
  if (parts.length === 0) return "无可读数值";
123
143
  return parts.join(" · ");
124
144
  }
125
145
  /**
126
- * Turn a provider note into something with a readable time horizon.
146
+ * Turn a provider note into something worth a place on the one-line balance cell — or nothing.
147
+ *
148
+ * Only one note shape carries a FACT the line cannot otherwise show: Ollama's
149
+ * `period <from> → <until>`, which is the sole source of that channel's cycle end. It is rewritten
150
+ * to 「周期至 <date>(还有 N 天)」.
127
151
  *
128
- * The only note this rewrites is Ollama's `period <from> → <until>` — the rest are already prose
129
- * written for a human (「unlimited」 and friends) and pass through untouched.
152
+ * 🔴 Everything else returns `undefined`, i.e. is DROPPED. That is the measured correction from the
153
+ * first cut of 0.0.29: OpenCode Go's note is `subscription usage windows; the credit balance is not
154
+ * readable with an API key`, which explains why a field is missing — a fact the reader can already
155
+ * see (no amount is rendered). Appending it turned a clean three-window line into a wall of text in
156
+ * a 256px-wide panel. ⚠️ It is NOT lost: the same string still travels in `/balance`, and the
157
+ * panel's own documentation covers it, so a reader who wants the explanation can still find it.
130
158
  *
131
- * 🔴 Why rewrite rather than append: 「period 2026-10-19T13:07:35Z → 2026-11-19T13:07:35Z」 is two
132
- * ISO timestamps. The reader wants "how long until it renews", not a diff to do in their head.
133
- * The absolute dates stay, because a horizon without an anchor cannot be checked against a
134
- * calendar.
135
159
  * @param note - the reading's note, verbatim from the parser.
136
160
  * @param now - clock, injectable for tests.
137
- * @returns the note, with an added 「还有 N 天」 when it is a period statement.
161
+ * @returns the rewritable sentence, or `undefined` when the note adds nothing to the line.
138
162
  */
139
163
  function describeNote(note, now = /* @__PURE__ */ new Date()) {
140
164
  const period = /^period\s+(\S+)\s+→\s+(\S+)$/.exec(note);
141
- if (period === null) return note;
165
+ if (period === null) return void 0;
142
166
  const from = period[1] ?? "";
143
167
  const until = period[2] ?? "";
144
168
  const untilText = formatTimeUntil(until, now);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-any-deepseek",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "One DeepSeek V4.1 Flash provider for DeepSeek Harness: paste a key per channel, switch channels manually, token usage booked per real upstream.",
5
5
  "license": "MIT",
6
6
  "repository": {