dsh-thinking-lang 1.0.6 → 1.0.8

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.
@@ -18,30 +18,43 @@ const CATALOGUE = [
18
18
  tag: "zh-CN",
19
19
  nativeName: "简体中文",
20
20
  section: "推理规则:思考、推理与规划一律使用简体中文。回复用户时使用用户所用的语言。",
21
- reminder: "继续用简体中文思考、推理与规划。"
21
+ reminder: "注意:思考、推理与规划用简体中文,即使上文不是",
22
+ tail: "下文请使用简体中文思考"
22
23
  },
23
24
  {
24
25
  tag: "zh-TW",
25
26
  nativeName: "繁體中文",
26
27
  section: "推理規則:思考、推理與規劃一律使用繁體中文。回覆使用者時使用使用者所用的語言。",
27
- reminder: "繼續用繁體中文思考、推理與規劃。"
28
+ reminder: "注意:思考、推理與規劃用繁體中文,即使上文不是",
29
+ tail: "下文請使用繁體中文思考"
28
30
  },
29
31
  {
30
32
  tag: "en",
31
33
  nativeName: "English",
32
34
  section: "Reasoning rules: think, reason, and plan in English. Reply to the user in the language they use.",
33
- reminder: "Keep thinking, reasoning, and planning in English."
35
+ reminder: "Note: think, reason, and plan in English, even if the text above is not",
36
+ tail: "Think in English from here on"
34
37
  }
35
38
  ];
36
39
  /** The sentinel meaning "follow the host locale". / 表示「跟随宿主语言」的哨兵值。 */
37
40
  const AUTO = "auto";
38
41
  /** Settings namespace owned by this plugin. / 本插件拥有的设置命名空间。 */
39
42
  const SETTINGS_NAMESPACE = "ay-dsh-tk-lang";
40
- /** The one field this plugin stores. / 本插件唯一保存的字段。 */
43
+ /** The language field this plugin stores. / 本插件保存的语言字段。 */
41
44
  const FIELD_LANGUAGE = "language";
45
+ /** The reminder field this plugin stores. / 本插件保存的提醒字段。 */
46
+ const FIELD_REMINDER = "reminderMinutes";
47
+ /** The extra-injection field this plugin stores. / 本插件保存的额外注入字段。 */
48
+ const FIELD_EXTRA = "extraInjection";
49
+ /** Largest accepted reminder interval. / 允许的最大提醒间隔(分钟)。 */
50
+ const MAX_REMINDER_MINUTES = 1440;
42
51
  CATALOGUE.map((language) => language.tag);
43
- /** Configuration applied when the field is absent. / 字段缺失时采用的配置。 */
44
- const DEFAULTS = { language: AUTO };
52
+ /** Configuration applied when the fields are absent. / 字段缺失时采用的配置。 */
53
+ const DEFAULTS = {
54
+ language: AUTO,
55
+ reminderMinutes: 30,
56
+ extraInjection: true
57
+ };
45
58
  /** Catalogue lookup keyed by lower-cased tag. / 以小写标签为键的目录索引。 */
46
59
  const BY_TAG = new Map(CATALOGUE.map((language) => [language.tag.toLowerCase(), language]));
47
60
  /**
@@ -63,38 +76,81 @@ function nativeNameFor(tag) {
63
76
  * Coerce an untrusted settings section into a complete configuration.
64
77
  * 把不可信的设置段强制转换为完整配置。
65
78
  */
