dsh-hub-reminders 0.1.0 → 0.1.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/icon.svg +6 -0
- package/package.json +3 -2
- package/plugin.js +27 -3
package/icon.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Reminders">
|
|
2
|
+
<rect x="3" y="3" width="58" height="58" rx="14" fill="#c96442"/>
|
|
3
|
+
<path d="M32 15a11 11 0 0 1 11 11v9l4 5H17l4-5v-9a11 11 0 0 1 11-11Z" fill="#fff8f3"/>
|
|
4
|
+
<path d="M27 44h10a5 5 0 0 1-10 0Z" fill="#8f3d24"/>
|
|
5
|
+
<circle cx="32" cy="13" r="2.6" fill="#fff8f3"/>
|
|
6
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hub-reminders",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./plugin.js",
|
|
6
6
|
"description": "DSH 会话 hook 注入:按白名单运行仓库 hooks/*.py,并把提醒文本注入每一轮(开工自检 / 测试清理 / 实事求是等)",
|
|
7
7
|
"files": [
|
|
8
8
|
"plugin.js",
|
|
9
|
-
"cordis.patch.yml"
|
|
9
|
+
"cordis.patch.yml",
|
|
10
|
+
"icon.svg"
|
|
10
11
|
],
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"repository": {
|
package/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { realpathSync, appendFileSync } from "node:fs";
|
|
1
|
+
import { realpathSync, existsSync, appendFileSync } from "node:fs";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -189,8 +189,32 @@ function applyInner(ctx, rawConfig = {}) {
|
|
|
189
189
|
maxBufferBytes: rawConfig.maxBufferBytes ?? 1024 * 1024,
|
|
190
190
|
sessionMemory: rawConfig.sessionMemory !== false,
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
// 2026-11-11 可移植性(第三方安装):hooksDir 缺失 / 不存在 / 无脚本时**不再抛错**。
|
|
193
|
+
// 原实现 `if (!config.hooksDir) throw` + `realpathSync(hooksDir)` 会让任何没配本机 hooks
|
|
194
|
+
// 目录的用户一装就崩;现改为「插件正常加载、只是不跑 hook」,缺失的脚本逐个跳过
|
|
195
|
+
// (部分 hook 缺失也照跑其余)。本机行为不变:hooksDir 存在且 25 个脚本齐全。
|
|
196
|
+
const warn = (msg) => {
|
|
197
|
+
try { ctx.logger?.warn?.(`[ai-agent-hub-reminders] ${msg}`); }
|
|
198
|
+
catch { try { console.warn(`[ai-agent-hub-reminders] ${msg}`); } catch {} }
|
|
199
|
+
};
|
|
200
|
+
if (!config.hooksDir) {
|
|
201
|
+
warn("hooksDir 未配置 —— 提醒 hook 全部跳过(插件本身正常加载)");
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const hooksRoot = resolve(config.hooksDir);
|
|
205
|
+
if (!existsSync(hooksRoot)) {
|
|
206
|
+
warn(`hooksDir 不存在(${hooksRoot})—— 提醒 hook 全部跳过`);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const present = config.scripts.filter((filename) => existsSync(join(hooksRoot, filename)));
|
|
210
|
+
if (present.length === 0) {
|
|
211
|
+
warn(`hooksDir 下没有任何白名单脚本(${hooksRoot})—— 提醒 hook 全部跳过`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (present.length < config.scripts.length) {
|
|
215
|
+
warn(`部分 hook 脚本缺失:应 ${config.scripts.length} 个、缺 ${config.scripts.length - present.length} 个`);
|
|
216
|
+
}
|
|
217
|
+
const scripts = resolveAllowedScripts(config.hooksDir, present);
|
|
194
218
|
const byFilename = new Map(scripts.map((entry) => [entry.filename, entry.script]));
|
|
195
219
|
|
|
196
220
|
const runOne = (filename, eventPayload, signal) => {
|