@morehao/dsh-github-trending 0.4.5 → 0.5.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/lib/internal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ErrorCode, FileArtifact, ErrorInfo, RunRequest, RunResult, State, StateRun } from '@morehao/trendradar-contract';
1
+ import { ErrorCode, FileArtifact, Usage, ReleasesReport, ErrorInfo, RunRequest, RunResult, State, StateRun, SubscriptionList } from '@morehao/trendradar-contract';
2
2
  import http from 'node:http';
3
3
  import { Updater, PluginMeta, Logger } from '@morehao/dsh-plugin-kit/update';
4
4
 
@@ -13,7 +13,7 @@ import { Updater, PluginMeta, Logger } from '@morehao/dsh-plugin-kit/update';
13
13
  */
14
14
 
15
15
  /** 插件在核心之外新增的码。前缀统一避免与核心码冲突。 */
16
- declare const PLUGIN_CODES: readonly ["CORE_UNAVAILABLE", "CORE_INCOMPATIBLE", "CORE_SPAWN_FAILED", "CORE_TIMEOUT", "CORE_CANCELLED", "CORE_CONFIG_CHANNEL_FAILED", "CORE_NOT_DOWNLOADED", "CORE_CHECKSUM_MISMATCH", "IPC_INVALID", "MODEL_KEY_MISSING", "MODEL_NOT_FOUND", "MODEL_PROVIDER_UNSUPPORTED", "GITHUB_AUTH", "PUSH_FAILED", "REPO_DIRTY"];
16
+ declare const PLUGIN_CODES: readonly ["CORE_UNAVAILABLE", "CORE_INCOMPATIBLE", "CORE_SPAWN_FAILED", "CORE_TIMEOUT", "CORE_CANCELLED", "CORE_CONFIG_CHANNEL_FAILED", "CORE_NOT_DOWNLOADED", "CORE_CHECKSUM_MISMATCH", "IPC_INVALID", "MODEL_KEY_MISSING", "MODEL_NOT_FOUND", "MODEL_PROVIDER_UNSUPPORTED", "GITHUB_AUTH", "PUSH_FAILED", "REPO_DIRTY", "SUBSCRIBE_FAILED"];
17
17
  type PluginCode = (typeof PLUGIN_CODES)[number];
18
18
  type AnyCode = ErrorCode | PluginCode;
