dsh-boost 0.2.0 → 0.2.2

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/lib/client.js CHANGED
@@ -20,12 +20,13 @@ window.__ModuleLoader__.load({
20
20
  const HINT_OVERHEAD$1 = "每次请求的常驻成本:协议段 + 工具 schema。它不随会话变化,也不被任何节省抵消。";
21
21
  const HINT_PROJECTION_GROSS_REPLAY$1 = "每条回执的节省乘以它自己的 (1 + horizon) 再求和。这个数才是净额的被减数。";
22
22
  const HINT_PROJECTION_NET$1 = "净额 = 重放毛额 − 取回内容成本 − 取回调用成本。回放用每条回执自己的 horizon,不是当前值;所以上面两个毛额不是同一个数,净额只与重放那个对齐。";
23
- const HINT_PROJECTION_ON_ROLLBACK$1 = "回滚:把「投影」改回 `shadow` 并保存(或跑 `boost shadow true`)。改动立即对后续请求生效,不需要重启宿主。";
23
+ const HINT_PROJECTION_ON_ROLLBACK$1 = '回滚:把「投影」改回 `shadow` 并保存;或调 `boost` 工具,`cmd: "scope-set"`、`body: {"projection": "shadow"}`。改动对后续请求立即生效,不需要重启宿主。';
24
24
  const HINT_PROJECTION_ON_SPILL$1 = "宿主有 spill 后端。没有的话投影会被跳过——`boost status` 的降级项会写 `ERR_HOST_NO_SPILL`,页面上也会显示这一条。";
25
- const HINT_PROJECTION_ON_THINKING$1 = "第一次真替换之后盯一次 `content[].thinking` 的 400。当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察;查不出来就不假装查过。";
26
25
  const HINT_SAVED_LOWER$1 = "下界是被跳过那次请求自己的总用量:它不含「后续还会回放多少次」,所以真实节省高于这个数。";
27
26
  const HINT_SAVED_UPPER$1 = "上界是「下一次请求的输入」:它把被替换调用的结果也算进了节省,所以真实节省低于这个数。";
28
27
  const HINT_SHADOW_MEANS$1 = "影子模式:插件照常决策并记账,但不真的改动发给模型的内容。";
28
+ const HINT_SUBSTITUTE_ON_ROLLBACK$1 = "回滚:把「影子模式」勾回去并保存,替换立即停止;投影的设置不受影响。";
29
+ const HINT_SUBSTITUTE_ON_THINKING$1 = "第一次真替换之后盯一次含 `content[].thinking` 的 400。合成回合没有 `replayState`,宿主侧的转换会丢掉 thinking 块;当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察。";
29
30
  const INTRO$1 = "投影裁剪工具回执、确定性替换可推导的调用。下面的数字全部来自收据,不是估算的替代品:区间给出下界与上界,两者都不是精确值。";
30
31
  const LABEL_CONFIG_KEY$1 = "键";
31
32
  const LABEL_CONFIG_VALUE$1 = "生效值";
@@ -40,13 +41,14 @@ window.__ModuleLoader__.load({
40
41
  const LABEL_PROJECTION_GROSS$1 = "投影毛额(一次性)";
41
42
  const LABEL_PROJECTION_GROSS_REPLAY$1 = "投影毛额(按各自 horizon 重放)";
42
43
  const LABEL_PROJECTION_NET$1 = "投影净额";
43
- const LABEL_PROJECTION_ON_PRECONDITIONS$1 = "开启投影前确认两件事";
44
+ const LABEL_PROJECTION_ON_PRECONDITIONS$1 = "开启投影前确认一件事";
44
45
  const LABEL_RETRIEVALS$1 = "取回次数";
45
46
  const LABEL_SAVED_LOWER$1 = "替换节省(下界)";
46
47
  const LABEL_SAVED_UPPER$1 = "替换节省(上界)";
47
48
  const LABEL_SAVE_FAILED$1 = "保存没有生效:";
48
49
  const LABEL_SHADOW$1 = "影子模式";
49
50
  const LABEL_STALE_IDS$1 = "已保存但注册表里没有";
51
+ const LABEL_SUBSTITUTE_ON_PRECONDITIONS$1 = "关掉影子模式前确认一件事";
50
52
  const LABEL_UNMATCHED_IDS$1 = "已勾选但注册表里没有";
51
53
  const LABEL_WORKSPACES$1 = "工作区";
52
54
  const LOADING$1 = "读取中…";
@@ -56,15 +58,16 @@ window.__ModuleLoader__.load({
56
58
  const PROJECTION_ON$1 = "开启(真替换)";
57
59
  const PROJECTION_SHADOW$1 = "影子(只记账)";
58
60
  const RETRY$1 = "重试";
59
- const SAVED$1 = "与磁盘上的文档一致。";
61
+ const SAVED$1 = "与页面上次读到或保存时的文档一致。页面不会轮询:别处(例如让模型调用 boost)改了 scope,这里要重新读取才看得到。";
60
62
  const SECTION_CONFIG$1 = "生效配置";
61
63
  const SECTION_COUNTS$1 = "收据计数";
62
64
  const SECTION_SCOPE$1 = "作用域";
63
65
  const SECTION_STATUS$1 = "运行状态";
64
66
  const TITLE$1 = "Token 效率";
65
67
  const UNAVAILABLE_REGISTRY$1 = "读不到作用域文档,这一块暂时只读。";
66
- const UNKNOWN$1 = "未测量";
68
+ const UNKNOWN$1 = "未知错误";
67
69
  const meta$1 = { "description": "通过工具回执投影与确定性只读替换降低 DeepSeek Harness 的 token 消耗。", "title": "dsh-boost" };
70
+ const STATUS_UNAVAILABLE$1 = "状态读取失败,下面的数字不是「没有」,而是没读到";
68
71
  const zh = {
69
72
  ACTION_REREAD: ACTION_REREAD$1,
70
73
  ACTION_SAVE: ACTION_SAVE$1,
@@ -116,10 +119,11 @@ window.__ModuleLoader__.load({
116
119
  HINT_PROJECTION_NET: HINT_PROJECTION_NET$1,
117
120
  HINT_PROJECTION_ON_ROLLBACK: HINT_PROJECTION_ON_ROLLBACK$1,
118
121
  HINT_PROJECTION_ON_SPILL: HINT_PROJECTION_ON_SPILL$1,
119
- HINT_PROJECTION_ON_THINKING: HINT_PROJECTION_ON_THINKING$1,
120
122
  HINT_SAVED_LOWER: HINT_SAVED_LOWER$1,
121
123
  HINT_SAVED_UPPER: HINT_SAVED_UPPER$1,
122
124
  HINT_SHADOW_MEANS: HINT_SHADOW_MEANS$1,
125
+ HINT_SUBSTITUTE_ON_ROLLBACK: HINT_SUBSTITUTE_ON_ROLLBACK$1,
126
+ HINT_SUBSTITUTE_ON_THINKING: HINT_SUBSTITUTE_ON_THINKING$1,
123
127
  INTRO: INTRO$1,
124
128
  LABEL_CONFIG_KEY: LABEL_CONFIG_KEY$1,
125
129
  LABEL_CONFIG_VALUE: LABEL_CONFIG_VALUE$1,
@@ -141,6 +145,7 @@ window.__ModuleLoader__.load({
141
145
  LABEL_SAVE_FAILED: LABEL_SAVE_FAILED$1,
142
146
  LABEL_SHADOW: LABEL_SHADOW$1,
143
147
  LABEL_STALE_IDS: LABEL_STALE_IDS$1,
148
+ LABEL_SUBSTITUTE_ON_PRECONDITIONS: LABEL_SUBSTITUTE_ON_PRECONDITIONS$1,
144
149
  LABEL_UNMATCHED_IDS: LABEL_UNMATCHED_IDS$1,
145
150
  LABEL_WORKSPACES: LABEL_WORKSPACES$1,
146
151
  LOADING: LOADING$1,
@@ -158,7 +163,8 @@ window.__ModuleLoader__.load({
158
163
  TITLE: TITLE$1,
159
164
  UNAVAILABLE_REGISTRY: UNAVAILABLE_REGISTRY$1,
160
165
  UNKNOWN: UNKNOWN$1,
161
- meta: meta$1
166
+ meta: meta$1,
167
+ STATUS_UNAVAILABLE: STATUS_UNAVAILABLE$1
162
168
  };
163
169
  function copyOf(t) {
164
170
  const resolved = {};
@@ -182,6 +188,95 @@ window.__ModuleLoader__.load({
182
188
  shadow: "PROJECTION_SHADOW",
183
189
  on: "PROJECTION_ON"
184
190
  };
191
+ const PROJECTIONS = ["off", "shadow", "on"];
192
+ const isMode = (value) => value === "selected" || value === "global";
193
+ const isProjection = (value) => value === "off" || value === "shadow" || value === "on";
194
+ function seedOf(scope) {
195
+ if (scope === null || typeof scope !== "object") return void 0;
196
+ const envelope = scope;
197
+ if (envelope.ok !== true || envelope.data === null || typeof envelope.data !== "object") return void 0;
198
+ const doc = envelope.data;
199
+ const revision = doc.revision;
200
+ const version2 = doc.version;
201
+ const shadow = doc.shadow;
202
+ const workspaceIds = doc.workspaceIds;
203
+ if (typeof revision !== "number" || !Number.isFinite(revision)) return void 0;
204
+ if (typeof version2 !== "number" || !Number.isFinite(version2)) return void 0;
205
+ if (typeof shadow !== "boolean") return void 0;
206
+ if (!Array.isArray(workspaceIds) || !workspaceIds.every((id) => typeof id === "string")) return void 0;
207
+ if (!isMode(doc.mode) || !isProjection(doc.projection)) return void 0;
208
+ return {
209
+ version: version2,
210
+ revision,
211
+ mode: doc.mode,
212
+ workspaceIds: [...workspaceIds],
213
+ shadow,
214
+ projection: doc.projection
215
+ };
216
+ }
217
+ function draftOf(seed) {
218
+ return patchOf(seed);
219
+ }
220
+ function isDirty(draft, seed) {
221
+ if (draft.mode !== seed.mode) return true;
222
+ if (draft.shadow !== seed.shadow) return true;
223
+ if (draft.projection !== seed.projection) return true;
224
+ if (draft.workspaceIds.length !== seed.workspaceIds.length) return true;
225
+ return draft.workspaceIds.some((id) => !seed.workspaceIds.includes(id));
226
+ }
227
+ const VERSION_CODES = /* @__PURE__ */ new Set([
228
+ "ERR_SCOPE_UNKNOWN_VERSION",
229
+ "ERR_SCOPE_FUTURE_VERSION",
230
+ "ERR_SCOPE_PARSE_FAILED"
231
+ ]);
232
+ function disableReasons(scope, workspaces) {
233
+ const reasons = [];
234
+ const envelope = scope ?? {};
235
+ const code = typeof envelope.code === "string" ? envelope.code : "";
236
+ const unreadable = envelope.ok !== true;
237
+ if (unreadable && VERSION_CODES.has(code)) {
238
+ reasons.push({ id: "version-unsupported", code });
239
+ } else if (unreadable) {
240
+ reasons.push({ id: "not-writable", code: code === "" ? "ERR_SCOPE_READ_FAILED" : code });
241
+ }
242
+ if (workspaces !== void 0 && workspaces.available === false) {
243
+ reasons.push({ id: "workspaces-unavailable", code: workspaces.code });
244
+ }
245
+ return reasons;
246
+ }
247
+ function staleWorkspaceIds(seed, workspaces) {
248
+ if (seed === void 0 || workspaces === void 0 || workspaces.available !== true) return [];
249
+ const known = new Set(workspaces.entries.map((entry) => entry.id));
250
+ return seed.workspaceIds.filter((id) => !known.has(id));
251
+ }
252
+ function unmatchedDraftIds(draft, workspaces) {
253
+ if (workspaces === void 0 || workspaces.available !== true) return [];
254
+ const known = new Set(workspaces.entries.map((entry) => entry.id));
255
+ return draft.workspaceIds.filter((id) => !known.has(id));
256
+ }
257
+ function patchOf(draft) {
258
+ return {
259
+ mode: draft.mode,
260
+ workspaceIds: [...draft.workspaceIds],
261
+ shadow: draft.shadow,
262
+ projection: draft.projection
263
+ };
264
+ }
265
+ function isTicked(draft, entry) {
266
+ return draft.workspaceIds.includes(entry.id);
267
+ }
268
+ function toggleTicked(draft, entry) {
269
+ const has = draft.workspaceIds.includes(entry.id);
270
+ return {
271
+ ...draft,
272
+ workspaceIds: has ? draft.workspaceIds.filter((id) => id !== entry.id) : [...draft.workspaceIds, entry.id]
273
+ };
274
+ }
275
+ function payloadOf(value) {
276
+ if (value === null || typeof value !== "object") return value;
277
+ const envelope = value;
278
+ return envelope.ok === true ? envelope.data : value;
279
+ }
185
280
  const ACTION_REREAD = "Re-read";
186
281
  const ACTION_SAVE = "Save";
187
282
  const CONFIG_READONLY = "This section is read-only. It shows what resolveConfig decided at load (clamps and fallbacks included); to change it, edit the profile's cordis.patch.yml and restart the host.";
@@ -195,12 +290,13 @@ window.__ModuleLoader__.load({
195
290
  const HINT_OVERHEAD = "Fixed cost per request: the protocol section plus tool schemas. It does not vary by session and no saving offsets it.";
196
291
  const HINT_PROJECTION_GROSS_REPLAY = "Each receipt's saving multiplied by its own (1 + horizon), summed. This is the figure the net is derived from.";
197
292
  const HINT_PROJECTION_NET = "Net = replay gross − retrieval content cost − retrieval call cost. Replay uses each receipt's own horizon, not the current one; so the two gross figures above are not the same number, and only the replay one lines up with the net.";
198
- const HINT_PROJECTION_ON_ROLLBACK = "To roll back, set projection back to `shadow` and save (or run `boost shadow true`). The change applies to subsequent requests with no host restart.";
293
+ const HINT_PROJECTION_ON_ROLLBACK = 'To roll back, set projection back to `shadow` and save; or call the `boost` tool with `cmd: "scope-set"` and `body: {"projection": "shadow"}`. The change applies to subsequent requests with no host restart.';
199
294
  const HINT_PROJECTION_ON_SPILL = "The host has a spill backend. Without one, projection is skipped: `boost status` lists `ERR_HOST_NO_SPILL` among the degraded codes and this page shows the same line.";
200
- const HINT_PROJECTION_ON_THINKING = "Watch for one `content[].thinking` 400 after the first real substitution. Whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine; it only shows up on a real substitution, so the page does not pretend to have checked.";
201
295
  const HINT_SAVED_LOWER = "The lower bound is the skipped request's own total usage: it excludes how many more times it would have been replayed, so the true saving is higher.";
202
296
  const HINT_SAVED_UPPER = "The upper bound is the next request's input: it counts the replaced call's result as saved, so the true saving is lower.";
203
297
  const HINT_SHADOW_MEANS = "Shadow mode: the plugin still decides and records receipts, but never changes what reaches the model.";
298
+ const HINT_SUBSTITUTE_ON_ROLLBACK = "To roll back, tick shadow mode again and save: substitution stops at once and the projection setting is untouched.";
299
+ const HINT_SUBSTITUTE_ON_THINKING = "Watch for one 400 mentioning `content[].thinking` after the first real substitution. Synthesized turns carry no `replayState`, so the host-side conversion drops the thinking block; whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine and only shows up on a real substitution.";
204
300
  const INTRO = "Projection trims tool receipts; deterministic substitution replaces derivable calls. Every number below comes from receipts, not from an estimate: the range gives a lower and an upper bound, and neither is exact.";
205
301
  const LABEL_CONFIG_KEY = "Key";
206
302
  const LABEL_CONFIG_VALUE = "Effective value";
@@ -215,13 +311,14 @@ window.__ModuleLoader__.load({
215
311
  const LABEL_PROJECTION_GROSS = "Projection gross (one-time)";
216
312
  const LABEL_PROJECTION_GROSS_REPLAY = "Projection gross (replayed per horizon)";
217
313
  const LABEL_PROJECTION_NET = "Projection net";
218
- const LABEL_PROJECTION_ON_PRECONDITIONS = "Two things to check before switching projection on";
314
+ const LABEL_PROJECTION_ON_PRECONDITIONS = "One thing to check before switching projection on";
219
315
  const LABEL_RETRIEVALS = "Retrievals";
220
316
  const LABEL_SAVED_LOWER = "Substitution saving (lower)";
221
317
  const LABEL_SAVED_UPPER = "Substitution saving (upper)";
222
318
  const LABEL_SAVE_FAILED = "The save did not take effect:";
223
319
  const LABEL_SHADOW = "Shadow mode";
224
320
  const LABEL_STALE_IDS = "Saved, but not in the registry";
321
+ const LABEL_SUBSTITUTE_ON_PRECONDITIONS = "One thing to check before switching shadow mode off";
225
322
  const LABEL_UNMATCHED_IDS = "Ticked, but not in the registry";
226
323
  const LABEL_WORKSPACES = "Workspaces";
227
324
  const LOADING = "Loading…";
@@ -231,15 +328,16 @@ window.__ModuleLoader__.load({
231
328
  const PROJECTION_ON = "On (real substitution)";
232
329
  const PROJECTION_SHADOW = "Shadow (record only)";
233
330
  const RETRY = "Retry";
234
- const SAVED = "Matches the document on disk.";
331
+ const SAVED = "Matches the document as this page last read or saved it. The page does not poll: if something else changes the scope (say, the model runs boost), reload to see it.";
235
332
  const SECTION_CONFIG = "Effective config";
236
333
  const SECTION_COUNTS = "Receipt counts";
237
334
  const SECTION_SCOPE = "Scope";
238
335
  const SECTION_STATUS = "Status";
239
336
  const TITLE = "Token efficiency";
240
337
  const UNAVAILABLE_REGISTRY = "The scope document could not be read, so this section is read-only for now.";
241
- const UNKNOWN = "unmeasured";
338
+ const UNKNOWN = "unknown error";
242
339
  const meta = { "description": "Cut DeepSeek Harness token usage by projecting tool receipts and substituting deterministic read-only calls.", "title": "dsh-boost" };
340
+ const STATUS_UNAVAILABLE = "Status could not be read: the figures below are unread, not empty";
243
341
  const en = {
244
342
  ACTION_REREAD,
245
343
  ACTION_SAVE,
@@ -291,10 +389,11 @@ window.__ModuleLoader__.load({
291
389
  HINT_PROJECTION_NET,
292
390
  HINT_PROJECTION_ON_ROLLBACK,
293
391
  HINT_PROJECTION_ON_SPILL,
294
- HINT_PROJECTION_ON_THINKING,
295
392
  HINT_SAVED_LOWER,
296
393
  HINT_SAVED_UPPER,
297
394
  HINT_SHADOW_MEANS,
395
+ HINT_SUBSTITUTE_ON_ROLLBACK,
396
+ HINT_SUBSTITUTE_ON_THINKING,
298
397
  INTRO,
299
398
  LABEL_CONFIG_KEY,
300
399
  LABEL_CONFIG_VALUE,
@@ -316,6 +415,7 @@ window.__ModuleLoader__.load({
316
415
  LABEL_SAVE_FAILED,
317
416
  LABEL_SHADOW,
318
417
  LABEL_STALE_IDS,
418
+ LABEL_SUBSTITUTE_ON_PRECONDITIONS,
319
419
  LABEL_UNMATCHED_IDS,
320
420
  LABEL_WORKSPACES,
321
421
  LOADING,
@@ -333,7 +433,8 @@ window.__ModuleLoader__.load({
333
433
  TITLE,
334
434
  UNAVAILABLE_REGISTRY,
335
435
  UNKNOWN,
336
- meta
436
+ meta,
437
+ STATUS_UNAVAILABLE
337
438
  };
338
439
  const LOCALE_NAMESPACE = "dsh-boost";
339
440
  function stringsOf(source) {
@@ -442,90 +543,6 @@ window.__ModuleLoader__.load({
442
543
  }
443
544
  return { ok: true, data: body?.data };
444
545
  }
445
- const PROJECTIONS = ["off", "shadow", "on"];
446
- const isMode = (value) => value === "selected" || value === "global";
447
- const isProjection = (value) => value === "off" || value === "shadow" || value === "on";
448
- function seedOf(scope) {
449
- if (scope === null || typeof scope !== "object") return void 0;
450
- const envelope = scope;
451
- if (envelope.ok !== true || envelope.data === null || typeof envelope.data !== "object") return void 0;
452
- const doc = envelope.data;
453
- const revision = doc.revision;
454
- const version2 = doc.version;
455
- const shadow = doc.shadow;
456
- const workspaceIds = doc.workspaceIds;
457
- if (typeof revision !== "number" || !Number.isFinite(revision)) return void 0;
458
- if (typeof version2 !== "number" || !Number.isFinite(version2)) return void 0;
459
- if (typeof shadow !== "boolean") return void 0;
460
- if (!Array.isArray(workspaceIds) || !workspaceIds.every((id) => typeof id === "string")) return void 0;
461
- if (!isMode(doc.mode) || !isProjection(doc.projection)) return void 0;
462
- return {
463
- version: version2,
464
- revision,
465
- mode: doc.mode,
466
- workspaceIds: [...workspaceIds],
467
- shadow,
468
- projection: doc.projection
469
- };
470
- }
471
- function draftOf(seed) {
472
- return patchOf(seed);
473
- }
474
- function isDirty(draft, seed) {
475
- if (draft.mode !== seed.mode) return true;
476
- if (draft.shadow !== seed.shadow) return true;
477
- if (draft.projection !== seed.projection) return true;
478
- if (draft.workspaceIds.length !== seed.workspaceIds.length) return true;
479
- return draft.workspaceIds.some((id) => !seed.workspaceIds.includes(id));
480
- }
481
- const VERSION_CODES = /* @__PURE__ */ new Set([
482
- "ERR_SCOPE_UNKNOWN_VERSION",
483
- "ERR_SCOPE_FUTURE_VERSION",
484
- "ERR_SCOPE_PARSE_FAILED"
485
- ]);
486
- function disableReasons(scope, workspaces) {
487
- const reasons = [];
488
- const envelope = scope ?? {};
489
- const code = typeof envelope.code === "string" ? envelope.code : "";
490
- const unreadable = envelope.ok !== true;
491
- if (unreadable && VERSION_CODES.has(code)) {
492
- reasons.push({ id: "version-unsupported", code });
493
- } else if (unreadable) {
494
- reasons.push({ id: "not-writable", code: code === "" ? "ERR_SCOPE_READ_FAILED" : code });
495
- }
496
- if (workspaces !== void 0 && workspaces.available === false) {
497
- reasons.push({ id: "workspaces-unavailable", code: workspaces.code });
498
- }
499
- return reasons;
500
- }
501
- function staleWorkspaceIds(seed, workspaces) {
502
- if (seed === void 0 || workspaces === void 0 || workspaces.available !== true) return [];
503
- const known = new Set(workspaces.entries.map((entry) => entry.id));
504
- return seed.workspaceIds.filter((id) => !known.has(id));
505
- }
506
- function unmatchedDraftIds(draft, workspaces) {
507
- if (workspaces === void 0 || workspaces.available !== true) return [];
508
- const known = new Set(workspaces.entries.map((entry) => entry.id));
509
- return draft.workspaceIds.filter((id) => !known.has(id));
510
- }
511
- function patchOf(draft) {
512
- return {
513
- mode: draft.mode,
514
- workspaceIds: [...draft.workspaceIds],
515
- shadow: draft.shadow,
516
- projection: draft.projection
517
- };
518
- }
519
- function isTicked(draft, entry) {
520
- return draft.workspaceIds.includes(entry.id);
521
- }
522
- function toggleTicked(draft, entry) {
523
- const has = draft.workspaceIds.includes(entry.id);
524
- return {
525
- ...draft,
526
- workspaceIds: has ? draft.workspaceIds.filter((id) => id !== entry.id) : [...draft.workspaceIds, entry.id]
527
- };
528
- }
529
546
  const REREAD_CODES = /* @__PURE__ */ new Set([
530
547
  "ERR_SCOPE_REVISION_CONFLICT",
531
548
  "ERR_SCOPE_LOCKED",
@@ -665,13 +682,14 @@ window.__ModuleLoader__.load({
665
682
  ] }),
666
683
  draft.projection === "on" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__notice", role: "note", "data-notice": "projection-on", children: [
667
684
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: c.LABEL_PROJECTION_ON_PRECONDITIONS }),
668
- /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
669
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_SPILL }),
670
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_THINKING })
671
- ] }),
685
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_SPILL }) }),
672
686
  /* @__PURE__ */ jsxRuntime.jsx("p", { children: c.HINT_PROJECTION_ON_ROLLBACK })
673
687
  ] }) : null,
674
- draft.projection === "shadow" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__muted", children: c.HINT_SHADOW_MEANS }) : null,
688
+ draft.shadow ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__muted", children: c.HINT_SHADOW_MEANS }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__notice", role: "note", "data-notice": "substitute-on", children: [
689
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: c.LABEL_SUBSTITUTE_ON_PRECONDITIONS }),
690
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_SUBSTITUTE_ON_THINKING }) }),
691
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: c.HINT_SUBSTITUTE_ON_ROLLBACK })
692
+ ] }),
675
693
  stale.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__diagnostic", "data-diagnostic": "stale", children: [
676
694
  /* @__PURE__ */ jsxRuntime.jsx("h4", { children: c.LABEL_STALE_IDS }),
677
695
  /* @__PURE__ */ jsxRuntime.jsx("ul", { children: stale.map((id) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: id }, id)) })