79
+ /** Clamp one untrusted reminder value into the accepted range; any negative value disables it. / 把不可信的提醒值收敛到允许范围;负数一律视为关闭。 */
80
+ function normalizeReminder(raw) {
81
+ const numeric = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
82
+ if (!Number.isFinite(numeric)) return 30;
83
+ const rounded = Math.round(numeric);
84
+ if (rounded < 0) return -1;
85
+ return rounded > 1440 ? MAX_REMINDER_MINUTES : rounded;
86
+ }
87
+ /** Coerce one untrusted extra-injection value; only an explicit false turns it off. / 把不可信的额外注入值收敛为布尔;只有明确的 false 视为关闭。 */
88
+ function normalizeExtra(raw) {
89
+ return raw !== false && raw !== "false";
90
+ }
66
91
  function normalizeSettings(raw) {
67
- const stored = raw !== null && typeof raw === "object" && !Array.isArray(raw) ? raw[FIELD_LANGUAGE] : void 0;
68
- return { language: typeof stored === "string" && stored !== "" ? stored : DEFAULTS.language };
92
+ const section = raw !== null && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
93
+ const stored = section?.[FIELD_LANGUAGE];
94
+ return {
95
+ language: typeof stored === "string" && stored !== "" ? stored : DEFAULTS.language,
96
+ reminderMinutes: normalizeReminder(section?.[FIELD_REMINDER]),
97
+ extraInjection: normalizeExtra(section?.[FIELD_EXTRA])
98
+ };
69
99
  }
70
100
  /** Dictionaries keyed by UI locale, handed to the host locale service. / 以界面语言为键、交给宿主 locale 服务的字典。 */
71
101
  const dictionaries = {
72
102
  zh: {
73
103
  heading: "思考语言",
74
104
  description: "内部推理与规划使用的语言。「自动」优先跟随操作系统语言,其次是界面语言。",
75
- autoLabel: "自动"
105
+ autoLabel: "自动",
106
+ reminderHeading: "提醒间隔",
107
+ reminderDescription: "两次提醒之间的最小间隔;关闭后只保留系统提示里的规则。",
108
+ reminderOff: "关闭",
109
+ reminderTurn: "每轮",
110
+ reminderCustom: "自定义",
111
+ reminderUnit: "分钟",
112
+ reminderCustomHint: "1–1440 分钟",
113
+ extraHeading: "额外提醒注入",
114
+ extraDescription: "开启后把提醒同时并入技能目录;提醒间隔为「关闭」时,此项也一并关闭。",
115
+ extraOn: "开启",
116
+ extraOff: "关闭"
76
117
  },
77
118
  en: {
78
119
  heading: "Thinking language",
79
120
  description: "Language used for internal reasoning and planning. Automatic follows the operating-system language first, then the UI language.",
80
- autoLabel: "Automatic"
121
+ autoLabel: "Automatic",
122
+ reminderHeading: "Reminder interval",
123
+ reminderDescription: "Minimum gap between reminders. Off keeps only the system-prompt rule.",
124
+ reminderOff: "Off",
125
+ reminderTurn: "Every turn",
126
+ reminderCustom: "Custom",
127
+ reminderUnit: "min",
128
+ reminderCustomHint: "1–1440 minutes",
129
+ extraHeading: "Extra reminder injection",
130
+ extraDescription: "Also folds the reminder into the skill catalogue. Switching the reminder interval off turns this off too.",
131
+ extraOn: "On",
132
+ extraOff: "Off"
81
133
  }
82
134
  };
83
135
  //#endregion
84
136
  //#region src/client/panel.ts
85
137
  /**
86
- * The settings row: one language picker bound to the plugin's settings document.
87
- * 设置行:一个绑定到本插件设置文档的语言选择器。
138
+ * Settings UI: the General row and the plugin's configuration card.
139
+ * 设置界面:「通用」页的设置行,以及插件详情页的配置卡片。
88
140
  *
89
- * It is registered into the General settings page (see `./index.ts`) rather than
90
- * as a section of its own, so it sits directly under the host's language row.
91
- * 它注册进「通用」设置页(见 `./index.ts`)而不是自成菜单,因此紧邻宿主自身的
92
- * 语言设置项下方。
141
+ * Both surfaces bind to the same host settings document, so a change in either
142
+ * place is visible in the other. / 两个入口绑定同一份宿主设置文档,任一处修改
143
+ * 另一处都会看到。
93
144
  *
94
- * The row owns no state of its own: it reads the host's settings document,
95
- * subscribes to it, and writes the single field back.
96
- * 本行不持有自己的状态:它读取宿主的设置文档、订阅其变化,并回写那唯一一个字段。
145
+ * The row owns no state of its own: it reads the document, subscribes to it, and
146
+ * writes the fields back. / 控件不持有自己的状态:读取文档、订阅变化、回写字段。
97
147
  */
