@morehao/dsh-github-trending 0.4.4 → 0.5.0

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,38 @@ 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
+ * **订阅列表本身不落 settings.json**:它版本化在数据仓 `<output.dir>/subscriptions.yaml`,
267
+ * 经核心 `subscribe` IPC 读改。这里只放全局行为旋钮。
268
+ */
269
+ interface ReleasesSettings {
270
+ enabled: boolean;
271
+ includePrerelease: boolean;
272
+ includeDrafts: boolean;
273
+ fallbackToTags: boolean;
274
+ baselineOnFirstRun: boolean;
275
+ perRepoLimit: number;
276
+ maxNotesChars: number;
277
+ /** 发版摘要周期,独立默认 daily,不与 trending.since 联动。 */
278
+ period: Period;
279
+ }
217
280
  interface ScheduleSettings {
218
281
  enabled: boolean;
219
282
  /** `HH:MM:SS`(本地墙钟,按 timezone 解释)。 */
@@ -233,6 +296,8 @@ interface Settings {
233
296
  pr: PRSettings;
234
297
  github: GithubSettings;
235
298
  trending: TrendingSettings;
299
+ summarize: SummarizeSettings;
300
+ releases: ReleasesSettings;
236
301
  output: OutputSettings;
237
302
  schedule: ScheduleSettings;
238
303
  /** 核心二进制覆盖;只在开发/排障时用,对应 TRENDING_DIGEST_CORE。 */
@@ -245,7 +310,7 @@ declare const DEFAULT_SETTINGS: Settings;
245
310
  declare const PROVIDER_BASE_URLS: Record<string, string>;
246
311
  declare const CORE_PROVIDERS: readonly ["deepseek", "openai-compatible"];
247
312
  /** 设置页分区;分段保存时只提交并校验对应分区,互不牵连。 */
248
- declare const SETTINGS_SECTIONS: readonly ["source", "model", "repo", "auth", "scope", "schedule"];
313
+ declare const SETTINGS_SECTIONS: readonly ["source", "model", "repo", "auth", "scope", "summarize", "releases", "schedule"];
249
314
  type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
250
315
  /** 校验问题字段 → 所属分区(用于分段保存时只把本分区的问题回给界面)。 */
251
316
  declare function sectionOfField(field: string): SettingsSection | undefined;
@@ -301,6 +366,26 @@ interface CoreConfig {
301
366
  since: string;
302
367
  perLanguage: number;
303
368
  };
369
+ summarize: {
370
+ batchSize: number;
371
+ maxRetries: number;
372
+ enrich: string;
373
+ readmeChars: number;
374
+ enrichCacheTTLHours: number;
375
+ enrichConcurrency: number;
376
+ enrichTimeoutSeconds: number;
377
+ enrichBudgetSeconds: number;
378
+ };
379
+ releases: {
380
+ enabled: boolean;
381
+ includePrerelease: boolean;
382
+ includeDrafts: boolean;
383
+ fallbackToTags: boolean;
384
+ baselineOnFirstRun: boolean;
385
+ perRepoLimit: number;
386
+ maxNotesChars: number;
387
+ period: string;
388
+ };
304
389
  output: {
305
390
  dir: string;
306
391
  branchPrefix: string;
@@ -325,6 +410,7 @@ declare const config_CORE_PROVIDERS: typeof CORE_PROVIDERS;
325
410
  type config_CommitMode = CommitMode;
326
411
  type config_CoreConfig = CoreConfig;
327
412
  declare const config_DEFAULT_SETTINGS: typeof DEFAULT_SETTINGS;
413
+ type config_Enrich = Enrich;
328
414
  type config_GithubSettings = GithubSettings;
329
415
  type config_ModelSettings = ModelSettings;
330
416
  type config_OutputSettings = OutputSettings;
@@ -334,14 +420,17 @@ type config_PRSettings = PRSettings;
334
420
  type config_Period = Period;
335
421
  type config_Problem = Problem;
336
422
  type config_Provider = Provider;
423
+ type config_ReleasesSettings = ReleasesSettings;
337
424
  type config_RepoSettings = RepoSettings;
338
425
  declare const config_SETTINGS_SECTIONS: typeof SETTINGS_SECTIONS;
339
426
  type config_ScheduleSettings = ScheduleSettings;
340
427
  type config_Settings = Settings;
341
428
  type config_SettingsSection = SettingsSection;
342
429
  type config_Since = Since;
430
+ type config_SummarizeSettings = SummarizeSettings;
343
431
  type config_TrendingSettings = TrendingSettings;
344
432
  declare const config_effectiveBaseURL: typeof effectiveBaseURL;
433
+ declare const config_isEnrich: typeof isEnrich;
345
434
  declare const config_isPeriod: typeof isPeriod;
346
435
  declare const config_isValidTimezone: typeof isValidTimezone;
347
436
  declare const config_mergeSettingsSection: typeof mergeSettingsSection;
@@ -351,7 +440,7 @@ declare const config_toCoreConfig: typeof toCoreConfig;
351
440
  declare const config_toYaml: typeof toYaml;
352
441
  declare const config_validateSettings: typeof validateSettings;
353
442
  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 };
443
+ 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
444
  }
356
445
 
357
446
  declare const PLUGIN_DIR_NAME = "github-trending";
@@ -432,9 +521,26 @@ interface RunRecord {
432
521
  languages: string[];
433
522
  warnings: string[];
434
523
  logFile?: string;
524
+ /**
525
+ * 本次任务 token 总量(= usage.totalTokens + releases.usage.totalTokens,含订阅阶段)。
526
+ * 两个来源都缺省时该字段缺省(历史显示 `—`)。不拆维度。
527
+ */
528
+ tokens?: number;
529
+ /** 发版订阅阶段摘要(只存展示需要的字段);未启用/旧核心则缺省。 */
530
+ releases?: ReleasesSummary;
435
531
  /** true = 契约 v1 时代留下的旧记录(contentHash 算法不同,不可与 v2 比较)。 */
436
532
  legacy?: boolean;
437
533
  }
534
+ /** 发版订阅阶段在历史里保留的展示字段(来自契约 `ReleasesReport`)。 */
535
+ interface ReleasesSummary {
536
+ enabled: boolean;
537
+ repos: number;
538
+ newReleases: number;
539
+ summarized?: number;
540
+ degraded?: number;
541
+ failed?: number;
542
+ skipped?: number;
543
+ }
438
544
  interface PendingPr {
439
545
  url: string;
440
546
  createdAt: string;
@@ -508,6 +614,11 @@ declare class Store {
508
614
  }
509
615
  /** 运行 id:时间前缀便于按时间排序,随机后缀避免同毫秒撞车。 */
510
616
  declare function newRunId(now?: Date): string;
617
+ /**
618
+ * 历史里全部运行的 token 累计(不落盘,读时求和)。
619
+ * 缺省 `tokens` 的旧记录按 0 计;全部都没有则返回 undefined(界面显示 `—`)。
620
+ */
621
+ declare function sumTokens(records: readonly RunRecord[]): number | undefined;
511
622
 
512
623
  declare const state_CONTENT_HASH_ALGO_V2: typeof CONTENT_HASH_ALGO_V2;
513
624
  type state_DigestIdentity = DigestIdentity;
@@ -519,14 +630,16 @@ declare const state_PREVIEW_MAX_BYTES: typeof PREVIEW_MAX_BYTES;
519
630
  type state_PendingPr = PendingPr;
520
631
  type state_PluginState = PluginState;
521
632
  type state_PreviewMeta = PreviewMeta;
633
+ type state_ReleasesSummary = ReleasesSummary;
522
634
  type state_RunRecord = RunRecord;
523
635
  type state_Store = Store;
524
636
  declare const state_Store: typeof Store;
525
637
  type state_StoreOptions = StoreOptions;
526
638
  declare const state_newRunId: typeof newRunId;
639
+ declare const state_sumTokens: typeof sumTokens;
527
640
  declare const state_writeJsonAtomic: typeof writeJsonAtomic;
528
641
  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 };
642
+ 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
643
  }
