@anyul/koishi-plugin-rss 5.2.2 → 5.2.4

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.
Files changed (90) hide show
  1. package/README.md +92 -37
  2. package/lib/commands/error-handler.js +13 -4
  3. package/lib/commands/index.d.ts +20 -1
  4. package/lib/commands/index.js +394 -2
  5. package/lib/commands/runtime.d.ts +17 -0
  6. package/lib/commands/runtime.js +27 -0
  7. package/lib/commands/subscription-create.d.ts +23 -0
  8. package/lib/commands/subscription-create.js +145 -0
  9. package/lib/commands/subscription-edit.d.ts +7 -0
  10. package/lib/commands/subscription-edit.js +177 -0
  11. package/lib/commands/subscription-management.d.ts +12 -0
  12. package/lib/commands/subscription-management.js +176 -0
  13. package/lib/commands/utils.d.ts +13 -1
  14. package/lib/commands/utils.js +43 -2
  15. package/lib/commands/web-monitor.d.ts +15 -0
  16. package/lib/commands/web-monitor.js +222 -0
  17. package/lib/config.js +25 -0
  18. package/lib/constants.d.ts +1 -1
  19. package/lib/constants.js +46 -83
  20. package/lib/core/ai-cache.d.ts +27 -0
  21. package/lib/core/ai-cache.js +169 -0
  22. package/lib/core/ai-client.d.ts +12 -0
  23. package/lib/core/ai-client.js +65 -0
  24. package/lib/core/ai-selector.d.ts +2 -0
  25. package/lib/core/ai-selector.js +80 -0
  26. package/lib/core/ai-summary.d.ts +10 -0
  27. package/lib/core/ai-summary.js +73 -0
  28. package/lib/core/ai-utils.d.ts +10 -0
  29. package/lib/core/ai-utils.js +104 -0
  30. package/lib/core/ai.d.ts +3 -77
  31. package/lib/core/ai.js +13 -455
  32. package/lib/core/feeder-arg.d.ts +17 -0
  33. package/lib/core/feeder-arg.js +234 -0
  34. package/lib/core/feeder-runtime.d.ts +96 -0
  35. package/lib/core/feeder-runtime.js +233 -0
  36. package/lib/core/feeder.d.ts +4 -6
  37. package/lib/core/feeder.js +120 -304
  38. package/lib/core/item-processor-runtime.d.ts +46 -0
  39. package/lib/core/item-processor-runtime.js +215 -0
  40. package/lib/core/item-processor-template.d.ts +16 -0
  41. package/lib/core/item-processor-template.js +158 -0
  42. package/lib/core/item-processor.d.ts +1 -10
  43. package/lib/core/item-processor.js +48 -393
  44. package/lib/core/notification-queue-retry.d.ts +25 -0
  45. package/lib/core/notification-queue-retry.js +78 -0
  46. package/lib/core/notification-queue-sender.d.ts +20 -0
  47. package/lib/core/notification-queue-sender.js +118 -0
  48. package/lib/core/notification-queue-store.d.ts +19 -0
  49. package/lib/core/notification-queue-store.js +137 -0
  50. package/lib/core/notification-queue-types.d.ts +49 -0
  51. package/lib/core/notification-queue-types.js +2 -0
  52. package/lib/core/notification-queue.d.ts +13 -72
  53. package/lib/core/notification-queue.js +132 -262
  54. package/lib/core/parser.js +12 -0
  55. package/lib/core/renderer.d.ts +15 -0
  56. package/lib/core/renderer.js +91 -23
  57. package/lib/core/search-format.d.ts +3 -0
  58. package/lib/core/search-format.js +36 -0
  59. package/lib/core/search-providers.d.ts +13 -0
  60. package/lib/core/search-providers.js +175 -0
  61. package/lib/core/search-rotation.d.ts +4 -0
  62. package/lib/core/search-rotation.js +55 -0
  63. package/lib/core/search-service.d.ts +3 -0
  64. package/lib/core/search-service.js +100 -0
  65. package/lib/core/search-types.d.ts +39 -0
  66. package/lib/core/search-types.js +2 -0
  67. package/lib/core/search.d.ts +4 -101
  68. package/lib/core/search.js +10 -508
  69. package/lib/index.js +50 -1160
  70. package/lib/tsconfig.tsbuildinfo +1 -1
  71. package/lib/types.d.ts +51 -6
  72. package/lib/utils/common.js +52 -3
  73. package/lib/utils/error-handler.d.ts +8 -0
  74. package/lib/utils/error-handler.js +27 -0
  75. package/lib/utils/error-tracker.js +24 -8
  76. package/lib/utils/fetcher.js +68 -9
  77. package/lib/utils/legacy-config.d.ts +12 -0
  78. package/lib/utils/legacy-config.js +56 -0
  79. package/lib/utils/logger.d.ts +4 -2
  80. package/lib/utils/logger.js +193 -34
  81. package/lib/utils/media.js +3 -6
  82. package/lib/utils/proxy.d.ts +3 -0
  83. package/lib/utils/proxy.js +14 -0
  84. package/lib/utils/sanitizer.d.ts +58 -0
  85. package/lib/utils/sanitizer.js +227 -0
  86. package/lib/utils/security.d.ts +75 -0
  87. package/lib/utils/security.js +312 -0
  88. package/lib/utils/structured-logger.d.ts +7 -3
  89. package/lib/utils/structured-logger.js +29 -39
  90. package/package.json +2 -1
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # koishi-plugin-rss-owl
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@anyul/koishi-plugin-rss?style=flat-square)](https://www.npmjs.com/package/@anyul/koishi-plugin-rss)
4
- ![version](https://img.shields.io/badge/version-5.0.0--beta-orange)
4
+ ![version](https://img.shields.io/badge/version-5.2.3-brightgreen)
5
5
 
6
6
  > 功能强大的 Koishi RSS 订阅插件,支持多种订阅源、图片渲染、AI 摘要等高级功能
7
7
 
8
+ 当前文档基于 `v5.2.3`,已同步命令模块化、入口装配层收敛与最新模板名称。
9
+
8
10
  ## ✨ 功能特性
9
11
 
10
12
  ### 🚀 核心功能
@@ -27,24 +29,43 @@
27
29
  - **内容缓存** - 文件缓存管理,支持多种存储模式
28
30
  - **调试模式** - 详细的调试日志,方便问题排查
29
31
 
32
+ ## 📌 当前稳定性边界
33
+
34
+ - 当前版本优先保障 **RSS / Atom / RSSHub 快速订阅主链路** 的可用性与回归覆盖。
35
+ - **HTML / 网页监控** 目前仍属于基础能力,暂不作为当前版本的成熟度承诺重点。
36
+ - 为保持兼容,运行时已支持规范命名 `mergeVideo` / `resendUpdatedContent` / `nextUpdateTime`。
37
+ - 当前 **Koishi WebUI / Schema** 仍显示历史字段名 `margeVideo` / `resendUpdataContent`,这是兼容保留,不代表推荐命名方向。
38
+
30
39
  ## 📁 项目结构
31
40
 
32
41
  ```
33
42
  koishi-plugin-rss-owl/
34
43
  ├── src/
35
- │ ├── commands/ # 命令定义
36
- │ │ └── index.ts # RSS 订阅命令
44
+ │ ├── commands/ # 命令模块与运行时依赖
45
+ │ │ ├── index.ts
46
+ │ │ ├── runtime.ts
47
+ │ │ ├── subscription-create.ts
48
+ │ │ ├── subscription-edit.ts
49
+ │ │ ├── subscription-management.ts
50
+ │ │ └── web-monitor.ts
37
51
  │ ├── core/ # 核心功能模块
38
52
  │ │ ├── ai.ts # AI 摘要功能
39
53
  │ │ ├── feeder.ts # RSS 订阅调度
40
54
  │ │ ├── item-processor.ts # RSS 条目处理
55
+ │ │ ├── notification-queue.ts # 发送队列
41
56
  │ │ ├── parser.ts # RSS/HTML 解析
42
- │ │ └── renderer.ts # 图片渲染
43
- ├── utils/ # 工具函数
57
+ │ │ ├── renderer.ts # 图片渲染
58
+ │ └── search.ts # 联网搜索
59
+ │ ├── services/ # 服务注册
60
+ │ │ └── message-cache-service.ts
61
+ │ ├── utils/ # 工具函数与共享基础设施
44
62
  │ │ ├── common.ts # 通用工具
63
+ │ │ ├── error-tracker.ts # 错误追踪
45
64
  │ │ ├── fetcher.ts # HTTP 请求
46
65
  │ │ ├── logger.ts # 日志系统
47
66
  │ │ ├── media.ts # 媒体处理
67
+ │ │ ├── message-cache.ts # 消息缓存
68
+ │ │ ├── proxy.ts # 代理配置 helper
48
69
  │ │ └── template.ts # 模板定义
49
70
  │ ├── config.ts # 配置定义
50
71
  │ ├── constants.ts # 常量定义
@@ -52,10 +73,25 @@ koishi-plugin-rss-owl/
52
73
  │ ├── types.ts # TypeScript 类型
53
74
  │ └── index.ts # 插件入口
54
75
  ├── lib/ # 编译输出
76
+ ├── tests/ # Jest 测试与手工联调文件
77
+ │ ├── unit/
78
+ │ ├── integration/
79
+ │ ├── manual/
80
+ │ ├── setup.ts
81
+ │ └── web-search.test.ts
82
+ ├── docs/ # 开发记录与专题文档
55
83
  ├── package.json
56
84
  └── README.md
57
85
  ```
58
86
 
87
+ ### 当前架构概览
88
+
89
+ - `src/index.ts` 现在只保留**插件装配与生命周期管理**。
90
+ - `src/commands/*` 已按职责拆分为创建、管理、编辑、网页监控等独立模块。
91
+ - `src/commands/runtime.ts` 统一提供命令共享依赖,减少命令文件间重复拼装。
92
+ - `src/core/item-processor.ts` 统一模板选择、HTML 加载与图片资源回填逻辑。
93
+ - `src/utils/proxy.ts` 统一 AI / 搜索等模块的代理配置。
94
+
59
95
  ### 配置插件
60
96
 
61
97
  在 Koishi 配置文件中添加:
@@ -148,17 +184,17 @@ ai:
148
184
 
149
185
  ```bash
150
186
  # 关注订阅,更新时 @你
151
- rsso -f 早报网
187
+ rsso.follow 1
152
188
 
153
189
  # 取消关注
154
- rsso -f 早报网
190
+ rsso.follow 1
155
191
  ```
156
192
 
157
193
  ### 立即拉取
158
194
 
159
195
  ```bash
160
196
  # 立即拉取订阅最新内容
161
- rsso -p 早报网
197
+ rsso.pull 1
162
198
  ```
163
199
 
164
200
  ## 📋 命令说明
@@ -185,6 +221,14 @@ rsso -p 早报网
185
221
  | `rsso.follow <id>` | 关注订阅 | `rsso.follow 1` |
186
222
  | `rsso.follow <id> --all` | 全员提醒 | `rsso.follow 1 --all` |
187
223
 
224
+ ### 运行管理命令
225
+
226
+ | 命令 | 说明 | 示例 |
227
+ |------|------|------|
228
+ | `rsso.cache list [页数]` | 查看消息缓存列表 | `rsso.cache list`, `rsso.cache list 2` |
229
+ | `rsso.cache pull <序号>` | 重新推送缓存消息 | `rsso.cache pull 1` |
230
+ | `rsso.queue stats` | 查看发送队列统计 | `rsso.queue stats` |
231
+
188
232
  ### 修改订阅选项
189
233
 
190
234
  | 选项 | 说明 | 示例 |
@@ -240,25 +284,23 @@ rsso -a proxyAgent:false <url>
240
284
 
241
285
  ## 🎨 模板说明
242
286
 
243
- ### 基础模板(直接发送)
287
+ ### 当前模板类型
244
288
 
245
- | 模板 | 说明 | 内容 |
246
- |------|------|------|
247
- | `content` | 自定义基础模板 | 文字+图片+视频 |
248
- | `text` | 纯文本 | 仅文字 |
249
- | `media` | 媒体内容 | 图片+视频 |
250
- | `image` | 仅图片 | 仅图片 |
251
- | `video` | 仅视频 | 仅视频 |
252
- | `proto` | 原始内容 | 未处理的 description |
253
-
254
- ### Puppeteer 模板(图片渲染)
289
+ | 内部模板名 | 常用命令简写 | 说明 |
290
+ |-----------|--------------|------|
291
+ | `auto` | `auto` | 自动在轻量模板与渲染模板间选择 |
292
+ | `content` | `content` | 基础内容模板,适合文字较少的订阅 |
293
+ | `only text` | `text` | 仅发送文字 |
294
+ | `only media` | `media` | 仅发送图片和视频 |
295
+ | `only image` | `image` | 仅发送图片 |
296
+ | `only video` | `video` | 仅发送视频 |
297
+ | `proto` | `proto` | 直接输出原始 description |
298
+ | `default` | `default` | 内置 Puppeteer 渲染模板 |
299
+ | `only description` | `description` | 仅渲染 description 内容 |
300
+ | `custom` | `custom` | 自定义 HTML 模板 |
301
+ | `link` | `link` | 访问内容中的首个链接并渲染页面 |
255
302
 
256
- | 模板 | 说明 | 特点 |
257
- |------|------|------|
258
- | `default` | 基础渲染模板 | 完整样式,包含标题、时间等 |
259
- | `description` | 纯内容渲染 | 仅包含 description 内容 |
260
- | `custom` | 自定义模板 | 高度可定制,支持自定义 HTML |
261
- | `link` | 链接访问渲染 | 访问 description 中的第一个链接并渲染 |
303
+ > 说明:配置项与内部类型以 `only text / only media / only image / only video / only description` 为准,命令行中仍可使用 `text / media / image / video / description` 简写。
262
304
 
263
305
  ### 模板切换
264
306
 
@@ -569,6 +611,7 @@ plugins:
569
611
  content: "" # content 模板内容
570
612
 
571
613
  # === 基础配置 ===
614
+ # 当前 WebUI / Schema 里仍显示历史字段名,下面示例保持与配置界面一致
572
615
  basic:
573
616
  usePoster: false # 使用视频封面
574
617
  margeVideo: false # 合并视频
@@ -602,6 +645,8 @@ plugins:
602
645
  debug: "info" # disable | error | info | details
603
646
  ```
604
647
 
648
+ > 兼容说明:运行时内部已兼容 `mergeVideo` / `resendUpdatedContent` / `nextUpdateTime`;但当前 Koishi 配置 Schema 与 WebUI 仍展示历史字段名 `margeVideo` / `resendUpdataContent`,因此配置界面示例暂保持旧命名,避免和实际 UI 脱节。
649
+
605
650
  ## 🐛 调试指南
606
651
 
607
652
  ### 启用详细日志
@@ -614,7 +659,7 @@ debug: "details" # 显示所有调试信息
614
659
 
615
660
  **1. 订阅不更新**
616
661
  - 检查刷新间隔设置
617
- - 使用 `rsso -p <id>` 手动拉取测试
662
+ - 使用 `rsso.pull <id>` 手动拉取测试
618
663
  - 查看日志确认是否有错误
619
664
 
620
665
  **2. 图片不显示**
@@ -634,6 +679,16 @@ debug: "details" # 显示所有调试信息
634
679
 
635
680
  ## 📜 更新日志
636
681
 
682
+ ### 5.2.3 (2026-03-10)
683
+
684
+ #### 结构收敛与文档同步
685
+
686
+ - 🧩 **入口装配层收敛** - `src/index.ts` 进一步压缩为装配层,命令注册与生命周期更清晰
687
+ - 🗂️ **命令模块继续拆分** - 补齐 `runtime`、订阅创建、网页监控等命令模块结构
688
+ - 🎨 **模板/渲染逻辑复用** - 统一模板处理与图片资源回填,减少重复分支
689
+ - 🌐 **代理配置统一** - AI 与搜索模块改为共享代理 helper
690
+ - 📚 **文档同步** - 更新模板名称、目录结构、开发与测试说明
691
+
637
692
  ### 5.0.4 (2026-02-17)
638
693
 
639
694
  #### 🎉 重大更新 - 命令系统重构
@@ -719,9 +774,6 @@ git clone https://github.com/Anyuluo996/koishi-plugin-rss-owl.git
719
774
  cd koishi-plugin-rss-owl
720
775
  npm install --legacy-peer-deps
721
776
 
722
- # 开发模式
723
- npm run dev
724
-
725
777
  # 构建
726
778
  npm run build
727
779
 
@@ -737,22 +789,25 @@ npm run test:watch
737
789
 
738
790
  ### 测试
739
791
 
740
- 本项目拥有完善的测试套件,包含 165+ 个测试用例,覆盖核心功能模块。
792
+ 当前仓库包含 `unit`、`integration`、`manual` 三类测试/验证文件。
741
793
 
742
- **测试覆盖率**:
743
- - 语句覆盖率: 90.83%
744
- - 分支覆盖率: 74.86%
745
- - 函数覆盖率: 97.43%
746
- - 行覆盖率: 90.21%
794
+ **推荐验证方式**:
795
+ - `npm test`:运行默认 Jest 测试集
796
+ - `npm run test:watch`:开发中持续回归
797
+ - `npm run test:coverage`:需要覆盖率报告时执行
798
+ - `npm run build`:执行 TypeScript 编译检查
747
799
 
748
800
  **测试范围**:
749
801
  - ✅ 工具函数测试(日期解析、URL处理、内容清理)
750
802
  - ✅ HTTP 请求测试(RequestManager、createHttpFunction)
751
803
  - ✅ 错误处理测试(友好错误消息、错误类型识别)
752
804
  - ✅ 日志系统测试(debug输出、级别过滤)
753
- - ✅ 集成测试(真实HTTP请求、代理配置)
805
+ - ✅ 处理器/渲染逻辑测试(模板分支、图片回填、渲染边界)
806
+ - ✅ 命令工具与代理配置测试
807
+
808
+ `tests/manual/` 中的文件主要用于手工联调,不作为默认自动化回归通过信号。
754
809
 
755
- 详见 [TESTING.md](./TESTING.md) 了解更多测试信息。
810
+ 详见 [docs/TESTING.md](./docs/TESTING.md) 了解更多测试信息。
756
811
 
757
812
  ## 💬 致谢
758
813
 
@@ -10,9 +10,9 @@ exports.permissionDenied = permissionDenied;
10
10
  exports.invalidArgument = invalidArgument;
11
11
  exports.notFound = notFound;
12
12
  exports.alreadyExists = alreadyExists;
13
- const koishi_1 = require("koishi");
14
13
  const error_handler_1 = require("../utils/error-handler");
15
- const logger = new koishi_1.Logger('rss-owl-command');
14
+ const error_tracker_1 = require("../utils/error-tracker");
15
+ const logger_1 = require("../utils/logger");
16
16
  /**
17
17
  * 命令错误类型
18
18
  */
@@ -62,9 +62,18 @@ async function executeCommand(ctx, config, operationName, handler) {
62
62
  * 记录命令错误
63
63
  */
64
64
  function logError(config, operation, error) {
65
- if (config.debug === 'details' || config.debug === 'error') {
66
- logger.error(`[${operation}]`, error);
65
+ const normalizedError = (0, error_handler_1.normalizeError)(error, `${operation} failed`);
66
+ const context = {
67
+ command: operation,
68
+ };
69
+ if (error instanceof CommandError) {
70
+ context.commandErrorType = error.type;
67
71
  }
72
+ if (normalizedError && typeof normalizedError.code === 'string') {
73
+ context.errorCode = normalizedError.code;
74
+ }
75
+ (0, logger_1.debugError)(config, normalizedError, `${operation} error`, context);
76
+ (0, error_tracker_1.trackError)(normalizedError, context);
68
77
  }
69
78
  /**
70
79
  * 格式化命令错误消息
@@ -1 +1,20 @@
1
- export {};
1
+ import { Context } from 'koishi';
2
+ import type { Config } from '../types';
3
+ import { NotificationQueueManager } from '../core/notification-queue';
4
+ /**
5
+ * 管理类命令依赖
6
+ */
7
+ export interface ManagementCommandDeps {
8
+ ctx: Context;
9
+ config: Config;
10
+ queueManager: NotificationQueueManager;
11
+ }
12
+ /**
13
+ * 注册管理类命令
14
+ */
15
+ export declare function registerManagementCommands(deps: ManagementCommandDeps): void;
16
+ export { registerSubscriptionManagementCommands } from './subscription-management';
17
+ export { registerSubscriptionEditCommand } from './subscription-edit';
18
+ export { registerSubscriptionCreateCommand } from './subscription-create';
19
+ export { registerWebMonitorCommands } from './web-monitor';
20
+ export { createCommandRuntimeDeps } from './runtime';