@@ -744,9 +762,16 @@ window.__ModuleLoader__.load({
744
762
  rows ? /* @__PURE__ */ jsxRuntime.jsx("dl", { children }) : children
745
763
  ] });
746
764
  }
747
- function Degraded({ codes }) {
765
+ function Degraded({ codes, unavailable }) {
748
766
  const t = useT();
749
767
  const c = copyOf(t);
768
+ if (unavailable !== void 0) {
769
+ return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "boost-settings__warn", children: [
770
+ c.STATUS_UNAVAILABLE,
771
+ " ",
772
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: unavailable === "" ? c.UNKNOWN : unavailable })
773
+ ] });
774
+ }
750
775
  if (codes.length === 0) {
751
776
  return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__ok", children: c.NO_DEGRADED });
752
777
  }
@@ -772,9 +797,10 @@ window.__ModuleLoader__.load({
772
797
  return () => controller.abort();
773
798
  }, []);
774
799
  react.useEffect(load, [load]);
775
- const status = result?.ok === true ? result.data.status : void 0;
800
+ const status = payloadOf(result?.ok === true ? result.data.status : void 0);
776
801
  const scope = result?.ok === true ? result.data.scope : void 0;
777
- const config = result?.ok === true ? result.data.config : void 0;
802
+ const config = payloadOf(result?.ok === true ? result.data.config : void 0);
803
+ const statusCode = status !== null && typeof status === "object" && status.ok === false ? String(status.code ?? "") : void 0;
778
804
  const saved = pick(status, "saved");