531
644
 
532
645
  interface CoreRelease {
@@ -728,6 +841,8 @@ interface ExecOptions {
728
841
  signal?: AbortSignal;
729
842
  maxStdout?: number;
730
843
  maxStderr?: number;
844
+ /** 写入子进程 stdin 的内容(写完即关闭);省略则 stdin 为 ignore。 */
845
+ input?: string;
731
846
  }
732
847
  /**
733
848
  * 执行一次短命令并收集输出(握手、共存探测都走这里)。
@@ -1245,6 +1360,10 @@ interface RunSummary {
1245
1360
  logFile?: string;
1246
1361
  channel?: 'fifo' | 'tmpfile';
1247
1362
  proxy?: boolean;
1363
+ /** 本次任务 token 总量(榜单 + 订阅阶段,含订阅);两者都缺省则缺省。 */
1364
+ tokens?: number;
1365
+ /** 发版订阅阶段摘要;未启用/旧核心则缺省。 */
1366
+ releases?: ReleasesSummary;
1248
1367
  /** 核心从哪来:env/settings 覆盖、缓存、还是本次下载。 */
1249
1368
  coreSource?: 'settings' | 'env' | 'cache' | 'download';
1250
1369
  coreTag?: string;
@@ -1272,6 +1391,16 @@ interface RunnerDeps {
1272
1391
  */
1273
1392
  declare function isoWeekName(date: string): string;
1274
1393
  declare function periodFileBase(period: Period, date: string): string;
1394
+ /**
1395
+ * 从契约 `RunOutcome` 投影出「token 总量」与「发版摘要」:
1396
+ * - `tokens` = usage.totalTokens + releases.usage.totalTokens(含订阅阶段);
1397
+ * 两个来源都缺省则 `tokens` 缺省(历史显示 `—`)。
1398
+ * - `releases` 只在 outcome 带 `releases` 块时才有(旧核心或 enabled=false 都无)。
1399
+ */
1400
+ declare function projectUsage(outcome: RunOutcome): {
1401
+ tokens?: number;
1402
+ releases?: ReleasesSummary;
1403
+ };
1275
1404
  declare class Runner {
1276
1405
  private active;
1277
1406
  /** 批量运行(一次触发跑多个周期)期间为 true,挡住外部并发触发。 */
@@ -1316,8 +1445,35 @@ declare const runner_Runner: typeof Runner;
1316
1445
  type runner_RunnerDeps = RunnerDeps;
1317
1446
  declare const runner_isoWeekName: typeof isoWeekName;
1318
1447
  declare const runner_periodFileBase: typeof periodFileBase;
1448
+ declare const runner_projectUsage: typeof projectUsage;
1319
1449
  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 };
1450
+ 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 };
1451
+ }
1452
+
1453
+ /** 订阅命令超时:核心只做一次 GitHub 请求/本地文件读写,8 s 足够。 */
1454
+ declare const SUBSCRIBE_TIMEOUT_MS = 8000;
1455
+ declare function isValidRepo(repo: string): boolean;
1456
+ interface SubscribeDeps {
1457
+ store: Store;
1458
+ env?: NodeJS.ProcessEnv;
1459
+ /** 测试注入:跳过 locateCore,直接用给定二进制。 */
1460
+ corePath?: string;
1461
+ }
1462
+ /**
1463
+ * 执行一次 subscribe 命令:`action=list` 读列表,`add/remove` 改 pending 队列。
1464
+ * 返回 `{ ok, repos, error? }`;非 ok 由调用方(路由)决定转成 `SUBSCRIBE_FAILED`。
1465
+ */
1466
+ declare function runSubscribe(input: {
1467
+ action: SubscribeAction;
1468
+ repo?: string;
1469
+ }, deps: SubscribeDeps): Promise<SubscribeOutcome>;
1470
+
1471
+ declare const subscribe_SUBSCRIBE_TIMEOUT_MS: typeof SUBSCRIBE_TIMEOUT_MS;
1472
+ type subscribe_SubscribeDeps = SubscribeDeps;
1473
+ declare const subscribe_isValidRepo: typeof isValidRepo;
1474
+ declare const subscribe_runSubscribe: typeof runSubscribe;
1475
+ declare namespace subscribe {
1476
+ export { subscribe_SUBSCRIBE_TIMEOUT_MS as SUBSCRIBE_TIMEOUT_MS, type subscribe_SubscribeDeps as SubscribeDeps, subscribe_isValidRepo as isValidRepo, subscribe_runSubscribe as runSubscribe };
1321
1477
  }