148
+ /** Preset reminder intervals in minutes. / 预设提醒间隔(分钟)。 */
149
+ const PRESET_MINUTES = [
150
+ 10,
151
+ 30,
152
+ 60
153
+ ];
98
154
  /**
99
155
  * Read and normalize the current settings, falling back to defaults on refusal.
100
156
  * 读取并归一化当前设置;被拒绝时回退到默认值。
@@ -107,12 +163,8 @@ function readSettings(doc) {
107
163
  }
108
164
  }
109
165
  /**
110
- * Write one field back, swallowing a refusal so a read-only host cannot break the row.
111
- * 回写单个字段,并吞掉拒绝异常,使只读宿主不会让这一行崩溃。
112
- *
113
- * A host may return a promise instead of a value; an unhandled rejection from a
114
- * read-only document is not worth surfacing, so it is discarded here.
115
- * 宿主可能返回 promise 而不是值;只读文档产生的未处理拒绝不值得上抛,因此在此丢弃。
166
+ * Write one field back, swallowing a refusal so a read-only host cannot break the UI.
167
+ * 回写单个字段,并吞掉拒绝异常,使只读宿主不会让控件崩溃。
116
168
  */
117
169
  function writeField(doc, field, value) {
118
170
  try {
@@ -120,24 +172,26 @@ function writeField(doc, field, value) {
120
172
  if (typeof outcome?.then === "function") outcome.then(void 0, () => {});
121
173
  } catch {}
122
174
  }
175
+ /** Subscribe one component to the document and re-read it on every revision. / 订阅设置文档,并在每次修订时重新读取。 */
176
+ function useSettings(doc) {
177
+ const [settings, setSettings] = (0, react.useState)(() => readSettings(doc));
178
+ (0, react.useEffect)(() => {
179
+ const sync = () => setSettings(readSettings(doc));
180
+ sync();
181
+ return doc.subscribe(sync);
182
+ }, [doc]);
183
+ return settings;
184
+ }
123
185
  /**
124
- * Build the row component bound to the host's UI primitives.
125
- * 构建绑定到宿主 UI 原语的行组件。
186
+ * Build the language picker bound to the host's UI primitives.
187
+ * 构建绑定到宿主 UI 原语的语言选择器。
126
188
  */
127
- function createRow(primitives) {
189
+ function createLanguagePicker(primitives) {
128
190
  const Menu = primitives?.Menu;
129
191
  const Chevron = primitives?.IconChevronDownOutlineRegular ?? primitives?.IconChevronDownOutline14 ?? primitives?.IconChevronDownOutlineMedium;
130
- return function ThinkingLanguageRow(props) {
131
- const { doc, t: hostT } = props;
132
- const [settings, setSettings] = (0, react.useState)(() => readSettings(doc));
192
+ return function LanguagePicker(props) {
193
+ const { doc, t, settings } = props;
133
194
  const [open, setOpen] = (0, react.useState)(false);
134
- settings.language;
135
- const t = (key) => hostT(key);
136
- (0, react.useEffect)(() => {
137
- const sync = () => setSettings(readSettings(doc));
138
- sync();
139
- return doc.subscribe(sync);
140
- }, [doc]);
141
195
  const items = [{
142
196
  id: AUTO,
143
197
  label: t("autoLabel")
@@ -147,7 +201,6 @@ function createRow(primitives) {
147
201
  }))];
148
202
  const activeLabel = settings.language === "auto" ? t("autoLabel") : nativeNameFor(settings.language) ?? settings.language;
149
203
  const close = () => setOpen(false);
150
- const toggle = () => setOpen((value) => !value);
151
204
  const choose = (id) => {
152
205
  writeField(doc, FIELD_LANGUAGE, id);
153
206
  close();
@@ -157,9 +210,10 @@ function createRow(primitives) {
157
210
  className: "dsh_desk_lang_picker",
158
211
  "aria-haspopup": "menu",
159
212
  "aria-expanded": open,
160
- onClick: toggle
213
+ onClick: () => setOpen((value) => !value)
161
214
  }, activeLabel, Chevron === void 0 ? null : (0, react.createElement)(Chevron, { className: "dsh_desk_lang_chevron" }));
162
- const control = Menu ? (0, react.createElement)(Menu, {
215
+ if (!Menu) return picker;
216
+ return (0, react.createElement)(Menu, {
163
217
  open,
164
218
  anchor: picker,
165
219
  items,
@@ -168,33 +222,213 @@ function createRow(primitives) {
168
222
  portal: true,
169
223
  onClose: close,
170
224
  onSelect: choose
225
+ });
226
+ };
227
+ }
228
+ /** Map a stored minute count onto the picker id it should show. / 把存储的分钟数映射成选择器应显示的选项 id。 */
229
+ function derivedPreset(minutes) {
230
+ if (minutes < 0) return "off";
231
+ if (minutes === 0) return "turn";
232
+ const preset = PRESET_MINUTES.find((candidate) => candidate === minutes);
233
+ return preset === void 0 ? "custom" : String(preset);
234
+ }
235
+ /**
236
+ * Build the reminder picker: presets, every turn, off, and a custom minute count.
237
+ * 构建提醒选择器:预设、每轮、关闭,以及自定义分钟数。
238
+ *
239
+ * It uses the host Menu like the language picker, so the two controls match;
240
+ * a native `<select>` renders its own list chrome and breaks the row style.
241
+ * 与语言选择器一样使用宿主 Menu,两个控件因此外观一致;原生 `<select>` 的下拉列表
242
+ * 自带浏览器样式,会破坏这一行。
243
+ */
244
+ function createReminderPicker(primitives) {
245
+ const Menu = primitives?.Menu;
246
+ const Chevron = primitives?.IconChevronDownOutlineRegular ?? primitives?.IconChevronDownOutline14 ?? primitives?.IconChevronDownOutlineMedium;
247
+ return function ReminderPicker(props) {
248
+ const { doc, t, settings } = props;
249
+ const derived = derivedPreset(settings.reminderMinutes);
250
+ const current = settings.reminderMinutes > 0 ? settings.reminderMinutes : 30;
251
+ const [selected, setSelected] = (0, react.useState)(derived);
252
+ const [open, setOpen] = (0, react.useState)(false);
253
+ const [draft, setDraft] = (0, react.useState)(String(current));
254
+ (0, react.useEffect)(() => {
255
+ setSelected(derived);
256
+ }, [derived]);
257
+ (0, react.useEffect)(() => {
258
+ setDraft(String(current));
259
+ }, [current]);
260
+ const labelOf = (id) => {
261
+ if (id === "off") return t("reminderOff");
262
+ if (id === "turn") return t("reminderTurn");
263
+ if (id === "custom") return t("reminderCustom");
264
+ return `${id} ${t("reminderUnit")}`;
265
+ };
266
+ const items = [
267
+ "off",
268
+ "turn",
269
+ ...PRESET_MINUTES.map(String),
270
+ "custom"
271
+ ].map((id) => ({
272
+ id,
273
+ label: labelOf(id)
274
+ }));
275
+ const choose = (id) => {
276
+ setOpen(false);
277
+ setSelected(id);
278
+ if (id === "off") writeField(doc, FIELD_REMINDER, -1);
279
+ else if (id === "turn") writeField(doc, FIELD_REMINDER, 0);
280
+ else if (id !== "custom") writeField(doc, FIELD_REMINDER, Number(id));
281
+ };
282
+ const commit = () => {
283
+ const minutes = Math.round(Number(draft));
284
+ if (!Number.isFinite(minutes) || draft.trim() === "") {
285
+ setDraft(String(current));
286
+ return;
287
+ }
288
+ const clamped = Math.min(MAX_REMINDER_MINUTES, Math.max(1, minutes));
289
+ writeField(doc, FIELD_REMINDER, clamped);
290
+ setDraft(String(clamped));
291
+ };
292
+ const picker = (0, react.createElement)("button", {
293
+ type: "button",
294
+ className: "dsh_desk_lang_picker",
295
+ "aria-haspopup": "menu",
296
+ "aria-expanded": open,
297
+ onClick: () => setOpen((value) => !value)
298
+ }, labelOf(selected), Chevron === void 0 ? null : (0, react.createElement)(Chevron, { className: "dsh_desk_lang_chevron" }));
299
+ const control = Menu ? (0, react.createElement)(Menu, {
300
+ open,
301
+ anchor: picker,
302
+ items,
303
+ selectedId: selected,
304
+ align: "end",
305
+ portal: true,
306
+ onClose: () => setOpen(false),
307
+ onSelect: choose
171
308
  }) : picker;
172
- return (0, react.createElement)("div", { className: "dsh_desk_lang_row" }, (0, react.createElement)("div", { className: "dsh_desk_lang_text" }, (0, react.createElement)("div", { className: "dsh_desk_lang_title" }, t("heading")), (0, react.createElement)("div", { className: "dsh_desk_lang_desc" }, t("description"))), control);
309
+ if (selected !== "custom") return control;
310
+ return (0, react.createElement)("div", { className: "dsh_desk_lang_control" }, control, (0, react.createElement)("input", {
311
+ type: "number",
312
+ className: "dsh_desk_lang_input",
313
+ min: 1,
314
+ max: MAX_REMINDER_MINUTES,
315
+ placeholder: String(settings.reminderMinutes > 0 ? settings.reminderMinutes : 30),
316
+ value: draft,
317
+ onChange: (event) => setDraft(event.currentTarget.value),
318
+ onBlur: commit,
319
+ onKeyDown: (event) => {
320
+ if (event.key === "Enter") commit();
321
+ }
322
+ }), (0, react.createElement)("span", { className: "dsh_desk_lang_hint" }, t("reminderCustomHint")));
323
+ };
324
+ }
325
+ /**
326
+ * Build the extra-injection picker: on or off.
327
+ * 构建额外注入选择器:开启或关闭。
328
+ *
329
+ * It shares the host Menu with the other controls, so the three read as one column.
330
+ * 与另外两个控件共用宿主 Menu,三者在视觉上成一列。
331
+ */
332
+ function createExtraPicker(primitives) {
333
+ const Menu = primitives?.Menu;
334
+ const Chevron = primitives?.IconChevronDownOutlineRegular ?? primitives?.IconChevronDownOutline14 ?? primitives?.IconChevronDownOutlineMedium;
335
+ return function ExtraPicker(props) {
336
+ const { doc, t, settings, disabled = false } = props;
337
+ const [open, setOpen] = (0, react.useState)(false);
338
+ const items = [{
339
+ id: "on",
340
+ label: t("extraOn")
341
+ }, {
342
+ id: "off",
343
+ label: t("extraOff")
344
+ }];
345
+ const close = () => setOpen(false);
346
+ const choose = (id) => {
347
+ writeField(doc, FIELD_EXTRA, id === "on");
348
+ close();
349
+ };
350
+ const picker = (0, react.createElement)("button", {
351
+ type: "button",
352
+ className: "dsh_desk_lang_picker",
353
+ "aria-haspopup": "menu",
354
+ "aria-expanded": open,
355
+ disabled,
356
+ onClick: () => setOpen((value) => !value)
357
+ }, settings.extraInjection ? t("extraOn") : t("extraOff"), Chevron === void 0 ? null : (0, react.createElement)(Chevron, { className: "dsh_desk_lang_chevron" }));
358
+ if (!Menu) return picker;
359
+ return (0, react.createElement)(Menu, {
360
+ open,
361
+ anchor: picker,
362
+ items,
363
+ selectedId: settings.extraInjection ? "on" : "off",
364
+ align: "end",
365
+ portal: true,
366
+ onClose: close,
367
+ onSelect: choose
368
+ });
369
+ };
370
+ }
371
+ /**
372
+ * Build the General settings row: heading, description and the language picker.
373
+ * 构建「通用」设置行:标题、说明与语言选择器。
374
+ */
375
+ function createRow(primitives) {
376
+ const LanguagePicker = createLanguagePicker(primitives);
377
+ return function ThinkingLanguageRow(props) {
378
+ const settings = useSettings(props.doc);
379
+ return (0, react.createElement)("div", { className: "dsh_desk_lang_row" }, (0, react.createElement)("div", { className: "dsh_desk_lang_text" }, (0, react.createElement)("div", { className: "dsh_desk_lang_title" }, props.t("heading")), (0, react.createElement)("div", { className: "dsh_desk_lang_desc" }, props.t("description"))), (0, react.createElement)(LanguagePicker, {
380
+ doc: props.doc,
381
+ t: props.t,
382
+ settings
383
+ }));
384
+ };
385
+ }
386
+ /**
387
+ * Build the plugin configuration card: language and reminder interval.
388
+ * 构建插件配置卡片:思考语言与提醒间隔。
389
+ *
390
+ * The host renders this inside the plugin's detail page; `view: 'summary'` is the
391
+ * one-line form a card may ask for, which this plugin leaves empty.
392
+ * 宿主把它渲染在插件详情页里;`view: 'summary'` 是卡片可能请求的单行形式,本插件
393
+ * 留空。
394
+ */
395
+ function createConfigCard(primitives) {
396
+ const LanguagePicker = createLanguagePicker(primitives);
397
+ const ReminderPicker = createReminderPicker(primitives);
398
+ const ExtraPicker = createExtraPicker(primitives);
399
+ return function ThinkingLanguageCard(props) {
400
+ const settings = useSettings(props.doc);
401
+ if (props.view === "summary") return null;
402
+ const binding = {
403
+ doc: props.doc,
404
+ t: props.t,
405
+ settings
406
+ };
407
+ const reminderOff = settings.reminderMinutes < 0;
408
+ return (0, react.createElement)("div", null, (0, react.createElement)("div", { className: "dsh_desk_lang_row" }, (0, react.createElement)("div", { className: "dsh_desk_lang_text" }, (0, react.createElement)("div", { className: "dsh_desk_lang_title" }, props.t("heading")), (0, react.createElement)("div", { className: "dsh_desk_lang_desc" }, props.t("description"))), (0, react.createElement)(LanguagePicker, binding)), (0, react.createElement)("div", { className: "dsh_desk_lang_row" }, (0, react.createElement)("div", { className: "dsh_desk_lang_text" }, (0, react.createElement)("div", { className: "dsh_desk_lang_title" }, props.t("reminderHeading")), (0, react.createElement)("div", { className: "dsh_desk_lang_desc" }, props.t("reminderDescription"))), (0, react.createElement)(ReminderPicker, binding)), (0, react.createElement)("div", { className: reminderOff ? "dsh_desk_lang_row dsh_desk_lang_row_disabled" : "dsh_desk_lang_row" }, (0, react.createElement)("div", { className: "dsh_desk_lang_text" }, (0, react.createElement)("div", { className: "dsh_desk_lang_title" }, props.t("extraHeading")), (0, react.createElement)("div", { className: "dsh_desk_lang_desc" }, props.t("extraDescription"))), (0, react.createElement)(ExtraPicker, {
409
+ ...binding,
410
+ disabled: reminderOff
411
+ })));
173
412
  };
174
413
  }
175
414
  const rowCss = [
176
415
  ".dsh_desk_lang_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}",
416
+ ".dsh_desk_lang_row_disabled{opacity:.45;pointer-events:none}",
177
417
  ".dsh_desk_lang_text{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}",
178
418
  ".dsh_desk_lang_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}",
179
419
  ".dsh_desk_lang_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}",
180
420
  ".dsh_desk_lang_picker{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex;flex:none}",
181
421
  ".dsh_desk_lang_picker:hover{background:var(--dsw-alias-interactive-bg-hover)}",
182
- ".dsh_desk_lang_chevron{flex:none}"
422
+ ".dsh_desk_lang_chevron{flex:none}",
423
+ ".dsh_desk_lang_control{align-items:center;gap:8px;display:flex;flex:none}",
424
+ ".dsh_desk_lang_input{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;width:88px;font:inherit;color:var(--dsw-alias-label-primary);border:none;padding:0 12px;font-size:14px}",
425
+ ".dsh_desk_lang_hint{color:var(--dsw-alias-label-tertiary);font-size:12px;white-space:nowrap}"
183
426
  ].join("\n");
184
427
  /** Marks the injected stylesheet, so a second mount can detect the first. / 标记已注入的样式表,使第二次挂载能发现第一次。 */
185
428
  const STYLE_MARKER = "dsh-thinking-lang";
186
429
  /**
187
- * Inject the row stylesheet once per document, replacing a stale one.
188
- * 每份文档只注入一次行样式表,已过期的那张会被替换。
189
- *
190
- * The guard reads the document rather than a module-level flag: a client plugin
191
- * can be mounted more than once against the same page, and only the DOM knows
192
- * whether this sheet is already there. Content is compared as well, because a
193
- * hot-reloaded bundle keeps its marker while its CSS changes; skipping on the
194
- * marker alone would leave the row styled by class names that no longer exist.
195
- * 判重依据是文档本身而不是模块级标志:客户端插件可能被重复挂载到同一页面,只有 DOM
196
- * 知道这张样式表是否已经存在。同时比对内容:热重载的 bundle 标记不变而 CSS 已变,
197
- * 只看标记就跳过会让这一行按已不存在的类名取样式。
430
+ * Inject the settings stylesheet once per document, replacing a stale one.
431
+ * 每份文档只注入一次设置样式表,已过期的那张会被替换。
198
432
  */
199
433
  function mountRowStyles() {
200
434
  if (typeof document === "undefined") return;
@@ -223,6 +457,8 @@ function mountRowStyles() {
223
457
  */
224
458
  /** Stable Cordis plugin name. / 稳定的 Cordis 插件名。 */
225
459
  const name = "ay-dsh-tk-lang";
460
+ /** Package name; the key Plugins page uses to find a bundle's configuration page. / 包名;插件页用它查找某个 bundle 的配置页。 */
461
+ const PACKAGE_NAME = "dsh-thinking-lang";
226
462
  /** The one client service this plugin requires. / 本插件唯一需要的客户端服务。 */
227
463
  const inject = ["slots"];
228
464
  /** Locale namespace holding the row copy. / 保存行文案的 locale 命名空间。 */
@@ -293,6 +529,21 @@ function apply(ctx) {
293
529
  })
294
530
  }, Row);
295
531
  });
532
+ const whileServed = typeof forms.whileServed === "function" ? forms.whileServed.bind(forms) : void 0;
533
+ if (whileServed === void 0) {
534
+ report(uiCtx, "configForms.whileServed unavailable; plugin configuration page disabled");
535
+ return;
536
+ }
537
+ const Card = createConfigCard(primitives);
538
+ uiCtx.effect(() => whileServed([SETTINGS_NAMESPACE], () => uiCtx.slots.inject("plugins.bundle.config", () => uiCtx.slots.register({
539
+ name: "plugins.bundle.config",
540
+ key: PACKAGE_NAME,
541
+ locale: LOCALE_NS,
542
+ inject: () => ({
543
+ doc,
544
+ t
545
+ })
546
+ }, Card))), "dsh-thinking-lang: plugin configuration page");
296
547
  });
