dsh-hub-reminders 0.1.1 → 0.1.3
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/cordis.patch.yml +0 -1
- package/package.json +1 -1
- package/plugin.js +27 -3
package/cordis.patch.yml
CHANGED
package/package.json
CHANGED
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) => {
|