19
19
  interface ClassifiedError {
@@ -101,6 +101,10 @@ interface RunOutcome {
101
101
  prUrl?: string;
102
102
  /** 核心给出的跳过原因:merged | pr-closed | unchanged(可选,旧核心没有)。 */
103
103
  skipReason?: string;
104
+ /** 榜单阶段 token 用量(契约 Usage,可选;旧核心没有)。不拆维度,只取 totalTokens。 */
105
+ usage?: Usage;
106
+ /** 发版订阅阶段报告(契约 ReleasesReport,可选;旧核心/releases.enabled=false 时没有)。 */
107
+ releases?: ReleasesReport;
104
108
  error?: RunError;
105
109
  warnings: string[];
106
110
  startedAt: string;
@@ -135,6 +139,26 @@ interface ParseRunOptions {
135
139
  * 当成功写进状态。
136
140
  */
137
141
  declare function parseRunResult(text: string, options: ParseRunOptions): RunOutcome;
142
+ /** 订阅命令的结果:list 带回 repos,add/remove 只看 ok/error。 */
143
+ interface SubscribeOutcome {
144
+ ok: boolean;
145
+ repos: string[];
146
+ error?: RunError;
147
+ }
148
+ /** 订阅命令的一个动作(契约 `RunRequest.action`)。 */
149
+ type SubscribeAction = 'list' | 'add' | 'remove';
150
+ /**
151
+ * 解析核心 `subscribe --json` 的 stdout。
152
+ *
153
+ * 核心先由 `runSubscribe` 把 `list` 的结果**逐行**打到 stdout(每行一个 owner/repo),
154
+ * 再由 `emitSubscribeResult` 把契约 RunResult 信封打到 stdout(`command:"subscribe"`,
155
+ * 只带 `ok/error`,**不含 repos**)。因此:
156
+ * - 信封是**最后一段 JSON**;它前面的非空行才是 list 的仓库列表;
157
+ * - 信封 `command` 是 `"subscribe"`(不在契约 RunResult 枚举里,故不能直接用
158
+ * `validators.runResult` 校验),这里只按 envelope 必需字段做轻量校验。
159
+ * 任何形状不对都抛 `IPC_INVALID`:订阅结果读错会把失败当成功。
160
+ */
161
+ declare function parseSubscribeResult(text: string): SubscribeOutcome;
138
162
 
139
163
  declare const ipc_ErrorCode: typeof ErrorCode;
140
164
  declare const ipc_ErrorInfo: typeof ErrorInfo;
@@ -143,6 +167,7 @@ declare const ipc_IPC_SCHEMA_VERSION: typeof IPC_SCHEMA_VERSION;
143
167
  type ipc_IpcError = IpcError;
144
168
  declare const ipc_IpcError: typeof IpcError;
145
169
  type ipc_ParseRunOptions = ParseRunOptions;
170
+ declare const ipc_ReleasesReport: typeof ReleasesReport;
146
171
  type ipc_RunError = RunError;
147
172
  type ipc_RunOutcome = RunOutcome;
148
173
  declare const ipc_RunRequest: typeof RunRequest;
@@ -151,13 +176,18 @@ declare const ipc_SUPPORTED_CONTRACT_MAJOR: typeof SUPPORTED_CONTRACT_MAJOR;
151
176
  declare const ipc_SUPPORTED_DIGEST_SCHEMA: typeof SUPPORTED_DIGEST_SCHEMA;
152
177
  declare const ipc_State: typeof State;
153
178
  declare const ipc_StateRun: typeof StateRun;
179
+ type ipc_SubscribeAction = SubscribeAction;
180
+ type ipc_SubscribeOutcome = SubscribeOutcome;
181
+ declare const ipc_SubscriptionList: typeof SubscriptionList;
182
+ declare const ipc_Usage: typeof Usage;
154
183
  type ipc_VersionInfo = VersionInfo;
155
184
  declare const ipc_isVersionInfo: typeof isVersionInfo;
156
185
  declare const ipc_parseJsonObject: typeof parseJsonObject;
157
186
  declare const ipc_parseRunResult: typeof parseRunResult;
187
+ declare const ipc_parseSubscribeResult: typeof parseSubscribeResult;
158
188
  declare const ipc_parseVersionInfo: typeof parseVersionInfo;
159
189
  declare namespace ipc {
160
- export { ipc_ErrorCode as ErrorCode, ipc_ErrorInfo as ErrorInfo, ipc_FileArtifact as FileArtifact, ipc_IPC_SCHEMA_VERSION as IPC_SCHEMA_VERSION, ipc_IpcError as IpcError, type ipc_ParseRunOptions as ParseRunOptions, type ipc_RunError as RunError, type ipc_RunOutcome as RunOutcome, ipc_RunRequest as RunRequest, ipc_RunResult as RunResult, ipc_SUPPORTED_CONTRACT_MAJOR as SUPPORTED_CONTRACT_MAJOR, ipc_SUPPORTED_DIGEST_SCHEMA as SUPPORTED_DIGEST_SCHEMA, ipc_State as State, ipc_StateRun as StateRun, type ipc_VersionInfo as VersionInfo, ipc_isVersionInfo as isVersionInfo, ipc_parseJsonObject as parseJsonObject, ipc_parseRunResult as parseRunResult, ipc_parseVersionInfo as parseVersionInfo };
190
+ export { ipc_ErrorCode as ErrorCode, ipc_ErrorInfo as ErrorInfo, ipc_FileArtifact as FileArtifact, ipc_IPC_SCHEMA_VERSION as IPC_SCHEMA_VERSION, ipc_IpcError as IpcError, type ipc_ParseRunOptions as ParseRunOptions, ipc_ReleasesReport as ReleasesReport, type ipc_RunError as RunError, type ipc_RunOutcome as RunOutcome, ipc_RunRequest as RunRequest, ipc_RunResult as RunResult, ipc_SUPPORTED_CONTRACT_MAJOR as SUPPORTED_CONTRACT_MAJOR, ipc_SUPPORTED_DIGEST_SCHEMA as SUPPORTED_DIGEST_SCHEMA, ipc_State as State, ipc_StateRun as StateRun, type ipc_SubscribeAction as SubscribeAction, type ipc_SubscribeOutcome as SubscribeOutcome, ipc_SubscriptionList as SubscriptionList, ipc_Usage as Usage, type ipc_VersionInfo as VersionInfo, ipc_isVersionInfo as isVersionInfo, ipc_parseJsonObject as parseJsonObject, ipc_parseRunResult as parseRunResult, ipc_parseSubscribeResult as parseSubscribeResult, ipc_parseVersionInfo as parseVersionInfo };
161
191
  }
162
192
 
163
193
  type Provider = string;
@@ -174,6 +204,7 @@ type Since = Period;
174
204
  /** 规范顺序(索引分组、去重、UI 展示都以它为准)。 */
175
205
  declare const PERIODS: readonly Period[];
176
206
  declare function isPeriod(value: unknown): value is Period;
207
+ declare function isEnrich(value: unknown): value is Enrich;
177
208
  interface ModelSettings {
178
209
  provider: Provider;
179
210
  /** `direct` = 密钥经配置通道直传核心;`proxy` = 宿主 provider 无可导出密钥,走回环代理。 */
@@ -214,6 +245,39 @@ interface TrendingSettings {
214
245
  interface OutputSettings {
215
246
  dir: string;
216
247
  }
248
+ /** 摘要生成的外部上下文增强选项(核心 `summarize.enrich`)。 */
249
+ type Enrich = 'none' | 'repo' | 'readme';
250
+ /**
251
+ * 摘要与用量阶段参数(核心 `summarize.*`)。
252
+ * 只映射核心真实字段;插件不加核心没有的开关(不造「点了没反应」的配置)。
253
+ */
254
+ interface SummarizeSettings {
255
+ batchSize: number;
256
+ maxRetries: number;
257
+ enrich: Enrich;
258
+ readmeChars: number;
259
+ enrichCacheTTLHours: number;
260
+ enrichConcurrency: number;
261
+ enrichTimeoutSeconds: number;
262
+ enrichBudgetSeconds: number;
263
+ }
264
+ /**
265
+ * 发版订阅阶段的行为参数(核心 `releases.*`)。
266
+ * 阶段**常开**(`releases.enabled` 恒为 true,不出现在设置里):有没有产出只由订阅列表决定,
267
+ * 列表为空时核心不产出、不改动榜单产物。
268
+ * **订阅列表本身不落 settings.json**:它版本化在数据仓 `<output.dir>/subscriptions.yaml`,
269
+ * 经核心 `subscribe` IPC 读改。这里只放全局行为旋钮。
270
+ */
271
+ interface ReleasesSettings {
272
+ includePrerelease: boolean;
273
+ includeDrafts: boolean;
274
+ fallbackToTags: boolean;
275
+ baselineOnFirstRun: boolean;
276
+ perRepoLimit: number;
277
+ maxNotesChars: number;
278
+ /** 发版摘要周期,独立默认 daily,不与 trending.since 联动。 */
279
+ period: Period;
280
+ }
217
281
  interface ScheduleSettings {
218
282
  enabled: boolean;
219
283
  /** `HH:MM:SS`(本地墙钟,按 timezone 解释)。 */
@@ -233,6 +297,8 @@ interface Settings {
233
297
  pr: PRSettings;
234
298
  github: GithubSettings;
235
299
  trending: TrendingSettings;
300
+ summarize: SummarizeSettings;
301
+ releases: ReleasesSettings;
236
302
  output: OutputSettings;
237
303
  schedule: ScheduleSettings;
238
304
  /** 核心二进制覆盖;只在开发/排障时用,对应 TRENDING_DIGEST_CORE。 */
@@ -245,7 +311,7 @@ declare const DEFAULT_SETTINGS: Settings;
245
311
  declare const PROVIDER_BASE_URLS: Record<string, string>;
246
312
  declare const CORE_PROVIDERS: readonly ["deepseek", "openai-compatible"];
247
313
  /** 设置页分区;分段保存时只提交并校验对应分区,互不牵连。 */
248
- declare const SETTINGS_SECTIONS: readonly ["source", "model", "repo", "auth", "scope", "schedule"];
314
+ declare const SETTINGS_SECTIONS: readonly ["source", "model", "repo", "auth", "scope", "summarize", "releases", "schedule"];
249
315
  type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
250
316
  /** 校验问题字段 → 所属分区(用于分段保存时只把本分区的问题回给界面)。 */
251
317
  declare function sectionOfField(field: string): SettingsSection | undefined;
@@ -301,6 +367,26 @@ interface CoreConfig {
301
367
  since: string;
302
368
  perLanguage: number;
303
369
  };
370
+ summarize: {
371
+ batchSize: number;
372
+ maxRetries: number;
373
+ enrich: string;
374
+ readmeChars: number;
375
+ enrichCacheTTLHours: number;
376
+ enrichConcurrency: number;
377
+ enrichTimeoutSeconds: number;
378
+ enrichBudgetSeconds: number;
379
+ };
380
+ releases: {
381
+ enabled: boolean;
382
+ includePrerelease: boolean;
383
+ includeDrafts: boolean;
384
+ fallbackToTags: boolean;
385
+ baselineOnFirstRun: boolean;
386
+ perRepoLimit: number;
387
+ maxNotesChars: number;
388
+ period: string;
389
+ };
304
390
  output: {
305
391
  dir: string;
306
392
  branchPrefix: string;
@@ -325,6 +411,7 @@ declare const config_CORE_PROVIDERS: typeof CORE_PROVIDERS;
325
411
  type config_CommitMode = CommitMode;
326
412
  type config_CoreConfig = CoreConfig;
327
413
  declare const config_DEFAULT_SETTINGS: typeof DEFAULT_SETTINGS;
414
+ type config_Enrich = Enrich;
328
415
  type config_GithubSettings = GithubSettings;
329
416
  type config_ModelSettings = ModelSettings;
330
417
  type config_OutputSettings = OutputSettings;
@@ -334,14 +421,17 @@ type config_PRSettings = PRSettings;
334
421
  type config_Period = Period;
335
422
  type config_Problem = Problem;
336
423
  type config_Provider = Provider;
424
+ type config_ReleasesSettings = ReleasesSettings;
337
425
  type config_RepoSettings = RepoSettings;
338
426
  declare const config_SETTINGS_SECTIONS: typeof SETTINGS_SECTIONS;
339
427
  type config_ScheduleSettings = ScheduleSettings;
340
428
  type config_Settings = Settings;
341
429
  type config_SettingsSection = SettingsSection;
342
430
  type config_Since = Since;
431
+ type config_SummarizeSettings = SummarizeSettings;
343
432
  type config_TrendingSettings = TrendingSettings;
344
433
  declare const config_effectiveBaseURL: typeof effectiveBaseURL;
434
+ declare const config_isEnrich: typeof isEnrich;
345
435
  declare const config_isPeriod: typeof isPeriod;
346
436
  declare const config_isValidTimezone: typeof isValidTimezone;
347
437
  declare const config_mergeSettingsSection: typeof mergeSettingsSection;
@@ -351,7 +441,7 @@ declare const config_toCoreConfig: typeof toCoreConfig;
351
441
  declare const config_toYaml: typeof toYaml;
352
442
  declare const config_validateSettings: typeof validateSettings;
353
443
  declare namespace config {
354
- export { type config_AuthMode as AuthMode, config_CORE_PROVIDERS as CORE_PROVIDERS, type config_CommitMode as CommitMode, type config_CoreConfig as CoreConfig, config_DEFAULT_SETTINGS as DEFAULT_SETTINGS, type config_GithubSettings as GithubSettings, type config_ModelSettings as ModelSettings, type config_OutputSettings as OutputSettings, config_PERIODS as PERIODS, config_PROVIDER_BASE_URLS as PROVIDER_BASE_URLS, type config_PRSettings as PRSettings, type config_Period as Period, type config_Problem as Problem, type config_Provider as Provider, type config_RepoSettings as RepoSettings, config_SETTINGS_SECTIONS as SETTINGS_SECTIONS, type config_ScheduleSettings as ScheduleSettings, type config_Settings as Settings, type config_SettingsSection as SettingsSection, type config_Since as Since, type config_TrendingSettings as TrendingSettings, config_effectiveBaseURL as effectiveBaseURL, config_isPeriod as isPeriod, config_isValidTimezone as isValidTimezone, config_mergeSettingsSection as mergeSettingsSection, config_normalizeSettings as normalizeSettings, config_sectionOfField as sectionOfField, config_toCoreConfig as toCoreConfig, config_toYaml as toYaml, config_validateSettings as validateSettings };
444
+ export { type config_AuthMode as AuthMode, config_CORE_PROVIDERS as CORE_PROVIDERS, type config_CommitMode as CommitMode, type config_CoreConfig as CoreConfig, config_DEFAULT_SETTINGS as DEFAULT_SETTINGS, type config_Enrich as Enrich, type config_GithubSettings as GithubSettings, type config_ModelSettings as ModelSettings, type config_OutputSettings as OutputSettings, config_PERIODS as PERIODS, config_PROVIDER_BASE_URLS as PROVIDER_BASE_URLS, type config_PRSettings as PRSettings, type config_Period as Period, type config_Problem as Problem, type config_Provider as Provider, type config_ReleasesSettings as ReleasesSettings, type config_RepoSettings as RepoSettings, config_SETTINGS_SECTIONS as SETTINGS_SECTIONS, type config_ScheduleSettings as ScheduleSettings, type config_Settings as Settings, type config_SettingsSection as SettingsSection, type config_Since as Since, type config_SummarizeSettings as SummarizeSettings, type config_TrendingSettings as TrendingSettings, config_effectiveBaseURL as effectiveBaseURL, config_isEnrich as isEnrich, config_isPeriod as isPeriod, config_isValidTimezone as isValidTimezone, config_mergeSettingsSection as mergeSettingsSection, config_normalizeSettings as normalizeSettings, config_sectionOfField as sectionOfField, config_toCoreConfig as toCoreConfig, config_toYaml as toYaml, config_validateSettings as validateSettings };
355
445
  }
356
446
 
357
447
  declare const PLUGIN_DIR_NAME = "github-trending";
@@ -432,9 +522,26 @@ interface RunRecord {
432
522
  languages: string[];
433
523
  warnings: string[];
434
524
  logFile?: string;
525
+ /**
526
+ * 本次任务 token 总量(= usage.totalTokens + releases.usage.totalTokens,含订阅阶段)。
527
+ * 两个来源都缺省时该字段缺省(历史显示 `—`)。不拆维度。
528
+ */
529
+ tokens?: number;
530
+ /** 发版订阅阶段摘要(只存展示需要的字段);未启用/旧核心则缺省。 */
531
+ releases?: ReleasesSummary;
435
532
  /** true = 契约 v1 时代留下的旧记录(contentHash 算法不同,不可与 v2 比较)。 */
436
533
  legacy?: boolean;
437
534
  }
535
+ /** 发版订阅阶段在历史里保留的展示字段(来自契约 `ReleasesReport`)。 */
536
+ interface ReleasesSummary {
537
+ enabled: boolean;
538
+ repos: number;
539
+ newReleases: number;
540
+ summarized?: number;
541
+ degraded?: number;
542
+ failed?: number;
543
+ skipped?: number;
544
+ }
438
545
  interface PendingPr {
439
546
  url: string;
440
547
  createdAt: string;
@@ -508,6 +615,11 @@ declare class Store {
508
615
  }
509
616
  /** 运行 id:时间前缀便于按时间排序,随机后缀避免同毫秒撞车。 */
510
617
  declare function newRunId(now?: Date): string;
618
+ /**
619
+ * 历史里全部运行的 token 累计(不落盘,读时求和)。
620
+ * 缺省 `tokens` 的旧记录按 0 计;全部都没有则返回 undefined(界面显示 `—`)。
621
+ */
622
+ declare function sumTokens(records: readonly RunRecord[]): number | undefined;
511
623
 
512
624
  declare const state_CONTENT_HASH_ALGO_V2: typeof CONTENT_HASH_ALGO_V2;
513
625
  type state_DigestIdentity = DigestIdentity;
@@ -519,14 +631,16 @@ declare const state_PREVIEW_MAX_BYTES: typeof PREVIEW_MAX_BYTES;
519
631
  type state_PendingPr = PendingPr;
520
632
  type state_PluginState = PluginState;
521
633
  type state_PreviewMeta = PreviewMeta;
634
+ type state_ReleasesSummary = ReleasesSummary;
522
635
  type state_RunRecord = RunRecord;
523
636
  type state_Store = Store;
524
637
  declare const state_Store: typeof Store;
525
638
  type state_StoreOptions = StoreOptions;
526
639
  declare const state_newRunId: typeof newRunId;
640
+ declare const state_sumTokens: typeof sumTokens;
527
641
  declare const state_writeJsonAtomic: typeof writeJsonAtomic;
528
642
  declare namespace state {
529
- export { state_CONTENT_HASH_ALGO_V2 as CONTENT_HASH_ALGO_V2, type state_DigestIdentity as DigestIdentity, state_HISTORY_LIMIT as HISTORY_LIMIT, type state_HistoryFile as HistoryFile, type state_LegacyMigrationResult as LegacyMigrationResult, state_PREVIEW_LIMIT as PREVIEW_LIMIT, state_PREVIEW_MAX_BYTES as PREVIEW_MAX_BYTES, type state_PendingPr as PendingPr, type state_PluginState as PluginState, type state_PreviewMeta as PreviewMeta, type state_RunRecord as RunRecord, state_Store as Store, type state_StoreOptions as StoreOptions, state_newRunId as newRunId, state_writeJsonAtomic as writeJsonAtomic };
643
+ export { state_CONTENT_HASH_ALGO_V2 as CONTENT_HASH_ALGO_V2, type state_DigestIdentity as DigestIdentity, state_HISTORY_LIMIT as HISTORY_LIMIT, type state_HistoryFile as HistoryFile, type state_LegacyMigrationResult as LegacyMigrationResult, state_PREVIEW_LIMIT as PREVIEW_LIMIT, state_PREVIEW_MAX_BYTES as PREVIEW_MAX_BYTES, type state_PendingPr as PendingPr, type state_PluginState as PluginState, type state_PreviewMeta as PreviewMeta, type state_ReleasesSummary as ReleasesSummary, type state_RunRecord as RunRecord, state_Store as Store, type state_StoreOptions as StoreOptions, state_newRunId as newRunId, state_sumTokens as sumTokens, state_writeJsonAtomic as writeJsonAtomic };
530
644
  }
531
645
 
532
646
  interface CoreRelease {
@@ -728,6 +842,8 @@ interface ExecOptions {
728
842
  signal?: AbortSignal;
729
843
  maxStdout?: number;
730
844
  maxStderr?: number;
845
+ /** 写入子进程 stdin 的内容(写完即关闭);省略则 stdin 为 ignore。 */
846
+ input?: string;
731
847
  }
732
848
  /**
733
849
  * 执行一次短命令并收集输出(握手、共存探测都走这里)。
@@ -1245,6 +1361,10 @@ interface RunSummary {
1245
1361
  logFile?: string;
1246
1362
  channel?: 'fifo' | 'tmpfile';
1247
1363
  proxy?: boolean;
1364
+ /** 本次任务 token 总量(榜单 + 订阅阶段,含订阅);两者都缺省则缺省。 */
1365
+ tokens?: number;
1366
+ /** 发版订阅阶段摘要;未启用/旧核心则缺省。 */
1367
+ releases?: ReleasesSummary;
1248
1368
  /** 核心从哪来:env/settings 覆盖、缓存、还是本次下载。 */
1249
1369
  coreSource?: 'settings' | 'env' | 'cache' | 'download';
1250
1370
  coreTag?: string;
@@ -1272,6 +1392,16 @@ interface RunnerDeps {
1272
1392
  */
1273
1393
  declare function isoWeekName(date: string): string;
1274
1394
  declare function periodFileBase(period: Period, date: string): string;
1395
+ /**
1396
+ * 从契约 `RunOutcome` 投影出「token 总量」与「发版摘要」:
1397
+ * - `tokens` = usage.totalTokens + releases.usage.totalTokens(含订阅阶段);
1398
+ * 两个来源都缺省则 `tokens` 缺省(历史显示 `—`)。
1399
+ * - `releases` 只在 outcome 带 `releases` 块时才有(旧核心或 enabled=false 都无)。
1400
+ */
1401
+ declare function projectUsage(outcome: RunOutcome): {
1402
+ tokens?: number;
1403
+ releases?: ReleasesSummary;
1404
+ };
1275
1405
  declare class Runner {
1276
1406
  private active;
1277
1407
  /** 批量运行(一次触发跑多个周期)期间为 true,挡住外部并发触发。 */
@@ -1316,8 +1446,35 @@ declare const runner_Runner: typeof Runner;
1316
1446
  type runner_RunnerDeps = RunnerDeps;
1317
1447
  declare const runner_isoWeekName: typeof isoWeekName;
1318
1448
  declare const runner_periodFileBase: typeof periodFileBase;
1449
+ declare const runner_projectUsage: typeof projectUsage;
1319
1450
  declare namespace runner {
1320
- export { type runner_RunRequestOptions as RunRequestOptions, type runner_RunSummary as RunSummary, runner_Runner as Runner, type runner_RunnerDeps as RunnerDeps, runner_isoWeekName as isoWeekName, runner_periodFileBase as periodFileBase };
1451
+ export { type runner_RunRequestOptions as RunRequestOptions, type runner_RunSummary as RunSummary, runner_Runner as Runner, type runner_RunnerDeps as RunnerDeps, runner_isoWeekName as isoWeekName, runner_periodFileBase as periodFileBase, runner_projectUsage as projectUsage };
1452
+ }
1453
+
1454
+ /** 订阅命令超时:核心只做一次 GitHub 请求/本地文件读写,8 s 足够。 */
1455
+ declare const SUBSCRIBE_TIMEOUT_MS = 8000;
1456
+ declare function isValidRepo(repo: string): boolean;
1457
+ interface SubscribeDeps {
1458
+ store: Store;
1459
+ env?: NodeJS.ProcessEnv;
1460
+ /** 测试注入:跳过 locateCore,直接用给定二进制。 */
1461
+ corePath?: string;
1462
+ }
1463
+ /**
1464
+ * 执行一次 subscribe 命令:`action=list` 读列表,`add/remove` 改 pending 队列。
1465
+ * 返回 `{ ok, repos, error? }`;非 ok 由调用方(路由)决定转成 `SUBSCRIBE_FAILED`。
1466
+ */
1467
+ declare function runSubscribe(input: {
1468
+ action: SubscribeAction;
1469
+ repo?: string;
1470
+ }, deps: SubscribeDeps): Promise<SubscribeOutcome>;
1471
+
1472
+ declare const subscribe_SUBSCRIBE_TIMEOUT_MS: typeof SUBSCRIBE_TIMEOUT_MS;
1473
+ type subscribe_SubscribeDeps = SubscribeDeps;
1474
+ declare const subscribe_isValidRepo: typeof isValidRepo;
1475
+ declare const subscribe_runSubscribe: typeof runSubscribe;
1476
+ declare namespace subscribe {
1477
+ export { subscribe_SUBSCRIBE_TIMEOUT_MS as SUBSCRIBE_TIMEOUT_MS, type subscribe_SubscribeDeps as SubscribeDeps, subscribe_isValidRepo as isValidRepo, subscribe_runSubscribe as runSubscribe };
1321
1478
  }
1322
1479
 
1323
1480
  interface PluginInfo {
@@ -1596,12 +1753,16 @@ declare function createTrendingRunTool(runner: Runner): {
1596
1753
  errorCode?: string | undefined;
1597
1754
  errorMessage?: string | undefined;
1598
1755
  errorHint?: string | undefined;
1756
+ warnings: string[];
1757
+ tokens: number;
1599
1758
  ok: boolean;
1600
1759
  summaries: {
1601
1760
  errorCode?: string | undefined;
1602
1761
  errorMessage?: string | undefined;
1603
1762
  prUrl?: string | undefined;
1604
1763
  branch?: string | undefined;
1764
+ releases?: ReleasesSummary | undefined;
1765
+ tokens?: number | undefined;
1605
1766
  id: string;
1606
1767
  period: Period | undefined;
1607
1768
  ok: boolean;
@@ -1615,7 +1776,34 @@ declare function createTrendingRunTool(runner: Runner): {
1615
1776
  dryRun: boolean;
1616
1777
  durationMs: number;
1617
1778
  files: number;
1779
+ } | {
1780
+ markdown: string;
1781
+ errorCode?: string | undefined;
1782
+ errorMessage?: string | undefined;
1783
+ errorHint?: string | undefined;
1618
1784
  warnings: string[];
1785
+ tokens?: undefined;
1786
+ ok: boolean;
1787
+ summaries: {
1788
+ errorCode?: string | undefined;
1789
+ errorMessage?: string | undefined;
1790
+ prUrl?: string | undefined;
1791
+ branch?: string | undefined;
1792
+ releases?: ReleasesSummary | undefined;
1793
+ tokens?: number | undefined;
1794
+ id: string;
1795
+ period: Period | undefined;
1796
+ ok: boolean;
1797
+ skipped: boolean;
1798
+ dryRun: boolean;
1799
+ durationMs: number;
1800
+ files: number;
1801
+ }[];
1802
+ id: string | undefined;
1803
+ skipped: boolean;
1804
+ dryRun: boolean;
1805
+ durationMs: number;
1806
+ files: number;
1619
1807
  }>;
1620
1808
  };
1621
1809
  declare function createTrendingHistoryTool(store: Store, scheduler: Scheduler): {
@@ -1719,4 +1907,4 @@ declare namespace tools {
1719
1907
  export { tools_createTrendingHistoryTool as createTrendingHistoryTool, tools_createTrendingRunTool as createTrendingRunTool };
1720
1908
  }
1721
1909
 
1722
- export { channel, config, core, credentials, errors, exec, github, handshake$1 as handshake, importCli, ipc, locate, paths, pendingPr, pluginInfo, preflight, proxy, quickfill, release, repo, routes, run, runner, schedule, state, tools, update as updateService };
1910
+ export { channel, config, core, credentials, errors, exec, github, handshake$1 as handshake, importCli, ipc, locate, paths, pendingPr, pluginInfo, preflight, proxy, quickfill, release, repo, routes, run, runner, schedule, state, subscribe, tools, update as updateService };
package/lib/internal.js CHANGED
@@ -22,12 +22,13 @@ import {
22
22
  runner_exports,
23
23
  schedule_exports,
24
24
  state_exports,
25
+ subscribe_exports,
25
26
  tools_exports,
26
27
  update_exports
27
- } from "./chunk-GBXP2NGW.js";
28
+ } from "./chunk-R7EUBUTS.js";
28
29
  import {
29
30
  exec_exports
30
- } from "./chunk-XLIFTAVL.js";
31
+ } from "./chunk-R7BK7SJK.js";
31
32
  export {
32
33
  channel_exports as channel,
33
34
  config_exports as config,
@@ -53,6 +54,7 @@ export {
53
54
  runner_exports as runner,
54
55
  schedule_exports as schedule,
55
56
  state_exports as state,
57
+ subscribe_exports as subscribe,
56
58
  tools_exports as tools,
57
59
  update_exports as updateService
58
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morehao/dsh-github-trending",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
4
4
  "description": "GitHub 趋势日报插件:每天定时 spawn 本地 trendradar 核心,抓取 Trending、生成中文简介与总结,提交到你的仓库并自动合并 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@morehao/dsh-plugin-kit": "0.1.0",
54
- "@morehao/trendradar-contract": "0.2.0"
54
+ "@morehao/trendradar-contract": "0.3.0"
55
55
  },
56
56
  "dsh": {
57
57
  "bundle": {
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "core": {
61
61
  "repo": "morehao/trendradar",
62
- "version": "0.4.0"
62
+ "version": "0.6.0"
63
63
  },
64
64
  "client": {
65
65
  "platform": "web",