297
548
  }
298
549
  //#endregion
package/lib/core.d.ts CHANGED
@@ -33,8 +33,10 @@ export interface Language {
33
33
  nativeName: string;
34
34
  /** The rule sentence written in this language. / 用本语言写成的规则句。 */
35
35
  section: string;
36
- /** The short per-turn reminder written in this language. / 用本语言写成的每轮短提醒。 */
36
+ /** The short reminder written in this language for the head of the batch. / 写在批次开头的短提醒。 */
37
37
  reminder: string;
38
+ /** The short reminder written for the last message of the request. / 写在请求末尾的短提醒。 */
39
+ tail: string;
38
40
  }
39
41
  /**
40
42
  * The catalogue, in picker order.
@@ -53,16 +55,41 @@ export declare const CATALOGUE: readonly Language[];
53
55
  export declare const AUTO = "auto";
54
56
  /** Settings namespace owned by this plugin. / 本插件拥有的设置命名空间。 */
55
57
  export declare const SETTINGS_NAMESPACE = "ay-dsh-tk-lang";
56
- /** The one field this plugin stores. / 本插件唯一保存的字段。 */
58
+ /** The language field this plugin stores. / 本插件保存的语言字段。 */
57
59
  export declare const FIELD_LANGUAGE = "language";
60
+ /** The reminder field this plugin stores. / 本插件保存的提醒字段。 */
61
+ export declare const FIELD_REMINDER = "reminderMinutes";
62
+ /** The extra-injection field this plugin stores. / 本插件保存的额外注入字段。 */
63
+ export declare const FIELD_EXTRA = "extraInjection";
64
+ /** Reminder value that disables the per-turn reminder. / 关闭每轮提醒的取值。 */
65
+ export declare const REMINDER_OFF = -1;
66
+ /** Reminder value that injects on every turn. / 每轮都注入的取值。 */
67
+ export declare const REMINDER_EVERY_TURN = 0;
68
+ /** Reminder interval applied when the field is absent. / 字段缺失时的提醒间隔(分钟)。 */
69
+ export declare const DEFAULT_REMINDER_MINUTES = 30;
70
+ /** Largest accepted reminder interval. / 允许的最大提醒间隔(分钟)。 */
71
+ export declare const MAX_REMINDER_MINUTES = 1440;
58
72
  /** Every value the picker offers besides {@link AUTO}. / 选择器在 {@link AUTO} 之外提供的全部取值。 */
