@laraveladmin/dsh-stay-awake 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/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ # 变更记录 · Changelog
2
+
3
+ ## 0.1.1 — 2026-12-03
4
+
5
+ ### 修复
6
+
7
+ - npm 包页面上的相对链接(语言切换 `README.en.md`、`LICENSE`、`docs/VERIFICATION.md`)在 npmjs 上解析错误,
8
+ 点击「English」会跳到不存在的 npm 路径;现全部改为 Gitee 绝对地址,中英文文档、许可证与验证记录均可直接打开。
9
+
10
+ ## 0.1.0 — 2026-12-03
11
+
12
+ 首个版本。
13
+
14
+ ### 发布
15
+
16
+ - 已发布到 npm:`@laraveladmin/dsh-stay-awake@0.1.0`(2026-12-03)。
17
+
18
+ ### 功能
19
+
20
+ - **三类活跃源**:运行中的会话(`agent/status`)、手动 `/compact` 的维护期(会话事件 `compaction/start` → `compaction/end`)、后台任务(`ctx.jobs` + 持久事件 `job/registered` / `job/settled`)。
21
+ - **断言管理**:全局只持有一个系统电源断言;释放有 30 秒防抖;单次持有 8 小时上限,到期重建而不是放弃;断言意外退出按 1s→60s 退避重试。
22
+ - **崩溃安全**:断言绑定 DSH 宿主——macOS `caffeinate -w <pid>`、Windows stdin EOF、Linux 宿主看门狗。
23
+ - **三平台后端**:macOS `caffeinate`、Windows `SetThreadExecutionState`、Linux `systemd-inhibit`。
24
+ - **状态栏指示器**:输入框下方显示「守夜 · 保持中 / 未保持 / 释放中 / 异常 / 状态未知」。
25
+ - **设置弹层**:总开关、允许屏幕休眠、临时保持(30 分钟 / 2 小时 / 取消)、状态详情、源码与 npm 版本链接;中英双语,Esc / 点外部关闭。
26
+ - **偏好持久化**:`~/.dsh/plugin-data/dsh-stay-awake/state.json`(仅 enabled / scope,原子写)。
27
+
28
+ ### 平台验证
29
+
30
+ - macOS:真机验收(`pmset` 内核账本有逐条证据,见 `docs/VERIFICATION.md`)。
31
+ - Windows / Linux:提供实现与单元测试,电源效果需在对应真机确认。
32
+
33
+ ### 已知限制
34
+
35
+ - 合盖休眠、主动睡眠、低电量强制睡眠、MDM 策略无法阻止。
36
+ - 计划任务临近触发、电量阈值、日志导出尚未实现(P2)。
37
+ - npm 包里不含测试目录。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 laraveladmin
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.en.md ADDED
@@ -0,0 +1,223 @@
1
+ # Stay Awake · 守夜
2
+
3
+ **A DeepSeek Harness plugin that keeps the machine awake only while unattended work is still running, then releases automatically.**
4
+
5
+ [简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) · [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md) · [Repository](https://gitee.com/laravel-admin/dsh-stay-awake)
6
+
7
+ `@laraveladmin/dsh-stay-awake` · macOS / Windows / Linux
8
+
9
+ <p>
10
+ <img alt="version" src="https://img.shields.io/badge/version-0.1.1-blue">
11
+ <img alt="platform" src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-4c6ef5">
12
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-green">
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## Why this exists
18
+
19
+ Long DSH tasks die quietly when the machine idle-sleeps: processes are suspended, streams drop, model requests time out, and background builds stop halfway. The operating system cannot tell that the work is still alive — **Stay Awake** can. It holds the system assertion while work is running and lets go when there is none, so you never have to remember to turn it on or off.
20
+
21
+ ## What counts as work
22
+
23
+ Most existing plugins equate "a task" with "a session in the running state". DSH has at least three states where **the session is not running but work continues**:
24
+
25
+ | Source | Signal | Why it needs its own handling |
26
+ |---|---|---|
27
+ | Running agent turns | `agent/status` + `ctx.agents.list()` | The main path: streaming output and tool execution |
28
+ | Background jobs | `ctx.jobs` plus durable events `job/registered` / `job/settled` | `run_in_background` keeps running after the agent idles |
29
+ | Maintenance | session events `compaction/start` → `compaction/end` | `Agent.status` reports idle during a manual `/compact` |
30
+
31
+ The rule is a pure function: `wanted = enabled && (agents + maintenance + jobs > 0)`. Exactly one system power assertion is held process-wide.
32
+
33
+ ## Behaviour
34
+
35
+ - **Release debounce** (30s): the last work item ending does not release immediately; a new turn inside the window cancels it.
36
+ - **Hold cap** (8h): the assertion is rebuilt rather than abandoned, so day-long tasks are unaffected.
37
+ - **Crash safety**: the assertion is bound to the DSH host process — `caffeinate -w <pid>` on macOS, stdin EOF on Windows, a host watchdog on Linux. A host crash can never pin the machine awake forever.
38
+ - **Retry ladder**: an unexpected assertion exit retries with 1s → 60s backoff, never gives up, and logs once per failure round.
39
+ - **Reconciliation**: every 60 seconds the live registry corrects the state, covering missed events and plugin reloads.
40
+
41
+ ## Interface
42
+
43
+ **Composer status-bar indicator** (below the input, after the shipped `activity` and `usage` entries):
44
+
45
+ ![Status-bar indicator](https://gitee.com/laravel-admin/dsh-stay-awake/raw/main/docs/images/indicator.svg)
46
+
47
+ **Settings panel** (click the indicator):
48
+
49
+ ![Settings panel](https://gitee.com/laravel-admin/dsh-stay-awake/raw/main/docs/images/panel.svg)
50
+
51
+ > These are **schematics** drawn from the real layout; the palette follows the active DSH theme and the wording and controls match the implementation. Real screenshots have to be captured from a running GUI and are not bundled yet.
52
+
53
+ ## Install
54
+
55
+ **Requirements**: DSH 0.2.x (Desktop or `dsh web`). The plugin has no third-party runtime dependencies and needs no Node toolchain.
56
+
57
+ Published on npm: [`@laraveladmin/dsh-stay-awake@0.1.1`](https://www.npmjs.com/package/@laraveladmin/dsh-stay-awake)
58
+
59
+ ### Option 1 — install from npm (recommended)
60
+
61
+ Run this in a DSH session:
62
+
63
+ ```text
64
+ plugin_manager action: install_bundle target: @laraveladmin/dsh-stay-awake
65
+ ```
66
+
67
+ Then **reload the session page** (`Cmd + R` on macOS, `Ctrl + R` on Windows); the `☾ Stay awake · …` indicator appears in the composer status bar.
68
+
69
+ ### Option 2 — install from the DSH UI (local source directory)
70
+
71
+ Use this when you want to modify the code or prefer not to use npm:
72
+
73
+ 1. Clone the repository:
74
+
75
+ ```bash
76
+ git clone https://gitee.com/laravel-admin/dsh-stay-awake.git
77
+ ```
78
+
79
+ 2. Open DSH and go to **Plugins**.
80
+ 3. Choose **Add plugin** and pick the cloned directory (the one containing `package.json`).
81
+ 4. After installation, **reload the session page** (`Cmd + R` on macOS, `Ctrl + R` on Windows).
82
+
83
+ ### Option 3 — ask the agent to install it
84
+
85
+ Send this to the agent in DSH:
86
+
87
+ > Install @laraveladmin/dsh-stay-awake into the current DSH profile (or clone https://gitee.com/laravel-admin/dsh-stay-awake and install it).
88
+
89
+ ### Post-install checks
90
+
91
+ | Check | Expected |
92
+ |---|---|
93
+ | Composer status bar | The "Stay awake" indicator appears |
94
+ | Plugins page | A "Stay awake" row whose title and description follow the UI language |
95
+ | macOS assertion | `pmset -g assertions \| grep caffeinate` shows an entry while a session is running |
96
+ | Idle release | About 30 seconds after the session ends, the same command prints nothing |
97
+
98
+ ## Configure
99
+
100
+ Override the row by id in the profile's `cordis.patch.yml`:
101
+
102
+ ```yaml
103
+ - id: stay-awake
104
+ name: '@laraveladmin/dsh-stay-awake'
105
+ config:
106
+ enabled: true # master switch
107
+ scope: system # system = allow display sleep; display = keep the screen on too
108
+ releaseDelayMs: 30000 # release debounce in ms, 0 = release immediately
109
+ maxHoldHours: 8 # hold cap in hours, 0 = no cap
110
+ includeBackgroundJobs: true # count background jobs
111
+ includeMaintenance: true # count manual /compact maintenance
112
+ reconcileSeconds: 60 # reconciliation interval, 0 = disabled
113
+ maxMaintenanceMinutes: 120 # longest a maintenance bracket may stay open
114
+ caffeinatePath: /usr/bin/caffeinate # macOS only, advanced override
115
+ ```
116
+
117
+ Invalid values fall back to their defaults with a warning; a bad config never blocks loading.
118
+
119
+ ## Usage
120
+
121
+ **Day to day you do nothing** — the plugin decides on its own. These are the only manual actions worth knowing.
122
+
123
+ ### Check the state
124
+
125
+ - The label reads one of: holding, not holding, releasing, error, unknown.
126
+ - Click it to open the settings panel with active sources (agents / maintenance / jobs), scope, backend, hold duration, error reason and version.
127
+
128
+ ### Settings panel
129
+
130
+ Clicking the icon or the "Stay awake" label opens a panel at the bottom of the window:
131
+
132
+ | Control | Effect |
133
+ |---|---|
134
+ | Enabled | Turning it off releases the assertion immediately |
135
+ | Allow display sleep | On = block system sleep only; off = keep the screen on too |
136
+ | Hold for | 30 min / 2 h / cancel, for temporary keeps |
137
+ | Status block | Active sources, scope, backend, hold duration, error reason |
138
+ | Footer | Where advanced options live, source link, version |
139
+
140
+ The **enabled** and **display** preferences are stored in `~/.dsh/plugin-data/dsh-stay-awake/state.json` and survive a restart; everything else stays in `cordis.patch.yml` (the patch layer is the default, the panel overrides it). Press `Esc` or click outside to close.
141
+
142
+ ### Change the configuration
143
+
144
+ Edit the profile's `cordis.patch.yml` as shown above; saving hot-reloads the plugin. If it does not take effect, restart DSH.
145
+
146
+ ### Turn it off temporarily
147
+
148
+ Set `enabled: false`, or disable the plugin on the Plugins page. Both release the assertion **immediately**, without waiting for the 30-second debounce.
149
+
150
+ ### Uninstall
151
+
152
+ Remove the bundle from the Plugins page; the assertion is released with it and no process is left behind.
153
+
154
+ ## Verify
155
+
156
+ The indicator sits in the composer status bar, after the shipped `activity` and `usage` entries. It reports one of: holding, not holding, releasing, error, unknown (host unreachable), or off. **Click it to open the settings panel.**
157
+
158
+ ```bash
159
+ # macOS: exactly one assertion while working, no output when idle
160
+ pmset -g assertions | grep -A2 caffeinate
161
+ pgrep -fl "caffeinate -i -w"
162
+ ```
163
+
164
+ ```powershell
165
+ # Windows
166
+ powercfg /requests
167
+ ```
168
+
169
+ ```bash
170
+ # Linux
171
+ systemd-inhibit --list
172
+ ```
173
+
174
+ ## Limitations
175
+
176
+ **What no user-space tool can block**: lid-close sleep, manual sleep, critical-battery sleep, and MDM policies. On macOS a closed lid keeps running only through clamshell mode (power plus an external display). Inside WSL the plugin can only inhibit the distribution, not the Windows host.
177
+
178
+ **Verification scope**: macOS is the author's real-hardware acceptance platform; see the [verification record](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/docs/VERIFICATION.md) (Chinese) for per-case evidence. Windows and Linux ship with implementations and unit tests, but their power effect must be confirmed on the corresponding machine. A release note will never present "implemented" as "verified".
179
+
180
+ **Local writes**: exactly one state file, `~/.dsh/plugin-data/dsh-stay-awake/state.json` (the two panel preferences). It does not modify system power plans, request privileges, use the network, or read session content.
181
+
182
+ ## Internationalization
183
+
184
+ - The composer indicator follows the active DSH locale, with built-in Simplified Chinese and English; other locales fall back to English.
185
+ - The plugin manager title and description are localized as well (`locale/zh.json`, `locale/en.json`).
186
+ - Repository documentation: [简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md).
187
+
188
+ ## Development
189
+
190
+ ```bash
191
+ node --test test/*.test.js # 53 unit and wiring tests, no DSH runtime needed
192
+ node --test test/integration/*.test.js # macOS integration tests (real caffeinate + kernel ledger)
193
+ ```
194
+
195
+ Layout:
196
+
197
+ ```
198
+ index.js host entry: event wiring, reconciliation, route, lifecycle
199
+ client.js browser half: composer status-bar indicator with zh/en dictionaries
200
+ lib/config.js config validation and defaults
201
+ lib/activity.js activity bookkeeping (pure data structure)
202
+ lib/controller.js assertion state machine (injectable clock and power)
203
+ lib/platform.js per-platform command generation (pure functions)
204
+ lib/power.js assertion process lifecycle
205
+ lib/server.js same-origin status route
206
+ docs/REQUIREMENTS.md requirements and acceptance criteria
207
+ docs/VERIFICATION.md real-machine verification record and known gaps
208
+ test/ unit and wiring tests
209
+ test/integration/ integration tests (macOS)
210
+ ```
211
+
212
+ ## Publishing (maintainers)
213
+
214
+ ```bash
215
+ npm login --registry https://registry.npmjs.org # requires @laraveladmin scope access
216
+ npm publish # package.json sets publishConfig: public + npmjs registry
217
+ ```
218
+
219
+ `npm pack --dry-run` shows the tarball contents (about 20 files, tests excluded).
220
+
221
+ ## License
222
+
223
+ Released under the [MIT](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/LICENSE) license: use, modify, redistribute and sell freely, as long as the copyright and permission notice are retained.
package/README.md CHANGED
@@ -1,3 +1,226 @@
1
- # Temporary Holding Version
1
+ # 守夜 · Stay Awake
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
+ **DeepSeek Harness 插件:只在「无人值守但仍需继续的工作」存在时保持机器不休眠,工作结束自动释放。**
4
+
5
+ [简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) · [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md) · [仓库](https://gitee.com/laravel-admin/dsh-stay-awake)
6
+
7
+ `@laraveladmin/dsh-stay-awake` · macOS / Windows / Linux
8
+
9
+ <p>
10
+ <img alt="version" src="https://img.shields.io/badge/version-0.1.1-blue">
11
+ <img alt="platform" src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-4c6ef5">
12
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-green">
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## 它解决什么
18
+
19
+ DSH 跑长任务时你离开电脑,系统按空闲策略休眠:进程被挂起、流式连接断开、模型请求超时、后台构建只跑了一半。系统不知道「这个进程还在干活」,**守夜**替它知道——有工作在跑就钉住,没有就松开,不需要你记得开,也不需要你记得关。
20
+
21
+ ## 「还在干活」的判定
22
+
23
+ 已有方案通常把「任务」等同于「会话 running」。而 DSH 里至少三种状态是**会话不 running、工作仍在继续**:
24
+
25
+ | 活跃源 | 数据来源 | 为什么必须单独处理 |
26
+ |---|---|---|
27
+ | 会话运行中 | `agent/status` + `ctx.agents.list()` | 主路径:LLM 流式输出、工具执行 |
28
+ | 后台任务 | `ctx.jobs` + 持久事件 `job/registered` / `job/settled` | `run_in_background` 的进程在 agent idle 后继续跑 |
29
+ | 维护期 | 会话事件 `compaction/start` → `compaction/end` | 手动 `/compact` 时 `Agent.status` 误报 idle |
30
+
31
+ 判定为纯函数:`wanted = enabled && (会话 + 维护期 + 后台任务 > 0)`。全局只持有一个系统电源断言。
32
+
33
+ ## 释放与自愈
34
+
35
+ - **释放防抖**:最后一个工作结束后等 30 秒再释放,避免回合间隙误放;期间来了新工作就取消。
36
+ - **兜底时长**:单次断言最长 8 小时,到时立即重建(不是放弃),长任务不受影响。
37
+ - **崩溃安全**:断言进程绑定 DSH 宿主——macOS `caffeinate -w <pid>`、Windows stdin EOF、Linux 宿主看门狗,宿主崩溃不会把机器永久钉住。
38
+ - **失败重试**:断言进程意外退出时按 1s→60s 退避重试,永不放弃,也不会刷屏。
39
+ - **周期对账**:每 60 秒用实时注册表校正一次,覆盖事件丢失与热重载。
40
+
41
+ ## 界面
42
+
43
+ **状态栏指示器**(输入框下方,`activity` / `usage` 之后):
44
+
45
+ ![状态栏指示器示意](https://gitee.com/laravel-admin/dsh-stay-awake/raw/main/docs/images/indicator.svg)
46
+
47
+ **设置弹层**(点击指示器展开):
48
+
49
+ ![设置弹层示意](https://gitee.com/laravel-admin/dsh-stay-awake/raw/main/docs/images/panel.svg)
50
+
51
+ > 以上为按实际布局绘制的**示意图**,实际配色随 DSH 亮/暗主题变化;文字与控件与实现一致。
52
+ > 真实截图需要在本机 GUI 中截取,仓库暂未收录。
53
+
54
+ ## 安装
55
+
56
+ **前置条件**:DSH 0.2.x(Desktop 或 `dsh web`)。插件零第三方运行时依赖,不需要 Node 工具链。
57
+
58
+ 已发布到 npm:[`@laraveladmin/dsh-stay-awake@0.1.1`](https://www.npmjs.com/package/@laraveladmin/dsh-stay-awake)
59
+
60
+ ### 方式一:从 npm 安装(推荐)
61
+
62
+ 在 DSH 会话里执行:
63
+
64
+ ```text
65
+ plugin_manager action: install_bundle target: @laraveladmin/dsh-stay-awake
66
+ ```
67
+
68
+ 然后**刷新会话页面**(macOS `Cmd + R`,Windows `Ctrl + R`),输入框下方状态栏出现 `☾ 守夜 · …` 即安装成功。
69
+
70
+ ### 方式二:DSH 界面安装(从本地源码目录)
71
+
72
+ 想自己改代码、或暂时不用 npm 时:
73
+
74
+ 1. 克隆仓库:
75
+
76
+ ```bash
77
+ git clone https://gitee.com/laravel-admin/dsh-stay-awake.git
78
+ ```
79
+
80
+ 2. 打开 DSH,进入 **插件(Plugins)** 页面。
81
+ 3. 点 **添加插件(Add plugin)**,选择克隆下来的目录(必须是含 `package.json` 的那一层)。
82
+ 4. 安装完成后**刷新会话页面**(macOS `Cmd + R`,Windows `Ctrl + R`)。
83
+
84
+ ### 方式三:让 AI 帮你装
85
+
86
+ 把这句话发给 DSH 里的 AI:
87
+
88
+ > 帮我把 @laraveladmin/dsh-stay-awake 安装到当前 DSH profile(或从 https://gitee.com/laravel-admin/dsh-stay-awake 克隆后安装)。
89
+
90
+ ### 安装后自检
91
+
92
+ | 检查 | 预期 |
93
+ |---|---|
94
+ | 状态栏 | 出现「守夜」指示器 |
95
+ | 插件管理页 | 出现「守夜」条目,标题与说明随界面语言切换 |
96
+ | macOS 断言 | 会话运行中 `pmset -g assertions \| grep caffeinate` 有输出 |
97
+ | 空闲释放 | 会话结束后约 30 秒,上面命令无输出 |
98
+
99
+ ## 配置
100
+
101
+ 在 profile 的 `cordis.patch.yml` 里按行 id 覆盖:
102
+
103
+ ```yaml
104
+ - id: stay-awake
105
+ name: '@laraveladmin/dsh-stay-awake'
106
+ config:
107
+ enabled: true # 总开关
108
+ scope: system # system = 只防系统休眠;display = 连屏幕一起防
109
+ releaseDelayMs: 30000 # 释放防抖(毫秒),0 = 立即释放
110
+ maxHoldHours: 8 # 单次断言最长小时数,0 = 不限制
111
+ includeBackgroundJobs: true # 后台任务计入
112
+ includeMaintenance: true # 手动 /compact 计入
113
+ reconcileSeconds: 60 # 对账间隔,0 = 关闭
114
+ maxMaintenanceMinutes: 120 # 维护期括号的最长有效期
115
+ caffeinatePath: /usr/bin/caffeinate # 仅 macOS,高级覆盖
116
+ ```
117
+
118
+ 非法值会回落到默认值并记一条 warning,不会导致插件加载失败。
119
+
120
+ ## 使用
121
+
122
+ **日常不需要任何操作**:插件自己判断有没有工作。下面是你可能需要手动做的几件事。
123
+
124
+ ### 看状态
125
+
126
+ - 状态栏文案:`守夜 · 保持中 / 未保持 / 释放中 / 异常 / 状态未知`。
127
+ - 点「守夜」:打开设置弹层,里面能看到活跃源(会话 / 维护 / 后台任务)、范围、后端、已持续时长、错误原因与版本号。
128
+
129
+ ### 设置弹层
130
+
131
+ 点状态栏的「守夜」图标或文字,窗口底部弹出设置面板:
132
+
133
+ | 项 | 作用 |
134
+ |---|---|
135
+ | 总开关 | 关掉后立即释放断言,不再自动保持 |
136
+ | 允许屏幕休眠 | 开 = 只防系统休眠;关 = 连屏幕一起保持 |
137
+ | 临时保持 | 30 分钟 / 2 小时 / 取消,用于临时不想让机器睡 |
138
+ | 状态区 | 活跃源、范围、后端、已持续时长、错误原因 |
139
+ | 底部 | 高级参数在哪改、源码链接、版本号 |
140
+
141
+ 弹层里改的**总开关**与**屏幕休眠偏好**会写入 `~/.dsh/plugin-data/dsh-stay-awake/state.json`,重启 DSH 后仍生效;其余参数仍在 `cordis.patch.yml`(patch 是默认值,弹层改过的以弹层为准)。按 `Esc` 或点面板外部关闭。
142
+
143
+ ### 改配置
144
+
145
+ 编辑 profile 的 `cordis.patch.yml`(写法见上一节),保存后插件热重载;没生效就重启 DSH。
146
+
147
+ ### 临时关闭
148
+
149
+ 把 `enabled` 设为 `false`,或在插件管理页禁用插件——两种情况都会**立即释放**断言,不等 30 秒防抖。
150
+
151
+ ### 卸载
152
+
153
+ 在插件管理页移除该 bundle;卸载时断言同步释放,不留残留进程。
154
+
155
+ ## 怎么确认它在工作
156
+
157
+ 界面:输入框下方状态栏(`activity` / `usage` 之后)的「守夜 · 保持中 / 未保持 / 释放中 / 异常 / 状态未知」。**点击它打开设置弹层**。
158
+
159
+ 命令行:
160
+
161
+ ```bash
162
+ # macOS:运行中应恰好有一条断言,空闲后应无输出
163
+ pmset -g assertions | grep -A2 caffeinate
164
+ pgrep -fl "caffeinate -i -w"
165
+ ```
166
+
167
+ ```powershell
168
+ # Windows
169
+ powercfg /requests
170
+ ```
171
+
172
+ ```bash
173
+ # Linux
174
+ systemd-inhibit --list
175
+ ```
176
+
177
+ ## 边界与限制
178
+
179
+ **挡不住的**(任何用户态方案都一样):合盖休眠、手动点「睡眠」、低电量强制睡眠、企业 MDM 策略。macOS 合盖时要继续跑,只能靠「插电 + 外接显示器」进入合盖模式。WSL 内只能约束 WSL,管不到 Windows 宿主。
180
+
181
+ **验证范围**:macOS 为作者真机验收平台(逐条证据见 [验证记录](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/docs/VERIFICATION.md));Windows / Linux 提供实现与单元测试,电源效果需在对应真机用上面的命令确认。发布说明不会用「已实现」代替「已验证」。
182
+
183
+ **本地写入**:只写一个状态文件 `~/.dsh/plugin-data/dsh-stay-awake/state.json`(弹层里的两个偏好),不碰系统电源计划、不申请提权、不联网、不读取会话内容。
184
+
185
+ ## 多语言
186
+
187
+ - 状态栏指示器跟随 DSH 当前语言,内置简体中文与英文,其余语言回退到英文。
188
+ - 插件管理器中的标题与说明同样提供中英文(`locale/zh.json`、`locale/en.json`)。
189
+ - 仓库文档:[简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md)。
190
+
191
+ ## 开发
192
+
193
+ ```bash
194
+ node --test test/*.test.js # 53 个单元 + 接线测试,无需 DSH 运行时
195
+ node --test test/integration/*.test.js # macOS 真机集成测试(真实 caffeinate + 内核账本)
196
+ ```
197
+
198
+ 代码结构:
199
+
200
+ ```
201
+ index.js 宿主入口:事件接线、对账、路由、生命周期
202
+ client.js 浏览器半边:状态栏指示器(含中英文字典)
203
+ lib/config.js 配置校验与默认值
204
+ lib/activity.js 活跃源记账(纯数据结构)
205
+ lib/controller.js 断言状态机(可注入时钟与 power)
206
+ lib/platform.js 三平台命令行生成(纯函数)
207
+ lib/power.js 断言进程生命周期
208
+ lib/server.js 同源状态路由
209
+ docs/REQUIREMENTS.md 需求规格与验收标准
210
+ docs/VERIFICATION.md 真机验证记录与未验证项
211
+ test/ 单元测试与接线测试
212
+ test/integration/ 真机集成测试(macOS)
213
+ ```
214
+
215
+ ## 发布(维护者)
216
+
217
+ ```bash
218
+ npm login --registry https://registry.npmjs.org # 需要 @laraveladmin 作用域权限
219
+ npm publish # package.json 已配置 publishConfig: public + npmjs registry
220
+ ```
221
+
222
+ `npm pack --dry-run` 可先确认打包内容(约 20 个文件,不含测试)。
223
+
224
+ ## 许可证
225
+
226
+ 本项目以 [MIT](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/LICENSE) 协议开源:可自由使用、修改、分发与商用,保留版权与许可声明即可。