dsh-peak-checker 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The dsh-peak-checker authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # dsh-peak-checker
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 在 DSH(DeepSeek Harness)输入框工具行显示当前是否处于 **DeepSeek API 高峰时段**。
4
+
5
+ Shows whether the DeepSeek API is currently in **peak hours** as a small badge in the DSH composer toolbar.
6
+
7
+ ## 高峰时段 / Peak windows
8
+
9
+ 按北京时间(UTC+8)判断,其余时间均为空闲:/ Evaluated in Beijing time (UTC+8); everything else is off-peak.
10
+
11
+ | 时段 / Window | 是否高峰 / Peak |
12
+ | --- | --- |
13
+ | 周一至周五 09:00–12:00 / Mon–Fri 09:00–12:00 | 高峰 / peak |
14
+ | 周一至周五 14:00–18:00 / Mon–Fri 14:00–18:00 | 高峰 / peak |
15
+ | 周末全天 / weekends, all day | 空闲 / off-peak |
16
+ | 其他时间 / any other time | 空闲 / off-peak |
17
+
18
+ 徽标每 30 秒自动刷新,跨过高/低峰边界时无需刷新页面。/ The badge re-evaluates every 30 seconds, so it crosses peak boundaries without a page reload.
19
+
20
+ ## 安装 / Install
21
+
22
+ 把本包加入 DSH profile 的依赖并在 `dsh.profile.bundles` 中启用,然后重启 DSH web:
23
+
24
+ ```jsonc
25
+ // ~/.dsh/profiles/web/package.json
26
+ {
27
+ "dependencies": { "dsh-peak-checker": "^0.1.1" },
28
+ "dsh": { "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-peak-checker"] } }
29
+ }
30
+ ```
31
+
32
+ 插件随 bundle 的 `dsh.bundle.patch` 自动插入 Loader 行,无需修改 `cordis.patch.yml` 以外的配置。
33
+ The bundle patch inserts the Loader row automatically.
34
+
35
+ ## 包结构 / What is inside
36
+
37
+ | 路径 / Path | 作用 / Role |
38
+ | --- | --- |
39
+ | `lib/index.js` | 宿主半:仅作为 Loader 行存在 / host half (Loader row only) |
40
+ | `lib/client.js` | 浏览器半:DSH 客户端插件 bundle / browser half, a `window.__ModuleLoader__` bundle |
41
+ | `lib/peak.js` | 高峰时段判断逻辑 / peak-window logic |
42
+ | `cordis.patch.yml` | 插入 Loader 行的 bundle patch / bundle patch inserting the Loader row |
43
+
44
+ `lib/client.js` 由 `scripts/build-client.mjs` 用 esbuild 生成:把 `src/client/index.tsx` 打成 lazy-CJS,再由 `window.__ModuleLoader__.load({ id, factory })` 注册;`react` 作为 DSH 客户端基线模块保持 external。
45
+ The client bundle is built with esbuild into the lazy-CJS factory form DSH's module loader expects, with React left external.
46
+
47
+ ## 开发 / Development
48
+
49
+ ```bash
50
+ npm run build # tsc (host half + types) + esbuild (client bundle)
51
+ npm run typecheck # host and client type checks
52
+ npm test # unit tests, including a simulated DSH module loader
53
+ ```
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,6 @@
1
+ # dsh-peak-checker bundle patch.
2
+ # The bundle inserts its own Loader row; the client half is discovered from that
3
+ # row's `dsh.client` declaration and served to the browser as a plugin bundle.
4
+ - insert:
5
+ - id: dsh-peak-checker
6
+ name: dsh-peak-checker
package/lib/client.js ADDED
@@ -0,0 +1,107 @@
1
+ /* dsh-peak-checker client half — generated by scripts/build-client.mjs; do not edit. */
2
+ window.__ModuleLoader__.load({id:"dsh-peak-checker",factory:require=>{var module={exports:{}};var exports=module.exports;
3
+ "use strict";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/client/index.tsx
33
+ var index_exports = {};
34
+ __export(index_exports, {
35
+ apply: () => apply,
36
+ inject: () => inject
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+ var React = __toESM(require("react"), 1);
40
+
41
+ // src/peak.ts
42
+ var BEIJING_OFFSET_MS = 8 * 36e5;
43
+ function getPeakState(date = /* @__PURE__ */ new Date()) {
44
+ const bj = new Date(date.getTime() + BEIJING_OFFSET_MS);
45
+ const day = bj.getUTCDay();
46
+ const minutes = bj.getUTCHours() * 60 + bj.getUTCMinutes();
47
+ const isWeekday = day >= 1 && day <= 5;
48
+ if (!isWeekday) return "off-peak";
49
+ const inMorningPeak = minutes >= 9 * 60 && minutes < 12 * 60;
50
+ const inAfternoonPeak = minutes >= 14 * 60 && minutes < 18 * 60;
51
+ return inMorningPeak || inAfternoonPeak ? "peak" : "off-peak";
52
+ }
53
+
54
+ // src/client/styles.ts
55
+ function badgeStyle(isPeak) {
56
+ return {
57
+ display: "inline-flex",
58
+ alignItems: "center",
59
+ gap: 4,
60
+ padding: "2px 8px",
61
+ borderRadius: 999,
62
+ fontSize: 11,
63
+ fontWeight: 500,
64
+ lineHeight: "18px",
65
+ whiteSpace: "nowrap",
66
+ userSelect: "none",
67
+ cursor: "default",
68
+ color: isPeak ? "var(--dsh-color-warning, #b45309)" : "var(--dsh-color-success, #15803d)",
69
+ background: isPeak ? "rgba(234, 179, 8, 0.12)" : "rgba(34, 197, 94, 0.12)",
70
+ border: `1px solid ${isPeak ? "rgba(234, 179, 8, 0.35)" : "rgba(34, 197, 94, 0.35)"}`
71
+ };
72
+ }
73
+
74
+ // src/client/index.tsx
75
+ var inject = ["slots"];
76
+ var SLOT_NAME = "conversation.input.left";
77
+ var REFRESH_MS = 3e4;
78
+ function apply(ctx) {
79
+ ctx.slots.inject(
80
+ SLOT_NAME,
81
+ () => ctx.slots.register(
82
+ { name: SLOT_NAME, id: "dsh-peak-checker", order: 30 },
83
+ PeakIndicator
84
+ )
85
+ );
86
+ }
87
+ function PeakIndicator() {
88
+ const [state, setState] = React.useState(getPeakState);
89
+ React.useEffect(() => {
90
+ setState(getPeakState());
91
+ const timer = window.setInterval(() => setState(getPeakState()), REFRESH_MS);
92
+ return () => window.clearInterval(timer);
93
+ }, []);
94
+ const isPeak = state === "peak";
95
+ return /* @__PURE__ */ React.createElement(
96
+ "span",
97
+ {
98
+ "data-dsh-peak-state": state,
99
+ title: isPeak ? "\u5F53\u524D\u4E3A DeepSeek API \u9AD8\u5CF0\u65F6\u6BB5\uFF08\u5317\u4EAC\u65F6\u95F4\u5468\u4E00\u81F3\u5468\u4E94 09:00\u201312:00\u300114:00\u201318:00\uFF09" : "\u5F53\u524D\u4E3A DeepSeek API \u7A7A\u95F2\u65F6\u6BB5",
100
+ style: badgeStyle(isPeak)
101
+ },
102
+ /* @__PURE__ */ React.createElement("span", { style: { fontSize: 8, lineHeight: 1 } }, "\u25CF"),
103
+ isPeak ? "\u9AD8\u5CF0" : "\u7A7A\u95F2"
104
+ );
105
+ }
106
+
107
+ return module.exports}})
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // src/index.ts
2
+ //
3
+ // Host half. This plugin only contributes browser UI, so the host half exists
4
+ // solely as the Loader row that the client module system scans for a
5
+ // `dsh.client` declaration. It intentionally has no host-plane behavior.
6
+ export const name = 'dsh-peak-checker';
7
+ export function apply() {
8
+ // Nothing to do on the host plane.
9
+ }
package/lib/peak.js ADDED
@@ -0,0 +1,25 @@
1
+ /** Beijing time offset from UTC, in milliseconds. */
2
+ const BEIJING_OFFSET_MS = 8 * 3_600_000;
3
+ /**
4
+ * 按北京时间 (UTC+8) 判断当前是否处于 DeepSeek API 高峰时段。
5
+ * 高峰:周一至周五 09:00–12:00、14:00–18:00
6
+ * 空闲:其余时间(含周末全天)
7
+ *
8
+ * 实现说明:先把时刻平移到北京时间,再用 UTC getter 读取,因此结果与
9
+ * 运行机器的本地时区、夏令时规则完全无关。
10
+ */
11
+ export function getPeakState(date = new Date()) {
12
+ const bj = new Date(date.getTime() + BEIJING_OFFSET_MS);
13
+ const day = bj.getUTCDay(); // 0=周日, 1=周一, ..., 6=周六
14
+ const minutes = bj.getUTCHours() * 60 + bj.getUTCMinutes();
15
+ const isWeekday = day >= 1 && day <= 5;
16
+ if (!isWeekday)
17
+ return 'off-peak';
18
+ const inMorningPeak = minutes >= 9 * 60 && minutes < 12 * 60;
19
+ const inAfternoonPeak = minutes >= 14 * 60 && minutes < 18 * 60;
20
+ return inMorningPeak || inAfternoonPeak ? 'peak' : 'off-peak';
21
+ }
22
+ /** 供 UI 直接用:是否高峰 */
23
+ export function isPeakNow(date = new Date()) {
24
+ return getPeakState(date) === 'peak';
25
+ }
@@ -0,0 +1,2 @@
1
+ export declare const name = "dsh-peak-checker";
2
+ export declare function apply(): void;
@@ -0,0 +1,12 @@
1
+ export type PeakState = 'peak' | 'off-peak';
2
+ /**
3
+ * 按北京时间 (UTC+8) 判断当前是否处于 DeepSeek API 高峰时段。
4
+ * 高峰:周一至周五 09:00–12:00、14:00–18:00
5
+ * 空闲:其余时间(含周末全天)
6
+ *
7
+ * 实现说明:先把时刻平移到北京时间,再用 UTC getter 读取,因此结果与
8
+ * 运行机器的本地时区、夏令时规则完全无关。
9
+ */
10
+ export declare function getPeakState(date?: Date): PeakState;
11
+ /** 供 UI 直接用:是否高峰 */
12
+ export declare function isPeakNow(date?: Date): boolean;
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Peak Checker",
4
+ "description": "Shows whether the DeepSeek API is currently in peak hours (Beijing time, weekdays)."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "高峰时段检查器",
4
+ "description": "在输入框工具行显示当前是否处于 DeepSeek API 高峰时段(北京时间工作日)。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
- "name": "dsh-peak-checker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "dsh-peak-checker",
3
+ "version": "0.1.1",
4
+ "description": "在 DSH 输入框工具行显示当前是否处于 DeepSeek API 高峰时段",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "types": "lib/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "./client": {
15
+ "default": "./lib/client.js"
16
+ },
17
+ "./locale/*.json": "./locale/*.json",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "lib",
22
+ "cordis.patch.yml",
23
+ "locale",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
28
+ "typecheck": "tsc -p tsconfig.client.json && tsc -p tsconfig.json --noEmit",
29
+ "test": "vitest run",
30
+ "prepack": "npm run build"
31
+ },
32
+ "keywords": [
33
+ "dsh-plugin",
34
+ "deepseek-harness",
35
+ "dsh",
36
+ "deepseek",
37
+ "peak-hours"
38
+ ],
39
+ "engines": {
40
+ "node": "^22.19.0 || >=24.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.0.0",
44
+ "@types/react": "^18.3.0",
45
+ "esbuild": "^0.28.0",
46
+ "typescript": "^5.7.0",
47
+ "vitest": "^3.0.0"
48
+ },
49
+ "dsh": {
50
+ "bundle": {
51
+ "patch": "./cordis.patch.yml"
52
+ },
53
+ "client": {
54
+ "platform": "web",
55
+ "immediately": true,
56
+ "inject": [
57
+ "@deepseek-ai/dsh-client-ui-conversation"
58
+ ]
59
+ }
60
+ }
61
+ }