779
805
  const degraded = pick(status, "degraded");
780
806
  const codes = Array.isArray(degraded) ? degraded.filter((code) => typeof code === "string") : [];
@@ -822,8 +848,8 @@ window.__ModuleLoader__.load({
822
848
  onReload: () => load()
823
849
  }
824
850
  ) : null,
825
- /* @__PURE__ */ jsxRuntime.jsx(Section, { title: c.LABEL_DEGRADED, rows: false, children: /* @__PURE__ */ jsxRuntime.jsx(Degraded, { codes }) }),
826
- /* @__PURE__ */ jsxRuntime.jsx(Section, { title: c.SECTION_COUNTS, rows: false, children: countRows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__muted", children: c.NO_RECEIPTS }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "boost-settings__codes", children: countRows.map(([code, count]) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
851
+ /* @__PURE__ */ jsxRuntime.jsx(Section, { title: c.LABEL_DEGRADED, rows: false, children: /* @__PURE__ */ jsxRuntime.jsx(Degraded, { codes, unavailable: statusCode }) }),
852
+ /* @__PURE__ */ jsxRuntime.jsx(Section, { title: c.SECTION_COUNTS, rows: false, children: countRows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__muted", children: statusCode === void 0 ? c.NO_RECEIPTS : c.STATUS_UNAVAILABLE }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "boost-settings__codes", children: countRows.map(([code, count]) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
827
853
  /* @__PURE__ */ jsxRuntime.jsx("code", { children: code }),
828
854
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: count.toLocaleString() })
829
855
  ] }, code)) }) }),