59
73
  export declare const SELECTABLE_TAGS: readonly string[];
60
74
  /** The resolved configuration this plugin acts on. / 本插件实际作用的已解析配置。 */
61
75
  export interface ThinkingSettings {
62
76
  /** Selected language tag, or {@link AUTO}. / 所选语言标签,或 {@link AUTO}。 */
63
77
  language: string;
78
+ /**
79
+ * Minutes between reminders: {@link REMINDER_OFF} disables them,
80
+ * {@link REMINDER_EVERY_TURN} injects on every turn, and 1–1440 is a minimum gap.
81
+ * 提醒间隔(分钟):{@link REMINDER_OFF} 关闭,{@link REMINDER_EVERY_TURN} 每轮
82
+ * 注入,1–1440 为最小间隔。
83
+ */
84
+ reminderMinutes: number;
85
+ /**
86
+ * Whether the closing rule is also folded into the skill catalogue. It only
87
+ * applies while the reminder is on.
88
+ * 是否把收尾规则同时折进技能目录;仅在提醒开启时生效。
89
+ */
90
+ extraInjection: boolean;
64
91
  }
65
- /** Configuration applied when the field is absent. / 字段缺失时采用的配置。 */
92
+ /** Configuration applied when the fields are absent. / 字段缺失时采用的配置。 */
66
93
  export declare const DEFAULTS: ThinkingSettings;