1322
1478
 
1323
1479
  interface PluginInfo {
@@ -1596,12 +1752,16 @@ declare function createTrendingRunTool(runner: Runner): {
1596
1752
  errorCode?: string | undefined;
1597
1753
  errorMessage?: string | undefined;
1598
1754
  errorHint?: string | undefined;
1755
+ warnings: string[];
1756
+ tokens: number;
1599
1757
  ok: boolean;
1600
1758
  summaries: {
1601
1759
  errorCode?: string | undefined;
1602
1760
  errorMessage?: string | undefined;
1603
1761
  prUrl?: string | undefined;
1604
1762
  branch?: string | undefined;
1763
+ releases?: ReleasesSummary | undefined;
1764
+ tokens?: number | undefined;
1605
1765
  id: string;
1606
1766
  period: Period | undefined;
1607
1767
  ok: boolean;
@@ -1615,7 +1775,34 @@ declare function createTrendingRunTool(runner: Runner): {
1615
1775
  dryRun: boolean;
1616
1776
  durationMs: number;
1617
1777
  files: number;
1778
+ } | {
1779
+ markdown: string;
1780
+ errorCode?: string | undefined;
1781
+ errorMessage?: string | undefined;
1782
+ errorHint?: string | undefined;
1618
1783
  warnings: string[];
1784
+ tokens?: undefined;
1785
+ ok: boolean;
1786
+ summaries: {
1787
+ errorCode?: string | undefined;
1788
+ errorMessage?: string | undefined;
1789
+ prUrl?: string | undefined;
1790
+ branch?: string | undefined;
1791
+ releases?: ReleasesSummary | undefined;
1792
+ tokens?: number | undefined;
1793
+ id: string;
1794
+ period: Period | undefined;
1795
+ ok: boolean;
1796
+ skipped: boolean;
1797
+ dryRun: boolean;
1798
+ durationMs: number;
1799
+ files: number;
1800
+ }[];
1801
+ id: string | undefined;
1802
+ skipped: boolean;
1803
+ dryRun: boolean;
1804
+ durationMs: number;
1805
+ files: number;
1619
1806
  }>;
1620
1807
  };
1621
1808
  declare function createTrendingHistoryTool(store: Store, scheduler: Scheduler): {
@@ -1719,4 +1906,4 @@ declare namespace tools {
1719
1906
  export { tools_createTrendingHistoryTool as createTrendingHistoryTool, tools_createTrendingRunTool as createTrendingRunTool };
1720
1907
  }
1721
1908
 
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 };
1909
+ 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-WFCULY72.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.4",
3
+ "version": "0.5.0",
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",