@@ -845,7 +871,8 @@ window.__ModuleLoader__.load({
845
871
  }
846
872
  const styles = "/**\n * The settings page's own styles.\n *\n * SCOPED DELIBERATELY. This stylesheet is injected into the HOST page's\n * document head, not a sandboxed frame, so a bare `button {}` rule restyles\n * every button in the host UI — a plugin must not do that. Every top-level\n * selector in this file is therefore rooted at a plugin-owned class in the\n * `boost-` namespace.\n */\n.boost-settings {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 16px;\n color: inherit;\n font-size: 13px;\n line-height: 1.6;\n}\n\n.boost-settings h2 {\n margin: 0;\n font-size: 16px;\n}\n\n.boost-settings__intro {\n margin: 0 0 1rem;\n color: var(--dsh-text-secondary, #5a5a5f);\n line-height: 1.6;\n}\n\n.boost-settings__section {\n margin: 0 0 1.25rem;\n}\n\n.boost-settings__section h3 {\n margin: 0 0 0.5rem;\n font-size: 0.95rem;\n font-weight: 600;\n}\n\n.boost-settings__row {\n display: grid;\n grid-template-columns: minmax(8rem, 14rem) 1fr;\n gap: 0.5rem 1rem;\n padding: 0.25rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n}\n\n.boost-settings__row dt {\n color: var(--dsh-text-secondary, #5a5a5f);\n}\n\n.boost-settings__row dd {\n margin: 0;\n font-variant-numeric: tabular-nums;\n}\n\n.boost-settings__hint {\n display: block;\n margin-top: 0.25rem;\n font-size: 0.85rem;\n color: var(--dsh-text-secondary, #5a5a5f);\n font-variant-numeric: normal;\n}\n\n.boost-settings__ok,\n.boost-settings__muted {\n color: var(--dsh-text-secondary, #5a5a5f);\n}\n\n.boost-settings__codes {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.boost-settings__codes li {\n display: flex;\n flex-direction: column;\n gap: 0.15rem;\n padding: 0.4rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n}\n\n.boost-settings__error {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem;\n padding: 0.6rem 0.75rem;\n border: 1px solid var(--dsh-danger, #c0392b);\n border-radius: 6px;\n}\n\n.boost-settings__workspaces {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.boost-settings__workspaces li {\n display: flex;\n gap: 0.75rem;\n padding: 0.3rem 0;\n}\n\n.boost-settings__workspaces li.is-selected {\n font-weight: 600;\n}\n\n.boost-settings__config {\n width: 100%;\n border-collapse: collapse;\n}\n\n.boost-settings__config th,\n.boost-settings__config td {\n text-align: left;\n padding: 0.25rem 0.5rem 0.25rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n font-variant-numeric: tabular-nums;\n}\n";
847
873
  const SETTINGS_SLOT = "settings.section";
848
- const SETTINGS_NAMESPACE = "boost";
874
+ const WARN_PREFIX = "dsh-boost";
875
+ const SETTINGS_ID = "boost";
849
876
  const inject = ["slots"];
850
877
  function installStyles() {
851
878
  const node = document.createElement("style");
@@ -857,23 +884,23 @@ window.__ModuleLoader__.load({
857
884
  function installTranslator(ctx) {
858
885
  const locale = ctx.get?.("locale");
859
886
  if (locale === void 0) {
860
- console.warn(`[${SETTINGS_NAMESPACE}] host has no locale service; the page stays readable but will not follow the host language`);
887
+ console.warn(`[${WARN_PREFIX}] host has no locale service; the page stays readable but will not follow the host language`);
861
888
  }
862
889
  if (locale !== void 0) {
863
890
  try {
864
- ctx.effect?.(() => locale.register(LOCALE_NAMESPACE, DICTIONARIES), `${SETTINGS_NAMESPACE}: dictionaries`);
891
+ ctx.effect?.(() => locale.register(LOCALE_NAMESPACE, DICTIONARIES), `${WARN_PREFIX}: dictionaries`);
865
892
  const bound = locale.bind(LOCALE_NAMESPACE);
866
893
  setTranslator(bound);
867
894
  ctx.effect?.(
868
895
  () => locale.subscribe?.(() => setTranslator(locale.bind(LOCALE_NAMESPACE))) ?? (() => {
869
896
  }),
870
- `${SETTINGS_NAMESPACE}: locale subscription`
897
+ `${WARN_PREFIX}: locale subscription`
871
898
  );
872
899
  return bound;
873
900
  } catch (error) {
874
901
  const message = error instanceof Error ? error.message : String(error);
875
902
  console.warn(
876
- `[${SETTINGS_NAMESPACE}] host locale service rejected the dictionaries (${message}); registering the section without a locale namespace and using the built-in translator`
903
+ `[${WARN_PREFIX}] host locale service rejected the dictionaries (${message}); registering the section without a locale namespace and using the built-in translator`
877
904
  );
878
905
  }
879
906
  }
@@ -881,19 +908,19 @@ window.__ModuleLoader__.load({
881
908
  return fallbackT;
882
909
  }
883
910
  function apply(ctx) {
884
- ctx.effect?.(() => installStyles(), `${SETTINGS_NAMESPACE}: settings styles`);
911
+ ctx.effect?.(() => installStyles(), `${WARN_PREFIX}: settings styles`);
885
912
  const t = installTranslator(ctx);
886
913
  if (ctx.slots === void 0) {
887
- console.warn(`[${SETTINGS_NAMESPACE}] client slots service unavailable; settings page not registered`);
914
+ console.warn(`[${WARN_PREFIX}] client slots service unavailable; settings page not registered`);
888
915
  return;
889
916
  }
890
917
  const slots = ctx.slots;
891
- slots.inject(
918
+ const disposeInjection = slots.inject(
892
919
  SETTINGS_SLOT,
893
920
  () => slots.register(
894
921
  {
895
922
  name: SETTINGS_SLOT,
896
- id: SETTINGS_NAMESPACE,
923
+ id: SETTINGS_ID,
897
924
  order: 50,
898
925
  // A thunk, not a string: the shell re-reads it when the locale changes,
899
926
  // so the nav item follows the language without this plugin subscribing.
@@ -903,9 +930,11 @@ window.__ModuleLoader__.load({
903
930
  App
904
931
  )
905
932
  );
933
+ ctx.effect?.(() => disposeInjection, `${WARN_PREFIX}: settings section`);
906
934
  }
907
- exports.SETTINGS_NAMESPACE = SETTINGS_NAMESPACE;
935
+ exports.SETTINGS_ID = SETTINGS_ID;
908
936
  exports.SETTINGS_SLOT = SETTINGS_SLOT;
937
+ exports.WARN_PREFIX = WARN_PREFIX;
909
938
  exports.apply = apply;
910
939
  exports.inject = inject;
911
940
  return module.exports;
package/locale/en.json CHANGED
@@ -47,12 +47,13 @@
47
47
  "HINT_OVERHEAD": "Fixed cost per request: the protocol section plus tool schemas. It does not vary by session and no saving offsets it.",
48
48
  "HINT_PROJECTION_GROSS_REPLAY": "Each receipt's saving multiplied by its own (1 + horizon), summed. This is the figure the net is derived from.",
49
49
  "HINT_PROJECTION_NET": "Net = replay gross − retrieval content cost − retrieval call cost. Replay uses each receipt's own horizon, not the current one; so the two gross figures above are not the same number, and only the replay one lines up with the net.",
50
- "HINT_PROJECTION_ON_ROLLBACK": "To roll back, set projection back to `shadow` and save (or run `boost shadow true`). The change applies to subsequent requests with no host restart.",
50
+ "HINT_PROJECTION_ON_ROLLBACK": "To roll back, set projection back to `shadow` and save; or call the `boost` tool with `cmd: \"scope-set\"` and `body: {\"projection\": \"shadow\"}`. The change applies to subsequent requests with no host restart.",
51
51
  "HINT_PROJECTION_ON_SPILL": "The host has a spill backend. Without one, projection is skipped: `boost status` lists `ERR_HOST_NO_SPILL` among the degraded codes and this page shows the same line.",
52
- "HINT_PROJECTION_ON_THINKING": "Watch for one `content[].thinking` 400 after the first real substitution. Whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine; it only shows up on a real substitution, so the page does not pretend to have checked.",
53
52
  "HINT_SAVED_LOWER": "The lower bound is the skipped request's own total usage: it excludes how many more times it would have been replayed, so the true saving is higher.",
54
53
  "HINT_SAVED_UPPER": "The upper bound is the next request's input: it counts the replaced call's result as saved, so the true saving is lower.",
55
54
  "HINT_SHADOW_MEANS": "Shadow mode: the plugin still decides and records receipts, but never changes what reaches the model.",
55
+ "HINT_SUBSTITUTE_ON_ROLLBACK": "To roll back, tick shadow mode again and save: substitution stops at once and the projection setting is untouched.",
56
+ "HINT_SUBSTITUTE_ON_THINKING": "Watch for one 400 mentioning `content[].thinking` after the first real substitution. Synthesized turns carry no `replayState`, so the host-side conversion drops the thinking block; whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine and only shows up on a real substitution.",
56
57
  "INTRO": "Projection trims tool receipts; deterministic substitution replaces derivable calls. Every number below comes from receipts, not from an estimate: the range gives a lower and an upper bound, and neither is exact.",
57
58
  "LABEL_CONFIG_KEY": "Key",
58
59
  "LABEL_CONFIG_VALUE": "Effective value",
@@ -67,13 +68,14 @@
67
68
  "LABEL_PROJECTION_GROSS": "Projection gross (one-time)",
68
69
  "LABEL_PROJECTION_GROSS_REPLAY": "Projection gross (replayed per horizon)",
69
70
  "LABEL_PROJECTION_NET": "Projection net",
70
- "LABEL_PROJECTION_ON_PRECONDITIONS": "Two things to check before switching projection on",
71
+ "LABEL_PROJECTION_ON_PRECONDITIONS": "One thing to check before switching projection on",
71
72
  "LABEL_RETRIEVALS": "Retrievals",
72
73
  "LABEL_SAVED_LOWER": "Substitution saving (lower)",
73
74
  "LABEL_SAVED_UPPER": "Substitution saving (upper)",
74
75
  "LABEL_SAVE_FAILED": "The save did not take effect:",
75
76
  "LABEL_SHADOW": "Shadow mode",
76
77
  "LABEL_STALE_IDS": "Saved, but not in the registry",
78
+ "LABEL_SUBSTITUTE_ON_PRECONDITIONS": "One thing to check before switching shadow mode off",
77
79
  "LABEL_UNMATCHED_IDS": "Ticked, but not in the registry",
78
80
  "LABEL_WORKSPACES": "Workspaces",
79
81
  "LOADING": "Loading…",
@@ -83,16 +85,17 @@
83
85
  "PROJECTION_ON": "On (real substitution)",
84
86
  "PROJECTION_SHADOW": "Shadow (record only)",
85
87
  "RETRY": "Retry",
86
- "SAVED": "Matches the document on disk.",
88
+ "SAVED": "Matches the document as this page last read or saved it. The page does not poll: if something else changes the scope (say, the model runs boost), reload to see it.",
87
89
  "SECTION_CONFIG": "Effective config",
88
90
  "SECTION_COUNTS": "Receipt counts",
89
91
  "SECTION_SCOPE": "Scope",
90
92
  "SECTION_STATUS": "Status",
91
93
  "TITLE": "Token efficiency",
92
94
  "UNAVAILABLE_REGISTRY": "The scope document could not be read, so this section is read-only for now.",
93
- "UNKNOWN": "unmeasured",
95
+ "UNKNOWN": "unknown error",
94
96
  "meta": {
95
97
  "description": "Cut DeepSeek Harness token usage by projecting tool receipts and substituting deterministic read-only calls.",
96
98
  "title": "dsh-boost"
97
- }
99
+ },
100
+ "STATUS_UNAVAILABLE": "Status could not be read: the figures below are unread, not empty"
98
101
  }
package/locale/zh.json CHANGED
@@ -47,12 +47,13 @@
47
47
  "HINT_OVERHEAD": "每次请求的常驻成本:协议段 + 工具 schema。它不随会话变化,也不被任何节省抵消。",
48
48
  "HINT_PROJECTION_GROSS_REPLAY": "每条回执的节省乘以它自己的 (1 + horizon) 再求和。这个数才是净额的被减数。",
49
49
  "HINT_PROJECTION_NET": "净额 = 重放毛额 − 取回内容成本 − 取回调用成本。回放用每条回执自己的 horizon,不是当前值;所以上面两个毛额不是同一个数,净额只与重放那个对齐。",
50
- "HINT_PROJECTION_ON_ROLLBACK": "回滚:把「投影」改回 `shadow` 并保存(或跑 `boost shadow true`)。改动立即对后续请求生效,不需要重启宿主。",
50
+ "HINT_PROJECTION_ON_ROLLBACK": "回滚:把「投影」改回 `shadow` 并保存;或调 `boost` 工具,`cmd: \"scope-set\"`、`body: {\"projection\": \"shadow\"}`。改动对后续请求立即生效,不需要重启宿主。",
51
51
  "HINT_PROJECTION_ON_SPILL": "宿主有 spill 后端。没有的话投影会被跳过——`boost status` 的降级项会写 `ERR_HOST_NO_SPILL`,页面上也会显示这一条。",
52
- "HINT_PROJECTION_ON_THINKING": "第一次真替换之后盯一次 `content[].thinking` 的 400。当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察;查不出来就不假装查过。",
53
52
  "HINT_SAVED_LOWER": "下界是被跳过那次请求自己的总用量:它不含「后续还会回放多少次」,所以真实节省高于这个数。",
54
53
  "HINT_SAVED_UPPER": "上界是「下一次请求的输入」:它把被替换调用的结果也算进了节省,所以真实节省低于这个数。",
55
54
  "HINT_SHADOW_MEANS": "影子模式:插件照常决策并记账,但不真的改动发给模型的内容。",
55
+ "HINT_SUBSTITUTE_ON_ROLLBACK": "回滚:把「影子模式」勾回去并保存,替换立即停止;投影的设置不受影响。",
56
+ "HINT_SUBSTITUTE_ON_THINKING": "第一次真替换之后盯一次含 `content[].thinking` 的 400。合成回合没有 `replayState`,宿主侧的转换会丢掉 thinking 块;当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察。",
56
57
  "INTRO": "投影裁剪工具回执、确定性替换可推导的调用。下面的数字全部来自收据,不是估算的替代品:区间给出下界与上界,两者都不是精确值。",
57
58
  "LABEL_CONFIG_KEY": "键",
58
59
  "LABEL_CONFIG_VALUE": "生效值",
@@ -67,13 +68,14 @@
67
68
  "LABEL_PROJECTION_GROSS": "投影毛额(一次性)",
68
69
  "LABEL_PROJECTION_GROSS_REPLAY": "投影毛额(按各自 horizon 重放)",
69
70
  "LABEL_PROJECTION_NET": "投影净额",
70
- "LABEL_PROJECTION_ON_PRECONDITIONS": "开启投影前确认两件事",
71
+ "LABEL_PROJECTION_ON_PRECONDITIONS": "开启投影前确认一件事",
71
72
  "LABEL_RETRIEVALS": "取回次数",
72
73
  "LABEL_SAVED_LOWER": "替换节省(下界)",
73
74
  "LABEL_SAVED_UPPER": "替换节省(上界)",
74
75
  "LABEL_SAVE_FAILED": "保存没有生效:",
75
76
  "LABEL_SHADOW": "影子模式",
76
77
  "LABEL_STALE_IDS": "已保存但注册表里没有",
78
+ "LABEL_SUBSTITUTE_ON_PRECONDITIONS": "关掉影子模式前确认一件事",
77
79
  "LABEL_UNMATCHED_IDS": "已勾选但注册表里没有",
78
80
  "LABEL_WORKSPACES": "工作区",
79
81
  "LOADING": "读取中…",
@@ -83,16 +85,17 @@
83
85
  "PROJECTION_ON": "开启(真替换)",
84
86
  "PROJECTION_SHADOW": "影子(只记账)",
85
87
  "RETRY": "重试",
86
- "SAVED": "与磁盘上的文档一致。",
88
+ "SAVED": "与页面上次读到或保存时的文档一致。页面不会轮询:别处(例如让模型调用 boost)改了 scope,这里要重新读取才看得到。",
87
89
  "SECTION_CONFIG": "生效配置",
88
90
  "SECTION_COUNTS": "收据计数",
89
91
  "SECTION_SCOPE": "作用域",
90
92
  "SECTION_STATUS": "运行状态",
91
93
  "TITLE": "Token 效率",
92
94
  "UNAVAILABLE_REGISTRY": "读不到作用域文档,这一块暂时只读。",
93
- "UNKNOWN": "未测量",
95
+ "UNKNOWN": "未知错误",
94
96
  "meta": {
95
97
  "description": "通过工具回执投影与确定性只读替换降低 DeepSeek Harness 的 token 消耗。",
96
98
  "title": "dsh-boost"
97
- }
99
+ },
100
+ "STATUS_UNAVAILABLE": "状态读取失败,下面的数字不是「没有」,而是没读到"
98
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-boost",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Cut DSH token usage by projecting tool receipts and substituting deterministic read-only calls.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",