67
94
  /** A minimal read handle over the host settings service. / 宿主设置服务的最小读取句柄。 */
68
95
  export interface Reader {
@@ -74,9 +101,13 @@ export interface Reader {
74
101
  */
75
102
  export declare function nativeNameFor(tag: string): string | undefined;
76
103
  /**
77
- * Coerce an untrusted settings section into a complete configuration.
78
- * 把不可信的设置段强制转换为完整配置。
104
+ * Convert stored minutes into the minimum gap between reminders.
105
+ * 把存储的分钟数换算成两次提醒之间的最小间隔。
106
+ *
107
+ * Returns {@link REMINDER_OFF} when the reminder is disabled and `0` when it runs
108
+ * on every turn. / 关闭时返回 {@link REMINDER_OFF},每轮注入时返回 `0`。
79
109
  */
110
+ export declare function reminderDelayMs(minutes: number): number;
80
111
  export declare function normalizeSettings(raw: unknown): ThinkingSettings;
81
112
  /**
82
113
  * Resolve the effective language for `auto`, most authoritative source first.
@@ -107,3 +138,8 @@ export declare function sectionText(code: string): string;
107
138
  * 用所选语言生成每轮短提醒。
108
139
  */
109
140
  export declare function reminderText(code: string): string;
141
+ /**
142
+ * Build the closing reminder appended as the request's last message.
143
+ * 生成追加在请求最后一条消息里的收尾提醒。
144
+ */
145
+ export declare function tailText(code: string): string;